]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Step 5 -> struct element into deepest SD
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
34
35 #include <algorithm>
36 #include <iterator>
37
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
42
43 using namespace MEDCoupling;
44
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
47
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
50
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
52 {
53   return new MEDFileFieldLoc(fid,locName);
54 }
55
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
57 {
58   return new MEDFileFieldLoc(fid,id);
59 }
60
61 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
62 {
63   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
64 }
65
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
67 {
68   med_geometry_type geotype;
69   med_geometry_type sectiongeotype;
70   int nsectionmeshcell;
71   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
74   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76   _nb_node_per_cell=cm.getNumberOfNodes();
77   _ref_coo.resize(_dim*_nb_node_per_cell);
78   _gs_coo.resize(_dim*_nb_gauss_pt);
79   _w.resize(_nb_gauss_pt);
80   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
81 }
82
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
84 {
85   med_geometry_type geotype;
86   med_geometry_type sectiongeotype;
87   int nsectionmeshcell;
88   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
92   _name=locName;
93   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95   _nb_node_per_cell=cm.getNumberOfNodes();
96   _ref_coo.resize(_dim*_nb_node_per_cell);
97   _gs_coo.resize(_dim*_nb_gauss_pt);
98   _w.resize(_nb_gauss_pt);
99   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
100 }
101
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
104                                      _w(w)
105 {
106   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107   _dim=cm.getDimension();
108   _nb_node_per_cell=cm.getNumberOfNodes();
109   _nb_gauss_pt=_w.size();
110 }
111
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
113 {
114   return new MEDFileFieldLoc(*this);
115 }
116
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
118 {
119   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
120 }
121
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
123 {
124   return std::vector<const BigMemoryObject *>();
125 }
126
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
128 {
129   static const char OFF7[]="\n    ";
130   oss << "\"" << _name << "\"" << OFF7;
131   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132   oss << "Dimension=" << _dim << OFF7;
133   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
138 }
139
140 void MEDFileFieldLoc::setName(const std::string& name)
141 {
142   _name=name;
143 }
144
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
146 {
147   if(_name!=other._name)
148     return false;
149   if(_dim!=other._dim)
150     return false;
151   if(_nb_gauss_pt!=other._nb_gauss_pt)
152     return false;
153   if(_nb_node_per_cell!=other._nb_node_per_cell)
154     return false;
155   if(_geo_type!=other._geo_type)
156     return false;
157   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
158     return false;
159   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
160     return false;
161   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162     return false;
163
164   return true;
165 }
166
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
168 {
169   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
170 }
171
172 std::string MEDFileFieldLoc::repr() const
173 {
174   std::ostringstream oss; oss.precision(15);
175   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
177   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
178   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
179   oss << "\n  - Ref coords are : ";
180   int sz=_ref_coo.size();
181   if(sz%_dim==0)
182     {
183       int nbOfTuples=sz/_dim;
184       for(int i=0;i<nbOfTuples;i++)
185         {
186           oss << "(";
187           for(int j=0;j<_dim;j++)
188             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189           oss << ") ";
190         }
191     }
192   else
193     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194   oss << "\n  - Gauss coords in reference element : ";
195   sz=_gs_coo.size();
196   if(sz%_dim==0)
197     {
198       int nbOfTuples=sz/_dim;
199       for(int i=0;i<nbOfTuples;i++)
200         {
201           oss << "(";
202           for(int j=0;j<_dim;j++)
203             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204           oss << ") ";
205         }
206     }
207   else
208     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
210   return oss.str();
211 }
212
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
214 {
215   _type=field->getTypeOfField();
216   _start=start;
217   switch(_type)
218   {
219     case ON_CELLS:
220       {
221         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222         _end=_start+nbOfCells;
223         _nval=nbOfCells;
224         break;
225       }
226     case ON_GAUSS_NE:
227       {
228         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229         const int *arrPtr=arr->getConstPointer();
230         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232         _nval=nbOfCells;
233         break;
234       }
235     case ON_GAUSS_PT:
236       {
237         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
240         if(!disc2)
241           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244         const int *dai2Ptr(dai2->getConstPointer());
245         int nbi(gsLoc.getWeights().size());
246         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248         const int *da3Ptr(da3->getConstPointer());
249         if(da3->getNumberOfTuples()!=nbOfCells)
250           {//profile : for gauss even in NoProfile !!!
251             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
252             _profile=oss.str();
253             da3->setName(_profile.c_str());
254             glob.appendProfile(da3);
255           }
256         MCAuto<DataArrayInt> da4(DataArrayInt::New());
257         _nval=da3->getNbOfElems();
258         da4->alloc(_nval*nbi,1);
259         int *da4Ptr(da4->getPointer());
260         for(int i=0;i<_nval;i++)
261           {
262             int ref=dai2Ptr[offset+da3Ptr[i]];
263             for(int j=0;j<nbi;j++)
264               *da4Ptr++=ref+j;
265           }
266         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267         _localization=oss2.str();
268         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269         _end=_start+_nval*nbi;
270         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
271         break;
272       }
273     default:
274       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275   }
276   start=_end;
277 }
278
279 /*!
280  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281  * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
282  * \param [in] multiTypePfl is the end user profile specified in high level API
283  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
285  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
287  */
288 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
289 {
290   _profile.clear();
291   _type=field->getTypeOfField();
292   std::string pflName(multiTypePfl->getName());
293   std::ostringstream oss; oss << pflName;
294   if(_type!=ON_NODES)
295     {
296       if(!isPflAlone)
297         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
298     }
299   else
300     { oss << "_NODE"; }
301   if(locIds)
302     {
303       if(pflName.empty())
304         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305       if(_type!=ON_GAUSS_PT)
306         {
307           locIds->setName(oss.str());
308           glob.appendProfile(locIds);
309           _profile=oss.str();
310         }
311     }
312   _start=start;
313   switch(_type)
314   {
315     case ON_NODES:
316       {
317         _nval=idsInPfl->getNumberOfTuples();
318         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
319         _end=_start+_nval;
320         break;
321       }
322     case ON_CELLS:
323       {
324         _nval=idsInPfl->getNumberOfTuples();
325         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326         _end=_start+_nval;
327         break;
328       }
329     case ON_GAUSS_NE:
330       {
331         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334         arr3->computeOffsetsFull();
335         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336         int trueNval=tmp->getNumberOfTuples();
337         _nval=idsInPfl->getNumberOfTuples();
338         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339         _end=_start+trueNval;
340         break;
341       }
342     case ON_GAUSS_PT:
343       {
344         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
345         if(!disc2)
346           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
352         //
353         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
355         //
356         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
357         int trueNval=0;
358         for(const int *pt=da4->begin();pt!=da4->end();pt++)
359           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360         tmp->alloc(trueNval,1);
361         int *tmpPtr=tmp->getPointer();
362         for(const int *pt=da4->begin();pt!=da4->end();pt++)
363           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
364             *tmpPtr++=j;
365         //
366         _nval=da4->getNumberOfTuples();
367         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368         _end=_start+trueNval;
369         oss << "_loc_" << _loc_id;
370         if(locIds)
371           {
372             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373             da5->setName(oss.str());
374             glob.appendProfile(da5);
375             _profile=oss.str();
376           }
377         else
378           {
379             if(!da3->isIota(nbOfEltsInWholeMesh))
380               {
381                 da3->setName(oss.str());
382                 glob.appendProfile(da3);
383                 _profile=oss.str();
384               }
385           }
386         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387         _localization=oss2.str();
388         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
389         break;
390       }
391     default:
392       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393   }
394   start=_end;
395 }
396
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
398 {
399   _start=start;
400   _nval=arrr->getNumberOfTuples();
401   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
402   _end=_start+_nval;
403   start=_end;
404 }
405
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
407 {
408   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
409 }
410
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
412 {
413   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
414 }
415
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
417 {
418   return new MEDFileFieldPerMeshPerTypePerDisc(other);
419 }
420
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
422 {
423   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
424 }
425
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
427 {
428   std::vector<const BigMemoryObject *> ret(1);
429   ret[0]=(const PartDefinition*)_pd;
430   return ret;
431 }
432
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
434 {
435   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
436   ret->_father=father;
437   return ret.retn();
438 }
439
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 {
443   if(pd)
444     pd->incrRef();
445 }
446 catch(INTERP_KERNEL::Exception& e)
447 {
448     throw e;
449 }
450
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
452 {
453 }
454
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
456 {
457 }
458
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
461 {
462 }
463
464 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
465 {
466   const PartDefinition *pd(_pd);
467   if(!pd)
468     {
469       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
470       int nbi,tmp1;
471       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472       if(_end-_start!=nbValsInFile*nbi)
473         {
474           std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
475           throw INTERP_KERNEL::Exception(oss.str());
476         }
477       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
478     }
479   else
480     {
481       if(!_profile.empty())
482         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
484       int profilesize,nbi;
485       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
487       if(spd)
488         {
489           int start,stop,step;
490           spd->getSlice(start,stop,step);
491           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492           med_filter filter=MED_FILTER_INIT;
493           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496                                    /*lastblocksize=useless because count=1*/0,&filter);
497           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498           MEDfilterClose(&filter);
499           return ;
500         }
501       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
502       if(dpd)
503         {
504           dpd->checkConsistencyLight();
505           MCAuto<DataArrayInt> myIds(dpd->toDAI());
506           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508           myIds->applyLin(1,-a);
509           int nbOfEltsToLoad(b-a+1);
510           med_filter filter=MED_FILTER_INIT;
511           {//TODO : manage int32 !
512             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517                                      /*lastblocksize=useless because count=1*/0,&filter);
518             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
522           }
523           MEDfilterClose(&filter);
524         }
525       else
526         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
527     }
528 }
529
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
531 {
532   return _father;
533 }
534
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
536 {
537   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539   std::string fieldName(nasc.getName()),meshName(getMeshName());
540   int iteration(getIteration()),order(getOrder());
541   TypeOfField type(getType());
542   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
543   int profilesize,nbi;
544   med_geometry_type mgeoti;
545   med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
546   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
547   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
548   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
549   const PartDefinition *pd(_pd);
550   if(!pd)
551     {
552       _nval=zeNVal;
553     }
554   else
555     {
556       if(!_profile.empty())
557         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
558       _nval=pd->getNumberOfElems();
559     }
560   _start=start;
561   _end=start+_nval*nbi;
562   start=_end;
563   if(type==ON_CELLS && !_localization.empty())
564     {
565       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
566         setType(ON_GAUSS_PT);
567       else
568         {
569           setType(ON_GAUSS_NE);
570           _localization.clear();
571         }
572     }
573 }
574
575 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 {
577   std::string fieldName(nasc.getName()),meshName(getMeshName());
578   int iteration(getIteration()),order(getOrder());
579   TypeOfField type(getType());
580   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
581   med_geometry_type mgeoti;
582   med_entity_type menti(MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti));
583   if(_start>_end)
584     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
585   if(_start==_end)
586     return ;
587   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
588   if(_start<0 || _start>=arr->getNumberOfTuples())
589     {
590       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
591       throw INTERP_KERNEL::Exception(oss.str());
592     }
593   if(_end<0 || _end>arr->getNumberOfTuples())
594     {
595       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
596       throw INTERP_KERNEL::Exception(oss.str());
597     }
598   int nbOfCompo(arr->getNumberOfComponents());
599   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
600   if(arrD)
601     {
602       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
603       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
604       return ;
605     }
606   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
607   if(arrI)
608     {
609       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
610       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
611       return ;
612     }
613   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
614 }
615
616 /*!
617  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618  */
619 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 {
621   int delta=_end-_start;
622   _start=newValueOfStart;
623   _end=_start+delta;
624 }
625
626 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 {
628   return _father->getIteration();
629 }
630
631 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 {
633   return _father->getOrder();
634 }
635
636 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 {
638   return _father->getTime();
639 }
640
641 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 {
643   return _father->getMeshName();
644 }
645
646 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 {
648   const char startLine[]="    ## ";
649   std::string startLine2(bkOffset,' ');
650   startLine2+=startLine;
651   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
652   oss << startLine2 << "Localization #" << id << "." << std::endl;
653   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
654   delete tmp;
655   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
656   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
657   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 }
659
660 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
661 {
662   return _type;
663 }
664
665 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
666 {
667   return _father->getGeoType();
668 }
669
670 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
671 {
672   types.insert(_type);
673 }
674
675 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
676 {
677   _type=newType;
678 }
679
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
681 {
682   return _father->getNumberOfComponents();
683 }
684
685 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
686 {
687   return _end-_start;
688 }
689
690 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
691 {
692   return _father->getOrCreateAndGetArray();
693 }
694
695 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
696 {
697   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
698   return fath->getOrCreateAndGetArray();
699 }
700
701 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
702 {
703   return _father->getInfo();
704 }
705
706 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
707 {
708   return _profile;
709 }
710
711 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
712 {
713   _profile=newPflName;
714 }
715
716 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
717 {
718   return _localization;
719 }
720
721 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
722 {
723   _localization=newLocName;
724 }
725
726 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
727 {
728   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
729     {
730       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
731         {
732           _profile=(*it2).second;
733           return;
734         }
735     }
736 }
737
738 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
739 {
740   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
741     {
742       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
743         {
744           _localization=(*it2).second;
745           return;
746         }
747     }
748 }
749
750 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
751 {
752   if(type!=_type)
753     return ;
754   dads.push_back(std::pair<int,int>(_start,_end));
755   geoTypes.push_back(getGeoType());
756   if(_profile.empty())
757     pfls.push_back(0);
758   else
759     {
760       pfls.push_back(glob->getProfile(_profile.c_str()));
761     }
762   if(_localization.empty())
763     locs.push_back(-1);
764   else
765     {
766       locs.push_back(glob->getLocalizationId(_localization.c_str()));
767     }
768 }
769
770 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
771 {
772   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
773   startEntryId++;
774 }
775
776 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
777 {
778   TypeOfField type=getType();
779   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
780   med_geometry_type mgeoti;
781   med_entity_type menti=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(type,geoType,mgeoti);
782   const DataArray *arr=getOrCreateAndGetArray();
783   if(!arr)
784     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
785   if(!arr->isAllocated())
786     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
787   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
788   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
789   const unsigned char *locToWrite=0;
790   if(arrD)
791     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792   else if(arrI)
793     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794   else
795     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
796   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
797                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
798                                                    locToWrite));
799 }
800
801 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
802 {
803   type=_type;
804   pfl=_profile;
805   loc=_localization;
806   dad.first=_start; dad.second=_end;
807 }
808
809 /*!
810  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
811  *             This code corresponds to the distribution of types in the corresponding mesh.
812  * \param [out] ptToFill memory zone where the output will be stored.
813  * \return the size of data pushed into output param \a ptToFill
814  */
815 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
816 {
817   _loc_id=offset;
818   std::ostringstream oss;
819   std::size_t nbOfType=codeOfMesh.size()/3;
820   int found=-1;
821   for(std::size_t i=0;i<nbOfType && found==-1;i++)
822     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
823       found=(int)i;
824   if(found==-1)
825     {
826       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
827       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
828       throw INTERP_KERNEL::Exception(oss.str());
829     }
830   int *work=ptToFill;
831   if(_profile.empty())
832     {
833       if(_nval!=codeOfMesh[3*found+1])
834         {
835           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
836           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
837           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
838           throw INTERP_KERNEL::Exception(oss.str());
839         }
840       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
841         *work++=ii;
842     }
843   else
844     {
845       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
846       if(pfl->getNumberOfTuples()!=_nval)
847         {
848           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
849           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850           oss << _nval;
851           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
852           throw INTERP_KERNEL::Exception(oss.str());
853         }
854       int offset2=codeOfMesh[3*found+2];
855       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856         {
857           if(*pflId<codeOfMesh[3*found+1])
858             *work++=offset2+*pflId;
859         }
860     }
861   return _nval;
862 }
863
864 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 {
866   for(int i=_start;i<_end;i++)
867     *ptToFill++=i;
868   return _end-_start;
869 }
870
871 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
872 {
873   switch(type)
874   {
875     case ON_CELLS:
876       return -2;
877     case ON_GAUSS_NE:
878       return -1;
879     case ON_GAUSS_PT:
880       return locId;
881     default:
882       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
883   }
884 }
885
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
887 {
888   int id=0;
889   std::map<std::pair<std::string,TypeOfField>,int> m;
890   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
891   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
893       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894   ret.resize(id);
895   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
896     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
897   return ret;
898 }
899
900 /*!
901  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902  * 
903  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
904  * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
905  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
906  * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
907  * \param [in,out] glob if necessary by the method, new profiles can be added to it
908  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
909  * \param [out] result All new entries will be appended on it.
910  * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
911  */
912 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
913                                                        const DataArrayInt *explicitIdsInMesh,
914                                                        const std::vector<int>& newCode,
915                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
916                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 {
918   if(entriesOnSameDisc.empty())
919     return false;
920   TypeOfField type=entriesOnSameDisc[0]->getType();
921   int szEntities=0,szTuples=0;
922   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
923     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
924   int nbi=szTuples/szEntities;
925   if(szTuples%szEntities!=0)
926     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
927   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
928   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
929   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
930   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
931   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
932   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
933   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934   int id=0;
935   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936     {
937       int startOfEltIdOfChunk=(*it)->_start;
938       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
939       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
940       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941       //
942       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
943       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944       //
945       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
946       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947     }
948   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
949   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
950   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
951   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952   //
953   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954   //
955   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
956   arrPart->renumberInPlace(renumTupleIds->begin());
957   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958   bool ret=false;
959   const int *idIt=diffVals->begin();
960   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961   int offset2=0;
962   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963     {
964       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
965       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
966       int nbEntityElts=subIds->getNumberOfTuples();
967       bool ret2;
968       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
969           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
970                                       offset+offset2,
971                                       li,glob,ret2);
972       ret=ret || ret2;
973       result.push_back(eltToAdd);
974       offset2+=nbEntityElts*nbi;
975     }
976   ret=ret || li.empty();
977   return ret;
978 }
979
980 /*!
981  * \param [in] typeF type of field of new chunk
982  * \param [in] geoType the geometric type of the chunk
983  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
984  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
985  * \param [in] nbi number of integration points
986  * \param [in] offset The offset in the **global array of data**.
987  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
988  *                 to the new chunk to create.
989  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
990  * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
991  *              and corresponding entry erased from \a entriesOnSameDisc.
992  * \return a newly allocated chunk
993  */
994 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
995                                                                                                   bool isPfl, int nbi, int offset,
996                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
997                                                                                                   MEDFileFieldGlobsReal& glob,
998                                                                                                   bool &notInExisting)
999 {
1000   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1001   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1002   for(;it!=entriesOnSameDisc.end();it++)
1003     {
1004       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1005         {
1006           if(!isPfl)
1007             {
1008               if((*it)->_profile.empty())
1009                 break;
1010               else
1011                 if(!(*it)->_profile.empty())
1012                   {
1013                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1014                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1015                       break;
1016                   }
1017             }
1018         }
1019     }
1020   if(it==entriesOnSameDisc.end())
1021     {
1022       notInExisting=true;
1023       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024       ret->_type=typeF;
1025       ret->_loc_id=(int)geoType;
1026       ret->_nval=nbMeshEntities;
1027       ret->_start=offset;
1028       ret->_end=ret->_start+ret->_nval*nbi;
1029       if(isPfl)
1030         {
1031           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1032           glob.appendProfile(idsOfMeshElt);
1033           ret->_profile=idsOfMeshElt->getName();
1034         }
1035       //tony treatment of localization
1036       return ret;
1037     }
1038   else
1039     {
1040       notInExisting=false;
1041       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1042       ret->_loc_id=(int)geoType;
1043       ret->setNewStart(offset);
1044       entriesOnSameDisc.erase(it);
1045       return ret;
1046     }
1047
1048 }
1049
1050 ////////////////////////////////////
1051
1052 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1053  {
1054  }
1055
1056 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1057 {
1058   _father=father;
1059 }
1060
1061 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1062 {
1063   std::size_t i=0;
1064   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065     {
1066       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1067         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1068     }
1069 }
1070
1071 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 {
1073   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1074 }
1075
1076 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 {
1078   std::vector<const BigMemoryObject *> ret;
1079   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1080     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1081   return ret;
1082 }
1083
1084 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 {
1086   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1087   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1088     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1089 }
1090
1091 /*!
1092  * This method is the most general one. No optimization is done here.
1093  * \param [in] multiTypePfl is the end user profile specified in high level API
1094  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1095  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1096  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1097  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1098  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1099  */
1100 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1101 {
1102   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1103   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1104     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1105 }
1106
1107 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 {
1109   _field_pm_pt_pd.resize(1);
1110   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1111   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1112 }
1113
1114 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 {
1116   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1117   if(!arr || !arr->isAllocated())
1118     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1119   _field_pm_pt_pd.resize(1);
1120   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1121   _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1122 }
1123
1124 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 {
1126   TypeOfField type=field->getTypeOfField();
1127   if(type!=ON_GAUSS_PT)
1128     {
1129       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1130       int sz=_field_pm_pt_pd.size();
1131       bool found=false;
1132       for(int j=0;j<sz && !found;j++)
1133         {
1134           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135             {
1136               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1137               found=true;
1138             }
1139         }
1140       if(!found)
1141         {
1142           _field_pm_pt_pd.resize(sz+1);
1143           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144         }
1145       std::vector<int> ret(1,(int)sz);
1146       return ret;
1147     }
1148   else
1149     {
1150       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1151       int sz2=ret2.size();
1152       std::vector<int> ret3(sz2);
1153       int k=0;
1154       for(int i=0;i<sz2;i++)
1155         {
1156           int sz=_field_pm_pt_pd.size();
1157           int locIdToFind=ret2[i];
1158           bool found=false;
1159           for(int j=0;j<sz && !found;j++)
1160             {
1161               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162                 {
1163                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1164                   ret3[k++]=j;
1165                   found=true;
1166                 }
1167             }
1168           if(!found)
1169             {
1170               _field_pm_pt_pd.resize(sz+1);
1171               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1172               ret3[k++]=sz;
1173             }
1174         }
1175       return ret3;
1176     }
1177 }
1178
1179 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 {
1181   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1182   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183   if(!disc2)
1184     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1185   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186   if(!da)
1187     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1188   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1189   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1190   if(retTmp->presenceOfValue(-1))
1191     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1192   std::vector<int> ret(retTmp->begin(),retTmp->end());
1193   return ret;
1194 }
1195
1196 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 {
1198   TypeOfField type=field->getTypeOfField();
1199   if(type!=ON_GAUSS_PT)
1200     {
1201       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1202       int sz=_field_pm_pt_pd.size();
1203       bool found=false;
1204       for(int j=0;j<sz && !found;j++)
1205         {
1206           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207             {
1208               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1209               found=true;
1210             }
1211         }
1212       if(!found)
1213         {
1214           _field_pm_pt_pd.resize(sz+1);
1215           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216         }
1217       std::vector<int> ret(1,0);
1218       return ret;
1219     }
1220   else
1221     {
1222       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1223       int sz2=ret2.size();
1224       std::vector<int> ret3(sz2);
1225       int k=0;
1226       for(int i=0;i<sz2;i++)
1227         {
1228           int sz=_field_pm_pt_pd.size();
1229           int locIdToFind=ret2[i];
1230           bool found=false;
1231           for(int j=0;j<sz && !found;j++)
1232             {
1233               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234                 {
1235                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1236                   ret3[k++]=j;
1237                   found=true;
1238                 }
1239             }
1240           if(!found)
1241             {
1242               _field_pm_pt_pd.resize(sz+1);
1243               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1244               ret3[k++]=sz;
1245             }
1246         }
1247       return ret3;
1248     }
1249 }
1250
1251 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 {
1253   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1254   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255   if(!disc2)
1256     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1257   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258   if(!da)
1259     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1260   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1261   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1262   if(retTmp->presenceOfValue(-1))
1263     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1264   std::vector<int> ret(retTmp->begin(),retTmp->end());
1265   return ret;
1266 }
1267
1268 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1269 {
1270   return _father;
1271 }
1272
1273 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 {
1275   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1276   int curDim((int)cm.getDimension());
1277   if(dim!=std::numeric_limits<int>::max())
1278     {
1279       if(dim!=curDim)
1280         return false;
1281     }
1282   else
1283     dim=curDim;
1284   return true;
1285 }
1286
1287 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 {
1289   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290     {
1291       (*it)->fillTypesOfFieldAvailable(types);
1292     }
1293 }
1294
1295 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1296 {
1297   int sz=_field_pm_pt_pd.size();
1298   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1299   for(int i=0;i<sz;i++)
1300     {
1301       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1302     }
1303 }
1304
1305 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 {
1307   return _father->getIteration();
1308 }
1309
1310 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 {
1312   return _father->getOrder();
1313 }
1314
1315 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 {
1317   return _father->getTime();
1318 }
1319
1320 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 {
1322   return _father->getMeshName();
1323 }
1324
1325 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 {
1327   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328     {
1329       globalSz+=(*it)->getNumberOfTuples();
1330     }
1331   nbOfEntries+=(int)_field_pm_pt_pd.size();
1332 }
1333
1334 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 {
1336   return _father->getNumberOfComponents();
1337 }
1338
1339 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1340 {
1341   std::size_t nb(0);
1342   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343     {
1344       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1345       if(fmtd)
1346         nb++;
1347     }
1348   return nb>1;
1349 }
1350
1351 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1352 {
1353   return _father->getOrCreateAndGetArray();
1354 }
1355
1356 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1357 {
1358   const MEDFileFieldPerMesh *fath=_father;
1359   return fath->getOrCreateAndGetArray();
1360 }
1361
1362 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1363 {
1364   return _father->getInfo();
1365 }
1366
1367 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1368 {
1369   std::vector<std::string> ret;
1370   std::set<std::string> ret2;
1371   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1372     {
1373       std::string tmp=(*it1)->getProfile();
1374       if(!tmp.empty())
1375         if(ret2.find(tmp)==ret2.end())
1376           {
1377             ret.push_back(tmp);
1378             ret2.insert(tmp);
1379           }
1380     }
1381   return ret;
1382 }
1383
1384 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1385 {
1386   std::vector<std::string> ret;
1387   std::set<std::string> ret2;
1388   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1389     {
1390       std::string tmp=(*it1)->getLocalization();
1391       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1392         if(ret2.find(tmp)==ret2.end())
1393           {
1394             ret.push_back(tmp);
1395             ret2.insert(tmp);
1396           }
1397     }
1398   return ret;
1399 }
1400
1401 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1402 {
1403   std::vector<std::string> ret;
1404   std::set<std::string> ret2;
1405   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1406     {
1407       std::string tmp=(*it1)->getProfile();
1408       if(!tmp.empty())
1409         ret.push_back(tmp);
1410     }
1411   return ret;
1412 }
1413
1414 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1415 {
1416   std::vector<std::string> ret;
1417   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1418     {
1419       std::string tmp=(*it1)->getLocalization();
1420       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1421         ret.push_back(tmp);
1422     }
1423   return ret;
1424 }
1425
1426 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1427 {
1428   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429     (*it1)->changePflsRefsNamesGen(mapOfModif);
1430 }
1431
1432 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1433 {
1434   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1435     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1436 }
1437
1438 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1439 {
1440   if(_field_pm_pt_pd.empty())
1441     {
1442       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1443       throw INTERP_KERNEL::Exception(oss.str());
1444     }
1445   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1446     return _field_pm_pt_pd[locId];
1447   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1448   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1449   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1450   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1451 }
1452
1453 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1454 {
1455   if(_field_pm_pt_pd.empty())
1456     {
1457       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1458       throw INTERP_KERNEL::Exception(oss.str());
1459     }
1460   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1461     return _field_pm_pt_pd[locId];
1462   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1463   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1464   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1465   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1466 }
1467
1468 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1469 {
1470   int i=0;
1471   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1472     {
1473       (*it)->fillValues(i,startEntryId,entries);
1474     }
1475 }
1476
1477 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1478 {
1479   _field_pm_pt_pd=leaves;
1480   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1481     (*it)->setFather(this);
1482 }
1483
1484 /*!
1485  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1486  *  \param [out] its - list of pair (start,stop) kept
1487  *  \return bool - false if the type of field \a tof is not contained in \a this.
1488  */
1489 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1490 {
1491   bool ret(false);
1492   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1493   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1494     if((*it)->getType()==tof)
1495       {
1496         newPmPtPd.push_back(*it);
1497         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1498         (*it)->setNewStart(globalNum);
1499         globalNum=(*it)->getEnd();
1500         its.push_back(bgEnd);
1501         ret=true;
1502       }
1503   if(ret)
1504     _field_pm_pt_pd=newPmPtPd;
1505   return ret;
1506 }
1507
1508 /*!
1509  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1510  *  \param [out] its - list of pair (start,stop) kept
1511  *  \return bool - false if the type of field \a tof is not contained in \a this.
1512  */
1513 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1514 {
1515   if(_field_pm_pt_pd.size()<=idOfDisc)
1516     return false;
1517   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1518   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1519   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1520   elt->setNewStart(globalNum);
1521   globalNum=elt->getEnd();
1522   its.push_back(bgEnd);
1523   _field_pm_pt_pd=newPmPtPd;
1524   return true;
1525 }
1526
1527 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1528 {
1529   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1530     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1531 }
1532
1533 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1534 {
1535   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536     (*it)->loadBigArray(fid,nasc);
1537 }
1538
1539 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1540 {
1541   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542     {
1543       (*it)->copyOptionsFrom(*this);
1544       (*it)->writeLL(fid,nasc);
1545     }
1546 }
1547
1548 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1549 {
1550   switch(ikType)
1551   {
1552     case ON_CELLS:
1553       medfGeoType=typmai3[(int)ikGeoType];
1554       return MED_CELL;
1555     case ON_NODES:
1556       medfGeoType=MED_NONE;
1557       return MED_NODE;
1558     case ON_GAUSS_NE:
1559       medfGeoType=typmai3[(int)ikGeoType];
1560       return MED_NODE_ELEMENT;
1561     case ON_GAUSS_PT:
1562       medfGeoType=typmai3[(int)ikGeoType];
1563       return MED_CELL;
1564     default:
1565       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1566   }
1567   return MED_UNDEF_ENTITY_TYPE;
1568 }
1569
1570 //////////////////////////////////////////////////
1571
1572 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1573 {
1574   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1575 }
1576
1577 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1578 {
1579   return new MEDFileFieldPerMeshPerType(fath,geoType);
1580 }
1581
1582 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1583 {
1584   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1585   ret->setFather(father);
1586   ret->deepCopyElements();
1587   return ret.retn();
1588 }
1589
1590 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1591 {
1592   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1593     {
1594       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1595       if(meshDim!=(int)cm.getDimension())
1596         return ;
1597     }
1598   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1599     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1600 }
1601
1602 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1603 {
1604   return _geo_type;
1605 }
1606
1607 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1608 {
1609   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1610   int curDim((int)cm.getDimension());
1611   dim=std::max(dim,curDim);
1612 }
1613
1614 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1615 {
1616   const char startLine[]="  ## ";
1617   std::string startLine2(bkOffset,' ');
1618   std::string startLine3(startLine2);
1619   startLine3+=startLine;
1620   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1621     {
1622       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1623       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1624     }
1625   else
1626     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1627   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1628   int i=0;
1629   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1630     {
1631       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1632       if(cur)
1633         cur->simpleRepr(bkOffset,oss,i);
1634       else
1635         {
1636           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1637         }
1638     }
1639 }
1640
1641 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1642 {
1643   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1644   return std::string(cm.getRepr());
1645 }
1646
1647 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1648 {
1649 }
1650
1651 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1652 {
1653   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1654   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1655   med_geometry_type mgeoti;
1656   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1657   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1658   _field_pm_pt_pd.resize(nbProfiles);
1659   for(int i=0;i<nbProfiles;i++)
1660     {
1661       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1662     }
1663   if(type==ON_CELLS)
1664     {
1665       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1666       for(int i=0;i<nbProfiles2;i++)
1667         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1668     }
1669 }
1670
1671 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)
1672 {
1673   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1674   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1675   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1676     {
1677       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1678         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1679     }
1680   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1681     {
1682       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1683       ret->_field_pm_pt_pd.push_back(agg);
1684     }
1685   return ret;
1686 }
1687
1688 //////////////////////////////////////////////////
1689
1690 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1691 {
1692   if(!entities)
1693     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1694   const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1695   if(!entities2)
1696     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1697   const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1698   return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1699 }
1700
1701 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1702 {
1703   _se.takeRef(se);
1704   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1705   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1706   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1707   _field_pm_pt_pd.resize(nbProfiles);
1708   for(int i=0;i<nbProfiles;i++)
1709     {
1710       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1711     }
1712 }
1713
1714 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1715 {
1716   return _se->getDynGT();
1717 }
1718
1719 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1720 {
1721   throw INTERP_KERNEL::Exception("not implemented yet !");
1722 }
1723
1724 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1725 {
1726   throw INTERP_KERNEL::Exception("not implemented yet !");
1727 }
1728
1729 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1730 {
1731   const char startLine[]="  ## ";
1732   std::string startLine2(bkOffset,' ');
1733   std::string startLine3(startLine2);
1734   startLine3+=startLine;
1735   oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry type " << getDynGT() << "." << std::endl;
1736   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1737   int i=0;
1738   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1739     {
1740       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1741       if(cur)
1742         cur->simpleRepr(bkOffset,oss,i);
1743       else
1744         {
1745           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1746         }
1747     }
1748 }
1749
1750 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1751 {
1752   throw INTERP_KERNEL::Exception("not implemented yet !");
1753 }
1754
1755 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1756 {
1757   throw INTERP_KERNEL::Exception("not implemented yet !");
1758 }
1759
1760 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
1761 {
1762   throw INTERP_KERNEL::Exception("not implemented yet !");
1763 }
1764
1765 //////////////////////////////////////////////////
1766
1767 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1768 {
1769   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1770 }
1771
1772 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1773 {
1774   return new MEDFileFieldPerMesh(fath,mesh);
1775 }
1776
1777 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1778 {
1779   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1780 }
1781
1782 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1783 {
1784   std::vector<const BigMemoryObject *> ret;
1785   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1786     ret.push_back(*it);
1787   return ret;
1788 }
1789
1790 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1791 {
1792   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1793   ret->_father=father;
1794   std::size_t i=0;
1795   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1796     {
1797       if((*it).isNotNull())
1798         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1799     }
1800   return ret.retn();
1801 }
1802
1803 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1804 {
1805   std::string startLine(bkOffset,' ');
1806   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1807   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1808   int i=0;
1809   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1810     {
1811       if((*it).isNotNull())
1812         (*it)->simpleRepr(bkOffset,oss,i);
1813       else
1814         {
1815           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1816         }
1817     }
1818 }
1819
1820 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1821 {
1822   _mesh_name=mesh->getName();
1823   mesh->getTime(_mesh_iteration,_mesh_order);
1824 }
1825
1826 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1827 {
1828   int nbOfTypes=code.size()/3;
1829   int offset=0;
1830   for(int i=0;i<nbOfTypes;i++)
1831     {
1832       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1833       int nbOfCells=code[3*i+1];
1834       int pos=addNewEntryIfNecessary(type);
1835       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1836       offset+=nbOfCells;
1837     }
1838 }
1839
1840 /*!
1841  * This method is the most general one. No optimization is done here.
1842  * \param [in] multiTypePfl is the end user profile specified in high level API
1843  * \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].
1844  * \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.
1845  * \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.
1846  * \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.
1847  * \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.
1848  */
1849 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)
1850 {
1851   int nbOfTypes(code.size()/3);
1852   for(int i=0;i<nbOfTypes;i++)
1853     {
1854       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1855       int pos=addNewEntryIfNecessary(type);
1856       DataArrayInt *pfl=0;
1857       if(code[3*i+2]!=-1)
1858         pfl=idsPerType[code[3*i+2]];
1859       int nbOfTupes2=code2.size()/3;
1860       int found=0;
1861       for(;found<nbOfTupes2;found++)
1862         if(code[3*i]==code2[3*found])
1863           break;
1864       if(found==nbOfTupes2)
1865         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1866       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1867     }
1868 }
1869
1870 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1871 {
1872   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1873   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1874 }
1875
1876 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1877 {
1878   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1879   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1880 }
1881
1882 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1883 {
1884   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1885     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1886 }
1887
1888 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1889 {
1890   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1891     (*it)->loadBigArraysRecursively(fid,nasc);
1892 }
1893
1894 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1895 {
1896   int nbOfTypes=_field_pm_pt.size();
1897   for(int i=0;i<nbOfTypes;i++)
1898     {
1899       _field_pm_pt[i]->copyOptionsFrom(*this);
1900       _field_pm_pt[i]->writeLL(fid,nasc);
1901     }
1902 }
1903
1904 void MEDFileFieldPerMesh::getDimension(int& dim) const
1905 {
1906   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1907     (*it)->getDimension(dim);
1908 }
1909
1910 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1911 {
1912   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1913     if(!(*it)->isUniqueLevel(dim))
1914       return false;
1915   return true;
1916 }
1917
1918 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1919 {
1920   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1921     (*it)->fillTypesOfFieldAvailable(types);
1922 }
1923
1924 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
1925 {
1926   int sz=_field_pm_pt.size();
1927   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1928   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1929   for(int i=0;i<sz;i++)
1930     {
1931       types[i]=_field_pm_pt[i]->getGeoType();
1932       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1933     }
1934   return ret;
1935 }
1936
1937 double MEDFileFieldPerMesh::getTime() const
1938 {
1939   int tmp1,tmp2;
1940   return _father->getTime(tmp1,tmp2);
1941 }
1942
1943 int MEDFileFieldPerMesh::getIteration() const
1944 {
1945   return _father->getIteration();
1946 }
1947
1948 int MEDFileFieldPerMesh::getOrder() const
1949 {
1950   return _father->getOrder();
1951 }
1952
1953 int MEDFileFieldPerMesh::getNumberOfComponents() const
1954 {
1955   return _father->getNumberOfComponents();
1956 }
1957
1958 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1959 {
1960   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1961     {
1962       if((*it).isNull())
1963         continue;
1964       if((*it)->presenceOfMultiDiscPerGeoType())
1965         return true;
1966     }
1967   return false;
1968 }
1969
1970 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1971 {
1972   if(!_father)
1973     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1974   return _father->getOrCreateAndGetArray();
1975 }
1976
1977 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1978 {
1979   if(!_father)
1980     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1981   return _father->getOrCreateAndGetArray();
1982 }
1983
1984 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1985 {
1986   return _father->getInfo();
1987 }
1988
1989 /*!
1990  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1991  * 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.
1992  * It returns 2 output vectors :
1993  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1994  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1995  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1996  */
1997 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)
1998 {
1999   int notNullPflsSz=0;
2000   int nbOfArrs=geoTypes.size();
2001   for(int i=0;i<nbOfArrs;i++)
2002     if(pfls[i])
2003       notNullPflsSz++;
2004   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2005   int nbOfDiffGeoTypes=geoTypes3.size();
2006   code.resize(3*nbOfDiffGeoTypes);
2007   notNullPfls.resize(notNullPflsSz);
2008   notNullPflsSz=0;
2009   int j=0;
2010   for(int i=0;i<nbOfDiffGeoTypes;i++)
2011     {
2012       int startZone=j;
2013       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2014       std::vector<const DataArrayInt *> notNullTmp;
2015       if(pfls[j])
2016         notNullTmp.push_back(pfls[j]);
2017       j++;
2018       for(;j<nbOfArrs;j++)
2019         if(geoTypes[j]==refType)
2020           {
2021             if(pfls[j])
2022               notNullTmp.push_back(pfls[j]);
2023           }
2024         else
2025           break;
2026       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2027       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2028       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2029       code[3*i]=(int)refType;
2030       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2031       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2032       if(notNullTmp.empty())
2033         code[3*i+2]=-1;
2034       else
2035         {
2036           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2037           code[3*i+2]=notNullPflsSz++;
2038         }
2039     }
2040 }
2041
2042 /*!
2043  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2044  */
2045 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)
2046 {
2047   int sz=dads.size();
2048   int ret=0;
2049   for(int i=0;i<sz;i++)
2050     {
2051       if(locs[i]==-1)
2052         {
2053           if(type!=ON_GAUSS_NE)
2054             ret+=dads[i].second-dads[i].first;
2055           else
2056             {
2057               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2058               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2059             }
2060         }
2061       else
2062         {
2063           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2064           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2065         }
2066     }
2067   return ret;
2068 }
2069
2070 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2071 {
2072   std::vector<std::string> ret;
2073   std::set<std::string> ret2;
2074   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2075     {
2076       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2077       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2078         if(ret2.find(*it2)==ret2.end())
2079           {
2080             ret.push_back(*it2);
2081             ret2.insert(*it2);
2082           }
2083     }
2084   return ret;
2085 }
2086
2087 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2088 {
2089   std::vector<std::string> ret;
2090   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2091     {
2092       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2093       ret.insert(ret.end(),tmp.begin(),tmp.end());
2094     }
2095   return ret;
2096 }
2097
2098 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2099 {
2100   std::vector<std::string> ret;
2101   std::set<std::string> ret2;
2102   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2103     {
2104       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2105       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2106         if(ret2.find(*it2)==ret2.end())
2107           {
2108             ret.push_back(*it2);
2109             ret2.insert(*it2);
2110           }
2111     }
2112   return ret;
2113 }
2114
2115 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2116 {
2117   std::vector<std::string> ret;
2118   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2119     {
2120       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2121       ret.insert(ret.end(),tmp.begin(),tmp.end());
2122     }
2123   return ret;
2124 }
2125
2126 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2127 {
2128   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2129     {
2130       if((*it).first==_mesh_name)
2131         {
2132           _mesh_name=(*it).second;
2133           return true;
2134         }
2135     }
2136   return false;
2137 }
2138
2139 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2140                                                       MEDFileFieldGlobsReal& glob)
2141 {
2142   if(_mesh_name!=meshName)
2143     return false;
2144   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2145   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2146   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2147   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2148   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2149   getUndergroundDataArrayExt(entries);
2150   DataArray *arr0(getOrCreateAndGetArray());//tony
2151   if(!arr0)
2152     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2153   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2154   if(!arr0)
2155     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2156   int sz=0;
2157   if(!arr)
2158     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2159   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2160     {
2161       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2162         {
2163           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2164           sz+=(*it).second.second-(*it).second.first;
2165         }
2166       else
2167         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2168     }
2169   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2170   ////////////////////
2171   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2172   int *workI2=explicitIdsOldInMesh->getPointer();
2173   int sz1=0,sz2=0,sid=1;
2174   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2175   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2176   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2177     {
2178       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2179       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2180       int *workI=explicitIdsOldInArr->getPointer();
2181       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2182         {
2183           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2184           (*itL2)->setLocId(sz2);
2185           (*itL2)->_tmp_work1=(*itL2)->getStart();
2186           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2187         }
2188       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2189     }
2190   explicitIdsOldInMesh->reAlloc(sz2);
2191   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2192   ////////////////////
2193   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2194   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2195   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2196   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2197     {
2198       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2199       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2200       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2201     }
2202   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2203   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2204   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2205     {
2206       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2207       int newStart=elt->getLocId();
2208       elt->setLocId((*it)->getGeoType());
2209       elt->setNewStart(newStart);
2210       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2211       entriesKeptNew.push_back(elt);
2212       entriesKeptNew2.push_back(elt);
2213     }
2214   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2215   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2216   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2217   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2218   bool ret=false;
2219   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2220     {
2221       sid=0;
2222       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2223         {
2224           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2225           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2226           }*/
2227       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2228                                                             glob,arr2,otherEntriesNew) || ret;
2229     }
2230   if(!ret)
2231     return false;
2232   // Assign new dispatching
2233   assignNewLeaves(otherEntriesNew);
2234   arr->deepCopyFrom(*arr2);
2235   return true;
2236 }
2237
2238 /*!
2239  * \param [in,out] globalNum a global numbering counter for the renumbering.
2240  * \param [out] its - list of pair (start,stop) kept
2241  */
2242 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2243 {
2244   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2245   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2246     {
2247       std::vector< std::pair<int,int> > its2;
2248       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2249         {
2250           ret.push_back(*it);
2251           its.insert(its.end(),its2.begin(),its2.end());
2252         }
2253     }
2254   _field_pm_pt=ret;
2255 }
2256
2257 /*!
2258  * \param [in,out] globalNum a global numbering counter for the renumbering.
2259  * \param [out] its - list of pair (start,stop) kept
2260  */
2261 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2262 {
2263   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2264   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2265     {
2266       std::vector< std::pair<int,int> > its2;
2267       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2268         {
2269           ret.push_back(*it);
2270           its.insert(its.end(),its2.begin(),its2.end());
2271         }
2272     }
2273   _field_pm_pt=ret;
2274 }
2275
2276 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2277 {
2278   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2279   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2280     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2281   //
2282   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2283   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2284   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2285   for(;it1!=types.end();it1++,it2++)
2286     {
2287       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2288       elt->setLeaves((*it1).second);
2289       MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2290       *it2=elt2;
2291     }
2292   _field_pm_pt=fieldPmPt;
2293 }
2294
2295 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2296 {
2297   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2298     (*it)->changePflsRefsNamesGen(mapOfModif);
2299 }
2300
2301 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2302 {
2303   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304     (*it)->changeLocsRefsNamesGen(mapOfModif);
2305 }
2306
2307 /*!
2308  * \param [in] mesh is the whole mesh
2309  */
2310 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2311 {
2312   if(_field_pm_pt.empty())
2313     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2314   //
2315   std::vector< std::pair<int,int> > dads;
2316   std::vector<const DataArrayInt *> pfls;
2317   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2318   std::vector<int> locs,code;
2319   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2320   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2321     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2322   // Sort by types
2323   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2324   if(code.empty())
2325     {
2326       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2327       throw INTERP_KERNEL::Exception(oss.str());
2328     }
2329   //
2330   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2331   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2332   if(type!=ON_NODES)
2333     {
2334       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2335       if(!arr)
2336         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2337       else
2338         {
2339           MCAuto<DataArrayInt> arr2(arr);
2340           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2341         }
2342     }
2343   else
2344     {
2345       if(code.size()!=3)
2346         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2347       int nb=code[1];
2348       if(code[2]==-1)
2349         {
2350           if(nb!=mesh->getNumberOfNodes())
2351             {
2352               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2353               oss << " nodes in mesh !";
2354               throw INTERP_KERNEL::Exception(oss.str());
2355             }
2356           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2357         }
2358       else
2359         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2360     }
2361 }
2362
2363 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2364 {
2365   if(_field_pm_pt.empty())
2366     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2367   //
2368   std::vector<std::pair<int,int> > dads;
2369   std::vector<const DataArrayInt *> pfls;
2370   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2371   std::vector<int> locs,code;
2372   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2373   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2374     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2375   // Sort by types
2376   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2377   if(code.empty())
2378     {
2379       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2380       throw INTERP_KERNEL::Exception(oss.str());
2381     }
2382   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2383   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2384   if(type!=ON_NODES)
2385     {
2386       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2387       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2388     }
2389   else
2390     {
2391       if(code.size()!=3)
2392         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2393       int nb=code[1];
2394       if(code[2]==-1)
2395         {
2396           if(nb!=mesh->getNumberOfNodes())
2397             {
2398               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2399               oss << " nodes in mesh !";
2400               throw INTERP_KERNEL::Exception(oss.str());
2401             }
2402         }
2403       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2404     }
2405   //
2406   return 0;
2407 }
2408
2409 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2410 {
2411   int globalSz=0;
2412   int nbOfEntries=0;
2413   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2414     {
2415       (*it)->getSizes(globalSz,nbOfEntries);
2416     }
2417   entries.resize(nbOfEntries);
2418   nbOfEntries=0;
2419   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2420     {
2421       (*it)->fillValues(nbOfEntries,entries);
2422     }
2423 }
2424
2425 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2426 {
2427   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2428     {
2429       if((*it)->getGeoType()==typ)
2430         return (*it)->getLeafGivenLocId(locId);
2431     }
2432   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2433   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2434   oss << "Possiblities are : ";
2435   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2436     {
2437       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2438       oss << "\"" << cm2.getRepr() << "\", ";
2439     }
2440   throw INTERP_KERNEL::Exception(oss.str());
2441 }
2442
2443 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2444 {
2445   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2446     {
2447       if((*it)->getGeoType()==typ)
2448         return (*it)->getLeafGivenLocId(locId);
2449     }
2450   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2451   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2452   oss << "Possiblities are : ";
2453   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2454     {
2455       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2456       oss << "\"" << cm2.getRepr() << "\", ";
2457     }
2458   throw INTERP_KERNEL::Exception(oss.str());
2459 }
2460
2461 /*!
2462  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2463  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2464  * \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.
2465  * \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.
2466  */
2467 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)
2468 {
2469   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2470   if(pms.empty())
2471     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2472   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2473     {
2474       if(!(*it).second)
2475         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2476       if(!(*it).second->getProfile().empty())
2477         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2478       if(!(*it).second->getLocalization().empty())
2479         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2480     }
2481   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2482   std::size_t i(0);
2483   std::vector< std::pair<int,int> > filteredDTS;
2484   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2485     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2486       if((*it2).first==gt)
2487         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2488   if(pms.size()!=filteredDTS.size())
2489     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2490   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2491   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2492   int zeStart(start),nval(0);
2493   for(;it1!=pms.end();it1++,it2++)
2494     {
2495       if((*it1).first!=(*it2).first)
2496         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2497       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2498       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2499       start+=e1-s1;
2500       nval+=((*it1).second)->getNumberOfVals();
2501     }
2502   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2503   return ret;
2504 }
2505
2506 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)
2507 {
2508   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2509   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2510   std::size_t i(0);
2511   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2512     {
2513       const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2514       for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2515         {
2516           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2517           const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2518           if(!elt)
2519             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2520           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2521         }
2522     }
2523   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2524     {
2525       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2526       MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2527       ret->_field_pm_pt.push_back(agg2);
2528     }
2529   return ret;
2530 }
2531
2532 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2533 {
2534   int i=0;
2535   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2536   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2537   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2538     {
2539       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2540       if(type==curType)
2541         return i;
2542       else
2543         {
2544           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2545           if(pos>pos2)
2546             it2=it+1;
2547         }
2548     }
2549   int ret=std::distance(_field_pm_pt.begin(),it2);
2550   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2551   return ret;
2552 }
2553
2554 /*!
2555  * 'dads' and 'locs' input parameters have the same number of elements
2556  * \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
2557  */
2558 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2559                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2560                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2561 {
2562   isPfl=false;
2563   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2564   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2565   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2566   const std::vector<std::string>& infos=getInfo();
2567   da->setInfoOnComponents(infos);
2568   da->setName("");
2569   if(type==ON_GAUSS_PT)
2570     {
2571       int offset=0;
2572       int nbOfArrs=dads.size();
2573       for(int i=0;i<nbOfArrs;i++)
2574         {
2575           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2576           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2577           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2578           MCAuto<DataArrayInt> di=DataArrayInt::New();
2579           di->alloc(nbOfElems,1);
2580           di->iota(offset);
2581           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2582           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2583           offset+=nbOfElems;
2584         }
2585     }
2586   arrOut=da;
2587   return ret.retn();
2588 }
2589
2590 /*!
2591  * 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.
2592  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2593  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2594  * The order of cells in the returned field is those imposed by the profile.
2595  * \param [in] mesh is the global mesh.
2596  */
2597 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2598                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2599                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2600                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2601 {
2602   if(da->isIota(mesh->getNumberOfCells()))
2603     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2604   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2605   m2->setName(mesh->getName().c_str());
2606   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2607   isPfl=true;
2608   return ret.retn();
2609 }
2610
2611 /*!
2612  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2613  */
2614 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2615                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2616                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2617 {
2618   if(da->isIota(mesh->getNumberOfNodes()))
2619     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2620   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2621   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2622   if(meshu)
2623     {
2624       if(meshu->getNodalConnectivity()==0)
2625         {
2626           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2627           int nb=da->getNbOfElems();
2628           const int *ptr=da->getConstPointer();
2629           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2630           meshuc->allocateCells(nb);
2631           for(int i=0;i<nb;i++)
2632             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2633           meshuc->finishInsertingCells();
2634           ret->setMesh(meshuc);
2635           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2636           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2637           disc->checkCoherencyBetween(meshuc,arrOut);
2638           return ret.retn();
2639         }
2640     }
2641   //
2642   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2643   isPfl=true;
2644   DataArrayInt *arr2=0;
2645   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2646   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2647   MCAuto<DataArrayInt> arr3(arr2);
2648   int nnodes=mesh2->getNumberOfNodes();
2649   if(nnodes==(int)da->getNbOfElems())
2650     {
2651       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2652       arrOut->renumberInPlace(da3->getConstPointer());
2653       mesh2->setName(mesh->getName().c_str());
2654       ret->setMesh(mesh2);
2655       return ret.retn();
2656     }
2657   else
2658     {
2659       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 !!!";
2660       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2661       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2662       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2663       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2664       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2665       throw INTERP_KERNEL::Exception(oss.str());
2666     }
2667   return 0;
2668 }
2669
2670 /*!
2671  * This method is the most light method of field retrieving.
2672  */
2673 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2674 {
2675   if(!pflIn)
2676     {
2677       pflOut=DataArrayInt::New();
2678       pflOut->alloc(nbOfElems,1);
2679       pflOut->iota(0);
2680     }
2681   else
2682     {
2683       pflOut=const_cast<DataArrayInt*>(pflIn);
2684       pflOut->incrRef();
2685     }
2686   MCAuto<DataArrayInt> safePfl(pflOut);
2687   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2688   const std::vector<std::string>& infos=getInfo();
2689   int nbOfComp=infos.size();
2690   for(int i=0;i<nbOfComp;i++)
2691     da->setInfoOnComponent(i,infos[i].c_str());
2692   safePfl->incrRef();
2693   return da.retn();
2694 }
2695
2696
2697 /// @cond INTERNAL
2698
2699 class MFFPMIter
2700 {
2701 public:
2702   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2703   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2704   virtual ~MFFPMIter() { }
2705   virtual void begin() = 0;
2706   virtual bool finished() const = 0;
2707   virtual void next() = 0;
2708   virtual int current() const = 0;
2709 };
2710
2711 class MFFPMIterSimple : public MFFPMIter
2712 {
2713 public:
2714   MFFPMIterSimple():_pos(0) { }
2715   void begin() { _pos=0; }
2716   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2717   void next() { _pos++; }
2718   int current() const { return _pos; }
2719 private:
2720   int _pos;
2721 };
2722
2723 class MFFPMIter2 : public MFFPMIter
2724 {
2725 public:
2726   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2727   void begin() { _it=_ids.begin(); }
2728   bool finished() const { return _it==_ids.end(); }
2729   void next() { _it++; }
2730   int current() const { return *_it; }
2731 private:
2732   std::vector<int> _ids;
2733   std::vector<int>::const_iterator _it;
2734 };
2735
2736 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2737 {
2738   if(!entities)
2739     return new MFFPMIterSimple;
2740   else
2741     {
2742       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2743       if(entities2)
2744         {
2745           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2746           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2747           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2748             {
2749               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2750                 tmp.push_back((*it).second);
2751             }
2752           return new MFFPMIter2(tmp);
2753         }
2754       return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2755     }
2756 }
2757
2758 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2759 {
2760   if(!entities)
2761     return true;
2762   else
2763     {
2764       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2765       if(entities2)
2766         {
2767           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2768           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2769             if((*it).first==ON_NODES)
2770               return true;
2771           return false;
2772         }
2773       return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2774     }
2775 }
2776
2777 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2778 {
2779   std::size_t sz(cts.size());
2780   _ids.resize(sz);
2781   for(std::size_t i=0;i<sz;i++)
2782     {
2783       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2784       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2785         _ids[i]=(int)std::distance(typmai2,loc);
2786       else
2787         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2788     }
2789 }
2790
2791 /// @endcond
2792
2793 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),
2794     _father(fath)
2795 {
2796   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2797   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2798   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2799   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2800   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2801   for(iter0->begin();!iter0->finished();iter0->next())
2802     {
2803       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2804       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2805       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2806       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2807       if(nbProfile>0 || nbProfile2>0)
2808         {
2809           const PartDefinition *pd(0);
2810           if(mmu)
2811             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2812           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2813           if(nbProfile>0)
2814             _mesh_name=name0;
2815           else
2816             _mesh_name=name1;
2817         }
2818     }
2819   if(MFFPMIter::IsPresenceOfNode(entities))
2820     {
2821       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2822       if(nbProfile>0)
2823         {
2824           const PartDefinition *pd(0);
2825           if(mmu)
2826             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2827           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2828           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2829         }
2830     }
2831   if(!entities)
2832     return ;
2833   std::vector<int> dynGT(entities->getDynGTAvail());
2834   for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2835     {
2836       int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2837       if(nbPfl>0)
2838         {
2839           _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2840         }
2841     }
2842 }
2843
2844 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2845 {
2846   copyTinyInfoFrom(mesh);
2847 }
2848
2849 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2850 {
2851   if(id>=(int)_pfls.size())
2852     _pfls.resize(id+1);
2853   _pfls[id]=DataArrayInt::New();
2854   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2855   _pfls[id]->setName(pflName);
2856   _pfls[id]->alloc(lgth,1);
2857   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2858   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2859 }
2860
2861 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2862 {
2863   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2864   int sz;
2865   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2866   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2867   if(i>=(int)_pfls.size())
2868     _pfls.resize(i+1);
2869   _pfls[i]=DataArrayInt::New();
2870   _pfls[i]->alloc(sz,1);
2871   _pfls[i]->setName(pflCpp.c_str());
2872   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2873   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2874 }
2875
2876 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2877 {
2878   int nbOfPfls=_pfls.size();
2879   for(int i=0;i<nbOfPfls;i++)
2880     {
2881       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2882       cpy->applyLin(1,1,0);
2883       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2884       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2885       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2886     }
2887   //
2888   int nbOfLocs=_locs.size();
2889   for(int i=0;i<nbOfLocs;i++)
2890     _locs[i]->writeLL(fid);
2891 }
2892
2893 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2894 {
2895   std::vector<std::string> pfls=getPfls();
2896   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2897     {
2898       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2899       if(it2==pfls.end())
2900         {
2901           _pfls.push_back(*it);
2902         }
2903       else
2904         {
2905           int id=std::distance(pfls.begin(),it2);
2906           if(!(*it)->isEqual(*_pfls[id]))
2907             {
2908               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2909               throw INTERP_KERNEL::Exception(oss.str());
2910             }
2911         }
2912     }
2913   std::vector<std::string> locs=getLocs();
2914   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2915     {
2916       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2917       if(it2==locs.end())
2918         {
2919           _locs.push_back(*it);
2920         }
2921       else
2922         {
2923           int id=std::distance(locs.begin(),it2);
2924           if(!(*it)->isEqual(*_locs[id],eps))
2925             {
2926               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2927               throw INTERP_KERNEL::Exception(oss.str());
2928             }
2929         }
2930     }
2931 }
2932
2933 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2934 {
2935   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2936     getProfile((*it).c_str());
2937 }
2938
2939 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2940 {
2941   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2942     getLocalization((*it).c_str());
2943 }
2944
2945 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2946 {
2947   std::vector<std::string> profiles=real.getPflsReallyUsed();
2948   int sz=profiles.size();
2949   _pfls.resize(sz);
2950   for(int i=0;i<sz;i++)
2951     loadProfileInFile(fid,i,profiles[i].c_str());
2952   //
2953   std::vector<std::string> locs=real.getLocsReallyUsed();
2954   sz=locs.size();
2955   _locs.resize(sz);
2956   for(int i=0;i<sz;i++)
2957     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2958 }
2959
2960 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2961 {
2962   int nProfil=MEDnProfile(fid);
2963   for(int i=0;i<nProfil;i++)
2964     loadProfileInFile(fid,i);
2965   int sz=MEDnLocalization(fid);
2966   _locs.resize(sz);
2967   for(int i=0;i<sz;i++)
2968     {
2969       _locs[i]=MEDFileFieldLoc::New(fid,i);
2970     }
2971 }
2972
2973 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
2974 {
2975   return new MEDFileFieldGlobs(fid);
2976 }
2977
2978 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2979 {
2980   return new MEDFileFieldGlobs;
2981 }
2982
2983 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2984 {
2985   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2986 }
2987
2988 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2989 {
2990   std::vector<const BigMemoryObject *> ret;
2991   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2992     ret.push_back((const DataArrayInt *)*it);
2993   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2994     ret.push_back((const MEDFileFieldLoc *)*it);
2995   return ret;
2996 }
2997
2998 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2999 {
3000   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3001   std::size_t i=0;
3002   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3003     {
3004       if((const DataArrayInt *)*it)
3005         ret->_pfls[i]=(*it)->deepCopy();
3006     }
3007   i=0;
3008   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3009     {
3010       if((const MEDFileFieldLoc*)*it)
3011         ret->_locs[i]=(*it)->deepCopy();
3012     }
3013   return ret.retn();
3014 }
3015
3016 /*!
3017  * \throw if a profile in \a pfls in not in \a this.
3018  * \throw if a localization in \a locs in not in \a this.
3019  * \sa MEDFileFieldGlobs::deepCpyPart
3020  */
3021 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3022 {
3023   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3024   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3025     {
3026       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3027       if(!pfl)
3028         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3029       pfl->incrRef();
3030       MCAuto<DataArrayInt> pfl2(pfl);
3031       ret->_pfls.push_back(pfl2);
3032     }
3033   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3034     {
3035       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3036       if(!loc)
3037         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3038       loc->incrRef();
3039       MCAuto<MEDFileFieldLoc> loc2(loc);
3040       ret->_locs.push_back(loc2);
3041     }
3042   ret->setFileName(getFileName());
3043   return ret.retn();
3044 }
3045
3046 /*!
3047  * \throw if a profile in \a pfls in not in \a this.
3048  * \throw if a localization in \a locs in not in \a this.
3049  * \sa MEDFileFieldGlobs::shallowCpyPart
3050  */
3051 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3052 {
3053   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3054   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3055     {
3056       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3057       if(!pfl)
3058         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3059       ret->_pfls.push_back(pfl->deepCopy());
3060     }
3061   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3062     {
3063       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3064       if(!loc)
3065         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3066       ret->_locs.push_back(loc->deepCopy());
3067     }
3068   ret->setFileName(getFileName());
3069   return ret.retn();
3070 }
3071
3072 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3073 {
3074 }
3075
3076 MEDFileFieldGlobs::MEDFileFieldGlobs()
3077 {
3078 }
3079
3080 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3081 {
3082 }
3083
3084 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3085 {
3086   oss << "Profiles :\n";
3087   std::size_t n=_pfls.size();
3088   for(std::size_t i=0;i<n;i++)
3089     {
3090       oss << "  - #" << i << " ";
3091       const DataArrayInt *pfl=_pfls[i];
3092       if(pfl)
3093         oss << "\"" << pfl->getName() << "\"\n";
3094       else
3095         oss << "EMPTY !\n";
3096     }
3097   n=_locs.size();
3098   oss << "Localizations :\n";
3099   for(std::size_t i=0;i<n;i++)
3100     {
3101       oss << "  - #" << i << " ";
3102       const MEDFileFieldLoc *loc=_locs[i];
3103       if(loc)
3104         loc->simpleRepr(oss);
3105       else
3106         oss<< "EMPTY !\n";
3107     }
3108 }
3109
3110 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3111 {
3112   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3113     {
3114       DataArrayInt *elt(*it);
3115       if(elt)
3116         {
3117           std::string name(elt->getName());
3118           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3119             {
3120               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3121                 {
3122                   elt->setName((*it2).second.c_str());
3123                   return;
3124                 }
3125             }
3126         }
3127     }
3128 }
3129
3130 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3131 {
3132   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3133     {
3134       MEDFileFieldLoc *elt(*it);
3135       if(elt)
3136         {
3137           std::string name(elt->getName());
3138           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3139             {
3140               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3141                 {
3142                   elt->setName((*it2).second.c_str());
3143                   return;
3144                 }
3145             }
3146         }
3147     }
3148 }
3149
3150 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3151 {
3152   if(locId<0 || locId>=(int)_locs.size())
3153     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3154   return _locs[locId]->getNbOfGaussPtPerCell();
3155 }
3156
3157 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3158 {
3159   return getLocalizationFromId(getLocalizationId(locName));
3160 }
3161
3162 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3163 {
3164   if(locId<0 || locId>=(int)_locs.size())
3165     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3166   return *_locs[locId];
3167 }
3168
3169 /// @cond INTERNAL
3170 namespace MEDCouplingImpl
3171 {
3172   class LocFinder
3173   {
3174   public:
3175     LocFinder(const std::string& loc):_loc(loc) { }
3176     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3177   private:
3178     const std::string &_loc;
3179   };
3180
3181   class PflFinder
3182   {
3183   public:
3184     PflFinder(const std::string& pfl):_pfl(pfl) { }
3185     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3186   private:
3187     const std::string& _pfl;
3188   };
3189 }
3190 /// @endcond
3191
3192 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3193 {
3194   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3195   if(it==_locs.end())
3196     {
3197       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3198       for(it=_locs.begin();it!=_locs.end();it++)
3199         oss << "\"" << (*it)->getName() << "\", ";
3200       throw INTERP_KERNEL::Exception(oss.str());
3201     }
3202   return std::distance(_locs.begin(),it);
3203 }
3204
3205 /*!
3206  * The returned value is never null.
3207  */
3208 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3209 {
3210   std::string pflNameCpp(pflName);
3211   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3212   if(it==_pfls.end())
3213     {
3214       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3215       for(it=_pfls.begin();it!=_pfls.end();it++)
3216         oss << "\"" << (*it)->getName() << "\", ";
3217       throw INTERP_KERNEL::Exception(oss.str());
3218     }
3219   return *it;
3220 }
3221
3222 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3223 {
3224   if(pflId<0 || pflId>=(int)_pfls.size())
3225     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3226   return _pfls[pflId];
3227 }
3228
3229 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3230 {
3231   if(locId<0 || locId>=(int)_locs.size())
3232     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3233   return *_locs[locId];
3234 }
3235
3236 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3237 {
3238   return getLocalizationFromId(getLocalizationId(locName));
3239 }
3240
3241 /*!
3242  * The returned value is never null.
3243  */
3244 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3245 {
3246   std::string pflNameCpp(pflName);
3247   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3248   if(it==_pfls.end())
3249     {
3250       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3251       for(it=_pfls.begin();it!=_pfls.end();it++)
3252         oss << "\"" << (*it)->getName() << "\", ";
3253       throw INTERP_KERNEL::Exception(oss.str());
3254     }
3255   return *it;
3256 }
3257
3258 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3259 {
3260   if(pflId<0 || pflId>=(int)_pfls.size())
3261     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3262   return _pfls[pflId];
3263 }
3264
3265 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3266 {
3267   std::vector< MCAuto<DataArrayInt> > newPfls;
3268   int i=0;
3269   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3270     {
3271       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3272         newPfls.push_back(*it);
3273     }
3274   _pfls=newPfls;
3275 }
3276
3277 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3278 {
3279   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3280   int i=0;
3281   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3282     {
3283       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3284         newLocs.push_back(*it);
3285     }
3286   _locs=newLocs;
3287 }
3288
3289 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3290 {
3291   int sz=_pfls.size();
3292   std::vector<std::string> ret(sz);
3293   for(int i=0;i<sz;i++)
3294     ret[i]=_pfls[i]->getName();
3295   return ret;
3296 }
3297
3298 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3299 {
3300   int sz=_locs.size();
3301   std::vector<std::string> ret(sz);
3302   for(int i=0;i<sz;i++)
3303     ret[i]=_locs[i]->getName();
3304   return ret;
3305 }
3306
3307 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3308 {
3309   std::vector<std::string> v=getPfls();
3310   std::string s(pflName);
3311   return std::find(v.begin(),v.end(),s)!=v.end();
3312 }
3313
3314 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3315 {
3316   std::vector<std::string> v=getLocs();
3317   std::string s(locName);
3318   return std::find(v.begin(),v.end(),s)!=v.end();
3319 }
3320
3321 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3322 {
3323   std::map<int,std::vector<int> > m;
3324   int i=0;
3325   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3326     {
3327       const DataArrayInt *tmp=(*it);
3328       if(tmp)
3329         {
3330           m[tmp->getHashCode()].push_back(i);
3331         }
3332     }
3333   std::vector< std::vector<int> > ret;
3334   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3335     {
3336       if((*it2).second.size()>1)
3337         {
3338           std::vector<int> ret0;
3339           bool equalityOrNot=false;
3340           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3341             {
3342               std::vector<int>::const_iterator it4=it3; it4++;
3343               for(;it4!=(*it2).second.end();it4++)
3344                 {
3345                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3346                     {
3347                       if(!equalityOrNot)
3348                         ret0.push_back(*it3);
3349                       ret0.push_back(*it4);
3350                       equalityOrNot=true;
3351                     }
3352                 }
3353             }
3354           if(!ret0.empty())
3355             ret.push_back(ret0);
3356         }
3357     }
3358   return ret;
3359 }
3360
3361 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3362 {
3363   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3364 }
3365
3366 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3367 {
3368   std::string name(pfl->getName());
3369   if(name.empty())
3370     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3371   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3372     if(name==(*it)->getName())
3373       {
3374         if(!pfl->isEqual(*(*it)))
3375           {
3376             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3377             throw INTERP_KERNEL::Exception(oss.str());
3378           }
3379       }
3380   pfl->incrRef();
3381   _pfls.push_back(pfl);
3382 }
3383
3384 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)
3385 {
3386   std::string name(locName);
3387   if(name.empty())
3388     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3389   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3390   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3391     if((*it)->isName(locName))
3392       {
3393         if(!(*it)->isEqual(*obj,1e-12))
3394           {
3395             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3396             throw INTERP_KERNEL::Exception(oss.str());
3397           }
3398       }
3399   _locs.push_back(obj);
3400 }
3401
3402 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3403 {
3404   std::vector<std::string> names=getPfls();
3405   return CreateNewNameNotIn("NewPfl_",names);
3406 }
3407
3408 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3409 {
3410   std::vector<std::string> names=getLocs();
3411   return CreateNewNameNotIn("NewLoc_",names);
3412 }
3413
3414 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3415 {
3416   for(std::size_t sz=0;sz<100000;sz++)
3417     {
3418       std::ostringstream tryName;
3419       tryName << prefix << sz;
3420       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3421         return tryName.str();
3422     }
3423   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3424 }
3425
3426 /*!
3427  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3428  *  \param [in] fname - the file name.
3429  */
3430 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3431 {
3432 }
3433
3434 /*!
3435  * Creates an empty MEDFileFieldGlobsReal.
3436  */
3437 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3438 {
3439 }
3440
3441 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3442 {
3443   return 0;
3444 }
3445
3446 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3447 {
3448   std::vector<const BigMemoryObject *> ret;
3449   ret.push_back((const MEDFileFieldGlobs *)_globals);
3450   return ret;
3451 }
3452
3453 /*!
3454  * Returns a string describing profiles and Gauss points held in \a this.
3455  *  \return std::string - the description string.
3456  */
3457 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3458 {
3459   const MEDFileFieldGlobs *glob=_globals;
3460   std::ostringstream oss2; oss2 << glob;
3461   std::string stars(oss2.str().length(),'*');
3462   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3463   if(glob)
3464     glob->simpleRepr(oss);
3465   else
3466     oss << "NO GLOBAL INFORMATION !\n";
3467 }
3468
3469 void MEDFileFieldGlobsReal::resetContent()
3470 {
3471   _globals=MEDFileFieldGlobs::New();
3472 }
3473
3474 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3475 {
3476 }
3477
3478 /*!
3479  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3480  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3481  */
3482 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3483 {
3484   _globals=other._globals;
3485 }
3486
3487 /*!
3488  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3489  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3490  */
3491 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3492 {
3493   const MEDFileFieldGlobs *otherg(other._globals);
3494   if(!otherg)
3495     return ;
3496   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3497 }
3498
3499 /*!
3500  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3501  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3502  */
3503 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3504 {
3505   const MEDFileFieldGlobs *otherg(other._globals);
3506   if(!otherg)
3507     return ;
3508   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3509 }
3510
3511 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3512 {
3513   _globals=other._globals;
3514   if((const MEDFileFieldGlobs *)_globals)
3515     _globals=other._globals->deepCopy();
3516 }
3517
3518 /*!
3519  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3520  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3521  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3522  *         \a this and \a other MEDFileFieldGlobsReal.
3523  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3524  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3525  */
3526 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3527 {
3528   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3529   if(thisGlobals==otherGlobals)
3530     return ;
3531   if(!thisGlobals)
3532     {
3533       _globals=other._globals;
3534       return ;
3535     }
3536   _globals->appendGlobs(*other._globals,eps);
3537 }
3538
3539 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3540 {
3541   checkGlobsPflsPartCoherency();
3542   checkGlobsLocsPartCoherency();
3543 }
3544
3545 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3546 {
3547   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3548 }
3549
3550 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3551 {
3552   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3553 }
3554
3555 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3556 {
3557   contentNotNull()->loadProfileInFile(fid,id,pflName);
3558 }
3559
3560 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3561 {
3562   contentNotNull()->loadProfileInFile(fid,id);
3563 }
3564
3565 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3566 {
3567   contentNotNull()->loadGlobals(fid,*this);
3568 }
3569
3570 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3571 {
3572   contentNotNull()->loadAllGlobals(fid);
3573 }
3574
3575 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3576 {
3577   contentNotNull()->writeGlobals(fid,opt);
3578 }
3579
3580 /*!
3581  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3582  * or getPflsReallyUsedMulti().
3583  *  \return std::vector<std::string> - a sequence of names of all profiles.
3584  */
3585 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3586 {
3587   return contentNotNull()->getPfls();
3588 }
3589
3590 /*!
3591  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3592  * or getLocsReallyUsedMulti().
3593  *  \return std::vector<std::string> - a sequence of names of all localizations.
3594  */
3595 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3596 {
3597   return contentNotNull()->getLocs();
3598 }
3599
3600 /*!
3601  * Checks if the profile with a given name exists.
3602  *  \param [in] pflName - the profile name of interest.
3603  *  \return bool - \c true if the profile named \a pflName exists.
3604  */
3605 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3606 {
3607   return contentNotNull()->existsPfl(pflName);
3608 }
3609
3610 /*!
3611  * Checks if the localization with a given name exists.
3612  *  \param [in] locName - the localization name of interest.
3613  *  \return bool - \c true if the localization named \a locName exists.
3614  */
3615 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3616 {
3617   return contentNotNull()->existsLoc(locName);
3618 }
3619
3620 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3621 {
3622   return contentNotNull()->createNewNameOfPfl();
3623 }
3624
3625 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3626 {
3627   return contentNotNull()->createNewNameOfLoc();
3628 }
3629
3630 /*!
3631  * Sets the name of a MED file.
3632  *  \param [inout] fileName - the file name.
3633  */
3634 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3635 {
3636   contentNotNull()->setFileName(fileName);
3637 }
3638
3639 /*!
3640  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3641  * in the same order.
3642  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3643  *          Each item of this sequence is a vector containing ids of equal profiles.
3644  */
3645 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3646 {
3647   return contentNotNull()->whichAreEqualProfiles();
3648 }
3649
3650 /*!
3651  * Finds equal localizations.
3652  *  \param [in] eps - a precision used to compare real values of the localizations.
3653  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3654  *          Each item of this sequence is a vector containing ids of equal localizations.
3655  */
3656 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3657 {
3658   return contentNotNull()->whichAreEqualLocs(eps);
3659 }
3660
3661 /*!
3662  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3663  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3664  *        this sequence is a pair whose 
3665  *        - the first item is a vector of profile names to replace by the second item,
3666  *        - the second item is a profile name to replace every profile name of the first item.
3667  */
3668 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3669 {
3670   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3671 }
3672
3673 /*!
3674  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3675  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3676  *        this sequence is a pair whose 
3677  *        - the first item is a vector of localization names to replace by the second item,
3678  *        - the second item is a localization name to replace every localization name of the first item.
3679  */
3680 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3681 {
3682   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3683 }
3684
3685 /*!
3686  * Replaces references to some profiles (a reference is a profile name) by references
3687  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3688  * them-selves accordingly. <br>
3689  * This method is a generalization of changePflName().
3690  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3691  *        this sequence is a pair whose 
3692  *        - the first item is a vector of profile names to replace by the second item,
3693  *        - the second item is a profile name to replace every profile of the first item.
3694  * \sa changePflsRefsNamesGen()
3695  * \sa changePflName()
3696  */
3697 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3698 {
3699   changePflsRefsNamesGen(mapOfModif);
3700   changePflsNamesInStruct(mapOfModif);
3701 }
3702
3703 /*!
3704  * Replaces references to some localizations (a reference is a localization name) by references
3705  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3706  * them-selves accordingly. <br>
3707  * This method is a generalization of changeLocName().
3708  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3709  *        this sequence is a pair whose 
3710  *        - the first item is a vector of localization names to replace by the second item,
3711  *        - the second item is a localization name to replace every localization of the first item.
3712  * \sa changeLocsRefsNamesGen()
3713  * \sa changeLocName()
3714  */
3715 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3716 {
3717   changeLocsRefsNamesGen(mapOfModif);
3718   changeLocsNamesInStruct(mapOfModif);
3719 }
3720
3721 /*!
3722  * Renames the profile having a given name and updates references to this profile.
3723  *  \param [in] oldName - the name of the profile to rename.
3724  *  \param [in] newName - a new name of the profile.
3725  * \sa changePflsNames().
3726  */
3727 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3728 {
3729   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3730   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3731   mapOfModif[0]=p;
3732   changePflsNames(mapOfModif);
3733 }
3734
3735 /*!
3736  * Renames the localization having a given name and updates references to this localization.
3737  *  \param [in] oldName - the name of the localization to rename.
3738  *  \param [in] newName - a new name of the localization.
3739  * \sa changeLocsNames().
3740  */
3741 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3742 {
3743   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3744   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3745   mapOfModif[0]=p;
3746   changeLocsNames(mapOfModif);
3747 }
3748
3749 /*!
3750  * Removes duplicated profiles. Returns a map used to update references to removed 
3751  * profiles via changePflsRefsNamesGen().
3752  * Equal profiles are found using whichAreEqualProfiles().
3753  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3754  *          a sequence describing the performed replacements of profiles. Each element of
3755  *          this sequence is a pair whose
3756  *          - the first item is a vector of profile names replaced by the second item,
3757  *          - the second item is a profile name replacing every profile of the first item.
3758  */
3759 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3760 {
3761   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3762   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3763   int i=0;
3764   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3765     {
3766       std::vector< std::string > tmp((*it).size());
3767       int j=0;
3768       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3769         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3770       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3771       ret[i]=p;
3772       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3773       killProfileIds(tmp2);
3774     }
3775   changePflsRefsNamesGen(ret);
3776   return ret;
3777 }
3778
3779 /*!
3780  * Removes duplicated localizations. Returns a map used to update references to removed 
3781  * localizations via changeLocsRefsNamesGen().
3782  * Equal localizations are found using whichAreEqualLocs().
3783  *  \param [in] eps - a precision used to compare real values of the localizations.
3784  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3785  *          a sequence describing the performed replacements of localizations. Each element of
3786  *          this sequence is a pair whose
3787  *          - the first item is a vector of localization names replaced by the second item,
3788  *          - the second item is a localization name replacing every localization of the first item.
3789  */
3790 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3791 {
3792   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3793   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3794   int i=0;
3795   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3796     {
3797       std::vector< std::string > tmp((*it).size());
3798       int j=0;
3799       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3800         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3801       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3802       ret[i]=p;
3803       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3804       killLocalizationIds(tmp2);
3805     }
3806   changeLocsRefsNamesGen(ret);
3807   return ret;
3808 }
3809
3810 /*!
3811  * Returns number of Gauss points per cell in a given localization.
3812  *  \param [in] locId - an id of the localization of interest.
3813  *  \return int - the number of the Gauss points per cell.
3814  */
3815 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3816 {
3817   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3818 }
3819
3820 /*!
3821  * Returns an id of a localization by its name.
3822  *  \param [in] loc - the localization name of interest.
3823  *  \return int - the id of the localization.
3824  *  \throw If there is no a localization named \a loc.
3825  */
3826 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3827 {
3828   return contentNotNull()->getLocalizationId(loc);
3829 }
3830
3831 /*!
3832  * Returns the name of the MED file.
3833  *  \return const std::string&  - the MED file name.
3834  */
3835 std::string MEDFileFieldGlobsReal::getFileName() const
3836 {
3837   return contentNotNull()->getFileName();
3838 }
3839
3840 /*!
3841  * Returns a localization object by its name.
3842  *  \param [in] locName - the name of the localization of interest.
3843  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3844  *  \throw If there is no a localization named \a locName.
3845  */
3846 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3847 {
3848   return contentNotNull()->getLocalization(locName);
3849 }
3850
3851 /*!
3852  * Returns a localization object by its id.
3853  *  \param [in] locId - the id of the localization of interest.
3854  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3855  *  \throw If there is no a localization with id \a locId.
3856  */
3857 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3858 {
3859   return contentNotNull()->getLocalizationFromId(locId);
3860 }
3861
3862 /*!
3863  * Returns a profile array by its name.
3864  *  \param [in] pflName - the name of the profile of interest.
3865  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3866  *  \throw If there is no a profile named \a pflName.
3867  */
3868 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3869 {
3870   return contentNotNull()->getProfile(pflName);
3871 }
3872
3873 /*!
3874  * Returns a profile array by its id.
3875  *  \param [in] pflId - the id of the profile of interest.
3876  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3877  *  \throw If there is no a profile with id \a pflId.
3878  */
3879 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3880 {
3881   return contentNotNull()->getProfileFromId(pflId);
3882 }
3883
3884 /*!
3885  * Returns a localization object, apt for modification, by its id.
3886  *  \param [in] locId - the id of the localization of interest.
3887  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3888  *          having the id \a locId.
3889  *  \throw If there is no a localization with id \a locId.
3890  */
3891 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3892 {
3893   return contentNotNull()->getLocalizationFromId(locId);
3894 }
3895
3896 /*!
3897  * Returns a localization object, apt for modification, by its name.
3898  *  \param [in] locName - the name of the localization of interest.
3899  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3900  *          having the name \a locName.
3901  *  \throw If there is no a localization named \a locName.
3902  */
3903 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3904 {
3905   return contentNotNull()->getLocalization(locName);
3906 }
3907
3908 /*!
3909  * Returns a profile array, apt for modification, by its name.
3910  *  \param [in] pflName - the name of the profile of interest.
3911  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3912  *  \throw If there is no a profile named \a pflName.
3913  */
3914 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3915 {
3916   return contentNotNull()->getProfile(pflName);
3917 }
3918
3919 /*!
3920  * Returns a profile array, apt for modification, by its id.
3921  *  \param [in] pflId - the id of the profile of interest.
3922  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3923  *  \throw If there is no a profile with id \a pflId.
3924  */
3925 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3926 {
3927   return contentNotNull()->getProfileFromId(pflId);
3928 }
3929
3930 /*!
3931  * Removes profiles given by their ids. No data is updated to track this removal.
3932  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3933  */
3934 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3935 {
3936   contentNotNull()->killProfileIds(pflIds);
3937 }
3938
3939 /*!
3940  * Removes localizations given by their ids. No data is updated to track this removal.
3941  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3942  */
3943 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3944 {
3945   contentNotNull()->killLocalizationIds(locIds);
3946 }
3947
3948 /*!
3949  * Stores a profile array.
3950  *  \param [in] pfl - the profile array to store.
3951  *  \throw If the name of \a pfl is empty.
3952  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3953  *         different ids.
3954  */
3955 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3956 {
3957   contentNotNull()->appendProfile(pfl);
3958 }
3959
3960 /*!
3961  * Adds a new localization of Gauss points.
3962  *  \param [in] locName - the name of the new localization.
3963  *  \param [in] geoType - a geometrical type of the reference cell.
3964  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3965  *         must be \c nbOfNodesPerCell * \c dimOfType.
3966  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3967  *         must be  _wg_.size() * \c dimOfType.
3968  *  \param [in] w - the weights of Gauss points.
3969  *  \throw If \a locName is empty.
3970  *  \throw If a localization with the name \a locName already exists but is
3971  *         different form the new one.
3972  */
3973 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)
3974 {
3975   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3976 }
3977
3978 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3979 {
3980   MEDFileFieldGlobs *g(_globals);
3981   if(!g)
3982     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3983   return g;
3984 }
3985
3986 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3987 {
3988   const MEDFileFieldGlobs *g(_globals);
3989   if(!g)
3990     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3991   return g;
3992 }
3993
3994 //= MEDFileFieldNameScope
3995
3996 MEDFileFieldNameScope::MEDFileFieldNameScope()
3997 {
3998 }
3999
4000 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4001 {
4002 }
4003
4004 /*!
4005  * Returns the name of \a this field.
4006  *  \return std::string - a string containing the field name.
4007  */
4008 std::string MEDFileFieldNameScope::getName() const
4009 {
4010   return _name;
4011 }
4012
4013 /*!
4014  * Sets name of \a this field
4015  *  \param [in] name - the new field name.
4016  */
4017 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4018 {
4019   _name=fieldName;
4020 }
4021
4022 std::string MEDFileFieldNameScope::getDtUnit() const
4023 {
4024   return _dt_unit;
4025 }
4026
4027 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4028 {
4029   _dt_unit=dtUnit;
4030 }
4031
4032 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4033 {
4034   _name=other._name;
4035   _dt_unit=other._dt_unit;
4036 }
4037
4038 //= MEDFileAnyTypeField1TSWithoutSDA
4039
4040 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4041 {
4042   _field_per_mesh.resize(other._field_per_mesh.size());
4043   std::size_t i=0;
4044   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4045     {
4046       if((const MEDFileFieldPerMesh *)*it)
4047         _field_per_mesh[i]=(*it)->deepCopy(this);
4048     }
4049 }
4050
4051 /*!
4052  * Prints a string describing \a this field into a stream. This string is outputted 
4053  * by \c print Python command.
4054  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4055  *  \param [in,out] oss - the out stream.
4056  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4057  *          info id printed, else, not.
4058  */
4059 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4060 {
4061   std::string startOfLine(bkOffset,' ');
4062   oss << startOfLine << "Field ";
4063   if(bkOffset==0)
4064     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4065   oss << "on one time Step ";
4066   if(f1tsId>=0)
4067     oss << "(" << f1tsId << ") ";
4068   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4069   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4070   const DataArray *arr=getUndergroundDataArray();
4071   if(arr)
4072     {
4073       const std::vector<std::string> &comps=arr->getInfoOnComponents();
4074       if(f1tsId<0)
4075         {
4076           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4077           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4078             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
4079         }
4080       if(arr->isAllocated())
4081         {
4082           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4083         }
4084       else
4085         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4086     }
4087   else
4088     {
4089       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4090     }
4091   oss << startOfLine << "----------------------" << std::endl;
4092   if(!_field_per_mesh.empty())
4093     {
4094       int i=0;
4095       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4096         {
4097           const MEDFileFieldPerMesh *cur=(*it2);
4098           if(cur)
4099             cur->simpleRepr(bkOffset,oss,i);
4100           else
4101             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4102         }
4103     }
4104   else
4105     {
4106       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4107     }
4108   oss << startOfLine << "----------------------" << std::endl;
4109 }
4110
4111 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4112 {
4113   const DataArray *arr(getUndergroundDataArray());
4114   if(!arr)
4115     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4116   int nbOfCompo=arr->getNumberOfComponents();
4117   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4118   for(int i=0;i<nbOfCompo;i++)
4119     {
4120       ret[i]=deepCopy();
4121       std::vector<int> v(1,i);
4122       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4123       ret[i]->setArray(arr2);
4124     }
4125   return ret;
4126 }
4127
4128 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)
4129 {
4130 }
4131
4132 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4133 {
4134 }
4135
4136 /*!
4137  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4138  * empty. Returns -1 if this in on nodes.
4139  *  \return int - the dimension of \a this.
4140  */
4141 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4142 {
4143   int ret=-2;
4144   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4145     (*it)->getDimension(ret);
4146   return ret;
4147 }
4148
4149 /*!
4150  * Returns the mesh name.
4151  *  \return std::string - a string holding the mesh name.
4152  *  \throw If \c _field_per_mesh.empty()
4153  */
4154 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4155 {
4156   if(_field_per_mesh.empty())
4157     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4158   return _field_per_mesh[0]->getMeshName();
4159 }
4160
4161 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4162 {
4163   std::string oldName(getMeshName());
4164   std::vector< std::pair<std::string,std::string> > v(1);
4165   v[0].first=oldName; v[0].second=newMeshName;
4166   changeMeshNames(v);
4167 }
4168
4169 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4170 {
4171   bool ret=false;
4172   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4173     {
4174       MEDFileFieldPerMesh *cur(*it);
4175       if(cur)
4176         ret=cur->changeMeshNames(modifTab) || ret;
4177     }
4178   return ret;
4179 }
4180
4181 /*!
4182  * Returns the number of iteration of the state of underlying mesh.
4183  *  \return int - the iteration number.
4184  *  \throw If \c _field_per_mesh.empty()
4185  */
4186 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4187 {
4188   if(_field_per_mesh.empty())
4189     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4190   return _field_per_mesh[0]->getMeshIteration();
4191 }
4192
4193 /*!
4194  * Returns the order number of iteration of the state of underlying mesh.
4195  *  \return int - the order number.
4196  *  \throw If \c _field_per_mesh.empty()
4197  */
4198 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4199 {
4200   if(_field_per_mesh.empty())
4201     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4202   return _field_per_mesh[0]->getMeshOrder();
4203 }
4204
4205 /*!
4206  * Checks if \a this field is tagged by a given iteration number and a given
4207  * iteration order number.
4208  *  \param [in] iteration - the iteration number of interest.
4209  *  \param [in] order - the iteration order number of interest.
4210  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4211  *          \a this->getOrder() == \a order.
4212  */
4213 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4214 {
4215   return iteration==_iteration && order==_order;
4216 }
4217
4218 /*!
4219  * Returns number of iteration and order number of iteration when
4220  * \a this field has been calculated.
4221  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4222  *          order number.
4223  */
4224 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4225 {
4226   std::pair<int,int> p;
4227   fillIteration(p);
4228   return p;
4229 }
4230
4231 /*!
4232  * Returns number of iteration and order number of iteration when
4233  * \a this field has been calculated.
4234  *  \param [in,out] p - a pair returning the iteration number and the iteration
4235  *          order number.
4236  */
4237 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4238 {
4239   p.first=_iteration;
4240   p.second=_order;
4241 }
4242
4243 /*!
4244  * Returns all types of spatial discretization of \a this field.
4245  *  \param [in,out] types - a sequence of types of \a this field.
4246  */
4247 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4248 {
4249   std::set<TypeOfField> types2;
4250   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4251     {
4252       (*it)->fillTypesOfFieldAvailable(types2);
4253     }
4254   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4255   std::copy(types2.begin(),types2.end(),bi);
4256 }
4257
4258 /*!
4259  * Returns all types of spatial discretization of \a this field.
4260  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4261  *          of \a this field.
4262  */
4263 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4264 {
4265   std::vector<TypeOfField> ret;
4266   fillTypesOfFieldAvailable(ret);
4267   return ret;
4268 }
4269
4270 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4271 {
4272   std::vector<std::string> ret;
4273   std::set<std::string> ret2;
4274   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4275     {
4276       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4277       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4278         if(ret2.find(*it2)==ret2.end())
4279           {
4280             ret.push_back(*it2);
4281             ret2.insert(*it2);
4282           }
4283     }
4284   return ret;
4285 }
4286
4287 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4288 {
4289   std::vector<std::string> ret;
4290   std::set<std::string> ret2;
4291   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4292     {
4293       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4294       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4295         if(ret2.find(*it2)==ret2.end())
4296           {
4297             ret.push_back(*it2);
4298             ret2.insert(*it2);
4299           }
4300     }
4301   return ret;
4302 }
4303
4304 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4305 {
4306   std::vector<std::string> ret;
4307   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4308     {
4309       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4310       ret.insert(ret.end(),tmp.begin(),tmp.end());
4311     }
4312   return ret;
4313 }
4314
4315 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4316 {
4317   std::vector<std::string> ret;
4318   std::set<std::string> ret2;
4319   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4320     {
4321       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4322       ret.insert(ret.end(),tmp.begin(),tmp.end());
4323     }
4324   return ret;
4325 }
4326
4327 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4328 {
4329   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4330     (*it)->changePflsRefsNamesGen(mapOfModif);
4331 }
4332
4333 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4334 {
4335   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4336     (*it)->changeLocsRefsNamesGen(mapOfModif);
4337 }
4338
4339 /*!
4340  * Returns all attributes of parts of \a this field lying on a given mesh.
4341  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4342  * item of every of returned sequences refers to the _i_-th part of \a this field.
4343  * Thus all sequences returned by this method are of the same length equal to number
4344  * of different types of supporting entities.<br>
4345  * A field part can include sub-parts with several different spatial discretizations,
4346  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4347  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4348  * of a nested sequence corresponds to a type of spatial discretization.<br>
4349  * This method allows for iteration over MEDFile DataStructure without any overhead.
4350  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4351  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4352  *          not checked if \a mname == \c NULL).
4353  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4354  *          a field part is returned. 
4355  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4356  *          This sequence is of the same length as \a types. 
4357  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4358  *          discretization. A profile name can be empty.
4359  *          Length of this and of nested sequences is the same as that of \a typesF.
4360  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4361  *          discretization. A localization name can be empty.
4362  *          Length of this and of nested sequences is the same as that of \a typesF.
4363  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4364  *          of ids of tuples within the data array, per each type of spatial
4365  *          discretization within one mesh entity type. 
4366  *          Length of this and of nested sequences is the same as that of \a typesF.
4367  *  \throw If no field is lying on \a mname.
4368  */
4369 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
4370 {
4371   int meshId=0;
4372   if(!mname.empty())
4373     meshId=getMeshIdFromMeshName(mname);
4374   else
4375     if(_field_per_mesh.empty())
4376       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4377   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4378 }
4379
4380 /*!
4381  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4382  * maximal absolute dimension and values returned via the out parameter \a levs are 
4383  * dimensions relative to the maximal absolute dimension. <br>
4384  * This method is designed for MEDFileField1TS instances that have a discretization
4385  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4386  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4387  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4388  * Only these 3 discretizations will be taken into account here. If \a this is
4389  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4390  * This method is useful to make the link between the dimension of the underlying mesh
4391  * and the levels of \a this, because it is possible that the highest dimension of \a this
4392  * field is not equal to the dimension of the underlying mesh.
4393  * 
4394  * Let's consider the following case:
4395  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4396  * TETRA4, HEXA8, TRI3 and SEG2.
4397  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4398  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4399  *
4400  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4401  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4402  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4403  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4404  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4405  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4406  * For example<br>
4407  * to retrieve the highest level of
4408  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4409  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4410  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4411  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4412  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4413  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4414  *          not checked if \a mname == \c NULL).
4415  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4416  *          absolute one. They are in decreasing order. This sequence is cleared before
4417  *          filling it in.
4418  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4419  *  \throw If no field is lying on \a mname.
4420  */
4421 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4422 {
4423   levs.clear();
4424   int meshId=getMeshIdFromMeshName(mname);
4425   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4426   std::vector< std::vector<TypeOfField> > typesF;
4427   std::vector< std::vector<std::string> > pfls, locs;
4428   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4429   if(types.empty())
4430     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4431   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4432   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4433     return -1;
4434   st.erase(INTERP_KERNEL::NORM_ERROR);
4435   std::set<int> ret1;
4436   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4437     {
4438       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4439       ret1.insert((int)cm.getDimension());
4440     }
4441   int ret=*std::max_element(ret1.begin(),ret1.end());
4442   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4443   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4444   return ret;
4445 }
4446
4447 /*!
4448  * \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.
4449  * \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.
4450  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4451  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4452  */
4453 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4454 {
4455   int mid=getMeshIdFromMeshName(mName);
4456   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4457 }
4458
4459 /*!
4460  * \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.
4461  * \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.
4462  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4463  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4464  */
4465 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4466 {
4467   int mid=getMeshIdFromMeshName(mName);
4468   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4469 }
4470
4471 /*!
4472  * \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.
4473  */
4474 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4475 {
4476   if(_field_per_mesh.empty())
4477     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4478   if(mName.empty())
4479     return 0;
4480   std::string mName2(mName);
4481   int ret=0;
4482   std::vector<std::string> msg;
4483   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4484     if(mName2==(*it)->getMeshName())
4485       return ret;
4486     else
4487       msg.push_back((*it)->getMeshName());
4488   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4489   oss << "Possible meshes are : ";
4490   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4491     oss << "\"" << (*it2) << "\" ";
4492   throw INTERP_KERNEL::Exception(oss.str());
4493 }
4494
4495 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4496 {
4497   if(!mesh)
4498     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4499   std::string tmp(mesh->getName());
4500   if(tmp.empty())
4501     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4502   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4503   int i=0;
4504   for(;it!=_field_per_mesh.end();it++,i++)
4505     {
4506       if((*it)->getMeshName()==tmp)
4507         return i;
4508     }
4509   int sz=_field_per_mesh.size();
4510   _field_per_mesh.resize(sz+1);
4511   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4512   return sz;
4513 }
4514
4515 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4516                                                                    MEDFileFieldGlobsReal& glob)
4517 {
4518   bool ret=false;
4519   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4520     {
4521       MEDFileFieldPerMesh *fpm(*it);
4522       if(fpm)
4523         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4524     }
4525   return ret;
4526 }
4527
4528 /*!
4529  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4530  * splitting that leads to single spatial discretization of this.
4531  *
4532  * \sa splitMultiDiscrPerGeoTypes
4533  */
4534 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4535 {
4536   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4537   std::vector< std::vector<TypeOfField> > typesF;
4538   std::vector< std::vector<std::string> > pfls,locs;
4539   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4540   std::set<TypeOfField> allEnt;
4541   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4542     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4543       allEnt.insert(*it2);
4544   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4545   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4546   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4547     {
4548       std::vector< std::pair<int,int> > its;
4549       ret[i]=shallowCpy();
4550       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4551       ret[i]->updateData(newLgth,its);
4552     }
4553   return ret;
4554 }
4555
4556 /*!
4557  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4558  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4559  *
4560  * \sa splitDiscretizations
4561  */
4562 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4563 {
4564   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4565   std::vector< std::vector<TypeOfField> > typesF;
4566   std::vector< std::vector<std::string> > pfls,locs;
4567   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4568   std::set<TypeOfField> allEnt;
4569   std::size_t nbOfMDPGT(0),ii(0);
4570   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4571     {
4572       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4573       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4574         allEnt.insert(*it2);
4575     }
4576   if(allEnt.size()!=1)
4577     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4578   if(nbOfMDPGT==0)
4579     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4580   if(nbOfMDPGT==1)
4581     {
4582       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4583       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4584       return ret0;
4585     }
4586   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4587   for(std::size_t i=0;i<nbOfMDPGT;i++)
4588     {
4589       std::vector< std::pair<int,int> > its;
4590       ret[i]=shallowCpy();
4591       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4592       ret[i]->updateData(newLgth,its);
4593     }
4594   return ret;
4595 }
4596
4597 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4598 {
4599   int globalCounter(0);
4600   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4601     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4602   return globalCounter;
4603 }
4604
4605 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4606 {
4607   int globalCounter(0);
4608   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4609     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4610   return globalCounter;
4611 }
4612
4613 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4614 {
4615   if(_nb_of_tuples_to_be_allocated>=0)
4616     {
4617       _nb_of_tuples_to_be_allocated=newLgth;
4618       const DataArray *oldArr(getUndergroundDataArray());
4619       if(oldArr)
4620         {
4621           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4622           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4623           setArray(newArr);
4624           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4625         }
4626       return ;
4627     }
4628   if(_nb_of_tuples_to_be_allocated==-1)
4629     return ;
4630   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4631     {
4632       const DataArray *oldArr(getUndergroundDataArray());
4633       if(!oldArr || !oldArr->isAllocated())
4634         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4635       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4636       newArr->alloc(newLgth,getNumberOfComponents());
4637       if(oldArr)
4638         newArr->copyStringInfoFrom(*oldArr);
4639       int pos=0;
4640       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4641         {
4642           if((*it).second<(*it).first)
4643             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4644           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4645           pos+=(*it).second-(*it).first;
4646         }
4647       setArray(newArr);
4648       return ;
4649     }
4650   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4651 }
4652
4653 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4654 {
4655   if(_field_per_mesh.empty())
4656     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4657   if(_field_per_mesh.size()>1)
4658     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4659   _field_per_mesh[0]->copyOptionsFrom(opts);
4660   _field_per_mesh[0]->writeLL(fid,nasc);
4661 }
4662
4663 /*!
4664  * 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.
4665  * If false is returned the memory allocation is not required.
4666  */
4667 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4668 {
4669   if(_nb_of_tuples_to_be_allocated>=0)
4670     {
4671       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4672       _nb_of_tuples_to_be_allocated=-2;
4673       return true;
4674     }
4675   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4676     return false;
4677   if(_nb_of_tuples_to_be_allocated==-1)
4678     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4679   if(_nb_of_tuples_to_be_allocated<-3)
4680     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4681   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4682 }
4683
4684 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4685 {
4686   med_int numdt,numit;
4687   med_float dt;
4688   med_int nmesh;
4689   med_bool localMesh;
4690   med_int meshnumdt,meshnumit;
4691   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4692   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4693   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4694   if(_iteration!=numdt || _order!=numit)
4695     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4696   _field_per_mesh.resize(nmesh);
4697   //
4698   MEDFileMesh *mm(0);
4699   if(ms)
4700     {
4701       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4702       mm=ms->getMeshWithName(meshNameCpp);
4703     }
4704   //
4705   for(int i=0;i<nmesh;i++)
4706     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4707   _nb_of_tuples_to_be_allocated=0;
4708   for(int i=0;i<nmesh;i++)
4709     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4710 }
4711
4712 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4713 {
4714   allocIfNecessaryTheArrayToReceiveDataFromFile();
4715   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4716     (*it)->loadBigArraysRecursively(fid,nasc);
4717 }
4718
4719 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4720 {
4721   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4722     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4723       (*it)->loadBigArraysRecursively(fid,nasc);
4724 }
4725
4726 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4727 {
4728   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4729   loadBigArraysRecursively(fid,nasc);
4730 }
4731
4732 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4733 {
4734   DataArray *thisArr(getUndergroundDataArray());
4735   if(thisArr && thisArr->isAllocated())
4736     {
4737       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4738       thisArr->desallocate();
4739     }
4740 }
4741
4742 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4743 {
4744   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4745 }
4746
4747 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4748 {
4749   std::vector<const BigMemoryObject *> ret;
4750   if(getUndergroundDataArray())
4751     ret.push_back(getUndergroundDataArray());
4752   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4753     ret.push_back((const MEDFileFieldPerMesh *)*it);
4754   return ret;
4755 }
4756
4757 /*!
4758  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4759  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4760  * "Sort By Type"), if not, an exception is thrown. 
4761  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4762  *  \param [in] arr - the array of values.
4763  *  \param [in,out] glob - the global data where profiles and localization present in
4764  *          \a field, if any, are added.
4765  *  \throw If the name of \a field is empty.
4766  *  \throw If the data array of \a field is not set.
4767  *  \throw If \a this->_arr is already allocated but has different number of components
4768  *         than \a field.
4769  *  \throw If the underlying mesh of \a field has no name.
4770  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4771  */
4772 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4773 {
4774   const MEDCouplingMesh *mesh=field->getMesh();
4775   //
4776   TypeOfField type=field->getTypeOfField();
4777   std::vector<DataArrayInt *> dummy;
4778   int start=copyTinyInfoFrom(field,arr);
4779   int pos=addNewEntryIfNecessary(mesh);
4780   if(type!=ON_NODES)
4781     {
4782       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4783       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4784     }
4785   else
4786     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4787 }
4788
4789 /*!
4790  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4791  * of a given mesh are used as the support of the given field (a real support is not used). 
4792  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4793  * Order of underlying mesh entities of the given field specified by \a profile parameter
4794  * is not prescribed; this method permutes field values to have them sorted by element
4795  * type as required for writing to MED file. A new profile is added only if no equal
4796  * profile is missing. 
4797  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4798  *  \param [in] arrOfVals - the values of the field \a field used.
4799  *  \param [in] mesh - the supporting mesh of \a field.
4800  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4801  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4802  *  \param [in,out] glob - the global data where profiles and localization present in
4803  *          \a field, if any, are added.
4804  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4805  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4806  *  \throw If the data array of \a field is not set.
4807  *  \throw If \a this->_arr is already allocated but has different number of components
4808  *         than \a field.
4809  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4810  *  \sa setFieldNoProfileSBT()
4811  */
4812 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4813 {
4814   if(!field)
4815     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4816   if(!arrOfVals || !arrOfVals->isAllocated())
4817     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4818   TypeOfField type=field->getTypeOfField();
4819   std::vector<DataArrayInt *> idsInPflPerType;
4820   std::vector<DataArrayInt *> idsPerType;
4821   std::vector<int> code,code2;
4822   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4823   if(type!=ON_NODES)
4824     {
4825       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4826       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4827       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4828       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4829       // start of check
4830       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4831       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4832       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4833         {
4834           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4835           throw INTERP_KERNEL::Exception(oss.str());
4836         }
4837       // end of check
4838       int start=copyTinyInfoFrom(field,arrOfVals);
4839       code2=m->getDistributionOfTypes();
4840       //
4841       int pos=addNewEntryIfNecessary(m);
4842       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4843     }
4844   else
4845     {
4846       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4847         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4848       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4849       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4850       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4851       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4852         {
4853           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4854           throw INTERP_KERNEL::Exception(oss.str());
4855         }
4856       int start=copyTinyInfoFrom(field,arrOfVals);
4857       int pos=addNewEntryIfNecessary(m);
4858       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4859     }
4860 }
4861
4862 /*!
4863  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4864  */
4865 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4866 {
4867   if(_nb_of_tuples_to_be_allocated>=0)
4868     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 !");
4869   DataArray *arr(getOrCreateAndGetArray());
4870   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4871   _nb_of_tuples_to_be_allocated=-3;
4872 }
4873
4874 /*!
4875  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4876  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4877  * larger by the size of \a field. Returns an id of the first not filled
4878  * tuple of \a this->_arr.
4879  *  \param [in] field - the field to copy the info on components and the name from.
4880  *  \return int - the id of first not initialized tuple of \a this->_arr.
4881  *  \throw If the name of \a field is empty.
4882  *  \throw If the data array of \a field is not set.
4883  *  \throw If \a this->_arr is already allocated but has different number of components
4884  *         than \a field.
4885  */
4886 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4887 {
4888   if(!field)
4889     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4890   std::string name(field->getName());
4891   setName(name.c_str());
4892   setDtUnit(field->getTimeUnit());
4893   if(name.empty())
4894     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4895   if(!arr)
4896     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4897   if(!arr->isAllocated())
4898     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4899   _dt=field->getTime(_iteration,_order);
4900   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4901   if(!getOrCreateAndGetArray()->isAllocated())
4902     {
4903       allocNotFromFile(arr->getNumberOfTuples());
4904       return 0;
4905     }
4906   else
4907     {
4908       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4909       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4910       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4911       _nb_of_tuples_to_be_allocated=-3;
4912       return oldNbOfTuples;
4913     }
4914 }
4915
4916 /*!
4917  * Returns number of components in \a this field
4918  *  \return int - the number of components.
4919  */
4920 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4921 {
4922   return getOrCreateAndGetArray()->getNumberOfComponents();
4923 }
4924
4925 /*!
4926  * Change info on components in \a this.
4927  * \throw If size of \a infos is not equal to the number of components already in \a this.
4928  */
4929 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4930 {
4931   DataArray *arr=getOrCreateAndGetArray();
4932   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4933 }
4934
4935 /*!
4936  * Returns info on components of \a this field.
4937  *  \return const std::vector<std::string>& - a sequence of strings each being an
4938  *          information on _i_-th component.
4939  */
4940 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4941 {
4942   const DataArray *arr=getOrCreateAndGetArray();
4943   return arr->getInfoOnComponents();
4944 }
4945
4946 /*!
4947  * Returns a mutable info on components of \a this field.
4948  *  \return std::vector<std::string>& - a sequence of strings each being an
4949  *          information on _i_-th component.
4950  */
4951 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4952 {
4953   DataArray *arr=getOrCreateAndGetArray();
4954   return arr->getInfoOnComponents();
4955 }
4956
4957 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4958 {
4959   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4960     {
4961       const MEDFileFieldPerMesh *fpm(*it);
4962       if(!fpm)
4963         continue;
4964       if(fpm->presenceOfMultiDiscPerGeoType())
4965         return true;
4966     }
4967   return false;
4968 }
4969
4970 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4971 {
4972   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 !";
4973   if(_field_per_mesh.empty())
4974     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4975   if(_field_per_mesh.size()>1)
4976     throw INTERP_KERNEL::Exception(MSG0);
4977   if(_field_per_mesh[0].isNull())
4978     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4979   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4980   std::set<TypeOfField> types;
4981   pm->fillTypesOfFieldAvailable(types);
4982   if(types.size()!=1)
4983     throw INTERP_KERNEL::Exception(MSG0);
4984   TypeOfField type(*types.begin());
4985   int meshDimRelToMax(0);
4986   if(type==ON_NODES)
4987     meshDimRelToMax=0;
4988   else
4989     {
4990       int myDim(std::numeric_limits<int>::max());
4991       bool isUnique(pm->isUniqueLevel(myDim));
4992       if(!isUnique)
4993         throw INTERP_KERNEL::Exception(MSG0);
4994       meshDimRelToMax=myDim-mesh->getMeshDimension();
4995       if(meshDimRelToMax>0)
4996         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4997     }
4998   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4999 }
5000
5001 /*!
5002  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5003  *  \param [in] type - a spatial discretization of the new field.
5004  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5005  *  \param [in] mName - a name of the supporting mesh.
5006  *  \param [in] renumPol - specifies how to permute values of the result field according to
5007  *          the optional numbers of cells and nodes, if any. The valid values are
5008  *          - 0 - do not permute.
5009  *          - 1 - permute cells.
5010  *          - 2 - permute nodes.
5011  *          - 3 - permute cells and nodes.
5012  *
5013  *  \param [in] glob - the global data storing profiles and localization.
5014  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5015  *          caller is to delete this field using decrRef() as it is no more needed. 
5016  *  \throw If the MED file is not readable.
5017  *  \throw If there is no mesh named \a mName in the MED file.
5018  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5019  *  \throw If no field of \a this is lying on the mesh \a mName.
5020  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5021  */
5022 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5023 {
5024   MCAuto<MEDFileMesh> mm;
5025   if(mName.empty())
5026     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5027   else
5028     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5029   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5030 }
5031
5032 /*!
5033  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5034  *  \param [in] type - a spatial discretization of the new field.
5035  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5036  *  \param [in] renumPol - specifies how to permute values of the result field according to
5037  *          the optional numbers of cells and nodes, if any. The valid values are
5038  *          - 0 - do not permute.
5039  *          - 1 - permute cells.
5040  *          - 2 - permute nodes.
5041  *          - 3 - permute cells and nodes.
5042  *
5043  *  \param [in] glob - the global data storing profiles and localization.
5044  *  \param [in] mesh - the supporting mesh.
5045  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5046  *          caller is to delete this field using decrRef() as it is no more needed. 
5047  *  \throw If the MED file is not readable.
5048  *  \throw If no field of \a this is lying on \a mesh.
5049  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5050  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5051  */
5052 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5053 {
5054   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5055   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5056   if(meshDimRelToMax==1)
5057     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5058   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5059 }
5060
5061 /*!
5062  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5063  * given mesh. 
5064  *  \param [in] type - a spatial discretization of the new field.
5065  *  \param [in] mName - a name of the supporting mesh.
5066  *  \param [in] renumPol - specifies how to permute values of the result field according to
5067  *          the optional numbers of cells and nodes, if any. The valid values are
5068  *          - 0 - do not permute.
5069  *          - 1 - permute cells.
5070  *          - 2 - permute nodes.
5071  *          - 3 - permute cells and nodes.
5072  *
5073  *  \param [in] glob - the global data storing profiles and localization.
5074  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5075  *          caller is to delete this field using decrRef() as it is no more needed. 
5076  *  \throw If the MED file is not readable.
5077  *  \throw If there is no mesh named \a mName in the MED file.
5078  *  \throw If there are no mesh entities in the mesh.
5079  *  \throw If no field values of the given \a type are available.
5080  */
5081 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5082 {
5083   MCAuto<MEDFileMesh> mm;
5084   if(mName.empty())
5085     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5086   else
5087     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5088   int absDim=getDimension();
5089   int meshDimRelToMax=absDim-mm->getMeshDimension();
5090   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5091 }
5092
5093 /*!
5094  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5095  *  \param [in] type - a spatial discretization of the new field.
5096  *  \param [in] renumPol - specifies how to permute values of the result field according to
5097  *          the optional numbers of cells and nodes, if any. The valid values are
5098  *          - 0 - do not permute.
5099  *          - 1 - permute cells.
5100  *          - 2 - permute nodes.
5101  *          - 3 - permute cells and nodes.
5102  *
5103  *  \param [in] glob - the global data storing profiles and localization.
5104  *  \param [in] mesh - the supporting mesh.
5105  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5106  *         field according to \a renumPol.
5107  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5108  *         field according to \a renumPol.
5109  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5110  *          caller is to delete this field using decrRef() as it is no more needed. 
5111  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5112  *  \throw If no field of \a this is lying on \a mesh.
5113  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5114  */
5115 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
5116 {
5117   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5118   int meshId=getMeshIdFromMeshName(mesh->getName());
5119   bool isPfl=false;
5120   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5121   switch(renumPol)
5122   {
5123     case 0:
5124       {
5125         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5126         return ret.retn();
5127       }
5128     case 3:
5129     case 1:
5130       {
5131         if(isPfl)
5132           throw INTERP_KERNEL::Exception(msg1);
5133         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5134         if(cellRenum)
5135           {
5136             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5137               {
5138                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5139                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5140                 throw INTERP_KERNEL::Exception(oss.str());
5141               }
5142             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5143             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5144             std::vector<DataArray *> arrOut2(1,arrOut);
5145             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5146             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5147             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5148           }
5149         if(renumPol==1)
5150           return ret.retn();
5151       }
5152     case 2:
5153       {
5154         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5155         if(isPfl)
5156           throw INTERP_KERNEL::Exception(msg1);
5157         if(nodeRenum)
5158           {
5159             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5160               {
5161                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5162                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5163                 throw INTERP_KERNEL::Exception(oss.str());
5164               }
5165             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5166             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5167               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5168             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5169           }
5170         return ret.retn();
5171       }
5172     default:
5173       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5174   }
5175 }
5176
5177 /*!
5178  * Returns values and a profile of the field of a given type lying on a given support.
5179  *  \param [in] type - a spatial discretization of the field.
5180  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5181  *  \param [in] mesh - the supporting mesh.
5182  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5183  *          field of interest lies on. If the field lies on all entities of the given
5184  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5185  *          using decrRef() as it is no more needed.  
5186  *  \param [in] glob - the global data storing profiles and localization.
5187  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5188  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5189  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5190  *  \throw If no field of \a this is lying on \a mesh.
5191  *  \throw If no field values of the given \a type are available.
5192  */
5193 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5194 {
5195   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5196   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5197   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5198   ret->setName(nasc.getName().c_str());
5199   return ret.retn();
5200 }
5201
5202 //= MEDFileField1TSWithoutSDA
5203
5204 /*!
5205  * Throws if a given value is not a valid (non-extended) relative dimension.
5206  *  \param [in] meshDimRelToMax - the relative dimension value.
5207  *  \throw If \a meshDimRelToMax > 0.
5208  */
5209 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5210 {
5211   if(meshDimRelToMax>0)
5212     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5213 }
5214
5215 /*!
5216  * Checks if elements of a given mesh are in the order suitable for writing 
5217  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5218  * vector describing types of elements and their number.
5219  *  \param [in] mesh - the mesh to check.
5220  *  \return std::vector<int> - a vector holding for each element type (1) item of
5221  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5222  *          These values are in full-interlace mode.
5223  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5224  */
5225 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5226 {
5227   if(!mesh)
5228     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5229   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5230   int nbOfTypes=geoTypes.size();
5231   std::vector<int> code(3*nbOfTypes);
5232   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5233   arr1->alloc(nbOfTypes,1);
5234   int *arrPtr=arr1->getPointer();
5235   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5236   for(int i=0;i<nbOfTypes;i++,it++)
5237     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5238   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5239   const int *arrPtr2=arr2->getConstPointer();
5240   int i=0;
5241   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5242     {
5243       int pos=arrPtr2[i];
5244       int nbCells=mesh->getNumberOfCellsWithType(*it);
5245       code[3*pos]=(int)(*it);
5246       code[3*pos+1]=nbCells;
5247       code[3*pos+2]=-1;//no profiles
5248     }
5249   std::vector<const DataArrayInt *> idsPerType;//no profiles
5250   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5251   if(da)
5252     {
5253       da->decrRef();
5254       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5255     }
5256   return code;
5257 }
5258
5259 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5260 {
5261   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5262 }
5263
5264 /*!
5265  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5266  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5267  * item of every of returned sequences refers to the _i_-th part of \a this field.
5268  * Thus all sequences returned by this method are of the same length equal to number
5269  * of different types of supporting entities.<br>
5270  * A field part can include sub-parts with several different spatial discretizations,
5271  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5272  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5273  * of a nested sequence corresponds to a type of spatial discretization.<br>
5274  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5275  * The overhead is due to selecting values into new instances of DataArrayDouble.
5276  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5277  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5278  *          not checked if \a mname == \c NULL).
5279  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5280  *          a field part is returned. 
5281  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5282  *          A field part can include sub-parts with several different spatial discretizations,
5283  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5284  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5285  *          This sequence is of the same length as \a types. 
5286  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5287  *          discretization. A profile name can be empty.
5288  *          Length of this and of nested sequences is the same as that of \a typesF.
5289  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5290  *          discretization. A localization name can be empty.
5291  *          Length of this and of nested sequences is the same as that of \a typesF.
5292  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5293  *          per each type of spatial discretization within one mesh entity type.
5294  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5295  *          Length of this and of nested sequences is the same as that of \a typesF.
5296  *  \throw If no field is lying on \a mname.
5297  */
5298 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
5299 {
5300   int meshId=0;
5301   if(!mname.empty())
5302     meshId=getMeshIdFromMeshName(mname);
5303   else
5304     if(_field_per_mesh.empty())
5305       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5306   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5307   int nbOfRet=ret0.size();
5308   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5309   for(int i=0;i<nbOfRet;i++)
5310     {
5311       const std::vector< std::pair<int,int> >& p=ret0[i];
5312       int nbOfRet1=p.size();
5313       ret[i].resize(nbOfRet1);
5314       for(int j=0;j<nbOfRet1;j++)
5315         {
5316           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5317           ret[i][j]=tmp;
5318         }
5319     }
5320   return ret;
5321 }
5322
5323 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5324 {
5325   return TYPE_STR;
5326 }
5327
5328 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5329 {
5330   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5331   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5332   ret->deepCpyLeavesFrom(*this);
5333   const DataArrayDouble *arr(_arr);
5334   if(arr)
5335     {
5336       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5337       ret->setArray(arr2);
5338     }
5339   return ret.retn();
5340 }
5341
5342 /*!
5343  * Returns a pointer to the underground DataArrayDouble instance and a
5344  * sequence describing parameters of a support of each part of \a this field. The
5345  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5346  * direct access to the field values. This method is intended for the field lying on one
5347  * mesh only.
5348  *  \param [in,out] entries - the sequence describing parameters of a support of each
5349  *         part of \a this field. Each item of this sequence consists of two parts. The
5350  *         first part describes a type of mesh entity and an id of discretization of a
5351  *         current field part. The second part describes a range of values [begin,end)
5352  *         within the returned array relating to the current field part.
5353  *  \return DataArrayDouble * - the pointer to the field values array.
5354  *  \throw If the number of underlying meshes is not equal to 1.
5355  *  \throw If no field values are available.
5356  *  \sa getUndergroundDataArray()
5357  */
5358 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5359 {
5360   if(_field_per_mesh.size()!=1)
5361     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5362   if(_field_per_mesh[0]==0)
5363     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5364   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5365   return getUndergroundDataArrayTemplate();
5366 }
5367
5368 /*!
5369  * Returns a pointer to the underground DataArrayDouble instance and a
5370  * sequence describing parameters of a support of each part of \a this field. The
5371  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5372  * direct access to the field values. This method is intended for the field lying on one
5373  * mesh only.
5374  *  \param [in,out] entries - the sequence describing parameters of a support of each
5375  *         part of \a this field. Each item of this sequence consists of two parts. The
5376  *         first part describes a type of mesh entity and an id of discretization of a
5377  *         current field part. The second part describes a range of values [begin,end)
5378  *         within the returned array relating to the current field part.
5379  *  \return DataArrayDouble * - the pointer to the field values array.
5380  *  \throw If the number of underlying meshes is not equal to 1.
5381  *  \throw If no field values are available.
5382  *  \sa getUndergroundDataArray()
5383  */
5384 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5385 {
5386   return getUndergroundDataArrayDoubleExt(entries);
5387 }
5388
5389 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5390 {
5391   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5392   arr->setInfoAndChangeNbOfCompo(infos);
5393 }
5394
5395 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5396 {
5397 }
5398
5399 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5400 {
5401   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5402   ret->deepCpyLeavesFrom(*this);
5403   return ret.retn();
5404 }
5405
5406 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5407 {
5408   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5409   if((const DataArrayDouble *)_arr)
5410     ret->_arr=_arr->deepCopy();
5411   return ret.retn();
5412 }
5413
5414 //= MEDFileIntField1TSWithoutSDA
5415
5416 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5417 {
5418   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5419 }
5420
5421 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5422 {
5423 }
5424
5425 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5426                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5427 {
5428   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5429   arr->setInfoAndChangeNbOfCompo(infos);
5430 }
5431
5432 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5433 {
5434   return TYPE_STR;
5435 }
5436
5437 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5438 {
5439   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5440   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5441   ret->deepCpyLeavesFrom(*this);
5442   const DataArrayInt *arr(_arr);
5443   if(arr)
5444     {
5445       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5446       ret->setArray(arr2);
5447     }
5448   return ret.retn();
5449 }
5450
5451 /*!
5452  * Returns a pointer to the underground DataArrayInt instance and a
5453  * sequence describing parameters of a support of each part of \a this field. The
5454  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5455  * direct access to the field values. This method is intended for the field lying on one
5456  * mesh only.
5457  *  \param [in,out] entries - the sequence describing parameters of a support of each
5458  *         part of \a this field. Each item of this sequence consists of two parts. The
5459  *         first part describes a type of mesh entity and an id of discretization of a
5460  *         current field part. The second part describes a range of values [begin,end)
5461  *         within the returned array relating to the current field part.
5462  *  \return DataArrayInt * - the pointer to the field values array.
5463  *  \throw If the number of underlying meshes is not equal to 1.
5464  *  \throw If no field values are available.
5465  *  \sa getUndergroundDataArray()
5466  */
5467 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5468 {
5469   return getUndergroundDataArrayIntExt(entries);
5470 }
5471
5472 /*!
5473  * Returns a pointer to the underground DataArrayInt instance and a
5474  * sequence describing parameters of a support of each part of \a this field. The
5475  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5476  * direct access to the field values. This method is intended for the field lying on one
5477  * mesh only.
5478  *  \param [in,out] entries - the sequence describing parameters of a support of each
5479  *         part of \a this field. Each item of this sequence consists of two parts. The
5480  *         first part describes a type of mesh entity and an id of discretization of a
5481  *         current field part. The second part describes a range of values [begin,end)
5482  *         within the returned array relating to the current field part.
5483  *  \return DataArrayInt * - the pointer to the field values array.
5484  *  \throw If the number of underlying meshes is not equal to 1.
5485  *  \throw If no field values are available.
5486  *  \sa getUndergroundDataArray()
5487  */
5488 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5489 {
5490   if(_field_per_mesh.size()!=1)
5491     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5492   if(_field_per_mesh[0]==0)
5493     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5494   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5495   return getUndergroundDataArrayTemplate();
5496 }
5497
5498 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5499 {
5500   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5501   ret->deepCpyLeavesFrom(*this);
5502   return ret.retn();
5503 }
5504
5505 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5506 {
5507   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5508   if((const DataArrayInt *)_arr)
5509     ret->_arr=_arr->deepCopy();
5510   return ret.retn();
5511 }
5512
5513 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5514 {
5515 }
5516
5517 //= MEDFileAnyTypeField1TS
5518
5519 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5520 {
5521   med_field_type typcha;
5522   //
5523   std::vector<std::string> infos;
5524   std::string dtunit,fieldName;
5525   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5526   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5527   switch(typcha)
5528   {
5529     case MED_FLOAT64:
5530       {
5531         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5532         break;
5533       }
5534     case MED_INT32:
5535       {
5536         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5537         break;
5538       }
5539     default:
5540       {
5541         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] !";
5542         throw INTERP_KERNEL::Exception(oss.str());
5543       }
5544   }
5545   ret->setDtUnit(dtunit.c_str());
5546   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5547   //
5548   med_int numdt,numit;
5549   med_float dt;
5550   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5551   ret->setTime(numdt,numit,dt);
5552   ret->_csit=1;
5553   if(loadAll)
5554     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5555   else
5556     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5557   return ret.retn();
5558 }
5559
5560 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5561 try:MEDFileFieldGlobsReal(fid)
5562 {
5563   _content=BuildContentFrom(fid,loadAll,ms);
5564   loadGlobals(fid);
5565 }
5566 catch(INTERP_KERNEL::Exception& e)
5567 {
5568     throw e;
5569 }
5570
5571 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5572 {
5573   med_field_type typcha;
5574   std::vector<std::string> infos;
5575   std::string dtunit;
5576   int iii=-1;
5577   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5578   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5579   switch(typcha)
5580   {
5581     case MED_FLOAT64:
5582       {
5583         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5584         break;
5585       }
5586     case MED_INT32:
5587       {
5588         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5589         break;
5590       }
5591     default:
5592       {
5593         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] !";
5594         throw INTERP_KERNEL::Exception(oss.str());
5595       }
5596   }
5597   ret->setDtUnit(dtunit.c_str());
5598   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5599   //
5600   if(nbSteps<1)
5601     {
5602       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5603       throw INTERP_KERNEL::Exception(oss.str());
5604     }
5605   //
5606   med_int numdt,numit;
5607   med_float dt;
5608   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5609   ret->setTime(numdt,numit,dt);
5610   ret->_csit=1;
5611   if(loadAll)
5612     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5613   else
5614     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5615   return ret.retn();
5616 }
5617
5618 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5619 try:MEDFileFieldGlobsReal(fid)
5620 {
5621   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5622   loadGlobals(fid);
5623 }
5624 catch(INTERP_KERNEL::Exception& e)
5625 {
5626     throw e;
5627 }
5628
5629 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5630 {
5631   if(!c)
5632     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5633   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5634     {
5635       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5636       ret->_content=c; c->incrRef();
5637       return ret.retn();
5638     }
5639   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5640     {
5641       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5642       ret->_content=c; c->incrRef();
5643       return ret.retn();
5644     }
5645   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5646 }
5647
5648 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5649 {
5650   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5651   ret->setFileName(FileNameFromFID(fid));
5652   return ret;
5653 }
5654
5655 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5656 {
5657   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5658   return New(fid,loadAll);
5659 }
5660
5661 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5662 {
5663   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5664   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5665   ret->loadGlobals(fid);
5666   return ret.retn();
5667 }
5668
5669 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5670 {
5671   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5672   return New(fid,fieldName,loadAll);
5673 }
5674
5675 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5676 {
5677   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5678   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5679   ret->loadGlobals(fid);
5680   return ret.retn();
5681 }
5682
5683 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5684 {
5685   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5686   return New(fid,fieldName,iteration,order,loadAll);
5687 }
5688
5689 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5690 {
5691   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5692   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5693   ret->loadGlobals(fid);
5694   return ret.retn();
5695 }
5696
5697 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5698 {
5699   med_field_type typcha;
5700   std::vector<std::string> infos;
5701   std::string dtunit;
5702   int iii(-1);
5703   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5704   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5705   switch(typcha)
5706   {
5707     case MED_FLOAT64:
5708       {
5709         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5710         break;
5711       }
5712     case MED_INT32:
5713       {
5714         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5715         break;
5716       }
5717     default:
5718       {
5719         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] !";
5720         throw INTERP_KERNEL::Exception(oss.str());
5721       }
5722   }
5723   ret->setDtUnit(dtunit.c_str());
5724   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5725   //
5726   bool found=false;
5727   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5728   for(int i=0;i<nbOfStep2 && !found;i++)
5729     {
5730       med_int numdt,numit;
5731       med_float dt;
5732       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5733       if(numdt==iteration && numit==order)
5734         {
5735           found=true;
5736           ret->_csit=i+1;
5737         }
5738       else
5739         dtits[i]=std::pair<int,int>(numdt,numit);
5740     }
5741   if(!found)
5742     {
5743       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5744       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5745         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5746       throw INTERP_KERNEL::Exception(oss.str());
5747     }
5748   if(loadAll)
5749     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5750   else
5751     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5752   return ret.retn();
5753 }
5754
5755 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5756 try:MEDFileFieldGlobsReal(fid)
5757 {
5758   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5759   loadGlobals(fid);
5760 }
5761 catch(INTERP_KERNEL::Exception& e)
5762 {
5763     throw e;
5764 }
5765
5766 /*!
5767  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5768  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5769  *
5770  * \warning this is a shallow copy constructor
5771  */
5772 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5773 {
5774   if(!shallowCopyOfContent)
5775     {
5776       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5777       otherPtr->incrRef();
5778       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5779     }
5780   else
5781     {
5782       _content=other.shallowCpy();
5783     }
5784 }
5785
5786 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)
5787 {
5788   if(checkFieldId)
5789     {
5790       int nbFields=MEDnField(fid);
5791       if(fieldIdCFormat>=nbFields)
5792         {
5793           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5794           throw INTERP_KERNEL::Exception(oss.str());
5795         }
5796     }
5797   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5798   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5799   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5800   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5801   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5802   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5803   med_bool localMesh;
5804   int nbOfStep;
5805   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5806   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5807   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5808   infos.clear(); infos.resize(ncomp);
5809   for(int j=0;j<ncomp;j++)
5810     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5811   return nbOfStep;
5812 }
5813
5814 /*!
5815  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5816  * 
5817  * \param [out]
5818  * \return in case of success the number of time steps available for the field with name \a fieldName.
5819  */
5820 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5821 {
5822   int nbFields=MEDnField(fid);
5823   bool found=false;
5824   std::vector<std::string> fns(nbFields);
5825   int nbOfStep2(-1);
5826   for(int i=0;i<nbFields && !found;i++)
5827     {
5828       std::string tmp;
5829       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
5830       fns[i]=tmp;
5831       found=(tmp==fieldName);
5832       if(found)
5833         posCFormat=i;
5834     }
5835   if(!found)
5836     {
5837       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
5838       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5839         oss << "\"" << *it << "\" ";
5840       throw INTERP_KERNEL::Exception(oss.str());
5841     }
5842   return nbOfStep2;
5843 }
5844
5845 /*!
5846  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5847  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5848  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5849  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5850  * to keep a valid instance.
5851  * 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.
5852  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5853  * 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.
5854  *
5855  * \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.
5856  * \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.
5857  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5858  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5859  * \param [in] newLocName is the new localization name.
5860  * \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.
5861  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5862  */
5863 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5864 {
5865   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5866   std::string oldPflName=disc->getProfile();
5867   std::vector<std::string> vv=getPflsReallyUsedMulti();
5868   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5869   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5870     {
5871       disc->setProfile(newPflName);
5872       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5873       pfl->setName(newPflName);
5874     }
5875   else
5876     {
5877       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5878       throw INTERP_KERNEL::Exception(oss.str());
5879     }
5880 }
5881
5882 /*!
5883  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5884  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5885  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5886  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5887  * to keep a valid instance.
5888  * 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.
5889  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5890  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5891  * 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.
5892  *
5893  * \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.
5894  * \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.
5895  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5896  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5897  * \param [in] newLocName is the new localization name.
5898  * \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.
5899  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5900  */
5901 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5902 {
5903   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5904   std::string oldLocName=disc->getLocalization();
5905   std::vector<std::string> vv=getLocsReallyUsedMulti();
5906   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5907   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5908     {
5909       disc->setLocalization(newLocName);
5910       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5911       loc.setName(newLocName);
5912     }
5913   else
5914     {
5915       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5916       throw INTERP_KERNEL::Exception(oss.str());
5917     }
5918 }
5919
5920 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5921 {
5922   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5923   if(!ret)
5924     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5925   return ret;
5926 }
5927
5928 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5929 {
5930   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5931   if(!ret)
5932     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5933   return ret;
5934 }
5935
5936 /*!
5937  * This method alloc the arrays and load potentially huge arrays contained in this field.
5938  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5939  * This method can be also called to refresh or reinit values from a file.
5940  * 
5941  * \throw If the fileName is not set or points to a non readable MED file.
5942  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5943  */
5944 void MEDFileAnyTypeField1TS::loadArrays()
5945 {
5946   if(getFileName().empty())
5947     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5948   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5949   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5950 }
5951
5952 /*!
5953  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5954  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5955  * this method does not throw if \a this does not come from file read.
5956  * 
5957  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5958  */
5959 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5960 {
5961   if(!getFileName().empty())
5962     {
5963       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
5964       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5965     }
5966 }
5967
5968 /*!
5969  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5970  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5971  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5972  * 
5973  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5974  */
5975 void MEDFileAnyTypeField1TS::unloadArrays()
5976 {
5977   contentNotNullBase()->unloadArrays();
5978 }
5979
5980 /*!
5981  * 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.
5982  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5983  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5984  * 
5985  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5986  */
5987 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5988 {
5989   if(!getFileName().empty())
5990     contentNotNullBase()->unloadArrays();
5991 }
5992
5993 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5994 {
5995   int nbComp(getNumberOfComponents());
5996   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5997   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
5998   for(int i=0;i<nbComp;i++)
5999     {
6000       std::string info=getInfo()[i];
6001       std::string c,u;
6002       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6003       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6004       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6005     }
6006   if(getName().empty())
6007     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6008   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6009   writeGlobals(fid,*this);
6010   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6011 }
6012
6013 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6014 {
6015   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6016 }
6017
6018 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6019 {
6020   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6021   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6022   return ret;
6023 }
6024
6025 /*!
6026  * Returns a string describing \a this field. This string is outputted 
6027  * by \c print Python command.
6028  */
6029 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6030 {
6031   std::ostringstream oss;
6032   contentNotNullBase()->simpleRepr(0,oss,-1);
6033   simpleReprGlobs(oss);
6034   return oss.str();
6035 }
6036
6037 /*!
6038  * This method returns all profiles whose name is non empty used.
6039  * \b WARNING If profile is used several times it will be reported \b only \b once.
6040  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6041  */
6042 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6043 {
6044   return contentNotNullBase()->getPflsReallyUsed2();
6045 }
6046
6047 /*!
6048  * This method returns all localizations whose name is non empty used.
6049  * \b WARNING If localization is used several times it will be reported \b only \b once.
6050  */
6051 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6052 {
6053   return contentNotNullBase()->getLocsReallyUsed2();
6054 }
6055
6056 /*!
6057  * This method returns all profiles whose name is non empty used.
6058  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6059  */
6060 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6061 {
6062   return contentNotNullBase()->getPflsReallyUsedMulti2();
6063 }
6064
6065 /*!
6066  * This method returns all localizations whose name is non empty used.
6067  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6068  */
6069 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6070 {
6071   return contentNotNullBase()->getLocsReallyUsedMulti2();
6072 }
6073
6074 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6075 {
6076   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6077 }
6078
6079 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6080 {
6081   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6082 }
6083
6084 int MEDFileAnyTypeField1TS::getDimension() const
6085 {
6086   return contentNotNullBase()->getDimension();
6087 }
6088
6089 int MEDFileAnyTypeField1TS::getIteration() const
6090 {
6091   return contentNotNullBase()->getIteration();
6092 }
6093
6094 int MEDFileAnyTypeField1TS::getOrder() const
6095 {
6096   return contentNotNullBase()->getOrder();
6097 }
6098
6099 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6100 {
6101   return contentNotNullBase()->getTime(iteration,order);
6102 }
6103
6104 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6105 {
6106   contentNotNullBase()->setTime(iteration,order,val);
6107 }
6108
6109 std::string MEDFileAnyTypeField1TS::getName() const
6110 {
6111   return contentNotNullBase()->getName();
6112 }
6113
6114 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6115 {
6116   contentNotNullBase()->setName(name);
6117 }
6118
6119 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6120 {
6121   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6122 }
6123
6124 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6125 {
6126   return contentNotNullBase()->getDtUnit();
6127 }
6128
6129 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6130 {
6131   contentNotNullBase()->setDtUnit(dtUnit);
6132 }
6133
6134 std::string MEDFileAnyTypeField1TS::getMeshName() const
6135 {
6136   return contentNotNullBase()->getMeshName();
6137 }
6138
6139 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6140 {
6141   contentNotNullBase()->setMeshName(newMeshName);
6142 }
6143
6144 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6145 {
6146   return contentNotNullBase()->changeMeshNames(modifTab);
6147 }
6148
6149 int MEDFileAnyTypeField1TS::getMeshIteration() const
6150 {
6151   return contentNotNullBase()->getMeshIteration();
6152 }
6153
6154 int MEDFileAnyTypeField1TS::getMeshOrder() const
6155 {
6156   return contentNotNullBase()->getMeshOrder();
6157 }
6158
6159 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6160 {
6161   return contentNotNullBase()->getNumberOfComponents();
6162 }
6163
6164 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6165 {
6166   return contentNotNullBase()->isDealingTS(iteration,order);
6167 }
6168
6169 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6170 {
6171   return contentNotNullBase()->getDtIt();
6172 }
6173
6174 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6175 {
6176   contentNotNullBase()->fillIteration(p);
6177 }
6178
6179 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6180 {
6181   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6182 }
6183
6184 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6185 {
6186   contentNotNullBase()->setInfo(infos);
6187 }
6188
6189 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6190 {
6191   return contentNotNullBase()->getInfo();
6192 }
6193 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6194 {
6195   return contentNotNullBase()->getInfo();
6196 }
6197
6198 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6199 {
6200   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6201 }
6202
6203 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6204 {
6205   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6206 }
6207
6208 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6209 {
6210   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6211 }
6212
6213 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6214 {
6215   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6216 }
6217
6218 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6219 {
6220   return contentNotNullBase()->getTypesOfFieldAvailable();
6221 }
6222
6223 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,
6224                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6225 {
6226   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6227 }
6228
6229 /*!
6230  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6231  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6232  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6233  */
6234 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6235 {
6236   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6237   if(!content)
6238     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6239   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6240   std::size_t sz(contentsSplit.size());
6241   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6242   for(std::size_t i=0;i<sz;i++)
6243     {
6244       ret[i]=shallowCpy();
6245       ret[i]->_content=contentsSplit[i];
6246     }
6247   return ret;
6248 }
6249
6250 /*!
6251  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6252  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6253  */
6254 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6255 {
6256   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6257   if(!content)
6258     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6259   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6260   std::size_t sz(contentsSplit.size());
6261   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6262   for(std::size_t i=0;i<sz;i++)
6263     {
6264       ret[i]=shallowCpy();
6265       ret[i]->_content=contentsSplit[i];
6266     }
6267   return ret;
6268 }
6269
6270 /*!
6271  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6272  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6273  */
6274 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6275 {
6276   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6277   if(!content)
6278     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6279   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6280   std::size_t sz(contentsSplit.size());
6281   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6282   for(std::size_t i=0;i<sz;i++)
6283     {
6284       ret[i]=shallowCpy();
6285       ret[i]->_content=contentsSplit[i];
6286     }
6287   return ret;
6288 }
6289
6290 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6291 {
6292   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6293   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6294     ret->_content=_content->deepCopy();
6295   ret->deepCpyGlobs(*this);
6296   return ret.retn();
6297 }
6298
6299 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6300 {
6301   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6302 }
6303
6304 //= MEDFileField1TS
6305
6306 /*!
6307  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6308  * the first field that has been read from a specified MED file.
6309  *  \param [in] fileName - the name of the MED file to read.
6310  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6311  *          is to delete this field using decrRef() as it is no more needed.
6312  *  \throw If reading the file fails.
6313  */
6314 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6315 {
6316   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6317   return New(fid,loadAll);
6318 }
6319
6320 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6321 {
6322   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6323   ret->contentNotNull();
6324   return ret.retn();
6325 }
6326
6327 /*!
6328  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6329  * a given field that has been read from a specified MED file.
6330  *  \param [in] fileName - the name of the MED file to read.
6331  *  \param [in] fieldName - the name of the field to read.
6332  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6333  *          is to delete this field using decrRef() as it is no more needed.
6334  *  \throw If reading the file fails.
6335  *  \throw If there is no field named \a fieldName in the file.
6336  */
6337 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6338 {
6339   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6340   return New(fid,fieldName,loadAll);
6341 }
6342
6343 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6344 {
6345   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6346   ret->contentNotNull();
6347   return ret.retn();
6348 }
6349
6350 /*!
6351  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6352  * a given field that has been read from a specified MED file.
6353  *  \param [in] fileName - the name of the MED file to read.
6354  *  \param [in] fieldName - the name of the field to read.
6355  *  \param [in] iteration - the iteration number of a required time step.
6356  *  \param [in] order - the iteration order number of required time step.
6357  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6358  *          is to delete this field using decrRef() as it is no more needed.
6359  *  \throw If reading the file fails.
6360  *  \throw If there is no field named \a fieldName in the file.
6361  *  \throw If the required time step is missing from the file.
6362  */
6363 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6364 {
6365   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6366   return New(fid,fieldName,iteration,order,loadAll);
6367 }
6368
6369 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6370 {
6371   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6372   ret->contentNotNull();
6373   return ret.retn();
6374 }
6375
6376 /*!
6377  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6378  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6379  *
6380  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6381  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6382  * \warning this is a shallow copy constructor
6383  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6384  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6385  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6386  *          is to delete this field using decrRef() as it is no more needed.
6387  */
6388 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6389 {
6390   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6391   ret->contentNotNull();
6392   return ret.retn();
6393 }
6394
6395 /*!
6396  * Returns a new empty instance of MEDFileField1TS.
6397  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6398  *          is to delete this field using decrRef() as it is no more needed.
6399  */
6400 MEDFileField1TS *MEDFileField1TS::New()
6401 {
6402   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6403   ret->contentNotNull();
6404   return ret.retn();
6405 }
6406
6407 /*!
6408  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6409  * following the given input policy.
6410  *
6411  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6412  *                            By default (true) the globals are deeply copied.
6413  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6414  */
6415 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6416 {
6417   MCAuto<MEDFileIntField1TS> ret;
6418   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6419   if(content)
6420     {
6421       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6422       if(!contc)
6423         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6424       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6425       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6426     }
6427   else
6428     ret=MEDFileIntField1TS::New();
6429   if(isDeepCpyGlobs)
6430     ret->deepCpyGlobs(*this);
6431   else
6432     ret->shallowCpyGlobs(*this);
6433   return ret.retn();
6434 }
6435
6436 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6437 {
6438   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6439   if(!pt)
6440     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6441   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6442   if(!ret)
6443     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 !");
6444   return ret;
6445 }
6446
6447 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6448 {
6449   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6450   if(!pt)
6451     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6452   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6453   if(!ret)
6454     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 !");
6455   return ret;
6456 }
6457
6458 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6459 {
6460   if(!f)
6461     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6462   if(arr.isNull())
6463     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6464   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6465   if(!arrOutC)
6466     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6467   f->setArray(arrOutC);
6468 }
6469
6470 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6471 {
6472   if(arr.isNull())
6473     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6474   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6475   if(!arrOutC)
6476     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6477   arrOutC->incrRef();
6478   return arrOutC;
6479 }
6480
6481 /*!
6482  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6483  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6484  *
6485  * \return A new object that the caller is responsible to deallocate.
6486  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6487  */
6488 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6489 {
6490   if(!mm)
6491     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6492   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6493   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6494   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6495     {
6496       if((*it0)!=ON_NODES)
6497         {
6498           std::vector<int> levs;
6499           getNonEmptyLevels(mm->getName(),levs);
6500           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6501             {
6502               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6503               if(it2!=extractDef.end())
6504                 {
6505                   MCAuto<DataArrayInt> t((*it2).second);
6506                   if(t.isNull())
6507                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6508                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6509                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6510                   ret->setFieldNoProfileSBT(fOut);
6511                 }
6512             }
6513         }
6514       else
6515         {
6516           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6517           if(it2==extractDef.end())
6518             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6519           MCAuto<DataArrayInt> t((*it2).second);
6520           if(t.isNull())
6521             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6522           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6523           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6524           DataArrayDouble *arr(f->getArray());
6525           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6526           fOut->setArray(newArr);
6527           ret->setFieldNoProfileSBT(fOut);
6528         }
6529     }
6530   return ret.retn();
6531 }
6532
6533 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6534 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6535 {
6536 }
6537 catch(INTERP_KERNEL::Exception& e)
6538 { throw e; }
6539
6540 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6541 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6542 {
6543 }
6544 catch(INTERP_KERNEL::Exception& e)
6545 { throw e; }
6546
6547 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6548 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6549 {
6550 }
6551 catch(INTERP_KERNEL::Exception& e)
6552 { throw e; }
6553
6554 /*!
6555  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6556  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6557  *
6558  * \warning this is a shallow copy constructor
6559  */
6560 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6561 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6562 {
6563 }
6564 catch(INTERP_KERNEL::Exception& e)
6565 { throw e; }
6566
6567 MEDFileField1TS::MEDFileField1TS()
6568 {
6569   _content=new MEDFileField1TSWithoutSDA;
6570 }
6571
6572 /*!
6573  * 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
6574  * method should be called (getFieldOnMeshAtLevel for example).
6575  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6576  *
6577  * \param [in] mesh - the mesh the field is lying on
6578  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6579  *          caller is to delete this field using decrRef() as it is no more needed. 
6580  */
6581 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6582 {
6583   MCAuto<DataArray> arrOut;
6584   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6585   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6586   return ret.retn();
6587 }
6588
6589 /*!
6590  * Returns a new MEDCouplingFieldDouble of a given type lying on
6591  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6592  * has not been constructed via file reading, an exception is thrown.
6593  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6594  *  \param [in] type - a spatial discretization of interest.
6595  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6596  *  \param [in] renumPol - specifies how to permute values of the result field according to
6597  *          the optional numbers of cells and nodes, if any. The valid values are
6598  *          - 0 - do not permute.
6599  *          - 1 - permute cells.
6600  *          - 2 - permute nodes.
6601  *          - 3 - permute cells and nodes.
6602  *
6603  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6604  *          caller is to delete this field using decrRef() as it is no more needed. 
6605  *  \throw If \a this field has not been constructed via file reading.
6606  *  \throw If the MED file is not readable.
6607  *  \throw If there is no mesh in the MED file.
6608  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6609  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6610  *  \sa getFieldOnMeshAtLevel()
6611  */
6612 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6613 {
6614   if(getFileName().empty())
6615     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6616   MCAuto<DataArray> arrOut;
6617   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6618   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6619   return ret.retn();
6620 }
6621
6622 /*!
6623  * Returns a new MEDCouplingFieldDouble of a given type lying on
6624  * the top level cells of the first mesh in MED file. If \a this field 
6625  * has not been constructed via file reading, an exception is thrown.
6626  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6627  *  \param [in] type - a spatial discretization of interest.
6628  *  \param [in] renumPol - specifies how to permute values of the result field according to
6629  *          the optional numbers of cells and nodes, if any. The valid values are
6630  *          - 0 - do not permute.
6631  *          - 1 - permute cells.
6632  *          - 2 - permute nodes.
6633  *          - 3 - permute cells and nodes.
6634  *
6635  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6636  *          caller is to delete this field using decrRef() as it is no more needed. 
6637  *  \throw If \a this field has not been constructed via file reading.
6638  *  \throw If the MED file is not readable.
6639  *  \throw If there is no mesh in the MED file.
6640  *  \throw If no field values of the given \a type.
6641  *  \throw If no field values lying on the top level support.
6642  *  \sa getFieldAtLevel()
6643  */
6644 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6645 {
6646   if(getFileName().empty())
6647     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6648   MCAuto<DataArray> arrOut;
6649   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6650   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6651   return ret.retn();
6652 }
6653
6654 /*!
6655  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6656  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6657  *  \param [in] type - a spatial discretization of the new field.
6658  *  \param [in] mesh - the supporting mesh.
6659  *  \param [in] renumPol - specifies how to permute values of the result field according to
6660  *          the optional numbers of cells and nodes, if any. The valid values are
6661  *          - 0 - do not permute.
6662  *          - 1 - permute cells.
6663  *          - 2 - permute nodes.
6664  *          - 3 - permute cells and nodes.
6665  *
6666  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6667  *          caller is to delete this field using decrRef() as it is no more needed. 
6668  *  \throw If no field of \a this is lying on \a mesh.
6669  *  \throw If the mesh is empty.
6670  *  \throw If no field values of the given \a type are available.
6671  *  \sa getFieldAtLevel()
6672  *  \sa getFieldOnMeshAtLevel() 
6673  */
6674 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6675 {
6676   MCAuto<DataArray> arrOut;
6677   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6678   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6679   return ret.retn();
6680 }
6681
6682 /*!
6683  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6684  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6685  *  \param [in] type - a spatial discretization of interest.
6686  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6687  *  \param [in] mesh - the supporting mesh.
6688  *  \param [in] renumPol - specifies how to permute values of the result field according to
6689  *          the optional numbers of cells and nodes, if any. The valid values are
6690  *          - 0 - do not permute.
6691  *          - 1 - permute cells.
6692  *          - 2 - permute nodes.
6693  *          - 3 - permute cells and nodes.
6694  *
6695  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6696  *          caller is to delete this field using decrRef() as it is no more needed. 
6697  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6698  *  \throw If no field of \a this is lying on \a mesh.
6699  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6700  *  \sa getFieldAtLevel()
6701  *  \sa getFieldOnMeshAtLevel() 
6702  */
6703 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6704 {
6705   MCAuto<DataArray> arrOut;
6706   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6707   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6708   return ret.retn();
6709 }
6710
6711 /*!
6712  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6713  * This method is called "Old" because in MED3 norm a field has only one meshName
6714  * attached, so this method is for readers of MED2 files. If \a this field 
6715  * has not been constructed via file reading, an exception is thrown.
6716  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6717  *  \param [in] type - a spatial discretization of interest.
6718  *  \param [in] mName - a name of the supporting mesh.
6719  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6720  *  \param [in] renumPol - specifies how to permute values of the result field according to
6721  *          the optional numbers of cells and nodes, if any. The valid values are
6722  *          - 0 - do not permute.
6723  *          - 1 - permute cells.
6724  *          - 2 - permute nodes.
6725  *          - 3 - permute cells and nodes.
6726  *
6727  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6728  *          caller is to delete this field using decrRef() as it is no more needed. 
6729  *  \throw If the MED file is not readable.
6730  *  \throw If there is no mesh named \a mName in the MED file.
6731  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6732  *  \throw If \a this field has not been constructed via file reading.
6733  *  \throw If no field of \a this is lying on the mesh named \a mName.
6734  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6735  *  \sa getFieldAtLevel()
6736  */
6737 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6738 {
6739   if(getFileName().empty())
6740     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6741   MCAuto<DataArray> arrOut;
6742   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6743   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6744   return ret.retn();
6745 }
6746
6747 /*!
6748  * Returns values and a profile of the field of a given type lying on a given support.
6749  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6750  *  \param [in] type - a spatial discretization of the field.
6751  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6752  *  \param [in] mesh - the supporting mesh.
6753  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6754  *          field of interest lies on. If the field lies on all entities of the given
6755  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6756  *          using decrRef() as it is no more needed.  
6757  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6758  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6759  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6760  *  \throw If no field of \a this is lying on \a mesh.
6761  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6762  */
6763 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6764 {
6765   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6766   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6767 }
6768
6769 /*!
6770  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6771  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6772  * "Sort By Type"), if not, an exception is thrown. 
6773  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6774  *  \param [in] field - the field to add to \a this.
6775  *  \throw If the name of \a field is empty.
6776  *  \throw If the data array of \a field is not set.
6777  *  \throw If the data array is already allocated but has different number of components
6778  *         than \a field.
6779  *  \throw If the underlying mesh of \a field has no name.
6780  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6781  */
6782 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6783 {
6784   setFileName("");
6785   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6786 }
6787
6788 /*!
6789  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6790  * can be an aggregation of several MEDCouplingFieldDouble instances.
6791  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6792  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6793  * and \a profile.
6794  *
6795  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6796  * A new profile is added only if no equal profile is missing.
6797  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6798  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6799  *  \param [in] mesh - the supporting mesh of \a field.
6800  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6801  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6802  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6803  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6804  *  \throw If the data array of \a field is not set.
6805  *  \throw If the data array of \a this is already allocated but has different number of
6806  *         components than \a field.
6807  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6808  *  \sa setFieldNoProfileSBT()
6809  */
6810 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6811 {
6812   setFileName("");
6813   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6814 }
6815
6816 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6817 {
6818   return new MEDFileField1TS(*this);
6819 }
6820
6821 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6822 {
6823   return contentNotNull()->getUndergroundDataArrayTemplate();
6824 }
6825
6826 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6827 {
6828   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6829 }
6830
6831 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6832                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6833 {
6834   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6835 }
6836
6837 //= MEDFileIntField1TS
6838
6839 MEDFileIntField1TS *MEDFileIntField1TS::New()
6840 {
6841   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
6842   ret->contentNotNull();
6843   return ret.retn();
6844 }
6845
6846 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6847 {
6848   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6849   return MEDFileIntField1TS::New(fid,loadAll);
6850 }
6851
6852 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
6853 {
6854   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
6855   ret->contentNotNull();
6856   return ret.retn();
6857 }
6858
6859 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6860 {
6861   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6862   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
6863 }
6864
6865 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6866 {
6867   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
6868   ret->contentNotNull();
6869   return ret.retn();
6870 }
6871
6872 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6873 {
6874   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6875   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
6876 }
6877
6878 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6879 {
6880   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
6881   ret->contentNotNull();
6882   return ret.retn();
6883 }
6884
6885 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6886 {
6887   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6888   ret->contentNotNull();
6889   return ret.retn();
6890 }
6891
6892 MEDFileIntField1TS::MEDFileIntField1TS()
6893 {
6894   _content=new MEDFileIntField1TSWithoutSDA;
6895 }
6896
6897 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6898 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6899 {
6900 }
6901 catch(INTERP_KERNEL::Exception& e)
6902 { throw e; }
6903
6904 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6905 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6906 {
6907 }
6908 catch(INTERP_KERNEL::Exception& e)
6909 { throw e; }
6910
6911 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6912 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6913 {
6914 }
6915 catch(INTERP_KERNEL::Exception& e)
6916 { throw e; }
6917
6918 /*!
6919  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6920  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6921  *
6922  * \warning this is a shallow copy constructor
6923  */
6924 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6925 {
6926 }
6927
6928 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6929 {
6930   return new MEDFileIntField1TS(*this);
6931 }
6932
6933 /*!
6934  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6935  * following the given input policy.
6936  *
6937  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6938  *                            By default (true) the globals are deeply copied.
6939  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6940  */
6941 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6942 {
6943   MCAuto<MEDFileField1TS> ret;
6944   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6945   if(content)
6946     {
6947       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6948       if(!contc)
6949         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6950       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6951       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
6952     }
6953   else
6954     ret=MEDFileField1TS::New();
6955   if(isDeepCpyGlobs)
6956     ret->deepCpyGlobs(*this);
6957   else
6958     ret->shallowCpyGlobs(*this);
6959   return ret.retn();
6960 }
6961
6962 /*!
6963  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6964  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6965  * "Sort By Type"), if not, an exception is thrown. 
6966  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6967  *  \param [in] field - the field to add to \a this.
6968  *  \throw If the name of \a field is empty.
6969  *  \throw If the data array of \a field is not set.
6970  *  \throw If the data array is already allocated but has different number of components
6971  *         than \a field.
6972  *  \throw If the underlying mesh of \a field has no name.
6973  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6974  */
6975 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6976 {
6977   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6978   setFileName("");
6979   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6980 }
6981
6982 /*!
6983  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6984  * can be an aggregation of several MEDCouplingFieldDouble instances.
6985  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6986  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6987  * and \a profile.
6988  *
6989  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6990  * A new profile is added only if no equal profile is missing.
6991  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6992  *  \param [in] field - the field to add to \a this.
6993  *  \param [in] mesh - the supporting mesh of \a field.
6994  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6995  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6996  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6997  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6998  *  \throw If the data array of \a field is not set.
6999  *  \throw If the data array of \a this is already allocated but has different number of
7000  *         components than \a field.
7001  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7002  *  \sa setFieldNoProfileSBT()
7003  */
7004 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7005 {
7006   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7007   setFileName("");
7008   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7009 }
7010
7011 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7012 {
7013   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7014   if(!pt)
7015     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7016   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7017   if(!ret)
7018     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 !");
7019   return ret;
7020 }
7021
7022 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7023 {
7024   if(getFileName().empty())
7025     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7026   MCAuto<DataArray> arrOut;
7027   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7028   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7029   return ret2.retn();
7030 }
7031
7032 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7033 {
7034   if(arr.isNull())
7035     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7036   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7037   if(!arrC)
7038     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7039   arrC->incrRef();
7040   return arrC;
7041 }
7042
7043 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7044 {
7045   int t1,t2;
7046   double t0(f->getTime(t1,t2));
7047   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7048   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7049   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7050   ret->setTime(t0,t1,t2); ret->setArray(arr2);
7051   return ret.retn();
7052 }
7053
7054 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7055 {
7056   if(!f)
7057     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7058   int t1,t2;
7059   double t0(f->getTime(t1,t2));
7060   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7061   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7062   ret->setTime(t0,t1,t2);
7063   return ret;
7064 }
7065
7066 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7067 {
7068   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7069 }
7070
7071 /*!
7072  * 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
7073  * method should be called (getFieldOnMeshAtLevel for example).
7074  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7075  *
7076  * \param [in] mesh - the mesh the field is lying on
7077  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7078  *          caller is to delete this field using decrRef() as it is no more needed. 
7079  */
7080 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7081 {
7082   MCAuto<DataArray> arrOut;
7083   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7084   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7085   return ret2.retn();
7086 }
7087
7088 /*!
7089  * Returns a new MEDCouplingFieldInt of a given type lying on
7090  * the top level cells of the first mesh in MED file. If \a this field 
7091  * has not been constructed via file reading, an exception is thrown.
7092  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7093  *  \param [in] type - a spatial discretization of interest.
7094  *  \param [in] renumPol - specifies how to permute values of the result field according to
7095  *          the optional numbers of cells and nodes, if any. The valid values are
7096  *          - 0 - do not permute.
7097  *          - 1 - permute cells.
7098  *          - 2 - permute nodes.
7099  *          - 3 - permute cells and nodes.
7100  *
7101  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7102  *          caller is to delete this field using decrRef() as it is no more needed. 
7103  *  \throw If \a this field has not been constructed via file reading.
7104  *  \throw If the MED file is not readable.
7105  *  \throw If there is no mesh in the MED file.
7106  *  \throw If no field values of the given \a type.
7107  *  \throw If no field values lying on the top level support.
7108  *  \sa getFieldAtLevel()
7109  */
7110 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7111 {
7112   if(getFileName().empty())
7113     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7114   MCAuto<DataArray> arrOut;
7115   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7116   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7117   return ret2.retn();
7118 }
7119
7120 /*!
7121  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7122  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7123  *  \param [in] type - a spatial discretization of the new field.
7124  *  \param [in] mesh - the supporting mesh.
7125  *  \param [in] renumPol - specifies how to permute values of the result field according to
7126  *          the optional numbers of cells and nodes, if any. The valid values are
7127  *          - 0 - do not permute.
7128  *          - 1 - permute cells.
7129  *          - 2 - permute nodes.
7130  *          - 3 - permute cells and nodes.
7131  *
7132  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7133  *          caller is to delete this field using decrRef() as it is no more needed. 
7134  *  \throw If no field of \a this is lying on \a mesh.
7135  *  \throw If the mesh is empty.
7136  *  \throw If no field values of the given \a type are available.
7137  *  \sa getFieldAtLevel()
7138  *  \sa getFieldOnMeshAtLevel() 
7139  */
7140 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7141 {
7142   MCAuto<DataArray> arrOut;
7143   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7144   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7145   return ret2.retn();
7146 }
7147
7148 /*!
7149  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7150  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7151  *  \param [in] type - a spatial discretization of interest.
7152  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7153  *  \param [in] mesh - the supporting mesh.
7154  *  \param [in] renumPol - specifies how to permute values of the result field according to
7155  *          the optional numbers of cells and nodes, if any. The valid values are
7156  *          - 0 - do not permute.
7157  *          - 1 - permute cells.
7158  *          - 2 - permute nodes.
7159  *          - 3 - permute cells and nodes.
7160  *
7161  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7162  *          caller is to delete this field using decrRef() as it is no more needed. 
7163  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7164  *  \throw If no field of \a this is lying on \a mesh.
7165  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7166  *  \sa getFieldAtLevel()
7167  *  \sa getFieldOnMeshAtLevel() 
7168  */
7169 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7170 {
7171   MCAuto<DataArray> arrOut;
7172   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7173   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7174   return ret2.retn();
7175 }
7176
7177 /*!
7178  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7179  * This method is called "Old" because in MED3 norm a field has only one meshName
7180  * attached, so this method is for readers of MED2 files. If \a this field 
7181  * has not been constructed via file reading, an exception is thrown.
7182  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7183  *  \param [in] type - a spatial discretization of interest.
7184  *  \param [in] mName - a name of the supporting mesh.
7185  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7186  *  \param [in] renumPol - specifies how to permute values of the result field according to
7187  *          the optional numbers of cells and nodes, if any. The valid values are
7188  *          - 0 - do not permute.
7189  *          - 1 - permute cells.
7190  *          - 2 - permute nodes.
7191  *          - 3 - permute cells and nodes.
7192  *
7193  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7194  *          caller is to delete this field using decrRef() as it is no more needed. 
7195  *  \throw If the MED file is not readable.
7196  *  \throw If there is no mesh named \a mName in the MED file.
7197  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7198  *  \throw If \a this field has not been constructed via file reading.
7199  *  \throw If no field of \a this is lying on the mesh named \a mName.
7200  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7201  *  \sa getFieldAtLevel()
7202  */
7203 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7204 {
7205   if(getFileName().empty())
7206     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7207   MCAuto<DataArray> arrOut;
7208   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7209   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7210   return ret2.retn();
7211 }
7212
7213 /*!
7214  * Returns values and a profile of the field of a given type lying on a given support.
7215  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7216  *  \param [in] type - a spatial discretization of the field.
7217  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7218  *  \param [in] mesh - the supporting mesh.
7219  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7220  *          field of interest lies on. If the field lies on all entities of the given
7221  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7222  *          using decrRef() as it is no more needed.  
7223  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7224  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7225  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7226  *  \throw If no field of \a this is lying on \a mesh.
7227  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7228  */
7229 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7230 {
7231   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7232   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7233 }
7234
7235 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7236 {
7237   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7238   if(!pt)
7239     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7240   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7241   if(!ret)
7242     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 !");
7243   return ret;
7244 }
7245
7246 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7247 {
7248   return contentNotNull()->getUndergroundDataArrayTemplate();
7249 }
7250
7251 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7252
7253 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7254 {
7255 }
7256
7257 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7258 {
7259 }
7260
7261 /*!
7262  * \param [in] fieldId field id in C mode
7263  */
7264 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7265 {
7266   med_field_type typcha;
7267   std::string dtunitOut;
7268   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7269   setDtUnit(dtunitOut.c_str());
7270   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7271 }
7272
7273 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)
7274 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7275 {
7276   setDtUnit(dtunit.c_str());
7277   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7278 }
7279 catch(INTERP_KERNEL::Exception& e)
7280 {
7281     throw e;
7282 }
7283
7284 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7285 {
7286   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7287   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7288     ret+=(*it).capacity();
7289   return ret;
7290 }
7291
7292 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7293 {
7294   std::vector<const BigMemoryObject *> ret;
7295   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7296     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7297   return ret;
7298 }
7299
7300 /*!
7301  * 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
7302  * NULL.
7303  */
7304 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7305 {
7306   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7307   ret->setInfo(_infos);
7308   int sz=(int)_time_steps.size();
7309   for(const int *id=startIds;id!=endIds;id++)
7310     {
7311       if(*id>=0 && *id<sz)
7312         {
7313           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7314           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7315           if(tse)
7316             {
7317               tse->incrRef();
7318               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7319             }
7320           ret->pushBackTimeStep(tse2);
7321         }
7322       else
7323         {
7324           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7325           oss << " ! Should be in [0," << sz << ") !";
7326           throw INTERP_KERNEL::Exception(oss.str());
7327         }
7328     }
7329   if(ret->getNumberOfTS()>0)
7330     ret->synchronizeNameScope();
7331   ret->copyNameScope(*this);
7332   return ret.retn();
7333 }
7334
7335 /*!
7336  * 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
7337  * NULL.
7338  */
7339 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7340 {
7341   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7342   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7343   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7344   ret->setInfo(_infos);
7345   int sz=(int)_time_steps.size();
7346   int j=bg;
7347   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7348     {
7349       if(j>=0 && j<sz)
7350         {
7351           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7352           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7353           if(tse)
7354             {
7355               tse->incrRef();
7356               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7357             }
7358           ret->pushBackTimeStep(tse2);
7359         }
7360       else
7361         {
7362           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7363           oss << " ! Should be in [0," << sz << ") !";
7364           throw INTERP_KERNEL::Exception(oss.str());
7365         }
7366     }
7367   if(ret->getNumberOfTS()>0)
7368     ret->synchronizeNameScope();
7369   ret->copyNameScope(*this);
7370   return ret.retn();
7371 }
7372
7373 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7374 {
7375   int id=0;
7376   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7377   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7378     {
7379       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7380       if(!cur)
7381         continue;
7382       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7383       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7384         ids->pushBackSilent(id);
7385     }
7386   return buildFromTimeStepIds(ids->begin(),ids->end());
7387 }
7388
7389 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7390 {
7391   int id=0;
7392   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7393   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7394     {
7395       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7396       if(!cur)
7397         continue;
7398       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7399       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7400         ids->pushBackSilent(id);
7401     }
7402   return buildFromTimeStepIds(ids->begin(),ids->end());
7403 }
7404
7405 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7406 {
7407   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7408     {
7409       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7410       if(!cur)
7411         continue;
7412       if(cur->presenceOfMultiDiscPerGeoType())
7413         return true;
7414     }
7415   return false;
7416 }
7417
7418 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7419 {
7420   return _infos;
7421 }
7422
7423 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7424 {
7425   _infos=info;
7426 }
7427
7428 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7429 {
7430   int ret=0;
7431   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7432     {
7433       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7434       if(pt->isDealingTS(iteration,order))
7435         return ret;
7436     }
7437   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7438   std::vector< std::pair<int,int> > vp=getIterations();
7439   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7440     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7441   throw INTERP_KERNEL::Exception(oss.str());
7442 }
7443
7444 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7445 {
7446   return *_time_steps[getTimeStepPos(iteration,order)];
7447 }
7448
7449 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7450 {
7451   return *_time_steps[getTimeStepPos(iteration,order)];
7452 }
7453
7454 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7455 {
7456   if(_time_steps.empty())
7457     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7458   return _time_steps[0]->getMeshName();
7459 }
7460
7461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7462 {
7463   std::string oldName(getMeshName());
7464   std::vector< std::pair<std::string,std::string> > v(1);
7465   v[0].first=oldName; v[0].second=newMeshName;
7466   changeMeshNames(v);
7467 }
7468
7469 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7470 {
7471   bool ret=false;
7472   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7473     {
7474       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7475       if(cur)
7476         ret=cur->changeMeshNames(modifTab) || ret;
7477     }
7478   return ret;
7479 }
7480
7481 /*!
7482  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7483  */
7484 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7485 {
7486   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7487 }
7488
7489 /*!
7490  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7491  */
7492 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7493 {
7494   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7495 }
7496
7497 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7498                                                                        MEDFileFieldGlobsReal& glob)
7499 {
7500   bool ret=false;
7501   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7502     {
7503       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7504       if(f1ts)
7505         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7506     }
7507   return ret;
7508 }
7509
7510 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7511 {
7512   std::string startLine(bkOffset,' ');
7513   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7514   if(fmtsId>=0)
7515     oss << " (" << fmtsId << ")";
7516   oss << " has the following name: \"" << _name << "\"." << std::endl;
7517   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7518   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7519     {
7520       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7521     }
7522   int i=0;
7523   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7524     {
7525       std::string chapter(17,'0'+i);
7526       oss << startLine << chapter << std::endl;
7527       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7528       if(cur)
7529         cur->simpleRepr(bkOffset+2,oss,i);
7530       else
7531         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7532       oss << startLine << chapter << std::endl;
7533     }
7534 }
7535
7536 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7537 {
7538   std::size_t sz=_time_steps.size();
7539   std::vector< std::pair<int,int> > ret(sz);
7540   ret1.resize(sz);
7541   for(std::size_t i=0;i<sz;i++)
7542     {
7543       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7544       if(f1ts)
7545         {
7546           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7547         }
7548       else
7549         {
7550           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7551           throw INTERP_KERNEL::Exception(oss.str());
7552         }
7553     }
7554   return ret;
7555 }
7556
7557 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7558 {
7559   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7560   if(!tse2)
7561     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7562   checkCoherencyOfType(tse2);
7563   if(_time_steps.empty())
7564     {
7565       setName(tse2->getName().c_str());
7566       setInfo(tse2->getInfo());
7567     }
7568   checkThatComponentsMatch(tse2->getInfo());
7569   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7570     setDtUnit(tse->getDtUnit());
7571   _time_steps.push_back(tse);
7572 }
7573
7574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7575 {
7576   std::size_t nbOfCompo=_infos.size();
7577   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7578     {
7579       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7580       if(cur)
7581         {
7582           if((cur->getInfo()).size()!=nbOfCompo)
7583             {
7584               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7585               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7586               throw INTERP_KERNEL::Exception(oss.str());
7587             }
7588           cur->copyNameScope(*this);
7589         }
7590     }
7591 }
7592
7593 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7594 {
7595   _time_steps.resize(nbPdt);
7596   for(int i=0;i<nbPdt;i++)
7597     {
7598       std::vector< std::pair<int,int> > ts;
7599       med_int numdt=0,numo=0;
7600       med_float dt=0.0;
7601       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7602       switch(fieldTyp)
7603       {
7604         case MED_FLOAT64:
7605           {
7606             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7607             break;
7608           }
7609         case MED_INT32:
7610           {
7611             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7612             break;
7613           }
7614         default:
7615           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7616       }
7617       if(loadAll)
7618         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7619       else
7620         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7621       synchronizeNameScope();
7622     }
7623 }
7624
7625 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7626 {
7627   if(_time_steps.empty())
7628     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7629   checkThatNbOfCompoOfTSMatchThis();
7630   std::vector<std::string> infos(getInfo());
7631   int nbComp=infos.size();
7632   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7633   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7634   for(int i=0;i<nbComp;i++)
7635     {
7636       std::string info=infos[i];
7637       std::string c,u;
7638       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7639       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7640       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7641     }
7642   if(_name.empty())
7643     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7644   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7645   int nbOfTS=_time_steps.size();
7646   for(int i=0;i<nbOfTS;i++)
7647     _time_steps[i]->writeLL(fid,opts,*this);
7648 }
7649
7650 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7651 {
7652   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7653     {
7654       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7655       if(elt)
7656         elt->loadBigArraysRecursively(fid,nasc);
7657     }
7658 }
7659
7660 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7661 {
7662   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7663     {
7664       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7665       if(elt)
7666         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7667     }
7668 }
7669
7670 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7671 {
7672   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7673     {
7674       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7675       if(elt)
7676         elt->unloadArrays();
7677     }
7678 }
7679
7680 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7681 {
7682   return _time_steps.size();
7683 }
7684
7685 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7686 {
7687   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7688   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7689     {
7690       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7691       if(tmp)
7692         newTS.push_back(*it);
7693     }
7694   _time_steps=newTS;
7695 }
7696
7697 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7698 {
7699   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7700   int maxId=(int)_time_steps.size();
7701   int ii=0;
7702   std::set<int> idsToDel;
7703   for(const int *id=startIds;id!=endIds;id++,ii++)
7704     {
7705       if(*id>=0 && *id<maxId)
7706         {
7707           idsToDel.insert(*id);
7708         }
7709       else
7710         {
7711           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7712           throw INTERP_KERNEL::Exception(oss.str());
7713         }
7714     }
7715   for(int iii=0;iii<maxId;iii++)
7716     if(idsToDel.find(iii)==idsToDel.end())
7717       newTS.push_back(_time_steps[iii]);
7718   _time_steps=newTS;
7719 }
7720
7721 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7722 {
7723   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7724   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7725   if(nbOfEntriesToKill==0)
7726     return ;
7727   std::size_t sz=_time_steps.size();
7728   std::vector<bool> b(sz,true);
7729   int j=bg;
7730   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7731     b[j]=false;
7732   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7733   for(std::size_t i=0;i<sz;i++)
7734     if(b[i])
7735       newTS.push_back(_time_steps[i]);
7736   _time_steps=newTS;
7737 }
7738
7739 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7740 {
7741   int ret=0;
7742   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7743   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7744     {
7745       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7746       if(tmp)
7747         {
7748           int it2,ord;
7749           tmp->getTime(it2,ord);
7750           if(it2==iteration && order==ord)
7751             return ret;
7752           else
7753             oss << "(" << it2 << ","  << ord << "), ";
7754         }
7755     }
7756   throw INTERP_KERNEL::Exception(oss.str());
7757 }
7758
7759 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7760 {
7761   int ret=0;
7762   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7763   oss.precision(15);
7764   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7765     {
7766       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7767       if(tmp)
7768         {
7769           int it2,ord;
7770           double ti=tmp->getTime(it2,ord);
7771           if(fabs(time-ti)<eps)
7772             return ret;
7773           else
7774             oss << ti << ", ";
7775         }
7776     }
7777   throw INTERP_KERNEL::Exception(oss.str());
7778 }
7779
7780 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7781 {
7782   int lgth=_time_steps.size();
7783   std::vector< std::pair<int,int> > ret(lgth);
7784   for(int i=0;i<lgth;i++)
7785     _time_steps[i]->fillIteration(ret[i]);
7786   return ret;
7787 }
7788
7789 /*!
7790  * 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'
7791  * This method returns two things.
7792  * - The absolute dimension of 'this' in first parameter. 
7793  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7794  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7795  *
7796  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7797  * Only these 3 discretizations will be taken into account here.
7798  *
7799  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7800  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7801  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7802  *
7803  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7804  * 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'.
7805  * 
7806  * Let's consider the typical following case :
7807  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7808  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7809  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7810  *   TETRA4 and SEG2
7811  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7812  *
7813  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7814  * 
7815  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7816  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7817  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7818  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7819  */
7820 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7821 {
7822   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7823 }
7824
7825 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7826 {
7827   if(pos<0 || pos>=(int)_time_steps.size())
7828     {
7829       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7830       throw INTERP_KERNEL::Exception(oss.str());
7831     }
7832   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7833   if(item==0)
7834     {
7835       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7836       oss << "\nTry to use following method eraseEmptyTS !";
7837       throw INTERP_KERNEL::Exception(oss.str());
7838     }
7839   return item;
7840 }
7841
7842 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7843 {
7844   if(pos<0 || pos>=(int)_time_steps.size())
7845     {
7846       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7847       throw INTERP_KERNEL::Exception(oss.str());
7848     }
7849   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7850   if(item==0)
7851     {
7852       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7853       oss << "\nTry to use following method eraseEmptyTS !";
7854       throw INTERP_KERNEL::Exception(oss.str());
7855     }
7856   return item;
7857 }
7858
7859 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7860 {
7861   std::vector<std::string> ret;
7862   std::set<std::string> ret2;
7863   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7864     {
7865       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7866       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7867         if(ret2.find(*it2)==ret2.end())
7868           {
7869             ret.push_back(*it2);
7870             ret2.insert(*it2);
7871           }
7872     }
7873   return ret;
7874 }
7875
7876 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7877 {
7878   std::vector<std::string> ret;
7879   std::set<std::string> ret2;
7880   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7881     {
7882       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7883       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7884         if(ret2.find(*it2)==ret2.end())
7885           {
7886             ret.push_back(*it2);
7887             ret2.insert(*it2);
7888           }
7889     }
7890   return ret;
7891 }
7892
7893 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7894 {
7895   std::vector<std::string> ret;
7896   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7897     {
7898       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7899       ret.insert(ret.end(),tmp.begin(),tmp.end());
7900     }
7901   return ret;
7902 }
7903
7904 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7905 {
7906   std::vector<std::string> ret;
7907   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7908     {
7909       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7910       ret.insert(ret.end(),tmp.begin(),tmp.end());
7911     }
7912   return ret;
7913 }
7914
7915 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7916 {
7917   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7918     (*it)->changePflsRefsNamesGen2(mapOfModif);
7919 }
7920
7921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7922 {
7923   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7924     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7925 }
7926
7927 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7928 {
7929   int lgth=_time_steps.size();
7930   std::vector< std::vector<TypeOfField> > ret(lgth);
7931   for(int i=0;i<lgth;i++)
7932     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7933   return ret;
7934 }
7935
7936 /*!
7937  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7938  */
7939 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
7940 {
7941   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7942 }
7943
7944 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7945 {
7946   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7947   std::size_t i=0;
7948   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7949     {
7950       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7951         ret->_time_steps[i]=(*it)->deepCopy();
7952     }
7953   return ret.retn();
7954 }
7955
7956 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7957 {
7958   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7959   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7960   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7961   for(std::size_t i=0;i<sz;i++)
7962     {
7963       ret[i]=shallowCpy();
7964       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7965     }
7966   for(std::size_t i=0;i<sz2;i++)
7967     {
7968       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7969       if(ret1.size()!=sz)
7970         {
7971           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7972           throw INTERP_KERNEL::Exception(oss.str());
7973         }
7974       ts[i]=ret1;
7975     }
7976   for(std::size_t i=0;i<sz;i++)
7977     for(std::size_t j=0;j<sz2;j++)
7978       ret[i]->_time_steps[j]=ts[j][i];
7979   return ret;
7980 }
7981
7982 /*!
7983  * This method splits into discretization each time steps in \a this.
7984  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7985  */
7986 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7987 {
7988   std::size_t sz(_time_steps.size());
7989   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7990   for(std::size_t i=0;i<sz;i++)
7991     {
7992       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7993       if(!timeStep)
7994         {
7995           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7996           throw INTERP_KERNEL::Exception(oss.str());
7997         }
7998       items[i]=timeStep->splitDiscretizations();  
7999     }
8000   //
8001   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8002   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8003   std::vector< TypeOfField > types;
8004   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8005     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8006       {
8007         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8008         if(ts.size()!=1)
8009           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8010         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8011         if(it2==types.end())
8012           types.push_back(ts[0]);
8013       }
8014   ret.resize(types.size()); ret2.resize(types.size());
8015   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8016     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8017       {
8018         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8019         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8020         ret2[pos].push_back(*it1);
8021       }
8022   for(std::size_t i=0;i<types.size();i++)
8023     {
8024       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8025       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8026         elt->pushBackTimeStep(*it1);//also updates infos in elt
8027       ret[i]=elt;
8028       elt->MEDFileFieldNameScope::operator=(*this);
8029     }
8030   return ret;
8031 }
8032
8033 /*!
8034  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8035  */
8036 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8037 {
8038   std::size_t sz(_time_steps.size());
8039   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8040   std::size_t szOut(std::numeric_limits<std::size_t>::max());
8041   for(std::size_t i=0;i<sz;i++)
8042     {
8043       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8044       if(!timeStep)
8045         {
8046           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8047           throw INTERP_KERNEL::Exception(oss.str());
8048         }
8049       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8050       if(szOut==std::numeric_limits<std::size_t>::max())
8051         szOut=items[i].size();
8052       else
8053         if(items[i].size()!=szOut)
8054           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8055     }
8056   if(szOut==std::numeric_limits<std::size_t>::max())
8057     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8058   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8059   for(std::size_t i=0;i<szOut;i++)
8060     {
8061       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8062       for(std::size_t j=0;j<sz;j++)
8063         elt->pushBackTimeStep(items[j][i]);
8064       ret[i]=elt;
8065       elt->MEDFileFieldNameScope::operator=(*this);
8066     }
8067   return ret;
8068 }
8069
8070 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8071 {
8072   _name=field->getName();
8073   if(_name.empty())
8074     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8075   if(!arr)
8076     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8077   _infos=arr->getInfoOnComponents();
8078 }
8079
8080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8081 {
8082   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8083   if(_name!=field->getName())
8084     {
8085       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8086       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8087       throw INTERP_KERNEL::Exception(oss.str());
8088     }
8089   if(!arr)
8090     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8091   checkThatComponentsMatch(arr->getInfoOnComponents());
8092 }
8093
8094 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8095 {
8096   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8097   if(getInfo().size()!=compos.size())
8098     {
8099       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8100       oss << " number of components of element to append (" << compos.size() << ") !";
8101       throw INTERP_KERNEL::Exception(oss.str());
8102     }
8103   if(_infos!=compos)
8104     {
8105       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8106       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8107       oss << " But compo in input fields are : ";
8108       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8109       oss << " !";
8110       throw INTERP_KERNEL::Exception(oss.str());
8111     }
8112 }
8113
8114 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8115 {
8116   std::size_t sz=_infos.size();
8117   int j=0;
8118   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8119     {
8120       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8121       if(elt)
8122         if(elt->getInfo().size()!=sz)
8123           {
8124             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8125             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8126             throw INTERP_KERNEL::Exception(oss.str());
8127           }
8128     }
8129 }
8130
8131 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8132 {
8133   if(!field)
8134     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8135   if(!_time_steps.empty())
8136     checkCoherencyOfTinyInfo(field,arr);
8137   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8138   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8139   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8140   copyTinyInfoFrom(field,arr);
8141   _time_steps.push_back(obj);
8142 }
8143
8144 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8145 {
8146   if(!field)
8147     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8148   if(!_time_steps.empty())
8149     checkCoherencyOfTinyInfo(field,arr);
8150   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8151   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8152   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8153   copyTinyInfoFrom(field,arr);
8154   _time_steps.push_back(obj);
8155 }
8156
8157 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8158 {
8159   int sz=(int)_time_steps.size();
8160   if(i<0 || i>=sz)
8161     {
8162       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8163       throw INTERP_KERNEL::Exception(oss.str());
8164     }
8165   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8166   if(tsPtr)
8167     {
8168       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8169         {
8170           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8171           throw INTERP_KERNEL::Exception(oss.str());
8172         }
8173     }
8174   _time_steps[i]=ts;
8175 }
8176
8177 //= MEDFileFieldMultiTSWithoutSDA
8178
8179 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)
8180 {
8181   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8182 }
8183
8184 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8185 {
8186 }
8187
8188 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8189 {
8190 }
8191
8192 /*!
8193  * \param [in] fieldId field id in C mode
8194  */
8195 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8196 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8197 {
8198 }
8199 catch(INTERP_KERNEL::Exception& e)
8200 { throw e; }
8201
8202 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)
8203 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8204 {
8205 }
8206 catch(INTERP_KERNEL::Exception& e)
8207 { throw e; }
8208
8209 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8210 {
8211   return new MEDFileField1TSWithoutSDA;
8212 }
8213
8214 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8215 {
8216   if(!f1ts)
8217     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8218   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8219   if(!f1tsC)
8220     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8221 }
8222
8223 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8224 {
8225   return MEDFileField1TSWithoutSDA::TYPE_STR;
8226 }
8227
8228 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8229 {
8230   return new MEDFileFieldMultiTSWithoutSDA(*this);
8231 }
8232
8233 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8234 {
8235   return new MEDFileFieldMultiTSWithoutSDA;
8236 }
8237
8238 /*!
8239  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8240  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8241  */
8242 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
8243 {
8244   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8245   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8246   if(!myF1TSC)
8247     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8248   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8249 }
8250
8251 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8252 {
8253   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8254   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8255   int i=0;
8256   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8257     {
8258       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8259       if(eltToConv)
8260         {
8261           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8262           if(!eltToConvC)
8263             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8264           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8265           ret->setIteration(i,elt);
8266         }
8267     }
8268   return ret.retn();
8269 }
8270
8271 //= MEDFileAnyTypeFieldMultiTS
8272
8273 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8274 {
8275 }
8276
8277 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8278 try:MEDFileFieldGlobsReal(fid)
8279 {
8280   _content=BuildContentFrom(fid,loadAll,ms);
8281   loadGlobals(fid);
8282 }
8283 catch(INTERP_KERNEL::Exception& e)
8284 {
8285     throw e;
8286 }
8287
8288 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8289 {
8290   med_field_type typcha;
8291   std::vector<std::string> infos;
8292   std::string dtunit;
8293   int i(-1);
8294   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8295   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8296   switch(typcha)
8297   {
8298     case MED_FLOAT64:
8299       {
8300         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8301         break;
8302       }
8303     case MED_INT32:
8304       {
8305         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8306         break;
8307       }
8308     default:
8309       {
8310         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] !";
8311         throw INTERP_KERNEL::Exception(oss.str());
8312       }
8313   }
8314   ret->setDtUnit(dtunit.c_str());
8315   return ret.retn();
8316 }
8317
8318 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8319 {
8320   med_field_type typcha;
8321   //
8322   std::vector<std::string> infos;
8323   std::string dtunit,fieldName;
8324   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8325   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8326   switch(typcha)
8327   {
8328     case MED_FLOAT64:
8329       {
8330         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8331         break;
8332       }
8333     case MED_INT32:
8334       {
8335         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8336         break;
8337       }
8338     default:
8339       {
8340         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] !";
8341         throw INTERP_KERNEL::Exception(oss.str());
8342       }
8343   }
8344   ret->setDtUnit(dtunit.c_str());
8345   return ret.retn();
8346 }
8347
8348 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8349 {
8350   if(!c)
8351     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8352   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8353     {
8354       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8355       ret->_content=c;  c->incrRef();
8356       return ret.retn();
8357     }
8358   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8359     {
8360       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8361       ret->_content=c;  c->incrRef();
8362       return ret.retn();
8363     }
8364   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8365 }
8366
8367 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8368 {
8369   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8370   std::string fileName(FileNameFromFID(fid));
8371   ret->setFileName(fileName);
8372   return ret;
8373 }
8374
8375 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8376 try:MEDFileFieldGlobsReal(fid)
8377 {
8378   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8379   loadGlobals(fid);
8380 }
8381 catch(INTERP_KERNEL::Exception& e)
8382 {
8383     throw e;
8384 }
8385
8386 //= MEDFileIntFieldMultiTSWithoutSDA
8387
8388 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)
8389 {
8390   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8391 }
8392
8393 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8394 {
8395 }
8396
8397 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8398 {
8399 }
8400
8401 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)
8402 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8403 {
8404 }
8405 catch(INTERP_KERNEL::Exception& e)
8406 { throw e; }
8407
8408 /*!
8409  * \param [in] fieldId field id in C mode
8410  */
8411 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8412 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8413 {
8414 }
8415 catch(INTERP_KERNEL::Exception& e)
8416 { throw e; }
8417
8418 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8419 {
8420   return new MEDFileIntField1TSWithoutSDA;
8421 }
8422
8423 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8424 {
8425   if(!f1ts)
8426     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8427   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8428   if(!f1tsC)
8429     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8430 }
8431
8432 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8433 {
8434   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8435 }
8436
8437 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8438 {
8439   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8440 }
8441
8442 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8443 {
8444   return new MEDFileIntFieldMultiTSWithoutSDA;
8445 }
8446
8447 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8448 {
8449   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8450   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8451   int i=0;
8452   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8453     {
8454       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8455       if(eltToConv)
8456         {
8457           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8458           if(!eltToConvC)
8459             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8460           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8461           ret->setIteration(i,elt);
8462         }
8463     }
8464   return ret.retn();
8465 }
8466
8467 //= MEDFileAnyTypeFieldMultiTS
8468
8469 /*!
8470  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8471  * that has been read from a specified MED file.
8472  *  \param [in] fileName - the name of the MED file to read.
8473  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8474  *          is to delete this field using decrRef() as it is no more needed.
8475  *  \throw If reading the file fails.
8476  */
8477 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8478 {
8479   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8480   return New(fid,loadAll);
8481 }
8482
8483 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8484 {
8485   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8486   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8487   ret->loadGlobals(fid);
8488   return ret.retn();
8489 }
8490
8491 /*!
8492  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8493  * that has been read from a specified MED file.
8494  *  \param [in] fileName - the name of the MED file to read.
8495  *  \param [in] fieldName - the name of the field to read.
8496  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8497  *          is to delete this field using decrRef() as it is no more needed.
8498  *  \throw If reading the file fails.
8499  *  \throw If there is no field named \a fieldName in the file.
8500  */
8501 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8502 {
8503   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8504   return New(fid,fieldName,loadAll);
8505 }
8506
8507 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8508 {
8509   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8510   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8511   ret->loadGlobals(fid);
8512   return ret.retn();
8513 }
8514
8515 /*!
8516  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8517  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8518  *
8519  * \warning this is a shallow copy constructor
8520  */
8521 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8522 {
8523   if(!shallowCopyOfContent)
8524     {
8525       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8526       otherPtr->incrRef();
8527       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8528     }
8529   else
8530     {
8531       _content=other.shallowCpy();
8532     }
8533 }
8534
8535 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8536 {
8537   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8538   if(!ret)
8539     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8540   return ret;
8541 }
8542
8543 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8544 {
8545   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8546   if(!ret)
8547     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8548   return ret;
8549 }
8550
8551 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8552 {
8553   return contentNotNullBase()->getPflsReallyUsed2();
8554 }
8555
8556 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8557 {
8558   return contentNotNullBase()->getLocsReallyUsed2();
8559 }
8560
8561 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8562 {
8563   return contentNotNullBase()->getPflsReallyUsedMulti2();
8564 }
8565
8566 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8567 {
8568   return contentNotNullBase()->getLocsReallyUsedMulti2();
8569 }
8570
8571 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8572 {
8573   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8574 }
8575
8576 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8577 {
8578   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8579 }
8580
8581 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8582 {
8583   return contentNotNullBase()->getNumberOfTS();
8584 }
8585
8586 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8587 {
8588   contentNotNullBase()->eraseEmptyTS();
8589 }
8590
8591 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8592 {
8593   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8594 }
8595
8596 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8597 {
8598   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8599 }
8600
8601 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8602 {
8603   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8604   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8605   ret->_content=c;
8606   return ret.retn();
8607 }
8608
8609 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8610 {
8611   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8612   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8613   ret->_content=c;
8614   return ret.retn();
8615 }
8616
8617 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8618 {
8619   return contentNotNullBase()->getIterations();
8620 }
8621
8622 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8623 {
8624   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8625     pushBackTimeStep(*it);
8626 }
8627
8628 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8629 {
8630   if(!fmts)
8631     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8632   int nbOfTS(fmts->getNumberOfTS());
8633   for(int i=0;i<nbOfTS;i++)
8634     {
8635       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8636       pushBackTimeStep(elt);
8637     }
8638 }
8639
8640 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8641 {
8642   if(!f1ts)
8643     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8644   checkCoherencyOfType(f1ts);
8645   f1ts->incrRef();
8646   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8647   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8648   c->incrRef();
8649   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8650   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8651     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8652   _content->pushBackTimeStep(cSafe);
8653   appendGlobs(*f1ts,1e-12);
8654 }
8655
8656 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8657 {
8658   contentNotNullBase()->synchronizeNameScope();
8659 }
8660
8661 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8662 {
8663   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8664 }
8665
8666 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8667 {
8668   return contentNotNullBase()->getPosGivenTime(time,eps);
8669 }
8670
8671 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8672 {
8673   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8674 }
8675
8676 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8677 {
8678   return contentNotNullBase()->getTypesOfFieldAvailable();
8679 }
8680
8681 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
8682 {
8683   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8684 }
8685
8686 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8687 {
8688   return contentNotNullBase()->getName();
8689 }
8690
8691 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8692 {
8693   contentNotNullBase()->setName(name);
8694 }
8695
8696 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8697 {
8698   return contentNotNullBase()->getDtUnit();
8699 }
8700
8701 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8702 {
8703   contentNotNullBase()->setDtUnit(dtUnit);
8704 }
8705
8706 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8707 {
8708   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8709 }
8710
8711 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8712 {
8713   return contentNotNullBase()->getTimeSteps(ret1);
8714 }
8715
8716 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8717 {
8718   return contentNotNullBase()->getMeshName();
8719 }
8720
8721 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8722 {
8723   contentNotNullBase()->setMeshName(newMeshName);
8724 }
8725
8726 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8727 {
8728   return contentNotNullBase()->changeMeshNames(modifTab);
8729 }
8730
8731 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8732 {
8733   return contentNotNullBase()->getInfo();
8734 }
8735
8736 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8737 {
8738   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8739 }
8740
8741 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8742 {
8743   return contentNotNullBase()->setInfo(info);
8744 }
8745
8746 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8747 {
8748   const std::vector<std::string> ret=getInfo();
8749   return (int)ret.size();
8750 }
8751
8752 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8753 {
8754   writeGlobals(fid,*this);
8755   contentNotNullBase()->writeLL(fid,*this);
8756 }
8757
8758 /*!
8759  * This method alloc the arrays and load potentially huge arrays contained in this field.
8760  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8761  * This method can be also called to refresh or reinit values from a file.
8762  * 
8763  * \throw If the fileName is not set or points to a non readable MED file.
8764  */
8765 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8766 {
8767   if(getFileName().empty())
8768     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8769   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8770   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8771 }
8772
8773 /*!
8774  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8775  * But once data loaded once, this method does nothing.
8776  * 
8777  * \throw If the fileName is not set or points to a non readable MED file.
8778  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8779  */
8780 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8781 {
8782   if(!getFileName().empty())
8783     {
8784       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
8785       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8786     }
8787 }
8788
8789 /*!
8790  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8791  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8792  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8793  * 
8794  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8795  */
8796 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8797 {
8798   contentNotNullBase()->unloadArrays();
8799 }
8800
8801 /*!
8802  * 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.
8803  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8804  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8805  * 
8806  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8807  */
8808 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8809 {
8810   if(!getFileName().empty())
8811     contentNotNullBase()->unloadArrays();
8812 }
8813
8814 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8815 {
8816   std::ostringstream oss;
8817   contentNotNullBase()->simpleRepr(0,oss,-1);
8818   simpleReprGlobs(oss);
8819   return oss.str();
8820 }
8821
8822 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8823 {
8824   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8825 }
8826
8827 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8828 {
8829   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8830   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8831   return ret;
8832 }
8833
8834 /*!
8835  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8836  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8837  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8838  */
8839 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8840 {
8841   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8842   if(!content)
8843     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8844   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8845   std::size_t sz(contentsSplit.size());
8846   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8847   for(std::size_t i=0;i<sz;i++)
8848     {
8849       ret[i]=shallowCpy();
8850       ret[i]->_content=contentsSplit[i];
8851     }
8852   return ret;
8853 }
8854
8855 /*!
8856  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8857  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8858  */
8859 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8860 {
8861   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8862   if(!content)
8863     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8864   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8865   std::size_t sz(contentsSplit.size());
8866   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8867   for(std::size_t i=0;i<sz;i++)
8868     {
8869       ret[i]=shallowCpy();
8870       ret[i]->_content=contentsSplit[i];
8871     }
8872   return ret;
8873 }
8874
8875 /*!
8876  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8877  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8878  */
8879 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8880 {
8881   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8882   if(!content)
8883     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8884   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8885   std::size_t sz(contentsSplit.size());
8886   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8887   for(std::size_t i=0;i<sz;i++)
8888     {
8889       ret[i]=shallowCpy();
8890       ret[i]->_content=contentsSplit[i];
8891     }
8892   return ret;
8893 }
8894
8895 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8896 {
8897   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8898   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8899     ret->_content=_content->deepCopy();
8900   ret->deepCpyGlobs(*this);
8901   return ret.retn();
8902 }
8903
8904 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8905 {
8906   return _content;
8907 }
8908
8909 /*!
8910  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8911  *  \param [in] iteration - the iteration number of a required time step.
8912  *  \param [in] order - the iteration order number of required time step.
8913  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8914  *          delete this field using decrRef() as it is no more needed.
8915  *  \throw If there is no required time step in \a this field.
8916  */
8917 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8918 {
8919   int pos=getPosOfTimeStep(iteration,order);
8920   return getTimeStepAtPos(pos);
8921 }
8922
8923 /*!
8924  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8925  *  \param [in] time - the time of the time step of interest.
8926  *  \param [in] eps - a precision used to compare time values.
8927  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8928  *          delete this field using decrRef() as it is no more needed.
8929  *  \throw If there is no required time step in \a this field.
8930  */
8931 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8932 {
8933   int pos=getPosGivenTime(time,eps);
8934   return getTimeStepAtPos(pos);
8935 }
8936
8937 /*!
8938  * 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.
8939  * The float64 value of time attached to the pair of integers are not considered here.
8940  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8941  *
8942  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8943  * \throw If there is a null pointer in \a vectFMTS.
8944  */
8945 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8946 {
8947   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8948   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8949   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8950   while(!lstFMTS.empty())
8951     {
8952       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8953       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8954       if(!curIt)
8955         throw INTERP_KERNEL::Exception(msg);
8956       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8957       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8958       elt.push_back(curIt); it=lstFMTS.erase(it);
8959       while(it!=lstFMTS.end())
8960         {
8961           curIt=*it;
8962           if(!curIt)
8963             throw INTERP_KERNEL::Exception(msg);
8964           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8965           if(refIts==curIts)
8966             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8967           else
8968             it++;
8969         }
8970       ret.push_back(elt);
8971     }
8972   return ret;
8973 }
8974
8975 /*!
8976  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8977  * All returned instances in a subvector can be safely loaded, rendered along time
8978  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8979  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8980  * 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).
8981  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8982  * 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.
8983  *
8984  * \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().
8985  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8986  * \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.
8987  * \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.
8988  *
8989  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8990  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8991  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8992  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8993  * \throw If mesh is null.
8994  * \throw If an element in \a vectFMTS is null.
8995  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8996  */
8997 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8998 {
8999   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9000   if(!mesh)
9001     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9002   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9003   if(vectFMTS.empty())
9004     return ret;
9005   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9006   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9007   if(!frstElt)
9008     throw INTERP_KERNEL::Exception(msg);
9009   std::size_t i=0;
9010   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9011   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9012   for(;it!=vectFMTS.end();it++,i++)
9013     {
9014       if(!(*it))
9015         throw INTERP_KERNEL::Exception(msg);
9016       TypeOfField tof0,tof1;
9017       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9018         {
9019           if(tof1!=ON_NODES)
9020             vectFMTSNotNodes.push_back(*it);
9021           else
9022             vectFMTSNodes.push_back(*it);
9023         }
9024       else
9025         vectFMTSNotNodes.push_back(*it);
9026     }
9027   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9028   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9029   ret=retCell;
9030   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9031     {
9032       i=0;
9033       bool isFetched(false);
9034       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9035         {
9036           if((*it0).empty())
9037             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9038           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9039             { ret[i].push_back(*it2); isFetched=true; }
9040         }
9041       if(!isFetched)
9042         {
9043           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9044           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9045           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9046         }
9047     }
9048   fsc=cmps;
9049   return ret;
9050 }
9051
9052 /*!
9053  * 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.
9054  * \param [out] cmps - same size than the returned vector.
9055  */
9056 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9057 {
9058   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9059   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9060   while(!lstFMTS.empty())
9061     {
9062       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9063       MEDFileAnyTypeFieldMultiTS *ref(*it);
9064       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9065       elt.push_back(ref); it=lstFMTS.erase(it);
9066       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9067       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9068       while(it!=lstFMTS.end())
9069         {
9070           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9071           if(cmp->isEqual(curIt))
9072             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9073           else
9074             it++;
9075         }
9076       ret.push_back(elt); cmps.push_back(cmp);
9077     }
9078   return ret;
9079 }
9080
9081 /*!
9082  * 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.
9083  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9084  *
9085  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9086  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9087  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9088  * \thorw If \a f0 and \a f1 do not have the same times steps.
9089  * \throw If mesh is null.
9090  * \throw If \a f0 or \a f1 is null.
9091  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9092  */
9093 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9094 {
9095   if(!mesh)
9096     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9097   if(!f0 || !f1)
9098     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9099   if(f0->getMeshName()!=mesh->getName())
9100     {
9101       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9102       throw INTERP_KERNEL::Exception(oss.str());
9103     }
9104   if(f1->getMeshName()!=mesh->getName())
9105     {
9106       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9107       throw INTERP_KERNEL::Exception(oss.str());
9108     }
9109   int nts=f0->getNumberOfTS();
9110   if(nts!=f1->getNumberOfTS())
9111     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9112   if(nts==0)
9113     return nts;
9114   for(int i=0;i<nts;i++)
9115     {
9116       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9117       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9118       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9119       if(tofs0.size()!=1 || tofs1.size()!=1)
9120         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9121       if(i!=0)
9122         {
9123           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9124             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9125         }
9126       else
9127         { tof0=tofs0[0]; tof1=tofs1[0]; }
9128       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9129         {
9130           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() << ") !";
9131           throw INTERP_KERNEL::Exception(oss.str());
9132         }
9133       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9134         {
9135           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() << ") !";
9136           throw INTERP_KERNEL::Exception(oss.str());
9137         }
9138       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9139         {
9140           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() << ") !";
9141           throw INTERP_KERNEL::Exception(oss.str());
9142         }
9143     }
9144   return nts;
9145 }
9146
9147 /*!
9148  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9149  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9150  *
9151  * \return A new object that the caller is responsible to deallocate.
9152  */
9153 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9154 {
9155   if(!mm)
9156     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9157   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9158   int nbTS(getNumberOfTS());
9159   for(int i=0;i<nbTS;i++)
9160     {
9161       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9162       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9163       fmtsOut->pushBackTimeStep(f1tsOut);
9164     }
9165   return fmtsOut.retn();
9166 }
9167
9168 template<class T>
9169 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9170 {
9171   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9172   if(f1tss.empty())
9173     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9174   std::size_t sz(f1tss.size()),i(0);
9175   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9176   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9177     {
9178       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9179       if(!elt)
9180         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9181       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9182     }
9183   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9184   if(!retc)
9185     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9186   retc->aggregate(f1tsw,dts);
9187   ret->setDtUnit(f1tss[0]->getDtUnit());
9188   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9189 }
9190
9191 template<class T>
9192 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9193 {
9194   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9195   if(fmtss.empty())
9196     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9197   std::size_t sz(fmtss.size());
9198   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9199     {
9200       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9201       if(!elt)
9202         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9203     }
9204   int nbTS(fmtss[0]->getNumberOfTS());
9205   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9206     if((*it)->getNumberOfTS()!=nbTS)
9207       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9208   for(int iterTS=0;iterTS<nbTS;iterTS++)
9209     {
9210       std::size_t i(0);
9211       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9212       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9213       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9214         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9215       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9216       ret->pushBackTimeStep(f1ts);
9217       ret->setDtUnit(f1ts->getDtUnit());
9218     }
9219   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9220 }
9221
9222 /*!
9223  * \a dts and \a ftmss are expected to have same size.
9224  */
9225 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9226 {
9227   if(fmtss.empty())
9228     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9229   std::size_t sz(fmtss.size());
9230   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9231   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9232   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9233     {
9234       if(!(*it))
9235         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9236       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9237       if(elt1)
9238         {
9239           fmtss1.push_back(elt1);
9240           continue;
9241         }
9242       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9243       if(elt2)
9244         {
9245           fmtss2.push_back(elt2);
9246           continue;
9247         }
9248       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9249     }
9250   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9251     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9252   if(fmtss1.size()==sz)
9253     return AggregateHelperFMTS<double>(fmtss1,dts);
9254   if(fmtss2.size()!=sz)
9255     return AggregateHelperFMTS<int>(fmtss2,dts);
9256   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9257 }
9258
9259 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9260 {
9261   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9262 }
9263
9264 //= MEDFileFieldMultiTS
9265
9266 /*!
9267  * Returns a new empty instance of MEDFileFieldMultiTS.
9268  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9269  *          is to delete this field using decrRef() as it is no more needed.
9270  */
9271 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9272 {
9273   return new MEDFileFieldMultiTS;
9274 }
9275
9276 /*!
9277  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9278  * that has been read from a specified MED file.
9279  *  \param [in] fileName - the name of the MED file to read.
9280  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9281  *          is to delete this field using decrRef() as it is no more needed.
9282  *  \throw If reading the file fails.
9283  */
9284 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9285 {
9286   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9287   return New(fid,loadAll);
9288 }
9289
9290 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9291 {
9292   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9293   ret->contentNotNull();//to check that content type matches with \a this type.
9294   return ret.retn();
9295 }
9296
9297 /*!
9298  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9299  * that has been read from a specified MED file.
9300  *  \param [in] fileName - the name of the MED file to read.
9301  *  \param [in] fieldName - the name of the field to read.
9302  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9303  *          is to delete this field using decrRef() as it is no more needed.
9304  *  \throw If reading the file fails.
9305  *  \throw If there is no field named \a fieldName in the file.
9306  */
9307 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9308 {
9309   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9310   return New(fid,fieldName,loadAll);
9311 }
9312
9313 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9314 {
9315   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9316   ret->contentNotNull();//to check that content type matches with \a this type.
9317   return ret.retn();
9318 }
9319
9320 /*!
9321  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9322  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9323  *
9324  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9325  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9326  * \warning this is a shallow copy constructor
9327  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9328  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9329  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9330  *          is to delete this field using decrRef() as it is no more needed.
9331  */
9332 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9333 {
9334   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9335 }
9336
9337 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9338 {
9339   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9340   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9341   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9342   ret->contentNotNull();//to check that content type matches with \a this type.
9343   return ret.retn();
9344 }
9345
9346 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9347 {
9348   return new MEDFileFieldMultiTS(*this);
9349 }
9350
9351 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9352 {
9353   if(!f1ts)
9354     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9355   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9356   if(!f1tsC)
9357     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9358 }
9359
9360 /*!
9361  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9362  * following the given input policy.
9363  *
9364  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9365  *                            By default (true) the globals are deeply copied.
9366  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9367  */
9368 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9369 {
9370   MCAuto<MEDFileIntFieldMultiTS> ret;
9371   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9372   if(content)
9373     {
9374       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9375       if(!contc)
9376         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9377       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9378       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9379     }
9380   else
9381     ret=MEDFileIntFieldMultiTS::New();
9382   if(isDeepCpyGlobs)
9383     ret->deepCpyGlobs(*this);
9384   else
9385     ret->shallowCpyGlobs(*this);
9386   return ret.retn();
9387 }
9388
9389 /*!
9390  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9391  *  \param [in] pos - a time step id.
9392  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9393  *          delete this field using decrRef() as it is no more needed.
9394  *  \throw If \a pos is not a valid time step id.
9395  */
9396 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9397 {
9398   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9399   if(!item)
9400     {
9401       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9402       throw INTERP_KERNEL::Exception(oss.str());
9403     }
9404   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9405   if(itemC)
9406     {
9407       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9408       ret->shallowCpyGlobs(*this);
9409       return ret.retn();
9410     }
9411   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9412   throw INTERP_KERNEL::Exception(oss.str());
9413 }
9414
9415 /*!
9416  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9417  * mesh entities of a given dimension of the first mesh in MED file.
9418  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9419  *  \param [in] type - a spatial discretization of interest.
9420  *  \param [in] iteration - the iteration number of a required time step.
9421  *  \param [in] order - the iteration order number of required time step.
9422  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9423  *  \param [in] renumPol - specifies how to permute values of the result field according to
9424  *          the optional numbers of cells and nodes, if any. The valid values are
9425  *          - 0 - do not permute.
9426  *          - 1 - permute cells.
9427  *          - 2 - permute nodes.
9428  *          - 3 - permute cells and nodes.
9429  *
9430  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9431  *          caller is to delete this field using decrRef() as it is no more needed. 
9432  *  \throw If the MED file is not readable.
9433  *  \throw If there is no mesh in the MED file.
9434  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9435  *  \throw If no field values of the required parameters are available.
9436  */
9437 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9438 {
9439   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9440   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9441   if(!myF1TSC)
9442     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9443   MCAuto<DataArray> arrOut;
9444   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9445   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9446   return ret.retn();
9447 }
9448
9449 /*!
9450  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9451  * the top level cells of the first mesh in MED file.
9452  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9453  *  \param [in] type - a spatial discretization of interest.
9454  *  \param [in] iteration - the iteration number of a required time step.
9455  *  \param [in] order - the iteration order number of required time step.
9456  *  \param [in] renumPol - specifies how to permute values of the result field according to
9457  *          the optional numbers of cells and nodes, if any. The valid values are
9458  *          - 0 - do not permute.
9459  *          - 1 - permute cells.
9460  *          - 2 - permute nodes.
9461  *          - 3 - permute cells and nodes.
9462  *
9463  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9464  *          caller is to delete this field using decrRef() as it is no more needed. 
9465  *  \throw If the MED file is not readable.
9466  *  \throw If there is no mesh in the MED file.
9467  *  \throw If no field values of the required parameters are available.
9468  */
9469 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9470 {
9471   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9472   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9473   if(!myF1TSC)
9474     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9475   MCAuto<DataArray> arrOut;
9476   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9477   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9478   return ret.retn();
9479 }
9480
9481 /*!
9482  * 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
9483  * method should be called (getFieldOnMeshAtLevel for example).
9484  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9485  *
9486  * \param [in] iteration - the iteration number of a required time step.
9487  * \param [in] order - the iteration order number of required time step.
9488  * \param [in] mesh - the mesh the field is lying on
9489  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9490  *          caller is to delete this field using decrRef() as it is no more needed. 
9491  */
9492 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9493 {
9494   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9495   MCAuto<DataArray> arrOut;
9496   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9497   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9498   return ret.retn();
9499 }
9500
9501 /*!
9502  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9503  * a given support.
9504  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9505  *  \param [in] type - a spatial discretization of interest.
9506  *  \param [in] iteration - the iteration number of a required time step.
9507  *  \param [in] order - the iteration order number of required time step.
9508  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9509  *  \param [in] mesh - the supporting mesh.
9510  *  \param [in] renumPol - specifies how to permute values of the result field according to
9511  *          the optional numbers of cells and nodes, if any. The valid values are
9512  *          - 0 - do not permute.
9513  *          - 1 - permute cells.
9514  *          - 2 - permute nodes.
9515  *          - 3 - permute cells and nodes.
9516  *
9517  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9518  *          caller is to delete this field using decrRef() as it is no more needed. 
9519  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9520  *  \throw If no field of \a this is lying on \a mesh.
9521  *  \throw If no field values of the required parameters are available.
9522  */
9523 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9524 {
9525   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9526   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9527   if(!myF1TSC)
9528     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9529   MCAuto<DataArray> arrOut;
9530   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9531   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9532   return ret.retn();
9533 }
9534
9535 /*!
9536  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9537  * given support. 
9538  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9539  *  \param [in] type - a spatial discretization of the new field.
9540  *  \param [in] iteration - the iteration number of a required time step.
9541  *  \param [in] order - the iteration order number of required time step.
9542  *  \param [in] mesh - the supporting mesh.
9543  *  \param [in] renumPol - specifies how to permute values of the result field according to
9544  *          the optional numbers of cells and nodes, if any. The valid values are
9545  *          - 0 - do not permute.
9546  *          - 1 - permute cells.
9547  *          - 2 - permute nodes.
9548  *          - 3 - permute cells and nodes.
9549  *
9550  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9551  *          caller is to delete this field using decrRef() as it is no more needed. 
9552  *  \throw If no field of \a this is lying on \a mesh.
9553  *  \throw If no field values of the required parameters are available.
9554  */
9555 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9556 {
9557   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9558   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9559   if(!myF1TSC)
9560     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9561   MCAuto<DataArray> arrOut;
9562   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9563   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9564   return ret.retn();
9565 }
9566
9567 /*!
9568  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9569  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9570  * This method is useful for MED2 file format when field on different mesh was autorized.
9571  */
9572 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9573 {
9574   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9575   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9576   if(!myF1TSC)
9577     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9578   MCAuto<DataArray> arrOut;
9579   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9580   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9581   return ret.retn();
9582 }
9583
9584 /*!
9585  * Returns values and a profile of the field of a given type, of a given time step,
9586  * lying on a given support.
9587  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9588  *  \param [in] type - a spatial discretization of the field.
9589  *  \param [in] iteration - the iteration number of a required time step.
9590  *  \param [in] order - the iteration order number of required time step.
9591  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9592  *  \param [in] mesh - the supporting mesh.
9593  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9594  *          field of interest lies on. If the field lies on all entities of the given
9595  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9596  *          using decrRef() as it is no more needed.  
9597  *  \param [in] glob - the global data storing profiles and localization.
9598  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9599  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9600  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9601  *  \throw If no field of \a this is lying on \a mesh.
9602  *  \throw If no field values of the required parameters are available.
9603  */
9604 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9605 {
9606   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9607   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9608   if(!myF1TSC)
9609     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9610   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9611   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9612 }
9613
9614 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9615 {
9616   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9617   if(!pt)
9618     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9619   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9620   if(!ret)
9621     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 !");
9622   return ret;
9623 }
9624
9625 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9626 {
9627   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9628   if(!pt)
9629     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9630   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9631   if(!ret)
9632     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 !");
9633   return ret;
9634 }
9635
9636 /*!
9637  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9638  * the given field is checked if its elements are sorted suitable for writing to MED file
9639  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9640  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9641  *  \param [in] field - the field to add to \a this.
9642  *  \throw If the name of \a field is empty.
9643  *  \throw If the data array of \a field is not set.
9644  *  \throw If existing time steps have different name or number of components than \a field.
9645  *  \throw If the underlying mesh of \a field has no name.
9646  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9647  */
9648 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9649 {
9650   const DataArrayDouble *arr=0;
9651   if(field)
9652     arr=field->getArray();
9653   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9654 }
9655
9656 /*!
9657  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9658  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9659  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9660  * and \a profile.
9661  *
9662  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9663  * A new profile is added only if no equal profile is missing.
9664  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9665  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9666  *  \param [in] mesh - the supporting mesh of \a field.
9667  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9668  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9669  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9670  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9671  *  \throw If the data array of \a field is not set.
9672  *  \throw If the data array of \a this is already allocated but has different number of
9673  *         components than \a field.
9674  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9675  *  \sa setFieldNoProfileSBT()
9676  */
9677 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9678 {
9679   const DataArrayDouble *arr=0;
9680   if(field)
9681     arr=field->getArray();
9682   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9683 }
9684
9685 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9686 {
9687   _content=new MEDFileFieldMultiTSWithoutSDA;
9688 }
9689
9690 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9691 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9692 {
9693 }
9694 catch(INTERP_KERNEL::Exception& e)
9695 { throw e; }
9696
9697 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9698 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9699 {
9700 }
9701 catch(INTERP_KERNEL::Exception& e)
9702 { throw e; }
9703
9704 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9705 {
9706 }
9707
9708 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
9709 {
9710   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9711 }
9712
9713 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9714 {
9715   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9716 }
9717
9718 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9719 {
9720   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9721 }
9722
9723 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9724 {
9725   return MEDFileFieldMultiTS::New();
9726 }
9727
9728 //= MEDFileAnyTypeFieldMultiTSIterator
9729
9730 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9731 {
9732   if(fmts)
9733     {
9734       fmts->incrRef();
9735       _nb_iter=fmts->getNumberOfTS();
9736     }
9737 }
9738
9739 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9740 {
9741 }
9742
9743 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9744 {
9745   if(_iter_id<_nb_iter)
9746     {
9747       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9748       if(fmts)
9749         return fmts->getTimeStepAtPos(_iter_id++);
9750       else
9751         return 0;
9752     }
9753   else
9754     return 0;
9755 }
9756
9757 //= MEDFileIntFieldMultiTS
9758
9759 /*!
9760  * Returns a new empty instance of MEDFileFieldMultiTS.
9761  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9762  *          is to delete this field using decrRef() as it is no more needed.
9763  */
9764 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9765 {
9766   return new MEDFileIntFieldMultiTS;
9767 }
9768
9769 /*!
9770  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9771  * that has been read from a specified MED file.
9772  *  \param [in] fileName - the name of the MED file to read.
9773  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9774  *          is to delete this field using decrRef() as it is no more needed.
9775  *  \throw If reading the file fails.
9776  */
9777 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9778 {
9779   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9780   return New(fid,loadAll);
9781 }
9782
9783 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
9784 {
9785   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
9786   ret->contentNotNull();//to check that content type matches with \a this type.
9787   return ret.retn();
9788 }
9789
9790 /*!
9791  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9792  * that has been read from a specified MED file.
9793  *  \param [in] fileName - the name of the MED file to read.
9794  *  \param [in] fieldName - the name of the field to read.
9795  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9796  *          is to delete this field using decrRef() as it is no more needed.
9797  *  \throw If reading the file fails.
9798  *  \throw If there is no field named \a fieldName in the file.
9799  */
9800 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9801 {
9802   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9803   return New(fid,fieldName,loadAll);
9804 }
9805
9806 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9807 {
9808   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
9809   ret->contentNotNull();//to check that content type matches with \a this type.
9810   return ret.retn();
9811 }
9812
9813 /*!
9814  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9815  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9816  *
9817  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9818  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9819  * \warning this is a shallow copy constructor
9820  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9821  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9822  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9823  *          is to delete this field using decrRef() as it is no more needed.
9824  */
9825 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9826 {
9827   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9828 }
9829
9830 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9831 {
9832   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9833   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9834   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
9835   ret->contentNotNull();//to check that content type matches with \a this type.
9836   return ret.retn();
9837 }
9838
9839 /*!
9840  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9841  * following the given input policy.
9842  *
9843  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9844  *                            By default (true) the globals are deeply copied.
9845  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9846  */
9847 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9848 {
9849   MCAuto<MEDFileFieldMultiTS> ret;
9850   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9851   if(content)
9852     {
9853       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9854       if(!contc)
9855         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9856       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9857       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
9858     }
9859   else
9860     ret=MEDFileFieldMultiTS::New();
9861   if(isDeepCpyGlobs)
9862     ret->deepCpyGlobs(*this);
9863   else
9864     ret->shallowCpyGlobs(*this);
9865   return ret.retn();
9866 }
9867
9868 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9869 {
9870   return new MEDFileIntFieldMultiTS(*this);
9871 }
9872
9873 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9874 {
9875   if(!f1ts)
9876     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9877   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9878   if(!f1tsC)
9879     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9880 }
9881
9882 /*!
9883  * 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
9884  * method should be called (getFieldOnMeshAtLevel for example).
9885  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9886  *
9887  * \param [in] iteration - the iteration number of a required time step.
9888  * \param [in] order - the iteration order number of required time step.
9889  * \param [in] mesh - the mesh the field is lying on
9890  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9891  *          caller is to delete this field using decrRef() as it is no more needed. 
9892  */
9893 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9894 {
9895   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9896   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9897   if(!myF1TSC)
9898     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9899   MCAuto<DataArray> arrOut;
9900   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9901   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9902   return ret2.retn();
9903 }
9904
9905 /*!
9906  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9907  * mesh entities of a given dimension of the first mesh in MED file.
9908  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9909  *  \param [in] type - a spatial discretization of interest.
9910  *  \param [in] iteration - the iteration number of a required time step.
9911  *  \param [in] order - the iteration order number of required time step.
9912  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9913  *  \param [in] renumPol - specifies how to permute values of the result field according to
9914  *          the optional numbers of cells and nodes, if any. The valid values are
9915  *          - 0 - do not permute.
9916  *          - 1 - permute cells.
9917  *          - 2 - permute nodes.
9918  *          - 3 - permute cells and nodes.
9919  *
9920  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9921  *          caller is to delete this field using decrRef() as it is no more needed. 
9922  *  \throw If the MED file is not readable.
9923  *  \throw If there is no mesh in the MED file.
9924  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9925  *  \throw If no field values of the required parameters are available.
9926  */
9927 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9928 {
9929   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9930   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9931   if(!myF1TSC)
9932     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9933   MCAuto<DataArray> arr;
9934   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9935   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9936   return ret2.retn();
9937 }
9938
9939 /*!
9940  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9941  * the top level cells of the first mesh in MED file.
9942  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9943  *  \param [in] type - a spatial discretization of interest.
9944  *  \param [in] iteration - the iteration number of a required time step.
9945  *  \param [in] order - the iteration order number of required time step.
9946  *  \param [in] renumPol - specifies how to permute values of the result field according to
9947  *          the optional numbers of cells and nodes, if any. The valid values are
9948  *          - 0 - do not permute.
9949  *          - 1 - permute cells.
9950  *          - 2 - permute nodes.
9951  *          - 3 - permute cells and nodes.
9952  *
9953  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9954  *          caller is to delete this field using decrRef() as it is no more needed. 
9955  *  \throw If the MED file is not readable.
9956  *  \throw If there is no mesh in the MED file.
9957  *  \throw If no field values of the required parameters are available.
9958  */
9959 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9960 {
9961   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9962   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9963   if(!myF1TSC)
9964     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9965   MCAuto<DataArray> arr;
9966   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9967   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9968   return ret2.retn();
9969 }
9970
9971 /*!
9972  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9973  * a given support.
9974  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9975  *  \param [in] type - a spatial discretization of interest.
9976  *  \param [in] iteration - the iteration number of a required time step.
9977  *  \param [in] order - the iteration order number of required time step.
9978  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9979  *  \param [in] mesh - the supporting mesh.
9980  *  \param [in] renumPol - specifies how to permute values of the result field according to
9981  *          the optional numbers of cells and nodes, if any. The valid values are
9982  *          - 0 - do not permute.
9983  *          - 1 - permute cells.
9984  *          - 2 - permute nodes.
9985  *          - 3 - permute cells and nodes.
9986  *
9987  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9988  *          caller is to delete this field using decrRef() as it is no more needed. 
9989  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9990  *  \throw If no field of \a this is lying on \a mesh.
9991  *  \throw If no field values of the required parameters are available.
9992  */
9993 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9994 {
9995   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9996   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9997   if(!myF1TSC)
9998     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9999   MCAuto<DataArray> arr;
10000   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10001   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10002   return ret2.retn();
10003 }
10004
10005 /*!
10006  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10007  * given support. 
10008  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10009  *  \param [in] type - a spatial discretization of the new field.
10010  *  \param [in] iteration - the iteration number of a required time step.
10011  *  \param [in] order - the iteration order number of required time step.
10012  *  \param [in] mesh - the supporting mesh.
10013  *  \param [out] arrOut - the DataArrayInt containing values of field.
10014  *  \param [in] renumPol - specifies how to permute values of the result field according to
10015  *          the optional numbers of cells and nodes, if any. The valid values are
10016  *          - 0 - do not permute.
10017  *          - 1 - permute cells.
10018  *          - 2 - permute nodes.
10019  *          - 3 - permute cells and nodes.
10020  *
10021  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10022  *          caller is to delete this field using decrRef() as it is no more needed. 
10023  *  \throw If no field of \a this is lying on \a mesh.
10024  *  \throw If no field values of the required parameters are available.
10025  */
10026 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10027 {
10028   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10029   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10030   if(!myF1TSC)
10031     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10032   MCAuto<DataArray> arr;
10033   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10034   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10035   return ret2.retn();
10036 }
10037
10038 /*!
10039  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10040  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10041  * This method is useful for MED2 file format when field on different mesh was autorized.
10042  */
10043 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10044 {
10045   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10046   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10047   if(!myF1TSC)
10048     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10049   MCAuto<DataArray> arr;
10050   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10051   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10052   return ret2.retn();
10053 }
10054
10055 /*!
10056  * Returns values and a profile of the field of a given type, of a given time step,
10057  * lying on a given support.
10058  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10059  *  \param [in] type - a spatial discretization of the field.
10060  *  \param [in] iteration - the iteration number of a required time step.
10061  *  \param [in] order - the iteration order number of required time step.
10062  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10063  *  \param [in] mesh - the supporting mesh.
10064  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10065  *          field of interest lies on. If the field lies on all entities of the given
10066  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10067  *          using decrRef() as it is no more needed.  
10068  *  \param [in] glob - the global data storing profiles and localization.
10069  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10070  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10071  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10072  *  \throw If no field of \a this is lying on \a mesh.
10073  *  \throw If no field values of the required parameters are available.
10074  */
10075 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10076 {
10077   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10078   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10079   if(!myF1TSC)
10080     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10081   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10082   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10083 }
10084
10085 /*!
10086  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10087  *  \param [in] pos - a time step id.
10088  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10089  *          delete this field using decrRef() as it is no more needed.
10090  *  \throw If \a pos is not a valid time step id.
10091  */
10092 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10093 {
10094   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10095   if(!item)
10096     {
10097       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10098       throw INTERP_KERNEL::Exception(oss.str());
10099     }
10100   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10101   if(itemC)
10102     {
10103       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10104       ret->shallowCpyGlobs(*this);
10105       return ret.retn();
10106     }
10107   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10108   throw INTERP_KERNEL::Exception(oss.str());
10109 }
10110
10111 /*!
10112  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10113  * the given field is checked if its elements are sorted suitable for writing to MED file
10114  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10115  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10116  *  \param [in] field - the field to add to \a this.
10117  *  \throw If the name of \a field is empty.
10118  *  \throw If the data array of \a field is not set.
10119  *  \throw If existing time steps have different name or number of components than \a field.
10120  *  \throw If the underlying mesh of \a field has no name.
10121  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10122  */
10123 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10124 {
10125   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10126   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10127 }
10128
10129 /*!
10130  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10131  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10132  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10133  * and \a profile.
10134  *
10135  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10136  * A new profile is added only if no equal profile is missing.
10137  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10138  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10139  *  \param [in] arrOfVals - the values of the field \a field used.
10140  *  \param [in] mesh - the supporting mesh of \a field.
10141  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10142  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10143  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10144  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10145  *  \throw If the data array of \a field is not set.
10146  *  \throw If the data array of \a this is already allocated but has different number of
10147  *         components than \a field.
10148  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10149  *  \sa setFieldNoProfileSBT()
10150  */
10151 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10152 {
10153   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10154   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10155 }
10156
10157 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10158 {
10159   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10160   if(!pt)
10161     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10162   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10163   if(!ret)
10164     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 !");
10165   return ret;
10166 }
10167
10168 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10169 {
10170   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10171   if(!pt)
10172     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10173   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10174   if(!ret)
10175     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 !");
10176   return ret;
10177 }
10178
10179 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10180 {
10181   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10182 }
10183
10184 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10185 {
10186 }
10187
10188 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10189 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10190 {
10191 }
10192 catch(INTERP_KERNEL::Exception& e)
10193 { throw e; }
10194
10195 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10196 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10197 {
10198 }
10199 catch(INTERP_KERNEL::Exception& e)
10200 { throw e; }
10201
10202 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10203 {
10204   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10205 }
10206
10207 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10208 {
10209   return MEDFileIntFieldMultiTS::New();
10210 }
10211
10212 //= MEDFileFields
10213
10214 MEDFileFields *MEDFileFields::New()
10215 {
10216   return new MEDFileFields;
10217 }
10218
10219 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10220 {
10221   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10222   return New(fid,loadAll);
10223 }
10224
10225 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10226 {
10227   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10228   return NewWithDynGT(fid,se,loadAll);
10229 }
10230
10231 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10232 {
10233   if(!se)
10234     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10235   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10236   return new MEDFileFields(fid,loadAll,0,entities);
10237 }
10238
10239 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10240 {
10241   return new MEDFileFields(fid,loadAll,0,0);
10242 }
10243
10244 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10245 {
10246   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10247   return new MEDFileFields(fid,loadAll,ms,0);
10248 }
10249
10250 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10251 {
10252   MEDFileUtilities::CheckFileForRead(fileName);
10253   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10254   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10255   return new MEDFileFields(fid,loadAll,0,ent);
10256 }
10257
10258 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10259 {
10260   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10261   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10262   return ret;
10263 }
10264
10265 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10266 {
10267   std::vector<const BigMemoryObject *> ret;
10268   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10269     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10270   return ret;
10271 }
10272
10273 MEDFileFields *MEDFileFields::deepCopy() const
10274 {
10275   MCAuto<MEDFileFields> ret(shallowCpy());
10276   std::size_t i(0);
10277   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10278     {
10279       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10280         ret->_fields[i]=(*it)->deepCopy();
10281     }
10282   ret->deepCpyGlobs(*this);
10283   return ret.retn();
10284 }
10285
10286 MEDFileFields *MEDFileFields::shallowCpy() const
10287 {
10288   return new MEDFileFields(*this);
10289 }
10290
10291 /*!
10292  * 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
10293  * 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.
10294  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10295  *
10296  * \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.
10297  * \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.
10298  * 
10299  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10300  */
10301 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10302 {
10303   std::set< std::pair<int,int> > s;
10304   bool firstShot=true;
10305   areThereSomeForgottenTS=false;
10306   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10307     {
10308       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10309         continue;
10310       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10311       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10312       if(firstShot)
10313         { s=s1; firstShot=false; }
10314       else
10315         {
10316           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10317           if(s!=s2)
10318             areThereSomeForgottenTS=true;
10319           s=s2;
10320         }
10321     }
10322   std::vector< std::pair<int,int> > ret;
10323   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10324   return ret;
10325 }
10326
10327 int MEDFileFields::getNumberOfFields() const
10328 {
10329   return _fields.size();
10330 }
10331
10332 std::vector<std::string> MEDFileFields::getFieldsNames() const
10333 {
10334   std::vector<std::string> ret(_fields.size());
10335   int i(0);
10336   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10337     {
10338       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10339       if(f)
10340         {
10341           ret[i]=f->getName();
10342         }
10343       else
10344         {
10345           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10346           throw INTERP_KERNEL::Exception(oss.str());
10347         }
10348     }
10349   return ret;
10350 }
10351
10352 std::vector<std::string> MEDFileFields::getMeshesNames() const
10353 {
10354   std::vector<std::string> ret;
10355   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10356     {
10357       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10358       if(cur)
10359         ret.push_back(cur->getMeshName());
10360     }
10361   return ret;
10362 }
10363
10364 std::string MEDFileFields::simpleRepr() const
10365 {
10366   std::ostringstream oss;
10367   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10368   simpleRepr(0,oss);
10369   return oss.str();
10370 }
10371
10372 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10373 {
10374   int nbOfFields(getNumberOfFields());
10375   std::string startLine(bkOffset,' ');
10376   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10377   int i=0;
10378   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10379     {
10380       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10381       if(cur)
10382         {
10383           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10384         }
10385       else
10386         {
10387           oss << startLine << "  - not defined !" << std::endl;
10388         }
10389     }
10390   i=0;
10391   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10392     {
10393       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10394       std::string chapter(17,'0'+i);
10395       oss << startLine << chapter << std::endl;
10396       if(cur)
10397         {
10398           cur->simpleRepr(bkOffset+2,oss,i);
10399         }
10400       else
10401         {
10402           oss << startLine << "  - not defined !" << std::endl;
10403         }
10404       oss << startLine << chapter << std::endl;
10405     }
10406   simpleReprGlobs(oss);
10407 }
10408
10409 MEDFileFields::MEDFileFields()
10410 {
10411 }
10412
10413 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10414 try:MEDFileFieldGlobsReal(fid)
10415 {
10416   int nbFields(MEDnField(fid));
10417   _fields.resize(nbFields);
10418   med_field_type typcha;
10419   for(int i=0;i<nbFields;i++)
10420     {
10421       std::vector<std::string> infos;
10422       std::string fieldName,dtunit;
10423       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10424       switch(typcha)
10425       {
10426         case MED_FLOAT64:
10427           {
10428             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10429             break;
10430           }
10431         case MED_INT32:
10432           {
10433             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10434             break;
10435           }
10436         default:
10437           {
10438             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] !";
10439             throw INTERP_KERNEL::Exception(oss.str());
10440           }
10441       }
10442     }
10443   loadAllGlobals(fid);
10444 }
10445 catch(INTERP_KERNEL::Exception& e)
10446 {
10447     throw e;
10448 }
10449
10450 void MEDFileFields::writeLL(med_idt fid) const
10451 {
10452   int i=0;
10453   writeGlobals(fid,*this);
10454   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10455     {
10456       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10457       if(!elt)
10458         {
10459           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10460           throw INTERP_KERNEL::Exception(oss.str());
10461         }
10462       elt->writeLL(fid,*this);
10463     }
10464 }
10465
10466 /*!
10467  * This method alloc the arrays and load potentially huge arrays contained in this field.
10468  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10469  * This method can be also called to refresh or reinit values from a file.
10470  * 
10471  * \throw If the fileName is not set or points to a non readable MED file.
10472  */
10473 void MEDFileFields::loadArrays()
10474 {
10475   if(getFileName().empty())
10476     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10477   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10478   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10479     {
10480       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10481       if(elt)
10482         elt->loadBigArraysRecursively(fid,*elt);
10483     }
10484 }
10485
10486 /*!
10487  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10488  * But once data loaded once, this method does nothing.
10489  * 
10490  * \throw If the fileName is not set or points to a non readable MED file.
10491  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10492  */
10493 void MEDFileFields::loadArraysIfNecessary()
10494 {
10495   if(!getFileName().empty())
10496     {
10497       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10498       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10499         {
10500           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10501           if(elt)
10502             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10503         }
10504     }
10505 }
10506
10507 /*!
10508  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10509  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10510  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10511  * 
10512  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10513  */
10514 void MEDFileFields::unloadArrays()
10515 {
10516   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10517     {
10518       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10519       if(elt)
10520         elt->unloadArrays();
10521     }
10522 }
10523
10524 /*!
10525  * 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.
10526  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10527  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10528  * 
10529  * \sa MEDFileFields::loadArraysIfNecessary
10530  */
10531 void MEDFileFields::unloadArraysWithoutDataLoss()
10532 {
10533   if(!getFileName().empty())
10534     unloadArrays();
10535 }
10536
10537 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10538 {
10539   std::vector<std::string> ret;
10540   std::set<std::string> ret2;
10541   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10542     {
10543       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10544       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10545         if(ret2.find(*it2)==ret2.end())
10546           {
10547             ret.push_back(*it2);
10548             ret2.insert(*it2);
10549           }
10550     }
10551   return ret;
10552 }
10553
10554 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10555 {
10556   std::vector<std::string> ret;
10557   std::set<std::string> ret2;
10558   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10559     {
10560       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10561       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10562         if(ret2.find(*it2)==ret2.end())
10563           {
10564             ret.push_back(*it2);
10565             ret2.insert(*it2);
10566           }
10567     }
10568   return ret;
10569 }
10570
10571 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10572 {
10573   std::vector<std::string> ret;
10574   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10575     {
10576       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10577       ret.insert(ret.end(),tmp.begin(),tmp.end());
10578     }
10579   return ret;
10580 }
10581
10582 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10583 {
10584   std::vector<std::string> ret;
10585   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10586     {
10587       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10588       ret.insert(ret.end(),tmp.begin(),tmp.end());
10589     }
10590   return ret;
10591 }
10592
10593 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10594 {
10595   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10596     (*it)->changePflsRefsNamesGen2(mapOfModif);
10597 }
10598
10599 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10600 {
10601   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10602     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10603 }
10604
10605 void MEDFileFields::resize(int newSize)
10606 {
10607   _fields.resize(newSize);
10608 }
10609
10610 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10611 {
10612   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10613     pushField(*it);
10614 }
10615
10616 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10617 {
10618   if(!field)
10619     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10620   _fields.push_back(field->getContent());
10621   appendGlobs(*field,1e-12);
10622 }
10623
10624 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10625 {
10626   if(!field)
10627     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10628   if(i>=(int)_fields.size())
10629     _fields.resize(i+1);
10630   _fields[i]=field->getContent();
10631   appendGlobs(*field,1e-12);
10632 }
10633
10634 void MEDFileFields::destroyFieldAtPos(int i)
10635 {
10636   destroyFieldsAtPos(&i,&i+1);
10637 }
10638
10639 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10640 {
10641   std::vector<bool> b(_fields.size(),true);
10642   for(const int *i=startIds;i!=endIds;i++)
10643     {
10644       if(*i<0 || *i>=(int)_fields.size())
10645         {
10646           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10647           throw INTERP_KERNEL::Exception(oss.str());
10648         }
10649       b[*i]=false;
10650     }
10651   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10652   std::size_t j=0;
10653   for(std::size_t i=0;i<_fields.size();i++)
10654     if(b[i])
10655       fields[j++]=_fields[i];
10656   _fields=fields;
10657 }
10658
10659 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10660 {
10661   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10662   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10663   std::vector<bool> b(_fields.size(),true);
10664   int k=bg;
10665   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10666     {
10667       if(k<0 || k>=(int)_fields.size())
10668         {
10669           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10670           throw INTERP_KERNEL::Exception(oss.str());
10671         }
10672       b[k]=false;
10673     }
10674   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10675   std::size_t j(0);
10676   for(std::size_t i=0;i<_fields.size();i++)
10677     if(b[i])
10678       fields[j++]=_fields[i];
10679   _fields=fields;
10680 }
10681
10682 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10683 {
10684   bool ret(false);
10685   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10686     {
10687       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10688       if(cur)
10689         ret=cur->changeMeshNames(modifTab) || ret;
10690     }
10691   return ret;
10692 }
10693
10694 /*!
10695  * \param [in] meshName the name of the mesh that will be renumbered.
10696  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10697  *             This code corresponds to the distribution of types in the corresponding mesh.
10698  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10699  * \param [in] renumO2N the old to new renumber array.
10700  * \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 
10701  *         field in \a this.
10702  */
10703 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10704 {
10705   bool ret(false);
10706   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10707     {
10708       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10709       if(fmts)
10710         {
10711           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10712         }
10713     }
10714   return ret;
10715 }
10716
10717 /*!
10718  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10719  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10720  *
10721  * \return A new object that the caller is responsible to deallocate.
10722  */
10723 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10724 {
10725   if(!mm)
10726     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10727   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10728   int nbFields(getNumberOfFields());
10729   for(int i=0;i<nbFields;i++)
10730     {
10731       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10732       if(!fmts)
10733         {
10734           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10735           throw INTERP_KERNEL::Exception(oss.str());
10736         }
10737       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10738       fsOut->pushField(fmtsOut);
10739     }
10740   return fsOut.retn();
10741 }
10742
10743 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10744 {
10745   if(i<0 || i>=(int)_fields.size())
10746     {
10747       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10748       throw INTERP_KERNEL::Exception(oss.str());
10749     }
10750   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10751   if(!fmts)
10752     return 0;
10753   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10754   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
10755   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
10756   if(fmtsC)
10757     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10758   else if(fmtsC2)
10759     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10760   else
10761     {
10762       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10763       throw INTERP_KERNEL::Exception(oss.str());
10764     }
10765   ret->shallowCpyGlobs(*this);
10766   return ret.retn();
10767 }
10768
10769 /*!
10770  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10771  * This method is accessible in python using __getitem__ with a list in input.
10772  * \return a new object that the caller should deal with.
10773  */
10774 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10775 {
10776   MCAuto<MEDFileFields> ret=shallowCpy();
10777   std::size_t sz=std::distance(startIds,endIds);
10778   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10779   int j=0;
10780   for(const int *i=startIds;i!=endIds;i++,j++)
10781     {
10782       if(*i<0 || *i>=(int)_fields.size())
10783         {
10784           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10785           throw INTERP_KERNEL::Exception(oss.str());
10786         }
10787       fields[j]=_fields[*i];
10788     }
10789   ret->_fields=fields;
10790   return ret.retn();
10791 }
10792
10793 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10794 {
10795   return getFieldAtPos(getPosFromFieldName(fieldName));
10796 }
10797
10798 /*!
10799  * This method removes, if any, fields in \a this having no time steps.
10800  * 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.
10801  * 
10802  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10803  */
10804 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10805 {
10806   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10807   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10808     {
10809       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10810       if(elt)
10811         {
10812           if(elt->getNumberOfTS()>0)
10813             newFields.push_back(*it);
10814         }
10815     }
10816   if(_fields.size()==newFields.size())
10817     return false;
10818   _fields=newFields;
10819   return true;
10820 }
10821
10822 /*!
10823  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10824  * This method can be seen as a filter applied on \a this, that returns an object containing
10825  * 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
10826  * shallow copied from \a this.
10827  * 
10828  * \param [in] meshName - the name of the mesh on w
10829  * \return a new object that the caller should deal with.
10830  */
10831 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10832 {
10833   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10834   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10835     {
10836       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10837       if(!cur)
10838         continue;
10839       if(cur->getMeshName()==meshName)
10840         {
10841           cur->incrRef();
10842           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10843           ret->_fields.push_back(cur2);
10844         }
10845     }
10846   ret->shallowCpyOnlyUsedGlobs(*this);
10847   return ret.retn();
10848 }
10849
10850 /*!
10851  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10852  * Input time steps are specified using a pair of integer (iteration, order).
10853  * 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,
10854  * but for each multitimestep only the time steps in \a timeSteps are kept.
10855  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10856  * 
10857  * The returned object points to shallow copy of elements in \a this.
10858  * 
10859  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10860  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10861  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10862  */
10863 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10864 {
10865   MCAuto<MEDFileFields> ret(MEDFileFields::New());
10866   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10867     {
10868       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10869       if(!cur)
10870         continue;
10871       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10872       ret->_fields.push_back(elt);
10873     }
10874   ret->shallowCpyOnlyUsedGlobs(*this);
10875   return ret.retn();
10876 }
10877
10878 /*!
10879  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10880  */
10881 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10882 {
10883   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10884   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10885     {
10886       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10887       if(!cur)
10888         continue;
10889       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10890       if(elt->getNumberOfTS()!=0)
10891         ret->_fields.push_back(elt);
10892     }
10893   ret->shallowCpyOnlyUsedGlobs(*this);
10894   return ret.retn();
10895 }
10896
10897 MEDFileFieldsIterator *MEDFileFields::iterator()
10898 {
10899   return new MEDFileFieldsIterator(this);
10900 }
10901
10902 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10903 {
10904   std::string tmp(fieldName);
10905   std::vector<std::string> poss;
10906   for(std::size_t i=0;i<_fields.size();i++)
10907     {
10908       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
10909       if(f)
10910         {
10911           std::string fname(f->getName());
10912           if(tmp==fname)
10913             return i;
10914           else
10915             poss.push_back(fname);
10916         }
10917     }
10918   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10919   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10920   oss << " !";
10921   throw INTERP_KERNEL::Exception(oss.str());
10922 }
10923
10924 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10925 {
10926   if(fs)
10927     {
10928       fs->incrRef();
10929       _nb_iter=fs->getNumberOfFields();
10930     }
10931 }
10932
10933 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10934 {
10935 }
10936
10937 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10938 {
10939   if(_iter_id<_nb_iter)
10940     {
10941       MEDFileFields *fs(_fs);
10942       if(fs)
10943         return fs->getFieldAtPos(_iter_id++);
10944       else
10945         return 0;
10946     }
10947   else
10948     return 0;
10949 }