]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Merge branch 'rnv/autoconf_macros' of salome:tools/medcoupling into rnv/autoconf_macros
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
31
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
34
35 #include <algorithm>
36 #include <iterator>
37
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
42
43 using namespace MEDCoupling;
44
45 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
46 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47
48 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
49 {
50   return new MEDFileFieldLoc(fid,locName);
51 }
52
53 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
54 {
55   return new MEDFileFieldLoc(fid,id);
56 }
57
58 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
59 {
60   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 }
62
63 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
64 {
65   med_geometry_type geotype;
66   med_geometry_type sectiongeotype;
67   int nsectionmeshcell;
68   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
70   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
71   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
72   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
73   _nb_node_per_cell=cm.getNumberOfNodes();
74   _ref_coo.resize(_dim*_nb_node_per_cell);
75   _gs_coo.resize(_dim*_nb_gauss_pt);
76   _w.resize(_nb_gauss_pt);
77   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 }
79
80 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
81 {
82   med_geometry_type geotype;
83   med_geometry_type sectiongeotype;
84   int nsectionmeshcell;
85   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
88   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
89   _name=locName;
90   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
91   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
92   _nb_node_per_cell=cm.getNumberOfNodes();
93   _ref_coo.resize(_dim*_nb_node_per_cell);
94   _gs_coo.resize(_dim*_nb_gauss_pt);
95   _w.resize(_nb_gauss_pt);
96   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 }
98
99 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
100                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
101                                      _w(w)
102 {
103   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
104   _dim=cm.getDimension();
105   _nb_node_per_cell=cm.getNumberOfNodes();
106   _nb_gauss_pt=_w.size();
107 }
108
109 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
110 {
111   return new MEDFileFieldLoc(*this);
112 }
113
114 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
115 {
116   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 }
118
119 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
120 {
121   return std::vector<const BigMemoryObject *>();
122 }
123
124 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
125 {
126   static const char OFF7[]="\n    ";
127   oss << "\"" << _name << "\"" << OFF7;
128   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
129   oss << "Dimension=" << _dim << OFF7;
130   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
131   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
132   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
134   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 }
136
137 void MEDFileFieldLoc::setName(const std::string& name)
138 {
139   _name=name;
140 }
141
142 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
143 {
144   if(_name!=other._name)
145     return false;
146   if(_dim!=other._dim)
147     return false;
148   if(_nb_gauss_pt!=other._nb_gauss_pt)
149     return false;
150   if(_nb_node_per_cell!=other._nb_node_per_cell)
151     return false;
152   if(_geo_type!=other._geo_type)
153     return false;
154   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
155     return false;
156   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
157     return false;
158   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
159     return false;
160
161   return true;
162 }
163
164 void MEDFileFieldLoc::writeLL(med_idt fid) const
165 {
166   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
167 }
168
169 std::string MEDFileFieldLoc::repr() const
170 {
171   std::ostringstream oss; oss.precision(15);
172   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
173   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
174   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
175   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
176   oss << "\n  - Ref coords are : ";
177   int sz=_ref_coo.size();
178   if(sz%_dim==0)
179     {
180       int nbOfTuples=sz/_dim;
181       for(int i=0;i<nbOfTuples;i++)
182         {
183           oss << "(";
184           for(int j=0;j<_dim;j++)
185             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
186           oss << ") ";
187         }
188     }
189   else
190     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
191   oss << "\n  - Gauss coords in reference element : ";
192   sz=_gs_coo.size();
193   if(sz%_dim==0)
194     {
195       int nbOfTuples=sz/_dim;
196       for(int i=0;i<nbOfTuples;i++)
197         {
198           oss << "(";
199           for(int j=0;j<_dim;j++)
200             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
201           oss << ") ";
202         }
203     }
204   else
205     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
206   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
207   return oss.str();
208 }
209
210 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
211 {
212   _type=field->getTypeOfField();
213   _start=start;
214   switch(_type)
215   {
216     case ON_CELLS:
217       {
218         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
219         _end=_start+nbOfCells;
220         _nval=nbOfCells;
221         break;
222       }
223     case ON_GAUSS_NE:
224       {
225         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
226         const int *arrPtr=arr->getConstPointer();
227         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
228         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
229         _nval=nbOfCells;
230         break;
231       }
232     case ON_GAUSS_PT:
233       {
234         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
235         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
236         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
237         if(!disc2)
238           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
239         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
240         MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
241         const int *dai2Ptr=dai2->getConstPointer();
242         int nbi=gsLoc.getWeights().size();
243         MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
244         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
245         const int *da3Ptr=da3->getConstPointer();
246         if(da3->getNumberOfTuples()!=nbOfCells)
247           {//profile : for gauss even in NoProfile !!!
248             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
249             _profile=oss.str();
250             da3->setName(_profile.c_str());
251             glob.appendProfile(da3);
252           }
253         MCAuto<DataArrayInt> da4=DataArrayInt::New();
254         _nval=da3->getNbOfElems();
255         da4->alloc(_nval*nbi,1);
256         int *da4Ptr=da4->getPointer();
257         for(int i=0;i<_nval;i++)
258           {
259             int ref=dai2Ptr[offset+da3Ptr[i]];
260             for(int j=0;j<nbi;j++)
261               *da4Ptr++=ref+j;
262           }
263         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
264         _localization=oss2.str();
265         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
266         _end=_start+_nval*nbi;
267         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
268         break;
269       }
270     default:
271       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
272   }
273   start=_end;
274 }
275
276 /*!
277  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
278  * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
279  * \param [in] multiTypePfl is the end user profile specified in high level API
280  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
281  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
282  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
283  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
284  */
285 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
286 {
287   _profile.clear();
288   _type=field->getTypeOfField();
289   std::string pflName(multiTypePfl->getName());
290   std::ostringstream oss; oss << pflName;
291   if(_type!=ON_NODES)
292     {
293       if(!isPflAlone)
294         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
295     }
296   else
297     { oss << "_NODE"; }
298   if(locIds)
299     {
300       if(pflName.empty())
301         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
302       if(_type!=ON_GAUSS_PT)
303         {
304           locIds->setName(oss.str());
305           glob.appendProfile(locIds);
306           _profile=oss.str();
307         }
308     }
309   _start=start;
310   switch(_type)
311   {
312     case ON_NODES:
313       {
314         _nval=idsInPfl->getNumberOfTuples();
315         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
316         _end=_start+_nval;
317         break;
318       }
319     case ON_CELLS:
320       {
321         _nval=idsInPfl->getNumberOfTuples();
322         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
323         _end=_start+_nval;
324         break;
325       }
326     case ON_GAUSS_NE:
327       {
328         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
329         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
330         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
331         arr3->computeOffsetsFull();
332         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
333         int trueNval=tmp->getNumberOfTuples();
334         _nval=idsInPfl->getNumberOfTuples();
335         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
336         _end=_start+trueNval;
337         break;
338       }
339     case ON_GAUSS_PT:
340       {
341         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
342         if(!disc2)
343           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
344         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
345         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
346         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
347         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
348         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349         //
350         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
351         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352         //
353         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
354         int trueNval=0;
355         for(const int *pt=da4->begin();pt!=da4->end();pt++)
356           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
357         tmp->alloc(trueNval,1);
358         int *tmpPtr=tmp->getPointer();
359         for(const int *pt=da4->begin();pt!=da4->end();pt++)
360           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361             *tmpPtr++=j;
362         //
363         _nval=da4->getNumberOfTuples();
364         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
365         _end=_start+trueNval;
366         oss << "_loc_" << _loc_id;
367         if(locIds)
368           {
369             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
370             da5->setName(oss.str());
371             glob.appendProfile(da5);
372             _profile=oss.str();
373           }
374         else
375           {
376             if(!da3->isIota(nbOfEltsInWholeMesh))
377               {
378                 da3->setName(oss.str());
379                 glob.appendProfile(da3);
380                 _profile=oss.str();
381               }
382           }
383         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
384         _localization=oss2.str();
385         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
386         break;
387       }
388     default:
389       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
390   }
391   start=_end;
392 }
393
394 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 {
396   _start=start;
397   _nval=arrr->getNumberOfTuples();
398   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
399   _end=_start+_nval;
400   start=_end;
401 }
402
403 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
404 {
405   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
406 }
407
408 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
409 {
410   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 }
412
413 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
414 {
415   return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 }
417
418 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
419 {
420   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
421 }
422
423 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
424 {
425   std::vector<const BigMemoryObject *> ret(1);
426   ret[0]=(const PartDefinition*)_pd;
427   return ret;
428 }
429
430 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
431 {
432   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
433   ret->_father=father;
434   return ret.retn();
435 }
436
437 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
438 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
439 {
440   if(pd)
441     pd->incrRef();
442 }
443 catch(INTERP_KERNEL::Exception& e)
444 {
445     throw e;
446 }
447
448 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
449 {
450 }
451
452 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
453 {
454 }
455
456 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
457     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
458 {
459 }
460
461 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
462 {
463   const PartDefinition *pd(_pd);
464   if(!pd)
465     {
466       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
467       int nbi,tmp1;
468       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
469       if(_end-_start!=nbValsInFile*nbi)
470         {
471           std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
472           throw INTERP_KERNEL::Exception(oss.str());
473         }
474       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
475     }
476   else
477     {
478       if(!_profile.empty())
479         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
480       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
481       int profilesize,nbi;
482       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
483       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
484       if(spd)
485         {
486           int start,stop,step;
487           spd->getSlice(start,stop,step);
488           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
489           med_filter filter=MED_FILTER_INIT;
490           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
491                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
492                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
493                                    /*lastblocksize=useless because count=1*/0,&filter);
494           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
495           MEDfilterClose(&filter);
496           return ;
497         }
498       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
499       if(dpd)
500         {
501           dpd->checkConsistencyLight();
502           MCAuto<DataArrayInt> myIds(dpd->toDAI());
503           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
504           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
505           myIds->applyLin(1,-a);
506           int nbOfEltsToLoad(b-a+1);
507           med_filter filter=MED_FILTER_INIT;
508           {//TODO : manage int32 !
509             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
510             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
511             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
512                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
513                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
514                                      /*lastblocksize=useless because count=1*/0,&filter);
515             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
516             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
517             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
518             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
519           }
520           MEDfilterClose(&filter);
521         }
522       else
523         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
524     }
525 }
526
527 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
528 {
529   return _father;
530 }
531
532 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
533 {
534   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
535   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
536   std::string fieldName(nasc.getName()),meshName(getMeshName());
537   int iteration(getIteration()),order(getOrder());
538   TypeOfField type(getType());
539   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
540   int profilesize,nbi;
541   med_geometry_type mgeoti;
542   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
543   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
544   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
545   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
546   const PartDefinition *pd(_pd);
547   if(!pd)
548     {
549       _nval=zeNVal;
550     }
551   else
552     {
553       if(!_profile.empty())
554         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
555       _nval=pd->getNumberOfElems();
556     }
557   _start=start;
558   _end=start+_nval*nbi;
559   start=_end;
560   if(type==ON_CELLS && !_localization.empty())
561     {
562       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
563         setType(ON_GAUSS_PT);
564       else
565         {
566           setType(ON_GAUSS_NE);
567           _localization.clear();
568         }
569     }
570 }
571
572 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
573 {
574   std::string fieldName(nasc.getName()),meshName(getMeshName());
575   int iteration(getIteration()),order(getOrder());
576   TypeOfField type(getType());
577   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
578   med_geometry_type mgeoti;
579   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
580   if(_start>_end)
581     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
582   if(_start==_end)
583     return ;
584   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
585   if(_start<0 || _start>=arr->getNumberOfTuples())
586     {
587       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
588       throw INTERP_KERNEL::Exception(oss.str());
589     }
590   if(_end<0 || _end>arr->getNumberOfTuples())
591     {
592       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
593       throw INTERP_KERNEL::Exception(oss.str());
594     }
595   int nbOfCompo(arr->getNumberOfComponents());
596   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
597   if(arrD)
598     {
599       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
600       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
601       return ;
602     }
603   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
604   if(arrI)
605     {
606       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
607       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
608       return ;
609     }
610   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
611 }
612
613 /*!
614  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
615  */
616 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
617 {
618   int delta=_end-_start;
619   _start=newValueOfStart;
620   _end=_start+delta;
621 }
622
623 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
624 {
625   return _father->getIteration();
626 }
627
628 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
629 {
630   return _father->getOrder();
631 }
632
633 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
634 {
635   return _father->getTime();
636 }
637
638 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
639 {
640   return _father->getMeshName();
641 }
642
643 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
644 {
645   const char startLine[]="    ## ";
646   std::string startLine2(bkOffset,' ');
647   startLine2+=startLine;
648   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
649   oss << startLine2 << "Localization #" << id << "." << std::endl;
650   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
651   delete tmp;
652   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
653   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
654   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
655 }
656
657 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
658 {
659   return _type;
660 }
661
662 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
663 {
664   types.insert(_type);
665 }
666
667 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
668 {
669   _type=newType;
670 }
671
672 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
673 {
674   return _father->getGeoType();
675 }
676
677 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
678 {
679   return _father->getNumberOfComponents();
680 }
681
682 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
683 {
684   return _end-_start;
685 }
686
687 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
688 {
689   return _father->getOrCreateAndGetArray();
690 }
691
692 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
693 {
694   const MEDFileFieldPerMeshPerType *fath=_father;
695   return fath->getOrCreateAndGetArray();
696 }
697
698 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
699 {
700   return _father->getInfo();
701 }
702
703 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
704 {
705   return _profile;
706 }
707
708 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
709 {
710   _profile=newPflName;
711 }
712
713 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
714 {
715   return _localization;
716 }
717
718 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
719 {
720   _localization=newLocName;
721 }
722
723 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
724 {
725   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
726     {
727       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
728         {
729           _profile=(*it2).second;
730           return;
731         }
732     }
733 }
734
735 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
736 {
737   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
738     {
739       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
740         {
741           _localization=(*it2).second;
742           return;
743         }
744     }
745 }
746
747 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
748 {
749   if(type!=_type)
750     return ;
751   dads.push_back(std::pair<int,int>(_start,_end));
752   geoTypes.push_back(getGeoType());
753   if(_profile.empty())
754     pfls.push_back(0);
755   else
756     {
757       pfls.push_back(glob->getProfile(_profile.c_str()));
758     }
759   if(_localization.empty())
760     locs.push_back(-1);
761   else
762     {
763       locs.push_back(glob->getLocalizationId(_localization.c_str()));
764     }
765 }
766
767 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
768 {
769   entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
770   startEntryId++;
771 }
772
773 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
774 {
775   TypeOfField type=getType();
776   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
777   med_geometry_type mgeoti;
778   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
779   const DataArray *arr=getOrCreateAndGetArray();
780   if(!arr)
781     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
782   if(!arr->isAllocated())
783     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
784   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
785   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
786   const unsigned char *locToWrite=0;
787   if(arrD)
788     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
789   else if(arrI)
790     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
791   else
792     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
793   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
794                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
795                                                    locToWrite));
796 }
797
798 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
799 {
800   type=_type;
801   pfl=_profile;
802   loc=_localization;
803   dad.first=_start; dad.second=_end;
804 }
805
806 /*!
807  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
808  *             This code corresponds to the distribution of types in the corresponding mesh.
809  * \param [out] ptToFill memory zone where the output will be stored.
810  * \return the size of data pushed into output param \a ptToFill
811  */
812 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
813 {
814   _loc_id=offset;
815   std::ostringstream oss;
816   std::size_t nbOfType=codeOfMesh.size()/3;
817   int found=-1;
818   for(std::size_t i=0;i<nbOfType && found==-1;i++)
819     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
820       found=(int)i;
821   if(found==-1)
822     {
823       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
824       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
825       throw INTERP_KERNEL::Exception(oss.str());
826     }
827   int *work=ptToFill;
828   if(_profile.empty())
829     {
830       if(_nval!=codeOfMesh[3*found+1])
831         {
832           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
833           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
834           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
835           throw INTERP_KERNEL::Exception(oss.str());
836         }
837       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
838         *work++=ii;
839     }
840   else
841     {
842       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
843       if(pfl->getNumberOfTuples()!=_nval)
844         {
845           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
846           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
847           oss << _nval;
848           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
849           throw INTERP_KERNEL::Exception(oss.str());
850         }
851       int offset2=codeOfMesh[3*found+2];
852       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
853         {
854           if(*pflId<codeOfMesh[3*found+1])
855             *work++=offset2+*pflId;
856         }
857     }
858   return _nval;
859 }
860
861 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
862 {
863   for(int i=_start;i<_end;i++)
864     *ptToFill++=i;
865   return _end-_start;
866 }
867
868 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
869 {
870   switch(type)
871   {
872     case ON_CELLS:
873       return -2;
874     case ON_GAUSS_NE:
875       return -1;
876     case ON_GAUSS_PT:
877       return locId;
878     default:
879       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
880   }
881 }
882
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
884 {
885   int id=0;
886   std::map<std::pair<std::string,TypeOfField>,int> m;
887   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
888   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
890       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
891   ret.resize(id);
892   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
893     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
894   return ret;
895 }
896
897 /*!
898  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
899  * 
900  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
901  * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
902  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
903  * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
904  * \param [in,out] glob if necessary by the method, new profiles can be added to it
905  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
906  * \param [out] result All new entries will be appended on it.
907  * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
908  */
909 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
910                                                        const DataArrayInt *explicitIdsInMesh,
911                                                        const std::vector<int>& newCode,
912                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
913                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
914 {
915   if(entriesOnSameDisc.empty())
916     return false;
917   TypeOfField type=entriesOnSameDisc[0]->getType();
918   int szEntities=0,szTuples=0;
919   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
920     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
921   int nbi=szTuples/szEntities;
922   if(szTuples%szEntities!=0)
923     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
924   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
925   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
926   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
927   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
928   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
929   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
930   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
931   int id=0;
932   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
933     {
934       int startOfEltIdOfChunk=(*it)->_start;
935       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
936       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
937       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
938       //
939       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
940       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
941       //
942       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
943       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
944     }
945   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
946   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
947   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
948   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
949   //
950   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
951   //
952   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
953   arrPart->renumberInPlace(renumTupleIds->begin());
954   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
955   bool ret=false;
956   const int *idIt=diffVals->begin();
957   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
958   int offset2=0;
959   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
960     {
961       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
962       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
963       int nbEntityElts=subIds->getNumberOfTuples();
964       bool ret2;
965       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
966           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
967                                       offset+offset2,
968                                       li,glob,ret2);
969       ret=ret || ret2;
970       result.push_back(eltToAdd);
971       offset2+=nbEntityElts*nbi;
972     }
973   ret=ret || li.empty();
974   return ret;
975 }
976
977 /*!
978  * \param [in] typeF type of field of new chunk
979  * \param [in] geoType the geometric type of the chunk
980  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
981  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
982  * \param [in] nbi number of integration points
983  * \param [in] offset The offset in the **global array of data**.
984  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
985  *                 to the new chunk to create.
986  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
987  * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
988  *              and corresponding entry erased from \a entriesOnSameDisc.
989  * \return a newly allocated chunk
990  */
991 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
992                                                                                                   bool isPfl, int nbi, int offset,
993                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
994                                                                                                   MEDFileFieldGlobsReal& glob,
995                                                                                                   bool &notInExisting)
996 {
997   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
998   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
999   for(;it!=entriesOnSameDisc.end();it++)
1000     {
1001       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1002         {
1003           if(!isPfl)
1004             {
1005               if((*it)->_profile.empty())
1006                 break;
1007               else
1008                 if(!(*it)->_profile.empty())
1009                   {
1010                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1011                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1012                       break;
1013                   }
1014             }
1015         }
1016     }
1017   if(it==entriesOnSameDisc.end())
1018     {
1019       notInExisting=true;
1020       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1021       ret->_type=typeF;
1022       ret->_loc_id=(int)geoType;
1023       ret->_nval=nbMeshEntities;
1024       ret->_start=offset;
1025       ret->_end=ret->_start+ret->_nval*nbi;
1026       if(isPfl)
1027         {
1028           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1029           glob.appendProfile(idsOfMeshElt);
1030           ret->_profile=idsOfMeshElt->getName();
1031         }
1032       //tony treatment of localization
1033       return ret;
1034     }
1035   else
1036     {
1037       notInExisting=false;
1038       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1039       ret->_loc_id=(int)geoType;
1040       ret->setNewStart(offset);
1041       entriesOnSameDisc.erase(it);
1042       return ret;
1043     }
1044
1045 }
1046
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1048 {
1049   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1050 }
1051
1052 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1053 {
1054   return new MEDFileFieldPerMeshPerType(fath,geoType);
1055 }
1056
1057 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1058 {
1059   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1060 }
1061
1062 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1063 {
1064   std::vector<const BigMemoryObject *> ret;
1065   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1066     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1067   return ret;
1068 }
1069
1070 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1071 {
1072   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1073   ret->_father=father;
1074   std::size_t i=0;
1075   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1076     {
1077       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1078         ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1079     }
1080   return ret.retn();
1081 }
1082
1083 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1084 {
1085   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 }
1089
1090 /*!
1091  * This method is the most general one. No optimization is done here.
1092  * \param [in] multiTypePfl is the end user profile specified in high level API
1093  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094  * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1098  */
1099 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1100 {
1101   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1104 }
1105
1106 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1107 {
1108   _field_pm_pt_pd.resize(1);
1109   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1111 }
1112
1113 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1114 {
1115   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116   if(!arr || !arr->isAllocated())
1117     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1118   _field_pm_pt_pd.resize(1);
1119   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120   _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1121 }
1122
1123 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1124 {
1125   TypeOfField type=field->getTypeOfField();
1126   if(type!=ON_GAUSS_PT)
1127     {
1128       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129       int sz=_field_pm_pt_pd.size();
1130       bool found=false;
1131       for(int j=0;j<sz && !found;j++)
1132         {
1133           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1134             {
1135               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1136               found=true;
1137             }
1138         }
1139       if(!found)
1140         {
1141           _field_pm_pt_pd.resize(sz+1);
1142           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143         }
1144       std::vector<int> ret(1,(int)sz);
1145       return ret;
1146     }
1147   else
1148     {
1149       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150       int sz2=ret2.size();
1151       std::vector<int> ret3(sz2);
1152       int k=0;
1153       for(int i=0;i<sz2;i++)
1154         {
1155           int sz=_field_pm_pt_pd.size();
1156           int locIdToFind=ret2[i];
1157           bool found=false;
1158           for(int j=0;j<sz && !found;j++)
1159             {
1160               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1161                 {
1162                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1163                   ret3[k++]=j;
1164                   found=true;
1165                 }
1166             }
1167           if(!found)
1168             {
1169               _field_pm_pt_pd.resize(sz+1);
1170               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1171               ret3[k++]=sz;
1172             }
1173         }
1174       return ret3;
1175     }
1176 }
1177
1178 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1179 {
1180   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1182   if(!disc2)
1183     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1185   if(!da)
1186     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189   if(retTmp->presenceOfValue(-1))
1190     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191   std::vector<int> ret(retTmp->begin(),retTmp->end());
1192   return ret;
1193 }
1194
1195 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1196 {
1197   TypeOfField type=field->getTypeOfField();
1198   if(type!=ON_GAUSS_PT)
1199     {
1200       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201       int sz=_field_pm_pt_pd.size();
1202       bool found=false;
1203       for(int j=0;j<sz && !found;j++)
1204         {
1205           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1206             {
1207               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1208               found=true;
1209             }
1210         }
1211       if(!found)
1212         {
1213           _field_pm_pt_pd.resize(sz+1);
1214           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1215         }
1216       std::vector<int> ret(1,0);
1217       return ret;
1218     }
1219   else
1220     {
1221       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222       int sz2=ret2.size();
1223       std::vector<int> ret3(sz2);
1224       int k=0;
1225       for(int i=0;i<sz2;i++)
1226         {
1227           int sz=_field_pm_pt_pd.size();
1228           int locIdToFind=ret2[i];
1229           bool found=false;
1230           for(int j=0;j<sz && !found;j++)
1231             {
1232               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1233                 {
1234                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1235                   ret3[k++]=j;
1236                   found=true;
1237                 }
1238             }
1239           if(!found)
1240             {
1241               _field_pm_pt_pd.resize(sz+1);
1242               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1243               ret3[k++]=sz;
1244             }
1245         }
1246       return ret3;
1247     }
1248 }
1249
1250 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1251 {
1252   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1254   if(!disc2)
1255     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1257   if(!da)
1258     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261   if(retTmp->presenceOfValue(-1))
1262     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263   std::vector<int> ret(retTmp->begin(),retTmp->end());
1264   return ret;
1265 }
1266
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1268 {
1269   return _father;
1270 }
1271
1272 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1273 {
1274   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1275   int curDim((int)cm.getDimension());
1276   dim=std::max(dim,curDim);
1277 }
1278
1279 bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
1280 {
1281   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1282   int curDim((int)cm.getDimension());
1283   if(dim!=std::numeric_limits<int>::max())
1284     {
1285       if(dim!=curDim)
1286         return false;
1287     }
1288   else
1289     dim=curDim;
1290   return true;
1291 }
1292
1293 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1294 {
1295   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1296     {
1297       (*it)->fillTypesOfFieldAvailable(types);
1298     }
1299 }
1300
1301 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1302 {
1303   int sz=_field_pm_pt_pd.size();
1304   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1305   for(int i=0;i<sz;i++)
1306     {
1307       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1308     }
1309 }
1310
1311 int MEDFileFieldPerMeshPerType::getIteration() const
1312 {
1313   return _father->getIteration();
1314 }
1315
1316 int MEDFileFieldPerMeshPerType::getOrder() const
1317 {
1318   return _father->getOrder();
1319 }
1320
1321 double MEDFileFieldPerMeshPerType::getTime() const
1322 {
1323   return _father->getTime();
1324 }
1325
1326 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1327 {
1328   return _father->getMeshName();
1329 }
1330
1331 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1332 {
1333   const char startLine[]="  ## ";
1334   std::string startLine2(bkOffset,' ');
1335   std::string startLine3(startLine2);
1336   startLine3+=startLine;
1337   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1338     {
1339       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1340       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1341     }
1342   else
1343     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1344   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1345   int i=0;
1346   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1347     {
1348       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1349       if(cur)
1350         cur->simpleRepr(bkOffset,oss,i);
1351       else
1352         {
1353           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1354         }
1355     }
1356 }
1357
1358 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1359 {
1360   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1361     {
1362       globalSz+=(*it)->getNumberOfTuples();
1363     }
1364   nbOfEntries+=(int)_field_pm_pt_pd.size();
1365 }
1366
1367 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1368 {
1369   return _geo_type;
1370 }
1371
1372
1373 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1374 {
1375   return _father->getNumberOfComponents();
1376 }
1377
1378 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1379 {
1380   std::size_t nb(0);
1381   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1382     {
1383       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1384       if(fmtd)
1385         nb++;
1386     }
1387   return nb>1;
1388 }
1389
1390 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1391 {
1392   return _father->getOrCreateAndGetArray();
1393 }
1394
1395 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1396 {
1397   const MEDFileFieldPerMesh *fath=_father;
1398   return fath->getOrCreateAndGetArray();
1399 }
1400
1401 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1402 {
1403   return _father->getInfo();
1404 }
1405
1406 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1407 {
1408   std::vector<std::string> ret;
1409   std::set<std::string> ret2;
1410   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1411     {
1412       std::string tmp=(*it1)->getProfile();
1413       if(!tmp.empty())
1414         if(ret2.find(tmp)==ret2.end())
1415           {
1416             ret.push_back(tmp);
1417             ret2.insert(tmp);
1418           }
1419     }
1420   return ret;
1421 }
1422
1423 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1424 {
1425   std::vector<std::string> ret;
1426   std::set<std::string> ret2;
1427   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428     {
1429       std::string tmp=(*it1)->getLocalization();
1430       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1431         if(ret2.find(tmp)==ret2.end())
1432           {
1433             ret.push_back(tmp);
1434             ret2.insert(tmp);
1435           }
1436     }
1437   return ret;
1438 }
1439
1440 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1441 {
1442   std::vector<std::string> ret;
1443   std::set<std::string> ret2;
1444   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1445     {
1446       std::string tmp=(*it1)->getProfile();
1447       if(!tmp.empty())
1448         ret.push_back(tmp);
1449     }
1450   return ret;
1451 }
1452
1453 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1454 {
1455   std::vector<std::string> ret;
1456   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1457     {
1458       std::string tmp=(*it1)->getLocalization();
1459       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1460         ret.push_back(tmp);
1461     }
1462   return ret;
1463 }
1464
1465 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1466 {
1467   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1468     (*it1)->changePflsRefsNamesGen(mapOfModif);
1469 }
1470
1471 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1472 {
1473   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1474     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1475 }
1476
1477 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1478 {
1479   if(_field_pm_pt_pd.empty())
1480     {
1481       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1482       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1483       throw INTERP_KERNEL::Exception(oss.str());
1484     }
1485   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1486     return _field_pm_pt_pd[locId];
1487   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1488   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1489   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1490   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1491   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1492 }
1493
1494 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1495 {
1496   if(_field_pm_pt_pd.empty())
1497     {
1498       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1499       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1500       throw INTERP_KERNEL::Exception(oss.str());
1501     }
1502   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1503     return _field_pm_pt_pd[locId];
1504   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1505   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1506   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1507   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1508   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1509 }
1510
1511 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1512 {
1513   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1514     {
1515       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1516       if(meshDim!=(int)cm.getDimension())
1517         return ;
1518     }
1519   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1520     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1521 }
1522
1523 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1524 {
1525   int i=0;
1526   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1527     {
1528       (*it)->fillValues(i,startEntryId,entries);
1529     }
1530 }
1531
1532 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1533 {
1534   _field_pm_pt_pd=leaves;
1535   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536     (*it)->setFather(this);
1537 }
1538
1539 /*!
1540  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1541  *  \param [out] its - list of pair (start,stop) kept
1542  *  \return bool - false if the type of field \a tof is not contained in \a this.
1543  */
1544 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1545 {
1546   bool ret(false);
1547   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1548   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1549     if((*it)->getType()==tof)
1550       {
1551         newPmPtPd.push_back(*it);
1552         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1553         (*it)->setNewStart(globalNum);
1554         globalNum=(*it)->getEnd();
1555         its.push_back(bgEnd);
1556         ret=true;
1557       }
1558   if(ret)
1559     _field_pm_pt_pd=newPmPtPd;
1560   return ret;
1561 }
1562
1563 /*!
1564  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1565  *  \param [out] its - list of pair (start,stop) kept
1566  *  \return bool - false if the type of field \a tof is not contained in \a this.
1567  */
1568 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1569 {
1570   if(_field_pm_pt_pd.size()<=idOfDisc)
1571     return false;
1572   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1573   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1574   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1575   elt->setNewStart(globalNum);
1576   globalNum=elt->getEnd();
1577   its.push_back(bgEnd);
1578   _field_pm_pt_pd=newPmPtPd;
1579   return true;
1580 }
1581
1582 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1583 {
1584 }
1585
1586 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1587 {
1588   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1589   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1590   med_geometry_type mgeoti;
1591   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1592   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1593   _field_pm_pt_pd.resize(nbProfiles);
1594   for(int i=0;i<nbProfiles;i++)
1595     {
1596       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1597     }
1598   if(type==ON_CELLS)
1599     {
1600       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1601       for(int i=0;i<nbProfiles2;i++)
1602         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1603     }
1604 }
1605
1606 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1607 {
1608   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1610 }
1611
1612 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1613 {
1614   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1615     (*it)->loadBigArray(fid,nasc);
1616 }
1617
1618 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1619 {
1620   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1621     {
1622       (*it)->copyOptionsFrom(*this);
1623       (*it)->writeLL(fid,nasc);
1624     }
1625 }
1626
1627 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1628 {
1629   switch(ikType)
1630   {
1631     case ON_CELLS:
1632       medfGeoType=typmai3[(int)ikGeoType];
1633       return MED_CELL;
1634     case ON_NODES:
1635       medfGeoType=MED_NONE;
1636       return MED_NODE;
1637     case ON_GAUSS_NE:
1638       medfGeoType=typmai3[(int)ikGeoType];
1639       return MED_NODE_ELEMENT;
1640     case ON_GAUSS_PT:
1641       medfGeoType=typmai3[(int)ikGeoType];
1642       return MED_CELL;
1643     default:
1644       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1645   }
1646   return MED_UNDEF_ENTITY_TYPE;
1647 }
1648
1649 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1650 {
1651   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1652 }
1653
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1655 {
1656   return new MEDFileFieldPerMesh(fath,mesh);
1657 }
1658
1659 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1660 {
1661   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1662 }
1663
1664 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1665 {
1666   std::vector<const BigMemoryObject *> ret;
1667   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1668     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1669   return ret;
1670 }
1671
1672 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1673 {
1674   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1675   ret->_father=father;
1676   std::size_t i=0;
1677   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1678     {
1679       if((const MEDFileFieldPerMeshPerType *)*it)
1680         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1681     }
1682   return ret.retn();
1683 }
1684
1685 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1686 {
1687   std::string startLine(bkOffset,' ');
1688   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1689   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1690   int i=0;
1691   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1692     {
1693       const MEDFileFieldPerMeshPerType *cur=*it;
1694       if(cur)
1695         cur->simpleRepr(bkOffset,oss,i);
1696       else
1697         {
1698           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1699         }
1700     }
1701 }
1702
1703 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1704 {
1705   _mesh_name=mesh->getName();
1706   mesh->getTime(_mesh_iteration,_mesh_order);
1707 }
1708
1709 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1710 {
1711   int nbOfTypes=code.size()/3;
1712   int offset=0;
1713   for(int i=0;i<nbOfTypes;i++)
1714     {
1715       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1716       int nbOfCells=code[3*i+1];
1717       int pos=addNewEntryIfNecessary(type);
1718       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1719       offset+=nbOfCells;
1720     }
1721 }
1722
1723 /*!
1724  * This method is the most general one. No optimization is done here.
1725  * \param [in] multiTypePfl is the end user profile specified in high level API
1726  * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1727  * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1728  * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1729  * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1730  * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1731  */
1732 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1733 {
1734   int nbOfTypes(code.size()/3);
1735   for(int i=0;i<nbOfTypes;i++)
1736     {
1737       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1738       int pos=addNewEntryIfNecessary(type);
1739       DataArrayInt *pfl=0;
1740       if(code[3*i+2]!=-1)
1741         pfl=idsPerType[code[3*i+2]];
1742       int nbOfTupes2=code2.size()/3;
1743       int found=0;
1744       for(;found<nbOfTupes2;found++)
1745         if(code[3*i]==code2[3*found])
1746           break;
1747       if(found==nbOfTupes2)
1748         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1749       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1750     }
1751 }
1752
1753 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1754 {
1755   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1756   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1757 }
1758
1759 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1760 {
1761   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1762   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1763 }
1764
1765 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1766 {
1767   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1768     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1769 }
1770
1771 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1772 {
1773   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1774     (*it)->loadBigArraysRecursively(fid,nasc);
1775 }
1776
1777 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1778 {
1779   int nbOfTypes=_field_pm_pt.size();
1780   for(int i=0;i<nbOfTypes;i++)
1781     {
1782       _field_pm_pt[i]->copyOptionsFrom(*this);
1783       _field_pm_pt[i]->writeLL(fid,nasc);
1784     }
1785 }
1786
1787 void MEDFileFieldPerMesh::getDimension(int& dim) const
1788 {
1789   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790     (*it)->getDimension(dim);
1791 }
1792
1793 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1794 {
1795   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1796     if(!(*it)->isUniqueLevel(dim))
1797       return false;
1798   return true;
1799 }
1800
1801 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1802 {
1803   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804     (*it)->fillTypesOfFieldAvailable(types);
1805 }
1806
1807 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
1808 {
1809   int sz=_field_pm_pt.size();
1810   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1811   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1812   for(int i=0;i<sz;i++)
1813     {
1814       types[i]=_field_pm_pt[i]->getGeoType();
1815       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1816     }
1817   return ret;
1818 }
1819
1820 double MEDFileFieldPerMesh::getTime() const
1821 {
1822   int tmp1,tmp2;
1823   return _father->getTime(tmp1,tmp2);
1824 }
1825
1826 int MEDFileFieldPerMesh::getIteration() const
1827 {
1828   return _father->getIteration();
1829 }
1830
1831 int MEDFileFieldPerMesh::getOrder() const
1832 {
1833   return _father->getOrder();
1834 }
1835
1836 int MEDFileFieldPerMesh::getNumberOfComponents() const
1837 {
1838   return _father->getNumberOfComponents();
1839 }
1840
1841 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1842 {
1843   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1844     {
1845       const MEDFileFieldPerMeshPerType *fpmt(*it);
1846       if(!fpmt)
1847         continue;
1848       if(fpmt->presenceOfMultiDiscPerGeoType())
1849         return true;
1850     }
1851   return false;
1852 }
1853
1854 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1855 {
1856   if(!_father)
1857     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1858   return _father->getOrCreateAndGetArray();
1859 }
1860
1861 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1862 {
1863   if(!_father)
1864     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1865   return _father->getOrCreateAndGetArray();
1866 }
1867
1868 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1869 {
1870   return _father->getInfo();
1871 }
1872
1873 /*!
1874  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1875  * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1876  * It returns 2 output vectors :
1877  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1878  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1879  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1880  */
1881 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1882 {
1883   int notNullPflsSz=0;
1884   int nbOfArrs=geoTypes.size();
1885   for(int i=0;i<nbOfArrs;i++)
1886     if(pfls[i])
1887       notNullPflsSz++;
1888   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1889   int nbOfDiffGeoTypes=geoTypes3.size();
1890   code.resize(3*nbOfDiffGeoTypes);
1891   notNullPfls.resize(notNullPflsSz);
1892   notNullPflsSz=0;
1893   int j=0;
1894   for(int i=0;i<nbOfDiffGeoTypes;i++)
1895     {
1896       int startZone=j;
1897       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1898       std::vector<const DataArrayInt *> notNullTmp;
1899       if(pfls[j])
1900         notNullTmp.push_back(pfls[j]);
1901       j++;
1902       for(;j<nbOfArrs;j++)
1903         if(geoTypes[j]==refType)
1904           {
1905             if(pfls[j])
1906               notNullTmp.push_back(pfls[j]);
1907           }
1908         else
1909           break;
1910       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1911       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1912       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1913       code[3*i]=(int)refType;
1914       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1915       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1916       if(notNullTmp.empty())
1917         code[3*i+2]=-1;
1918       else
1919         {
1920           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1921           code[3*i+2]=notNullPflsSz++;
1922         }
1923     }
1924 }
1925
1926 /*!
1927  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1928  */
1929 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
1930 {
1931   int sz=dads.size();
1932   int ret=0;
1933   for(int i=0;i<sz;i++)
1934     {
1935       if(locs[i]==-1)
1936         {
1937           if(type!=ON_GAUSS_NE)
1938             ret+=dads[i].second-dads[i].first;
1939           else
1940             {
1941               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1942               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1943             }
1944         }
1945       else
1946         {
1947           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1948           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1949         }
1950     }
1951   return ret;
1952 }
1953
1954 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1955 {
1956   std::vector<std::string> ret;
1957   std::set<std::string> ret2;
1958   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1959     {
1960       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1961       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1962         if(ret2.find(*it2)==ret2.end())
1963           {
1964             ret.push_back(*it2);
1965             ret2.insert(*it2);
1966           }
1967     }
1968   return ret;
1969 }
1970
1971 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1972 {
1973   std::vector<std::string> ret;
1974   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1975     {
1976       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1977       ret.insert(ret.end(),tmp.begin(),tmp.end());
1978     }
1979   return ret;
1980 }
1981
1982 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1983 {
1984   std::vector<std::string> ret;
1985   std::set<std::string> ret2;
1986   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1987     {
1988       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1989       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1990         if(ret2.find(*it2)==ret2.end())
1991           {
1992             ret.push_back(*it2);
1993             ret2.insert(*it2);
1994           }
1995     }
1996   return ret;
1997 }
1998
1999 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2000 {
2001   std::vector<std::string> ret;
2002   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2003     {
2004       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2005       ret.insert(ret.end(),tmp.begin(),tmp.end());
2006     }
2007   return ret;
2008 }
2009
2010 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2011 {
2012   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2013     {
2014       if((*it).first==_mesh_name)
2015         {
2016           _mesh_name=(*it).second;
2017           return true;
2018         }
2019     }
2020   return false;
2021 }
2022
2023 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2024                                                       MEDFileFieldGlobsReal& glob)
2025 {
2026   if(_mesh_name!=meshName)
2027     return false;
2028   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2029   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2030   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2031   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2032   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2033   getUndergroundDataArrayExt(entries);
2034   DataArray *arr0=getOrCreateAndGetArray();//tony
2035   if(!arr0)
2036     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2037   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2038   if(!arr0)
2039     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2040   int sz=0;
2041   if(!arr)
2042     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2043   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2044     {
2045       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2046         {
2047           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2048           sz+=(*it).second.second-(*it).second.first;
2049         }
2050       else
2051         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2052     }
2053   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2054   ////////////////////
2055   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2056   int *workI2=explicitIdsOldInMesh->getPointer();
2057   int sz1=0,sz2=0,sid=1;
2058   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2059   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2060   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2061     {
2062       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2063       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2064       int *workI=explicitIdsOldInArr->getPointer();
2065       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2066         {
2067           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2068           (*itL2)->setLocId(sz2);
2069           (*itL2)->_tmp_work1=(*itL2)->getStart();
2070           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2071         }
2072       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2073     }
2074   explicitIdsOldInMesh->reAlloc(sz2);
2075   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2076   ////////////////////
2077   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2078   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2079   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2080   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2081     {
2082       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2083       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2084       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2085     }
2086   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2087   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2088   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2089     {
2090       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2091       int newStart=elt->getLocId();
2092       elt->setLocId((*it)->getGeoType());
2093       elt->setNewStart(newStart);
2094       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2095       entriesKeptNew.push_back(elt);
2096       entriesKeptNew2.push_back(elt);
2097     }
2098   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2099   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2100   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2101   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2102   bool ret=false;
2103   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2104     {
2105       sid=0;
2106       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2107         {
2108           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2109           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2110           }*/
2111       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2112                                                             glob,arr2,otherEntriesNew) || ret;
2113     }
2114   if(!ret)
2115     return false;
2116   // Assign new dispatching
2117   assignNewLeaves(otherEntriesNew);
2118   arr->deepCopyFrom(*arr2);
2119   return true;
2120 }
2121
2122 /*!
2123  * \param [in,out] globalNum a global numbering counter for the renumbering.
2124  * \param [out] its - list of pair (start,stop) kept
2125  */
2126 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2127 {
2128   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2129   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2130     {
2131       std::vector< std::pair<int,int> > its2;
2132       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2133         {
2134           ret.push_back(*it);
2135           its.insert(its.end(),its2.begin(),its2.end());
2136         }
2137     }
2138   _field_pm_pt=ret;
2139 }
2140
2141 /*!
2142  * \param [in,out] globalNum a global numbering counter for the renumbering.
2143  * \param [out] its - list of pair (start,stop) kept
2144  */
2145 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2146 {
2147   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2148   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2149     {
2150       std::vector< std::pair<int,int> > its2;
2151       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2152         {
2153           ret.push_back(*it);
2154           its.insert(its.end(),its2.begin(),its2.end());
2155         }
2156     }
2157   _field_pm_pt=ret;
2158 }
2159
2160 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2161 {
2162   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2163   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2164     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2165   //
2166   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2167   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2168   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2169   for(;it1!=types.end();it1++,it2++)
2170     {
2171       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2172       elt->setLeaves((*it1).second);
2173       *it2=elt;
2174     }
2175   _field_pm_pt=fieldPmPt;
2176 }
2177
2178 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2179 {
2180   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181     (*it)->changePflsRefsNamesGen(mapOfModif);
2182 }
2183
2184 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2185 {
2186   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187     (*it)->changeLocsRefsNamesGen(mapOfModif);
2188 }
2189
2190 /*!
2191  * \param [in] mesh is the whole mesh
2192  */
2193 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2194 {
2195   if(_field_pm_pt.empty())
2196     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2197   //
2198   std::vector< std::pair<int,int> > dads;
2199   std::vector<const DataArrayInt *> pfls;
2200   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2201   std::vector<int> locs,code;
2202   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2203   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2205   // Sort by types
2206   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2207   if(code.empty())
2208     {
2209       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2210       throw INTERP_KERNEL::Exception(oss.str());
2211     }
2212   //
2213   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2214   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2215   if(type!=ON_NODES)
2216     {
2217       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2218       if(!arr)
2219         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2220       else
2221         {
2222           MCAuto<DataArrayInt> arr2(arr);
2223           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2224         }
2225     }
2226   else
2227     {
2228       if(code.size()!=3)
2229         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2230       int nb=code[1];
2231       if(code[2]==-1)
2232         {
2233           if(nb!=mesh->getNumberOfNodes())
2234             {
2235               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2236               oss << " nodes in mesh !";
2237               throw INTERP_KERNEL::Exception(oss.str());
2238             }
2239           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2240         }
2241       else
2242         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2243     }
2244 }
2245
2246 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2247 {
2248   if(_field_pm_pt.empty())
2249     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2250   //
2251   std::vector<std::pair<int,int> > dads;
2252   std::vector<const DataArrayInt *> pfls;
2253   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2254   std::vector<int> locs,code;
2255   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2256   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2257     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2258   // Sort by types
2259   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2260   if(code.empty())
2261     {
2262       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2263       throw INTERP_KERNEL::Exception(oss.str());
2264     }
2265   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2266   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2267   if(type!=ON_NODES)
2268     {
2269       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2270       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2271     }
2272   else
2273     {
2274       if(code.size()!=3)
2275         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2276       int nb=code[1];
2277       if(code[2]==-1)
2278         {
2279           if(nb!=mesh->getNumberOfNodes())
2280             {
2281               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2282               oss << " nodes in mesh !";
2283               throw INTERP_KERNEL::Exception(oss.str());
2284             }
2285         }
2286       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2287     }
2288   //
2289   return 0;
2290 }
2291
2292 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2293 {
2294   int globalSz=0;
2295   int nbOfEntries=0;
2296   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297     {
2298       (*it)->getSizes(globalSz,nbOfEntries);
2299     }
2300   entries.resize(nbOfEntries);
2301   nbOfEntries=0;
2302   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303     {
2304       (*it)->fillValues(nbOfEntries,entries);
2305     }
2306 }
2307
2308 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2309 {
2310   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311     {
2312       if((*it)->getGeoType()==typ)
2313         return (*it)->getLeafGivenLocId(locId);
2314     }
2315   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2316   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2317   oss << "Possiblities are : ";
2318   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2319     {
2320       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2321       oss << "\"" << cm2.getRepr() << "\", ";
2322     }
2323   throw INTERP_KERNEL::Exception(oss.str());
2324 }
2325
2326 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2327 {
2328   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2329     {
2330       if((*it)->getGeoType()==typ)
2331         return (*it)->getLeafGivenLocId(locId);
2332     }
2333   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2334   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2335   oss << "Possiblities are : ";
2336   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2337     {
2338       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2339       oss << "\"" << cm2.getRepr() << "\", ";
2340     }
2341   throw INTERP_KERNEL::Exception(oss.str());
2342 }
2343
2344 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2345 {
2346   int i=0;
2347   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2348   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2349   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2350     {
2351       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2352       if(type==curType)
2353         return i;
2354       else
2355         {
2356           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2357           if(pos>pos2)
2358             it2=it+1;
2359         }
2360     }
2361   int ret=std::distance(_field_pm_pt.begin(),it2);
2362   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2363   return ret;
2364 }
2365
2366 /*!
2367  * 'dads' and 'locs' input parameters have the same number of elements
2368  * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2369  */
2370 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2371                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2372                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2373 {
2374   isPfl=false;
2375   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2376   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2377   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2378   const std::vector<std::string>& infos=getInfo();
2379   da->setInfoOnComponents(infos);
2380   da->setName("");
2381   if(type==ON_GAUSS_PT)
2382     {
2383       int offset=0;
2384       int nbOfArrs=dads.size();
2385       for(int i=0;i<nbOfArrs;i++)
2386         {
2387           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2388           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2389           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2390           MCAuto<DataArrayInt> di=DataArrayInt::New();
2391           di->alloc(nbOfElems,1);
2392           di->iota(offset);
2393           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2394           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2395           offset+=nbOfElems;
2396         }
2397     }
2398   arrOut=da;
2399   return ret.retn();
2400 }
2401
2402 /*!
2403  * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2404  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2405  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2406  * The order of cells in the returned field is those imposed by the profile.
2407  * \param [in] mesh is the global mesh.
2408  */
2409 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2410                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2411                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2412                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2413 {
2414   if(da->isIota(mesh->getNumberOfCells()))
2415     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2416   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2417   m2->setName(mesh->getName().c_str());
2418   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2419   isPfl=true;
2420   return ret.retn();
2421 }
2422
2423 /*!
2424  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2425  */
2426 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2427                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2428                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2429 {
2430   if(da->isIota(mesh->getNumberOfNodes()))
2431     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2432   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2433   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2434   if(meshu)
2435     {
2436       if(meshu->getNodalConnectivity()==0)
2437         {
2438           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2439           int nb=da->getNbOfElems();
2440           const int *ptr=da->getConstPointer();
2441           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2442           meshuc->allocateCells(nb);
2443           for(int i=0;i<nb;i++)
2444             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2445           meshuc->finishInsertingCells();
2446           ret->setMesh(meshuc);
2447           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2448           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2449           disc->checkCoherencyBetween(meshuc,arrOut);
2450           return ret.retn();
2451         }
2452     }
2453   //
2454   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2455   isPfl=true;
2456   DataArrayInt *arr2=0;
2457   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2458   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2459   MCAuto<DataArrayInt> arr3(arr2);
2460   int nnodes=mesh2->getNumberOfNodes();
2461   if(nnodes==(int)da->getNbOfElems())
2462     {
2463       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2464       arrOut->renumberInPlace(da3->getConstPointer());
2465       mesh2->setName(mesh->getName().c_str());
2466       ret->setMesh(mesh2);
2467       return ret.retn();
2468     }
2469   else
2470     {
2471       std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2472       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2473       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2474       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2475       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2476       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2477       throw INTERP_KERNEL::Exception(oss.str());
2478     }
2479   return 0;
2480 }
2481
2482 /*!
2483  * This method is the most light method of field retrieving.
2484  */
2485 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2486 {
2487   if(!pflIn)
2488     {
2489       pflOut=DataArrayInt::New();
2490       pflOut->alloc(nbOfElems,1);
2491       pflOut->iota(0);
2492     }
2493   else
2494     {
2495       pflOut=const_cast<DataArrayInt*>(pflIn);
2496       pflOut->incrRef();
2497     }
2498   MCAuto<DataArrayInt> safePfl(pflOut);
2499   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2500   const std::vector<std::string>& infos=getInfo();
2501   int nbOfComp=infos.size();
2502   for(int i=0;i<nbOfComp;i++)
2503     da->setInfoOnComponent(i,infos[i].c_str());
2504   safePfl->incrRef();
2505   return da.retn();
2506 }
2507
2508
2509 /// @cond INTERNAL
2510
2511 class MFFPMIter
2512 {
2513 public:
2514   static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2515   static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2516   virtual ~MFFPMIter() { }
2517   virtual void begin() = 0;
2518   virtual bool finished() const = 0;
2519   virtual void next() = 0;
2520   virtual int current() const = 0;
2521 };
2522
2523 class MFFPMIterSimple : public MFFPMIter
2524 {
2525 public:
2526   MFFPMIterSimple():_pos(0) { }
2527   void begin() { _pos=0; }
2528   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2529   void next() { _pos++; }
2530   int current() const { return _pos; }
2531 private:
2532   int _pos;
2533 };
2534
2535 class MFFPMIter2 : public MFFPMIter
2536 {
2537 public:
2538   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2539   void begin() { _it=_ids.begin(); }
2540   bool finished() const { return _it==_ids.end(); }
2541   void next() { _it++; }
2542   int current() const { return *_it; }
2543 private:
2544   std::vector<int> _ids;
2545   std::vector<int>::const_iterator _it;
2546 };
2547
2548 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2549 {
2550   if(!entities)
2551     return new MFFPMIterSimple;
2552   else
2553     {
2554       std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2555       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2556         {
2557           if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2558             tmp.push_back((*it).second);
2559         }
2560       return new MFFPMIter2(tmp);
2561     }
2562 }
2563
2564 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2565 {
2566   if(!entities)
2567     return true;
2568   else
2569     {
2570       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2571         if((*it).first==ON_NODES)
2572           return true;
2573       return false;
2574     }
2575 }
2576
2577 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2578 {
2579   std::size_t sz(cts.size());
2580   _ids.resize(sz);
2581   for(std::size_t i=0;i<sz;i++)
2582     {
2583       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2584       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2585         _ids[i]=(int)std::distance(typmai2,loc);
2586       else
2587         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2588     }
2589 }
2590
2591 /// @endcond
2592
2593 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2594     _father(fath)
2595 {
2596   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2597   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2598   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2599   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2600   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2601   for(iter0->begin();!iter0->finished();iter0->next())
2602     {
2603       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2604       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2605       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2606       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2607       if(nbProfile>0 || nbProfile2>0)
2608         {
2609           const PartDefinition *pd(0);
2610           if(mmu)
2611             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2612           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2613           if(nbProfile>0)
2614             _mesh_name=name0;
2615           else
2616             _mesh_name=name1;
2617         }
2618     }
2619   if(MFFPMIter::IsPresenceOfNode(entities))
2620     {
2621       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2622       if(nbProfile>0)
2623         {
2624           const PartDefinition *pd(0);
2625           if(mmu)
2626             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2627           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2628           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2629         }
2630     }
2631 }
2632
2633 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2634 {
2635   copyTinyInfoFrom(mesh);
2636 }
2637
2638 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2639 {
2640   if(id>=(int)_pfls.size())
2641     _pfls.resize(id+1);
2642   _pfls[id]=DataArrayInt::New();
2643   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2644   _pfls[id]->setName(pflName);
2645   _pfls[id]->alloc(lgth,1);
2646   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2647   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2648 }
2649
2650 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2651 {
2652   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2653   int sz;
2654   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2655   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2656   if(i>=(int)_pfls.size())
2657     _pfls.resize(i+1);
2658   _pfls[i]=DataArrayInt::New();
2659   _pfls[i]->alloc(sz,1);
2660   _pfls[i]->setName(pflCpp.c_str());
2661   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2662   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2663 }
2664
2665 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2666 {
2667   int nbOfPfls=_pfls.size();
2668   for(int i=0;i<nbOfPfls;i++)
2669     {
2670       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2671       cpy->applyLin(1,1,0);
2672       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2673       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2674       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2675     }
2676   //
2677   int nbOfLocs=_locs.size();
2678   for(int i=0;i<nbOfLocs;i++)
2679     _locs[i]->writeLL(fid);
2680 }
2681
2682 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2683 {
2684   std::vector<std::string> pfls=getPfls();
2685   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2686     {
2687       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2688       if(it2==pfls.end())
2689         {
2690           _pfls.push_back(*it);
2691         }
2692       else
2693         {
2694           int id=std::distance(pfls.begin(),it2);
2695           if(!(*it)->isEqual(*_pfls[id]))
2696             {
2697               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2698               throw INTERP_KERNEL::Exception(oss.str());
2699             }
2700         }
2701     }
2702   std::vector<std::string> locs=getLocs();
2703   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2704     {
2705       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2706       if(it2==locs.end())
2707         {
2708           _locs.push_back(*it);
2709         }
2710       else
2711         {
2712           int id=std::distance(locs.begin(),it2);
2713           if(!(*it)->isEqual(*_locs[id],eps))
2714             {
2715               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2716               throw INTERP_KERNEL::Exception(oss.str());
2717             }
2718         }
2719     }
2720 }
2721
2722 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2723 {
2724   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2725     getProfile((*it).c_str());
2726 }
2727
2728 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2729 {
2730   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2731     getLocalization((*it).c_str());
2732 }
2733
2734 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2735 {
2736   std::vector<std::string> profiles=real.getPflsReallyUsed();
2737   int sz=profiles.size();
2738   _pfls.resize(sz);
2739   for(int i=0;i<sz;i++)
2740     loadProfileInFile(fid,i,profiles[i].c_str());
2741   //
2742   std::vector<std::string> locs=real.getLocsReallyUsed();
2743   sz=locs.size();
2744   _locs.resize(sz);
2745   for(int i=0;i<sz;i++)
2746     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2747 }
2748
2749 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2750 {
2751   int nProfil=MEDnProfile(fid);
2752   for(int i=0;i<nProfil;i++)
2753     loadProfileInFile(fid,i);
2754   int sz=MEDnLocalization(fid);
2755   _locs.resize(sz);
2756   for(int i=0;i<sz;i++)
2757     {
2758       _locs[i]=MEDFileFieldLoc::New(fid,i);
2759     }
2760 }
2761
2762 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2763 {
2764   return new MEDFileFieldGlobs(fname);
2765 }
2766
2767 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2768 {
2769   return new MEDFileFieldGlobs;
2770 }
2771
2772 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2773 {
2774   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2775 }
2776
2777 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2778 {
2779   std::vector<const BigMemoryObject *> ret;
2780   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2781     ret.push_back((const DataArrayInt *)*it);
2782   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2783     ret.push_back((const MEDFileFieldLoc *)*it);
2784   return ret;
2785 }
2786
2787 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2788 {
2789   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2790   std::size_t i=0;
2791   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2792     {
2793       if((const DataArrayInt *)*it)
2794         ret->_pfls[i]=(*it)->deepCopy();
2795     }
2796   i=0;
2797   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2798     {
2799       if((const MEDFileFieldLoc*)*it)
2800         ret->_locs[i]=(*it)->deepCopy();
2801     }
2802   return ret.retn();
2803 }
2804
2805 /*!
2806  * \throw if a profile in \a pfls in not in \a this.
2807  * \throw if a localization in \a locs in not in \a this.
2808  * \sa MEDFileFieldGlobs::deepCpyPart
2809  */
2810 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2811 {
2812   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2813   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2814     {
2815       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2816       if(!pfl)
2817         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2818       pfl->incrRef();
2819       MCAuto<DataArrayInt> pfl2(pfl);
2820       ret->_pfls.push_back(pfl2);
2821     }
2822   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2823     {
2824       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2825       if(!loc)
2826         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2827       loc->incrRef();
2828       MCAuto<MEDFileFieldLoc> loc2(loc);
2829       ret->_locs.push_back(loc2);
2830     }
2831   ret->setFileName(getFileName());
2832   return ret.retn();
2833 }
2834
2835 /*!
2836  * \throw if a profile in \a pfls in not in \a this.
2837  * \throw if a localization in \a locs in not in \a this.
2838  * \sa MEDFileFieldGlobs::shallowCpyPart
2839  */
2840 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2841 {
2842   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2843   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2844     {
2845       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2846       if(!pfl)
2847         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2848       ret->_pfls.push_back(pfl->deepCopy());
2849     }
2850   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2851     {
2852       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2853       if(!loc)
2854         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2855       ret->_locs.push_back(loc->deepCopy());
2856     }
2857   ret->setFileName(getFileName());
2858   return ret.retn();
2859 }
2860
2861 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2862 {
2863 }
2864
2865 MEDFileFieldGlobs::MEDFileFieldGlobs()
2866 {
2867 }
2868
2869 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2870 {
2871 }
2872
2873 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2874 {
2875   oss << "Profiles :\n";
2876   std::size_t n=_pfls.size();
2877   for(std::size_t i=0;i<n;i++)
2878     {
2879       oss << "  - #" << i << " ";
2880       const DataArrayInt *pfl=_pfls[i];
2881       if(pfl)
2882         oss << "\"" << pfl->getName() << "\"\n";
2883       else
2884         oss << "EMPTY !\n";
2885     }
2886   n=_locs.size();
2887   oss << "Localizations :\n";
2888   for(std::size_t i=0;i<n;i++)
2889     {
2890       oss << "  - #" << i << " ";
2891       const MEDFileFieldLoc *loc=_locs[i];
2892       if(loc)
2893         loc->simpleRepr(oss);
2894       else
2895         oss<< "EMPTY !\n";
2896     }
2897 }
2898
2899 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2900 {
2901   _file_name=fileName;
2902 }
2903
2904 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2905 {
2906   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2907     {
2908       DataArrayInt *elt(*it);
2909       if(elt)
2910         {
2911           std::string name(elt->getName());
2912           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2913             {
2914               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2915                 {
2916                   elt->setName((*it2).second.c_str());
2917                   return;
2918                 }
2919             }
2920         }
2921     }
2922 }
2923
2924 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2925 {
2926   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2927     {
2928       MEDFileFieldLoc *elt(*it);
2929       if(elt)
2930         {
2931           std::string name(elt->getName());
2932           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2933             {
2934               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2935                 {
2936                   elt->setName((*it2).second.c_str());
2937                   return;
2938                 }
2939             }
2940         }
2941     }
2942 }
2943
2944 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2945 {
2946   if(locId<0 || locId>=(int)_locs.size())
2947     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2948   return _locs[locId]->getNbOfGaussPtPerCell();
2949 }
2950
2951 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2952 {
2953   return getLocalizationFromId(getLocalizationId(locName));
2954 }
2955
2956 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2957 {
2958   if(locId<0 || locId>=(int)_locs.size())
2959     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2960   return *_locs[locId];
2961 }
2962
2963 /// @cond INTERNAL
2964 namespace MEDCouplingImpl
2965 {
2966   class LocFinder
2967   {
2968   public:
2969     LocFinder(const std::string& loc):_loc(loc) { }
2970     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2971   private:
2972     const std::string &_loc;
2973   };
2974
2975   class PflFinder
2976   {
2977   public:
2978     PflFinder(const std::string& pfl):_pfl(pfl) { }
2979     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2980   private:
2981     const std::string& _pfl;
2982   };
2983 }
2984 /// @endcond
2985
2986 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2987 {
2988   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2989   if(it==_locs.end())
2990     {
2991       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2992       for(it=_locs.begin();it!=_locs.end();it++)
2993         oss << "\"" << (*it)->getName() << "\", ";
2994       throw INTERP_KERNEL::Exception(oss.str());
2995     }
2996   return std::distance(_locs.begin(),it);
2997 }
2998
2999 /*!
3000  * The returned value is never null.
3001  */
3002 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3003 {
3004   std::string pflNameCpp(pflName);
3005   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3006   if(it==_pfls.end())
3007     {
3008       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3009       for(it=_pfls.begin();it!=_pfls.end();it++)
3010         oss << "\"" << (*it)->getName() << "\", ";
3011       throw INTERP_KERNEL::Exception(oss.str());
3012     }
3013   return *it;
3014 }
3015
3016 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3017 {
3018   if(pflId<0 || pflId>=(int)_pfls.size())
3019     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3020   return _pfls[pflId];
3021 }
3022
3023 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3024 {
3025   if(locId<0 || locId>=(int)_locs.size())
3026     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3027   return *_locs[locId];
3028 }
3029
3030 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3031 {
3032   return getLocalizationFromId(getLocalizationId(locName));
3033 }
3034
3035 /*!
3036  * The returned value is never null.
3037  */
3038 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3039 {
3040   std::string pflNameCpp(pflName);
3041   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3042   if(it==_pfls.end())
3043     {
3044       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3045       for(it=_pfls.begin();it!=_pfls.end();it++)
3046         oss << "\"" << (*it)->getName() << "\", ";
3047       throw INTERP_KERNEL::Exception(oss.str());
3048     }
3049   return *it;
3050 }
3051
3052 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3053 {
3054   if(pflId<0 || pflId>=(int)_pfls.size())
3055     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3056   return _pfls[pflId];
3057 }
3058
3059 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3060 {
3061   std::vector< MCAuto<DataArrayInt> > newPfls;
3062   int i=0;
3063   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3064     {
3065       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3066         newPfls.push_back(*it);
3067     }
3068   _pfls=newPfls;
3069 }
3070
3071 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3072 {
3073   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3074   int i=0;
3075   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3076     {
3077       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3078         newLocs.push_back(*it);
3079     }
3080   _locs=newLocs;
3081 }
3082
3083 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3084 {
3085   int sz=_pfls.size();
3086   std::vector<std::string> ret(sz);
3087   for(int i=0;i<sz;i++)
3088     ret[i]=_pfls[i]->getName();
3089   return ret;
3090 }
3091
3092 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3093 {
3094   int sz=_locs.size();
3095   std::vector<std::string> ret(sz);
3096   for(int i=0;i<sz;i++)
3097     ret[i]=_locs[i]->getName();
3098   return ret;
3099 }
3100
3101 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3102 {
3103   std::vector<std::string> v=getPfls();
3104   std::string s(pflName);
3105   return std::find(v.begin(),v.end(),s)!=v.end();
3106 }
3107
3108 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3109 {
3110   std::vector<std::string> v=getLocs();
3111   std::string s(locName);
3112   return std::find(v.begin(),v.end(),s)!=v.end();
3113 }
3114
3115 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3116 {
3117   std::map<int,std::vector<int> > m;
3118   int i=0;
3119   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3120     {
3121       const DataArrayInt *tmp=(*it);
3122       if(tmp)
3123         {
3124           m[tmp->getHashCode()].push_back(i);
3125         }
3126     }
3127   std::vector< std::vector<int> > ret;
3128   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3129     {
3130       if((*it2).second.size()>1)
3131         {
3132           std::vector<int> ret0;
3133           bool equalityOrNot=false;
3134           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3135             {
3136               std::vector<int>::const_iterator it4=it3; it4++;
3137               for(;it4!=(*it2).second.end();it4++)
3138                 {
3139                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3140                     {
3141                       if(!equalityOrNot)
3142                         ret0.push_back(*it3);
3143                       ret0.push_back(*it4);
3144                       equalityOrNot=true;
3145                     }
3146                 }
3147             }
3148           if(!ret0.empty())
3149             ret.push_back(ret0);
3150         }
3151     }
3152   return ret;
3153 }
3154
3155 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3156 {
3157   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3158 }
3159
3160 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3161 {
3162   std::string name(pfl->getName());
3163   if(name.empty())
3164     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3165   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3166     if(name==(*it)->getName())
3167       {
3168         if(!pfl->isEqual(*(*it)))
3169           {
3170             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3171             throw INTERP_KERNEL::Exception(oss.str());
3172           }
3173       }
3174   pfl->incrRef();
3175   _pfls.push_back(pfl);
3176 }
3177
3178 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3179 {
3180   std::string name(locName);
3181   if(name.empty())
3182     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3183   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3184   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3185     if((*it)->isName(locName))
3186       {
3187         if(!(*it)->isEqual(*obj,1e-12))
3188           {
3189             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3190             throw INTERP_KERNEL::Exception(oss.str());
3191           }
3192       }
3193   _locs.push_back(obj);
3194 }
3195
3196 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3197 {
3198   std::vector<std::string> names=getPfls();
3199   return CreateNewNameNotIn("NewPfl_",names);
3200 }
3201
3202 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3203 {
3204   std::vector<std::string> names=getLocs();
3205   return CreateNewNameNotIn("NewLoc_",names);
3206 }
3207
3208 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3209 {
3210   for(std::size_t sz=0;sz<100000;sz++)
3211     {
3212       std::ostringstream tryName;
3213       tryName << prefix << sz;
3214       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3215         return tryName.str();
3216     }
3217   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3218 }
3219
3220 /*!
3221  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3222  *  \param [in] fname - the file name.
3223  */
3224 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3225 {
3226 }
3227
3228 /*!
3229  * Creates an empty MEDFileFieldGlobsReal.
3230  */
3231 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3232 {
3233 }
3234
3235 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3236 {
3237   return 0;
3238 }
3239
3240 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3241 {
3242   std::vector<const BigMemoryObject *> ret;
3243   ret.push_back((const MEDFileFieldGlobs *)_globals);
3244   return ret;
3245 }
3246
3247 /*!
3248  * Returns a string describing profiles and Gauss points held in \a this.
3249  *  \return std::string - the description string.
3250  */
3251 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3252 {
3253   const MEDFileFieldGlobs *glob=_globals;
3254   std::ostringstream oss2; oss2 << glob;
3255   std::string stars(oss2.str().length(),'*');
3256   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3257   if(glob)
3258     glob->simpleRepr(oss);
3259   else
3260     oss << "NO GLOBAL INFORMATION !\n";
3261 }
3262
3263 void MEDFileFieldGlobsReal::resetContent()
3264 {
3265   _globals=MEDFileFieldGlobs::New();
3266 }
3267
3268 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3269 {
3270 }
3271
3272 /*!
3273  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3274  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3275  */
3276 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3277 {
3278   _globals=other._globals;
3279 }
3280
3281 /*!
3282  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3283  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3284  */
3285 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3286 {
3287   const MEDFileFieldGlobs *otherg(other._globals);
3288   if(!otherg)
3289     return ;
3290   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3291 }
3292
3293 /*!
3294  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3295  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3296  */
3297 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3298 {
3299   const MEDFileFieldGlobs *otherg(other._globals);
3300   if(!otherg)
3301     return ;
3302   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3303 }
3304
3305 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3306 {
3307   _globals=other._globals;
3308   if((const MEDFileFieldGlobs *)_globals)
3309     _globals=other._globals->deepCopy();
3310 }
3311
3312 /*!
3313  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3314  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3315  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3316  *         \a this and \a other MEDFileFieldGlobsReal.
3317  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3318  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3319  */
3320 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3321 {
3322   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3323   if(thisGlobals==otherGlobals)
3324     return ;
3325   if(!thisGlobals)
3326     {
3327       _globals=other._globals;
3328       return ;
3329     }
3330   _globals->appendGlobs(*other._globals,eps);
3331 }
3332
3333 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3334 {
3335   checkGlobsPflsPartCoherency();
3336   checkGlobsLocsPartCoherency();
3337 }
3338
3339 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3340 {
3341   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3342 }
3343
3344 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3345 {
3346   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3347 }
3348
3349 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3350 {
3351   contentNotNull()->loadProfileInFile(fid,id,pflName);
3352 }
3353
3354 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3355 {
3356   contentNotNull()->loadProfileInFile(fid,id);
3357 }
3358
3359 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3360 {
3361   contentNotNull()->loadGlobals(fid,*this);
3362 }
3363
3364 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3365 {
3366   contentNotNull()->loadAllGlobals(fid);
3367 }
3368
3369 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3370 {
3371   contentNotNull()->writeGlobals(fid,opt);
3372 }
3373
3374 /*!
3375  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3376  * or getPflsReallyUsedMulti().
3377  *  \return std::vector<std::string> - a sequence of names of all profiles.
3378  */
3379 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3380 {
3381   return contentNotNull()->getPfls();
3382 }
3383
3384 /*!
3385  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3386  * or getLocsReallyUsedMulti().
3387  *  \return std::vector<std::string> - a sequence of names of all localizations.
3388  */
3389 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3390 {
3391   return contentNotNull()->getLocs();
3392 }
3393
3394 /*!
3395  * Checks if the profile with a given name exists.
3396  *  \param [in] pflName - the profile name of interest.
3397  *  \return bool - \c true if the profile named \a pflName exists.
3398  */
3399 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3400 {
3401   return contentNotNull()->existsPfl(pflName);
3402 }
3403
3404 /*!
3405  * Checks if the localization with a given name exists.
3406  *  \param [in] locName - the localization name of interest.
3407  *  \return bool - \c true if the localization named \a locName exists.
3408  */
3409 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3410 {
3411   return contentNotNull()->existsLoc(locName);
3412 }
3413
3414 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3415 {
3416   return contentNotNull()->createNewNameOfPfl();
3417 }
3418
3419 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3420 {
3421   return contentNotNull()->createNewNameOfLoc();
3422 }
3423
3424 /*!
3425  * Sets the name of a MED file.
3426  *  \param [inout] fileName - the file name.
3427  */
3428 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3429 {
3430   contentNotNull()->setFileName(fileName);
3431 }
3432
3433 /*!
3434  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3435  * in the same order.
3436  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3437  *          Each item of this sequence is a vector containing ids of equal profiles.
3438  */
3439 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3440 {
3441   return contentNotNull()->whichAreEqualProfiles();
3442 }
3443
3444 /*!
3445  * Finds equal localizations.
3446  *  \param [in] eps - a precision used to compare real values of the localizations.
3447  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3448  *          Each item of this sequence is a vector containing ids of equal localizations.
3449  */
3450 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3451 {
3452   return contentNotNull()->whichAreEqualLocs(eps);
3453 }
3454
3455 /*!
3456  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3457  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3458  *        this sequence is a pair whose 
3459  *        - the first item is a vector of profile names to replace by the second item,
3460  *        - the second item is a profile name to replace every profile name of the first item.
3461  */
3462 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3463 {
3464   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3465 }
3466
3467 /*!
3468  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3469  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3470  *        this sequence is a pair whose 
3471  *        - the first item is a vector of localization names to replace by the second item,
3472  *        - the second item is a localization name to replace every localization name of the first item.
3473  */
3474 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3475 {
3476   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3477 }
3478
3479 /*!
3480  * Replaces references to some profiles (a reference is a profile name) by references
3481  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3482  * them-selves accordingly. <br>
3483  * This method is a generalization of changePflName().
3484  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3485  *        this sequence is a pair whose 
3486  *        - the first item is a vector of profile names to replace by the second item,
3487  *        - the second item is a profile name to replace every profile of the first item.
3488  * \sa changePflsRefsNamesGen()
3489  * \sa changePflName()
3490  */
3491 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3492 {
3493   changePflsRefsNamesGen(mapOfModif);
3494   changePflsNamesInStruct(mapOfModif);
3495 }
3496
3497 /*!
3498  * Replaces references to some localizations (a reference is a localization name) by references
3499  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3500  * them-selves accordingly. <br>
3501  * This method is a generalization of changeLocName().
3502  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3503  *        this sequence is a pair whose 
3504  *        - the first item is a vector of localization names to replace by the second item,
3505  *        - the second item is a localization name to replace every localization of the first item.
3506  * \sa changeLocsRefsNamesGen()
3507  * \sa changeLocName()
3508  */
3509 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3510 {
3511   changeLocsRefsNamesGen(mapOfModif);
3512   changeLocsNamesInStruct(mapOfModif);
3513 }
3514
3515 /*!
3516  * Renames the profile having a given name and updates references to this profile.
3517  *  \param [in] oldName - the name of the profile to rename.
3518  *  \param [in] newName - a new name of the profile.
3519  * \sa changePflsNames().
3520  */
3521 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3522 {
3523   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3524   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3525   mapOfModif[0]=p;
3526   changePflsNames(mapOfModif);
3527 }
3528
3529 /*!
3530  * Renames the localization having a given name and updates references to this localization.
3531  *  \param [in] oldName - the name of the localization to rename.
3532  *  \param [in] newName - a new name of the localization.
3533  * \sa changeLocsNames().
3534  */
3535 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3536 {
3537   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3538   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3539   mapOfModif[0]=p;
3540   changeLocsNames(mapOfModif);
3541 }
3542
3543 /*!
3544  * Removes duplicated profiles. Returns a map used to update references to removed 
3545  * profiles via changePflsRefsNamesGen().
3546  * Equal profiles are found using whichAreEqualProfiles().
3547  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3548  *          a sequence describing the performed replacements of profiles. Each element of
3549  *          this sequence is a pair whose
3550  *          - the first item is a vector of profile names replaced by the second item,
3551  *          - the second item is a profile name replacing every profile of the first item.
3552  */
3553 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3554 {
3555   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3556   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3557   int i=0;
3558   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3559     {
3560       std::vector< std::string > tmp((*it).size());
3561       int j=0;
3562       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3563         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3564       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3565       ret[i]=p;
3566       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3567       killProfileIds(tmp2);
3568     }
3569   changePflsRefsNamesGen(ret);
3570   return ret;
3571 }
3572
3573 /*!
3574  * Removes duplicated localizations. Returns a map used to update references to removed 
3575  * localizations via changeLocsRefsNamesGen().
3576  * Equal localizations are found using whichAreEqualLocs().
3577  *  \param [in] eps - a precision used to compare real values of the localizations.
3578  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3579  *          a sequence describing the performed replacements of localizations. Each element of
3580  *          this sequence is a pair whose
3581  *          - the first item is a vector of localization names replaced by the second item,
3582  *          - the second item is a localization name replacing every localization of the first item.
3583  */
3584 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3585 {
3586   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3587   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3588   int i=0;
3589   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3590     {
3591       std::vector< std::string > tmp((*it).size());
3592       int j=0;
3593       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3594         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3595       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3596       ret[i]=p;
3597       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3598       killLocalizationIds(tmp2);
3599     }
3600   changeLocsRefsNamesGen(ret);
3601   return ret;
3602 }
3603
3604 /*!
3605  * Returns number of Gauss points per cell in a given localization.
3606  *  \param [in] locId - an id of the localization of interest.
3607  *  \return int - the number of the Gauss points per cell.
3608  */
3609 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3610 {
3611   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3612 }
3613
3614 /*!
3615  * Returns an id of a localization by its name.
3616  *  \param [in] loc - the localization name of interest.
3617  *  \return int - the id of the localization.
3618  *  \throw If there is no a localization named \a loc.
3619  */
3620 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3621 {
3622   return contentNotNull()->getLocalizationId(loc);
3623 }
3624
3625 /*!
3626  * Returns the name of the MED file.
3627  *  \return const std::string&  - the MED file name.
3628  */
3629 std::string MEDFileFieldGlobsReal::getFileName() const
3630 {
3631   return contentNotNull()->getFileName();
3632 }
3633
3634 /*!
3635  * Returns a localization object by its name.
3636  *  \param [in] locName - the name of the localization of interest.
3637  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3638  *  \throw If there is no a localization named \a locName.
3639  */
3640 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3641 {
3642   return contentNotNull()->getLocalization(locName);
3643 }
3644
3645 /*!
3646  * Returns a localization object by its id.
3647  *  \param [in] locId - the id of the localization of interest.
3648  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3649  *  \throw If there is no a localization with id \a locId.
3650  */
3651 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3652 {
3653   return contentNotNull()->getLocalizationFromId(locId);
3654 }
3655
3656 /*!
3657  * Returns a profile array by its name.
3658  *  \param [in] pflName - the name of the profile of interest.
3659  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3660  *  \throw If there is no a profile named \a pflName.
3661  */
3662 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3663 {
3664   return contentNotNull()->getProfile(pflName);
3665 }
3666
3667 /*!
3668  * Returns a profile array by its id.
3669  *  \param [in] pflId - the id of the profile of interest.
3670  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3671  *  \throw If there is no a profile with id \a pflId.
3672  */
3673 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3674 {
3675   return contentNotNull()->getProfileFromId(pflId);
3676 }
3677
3678 /*!
3679  * Returns a localization object, apt for modification, by its id.
3680  *  \param [in] locId - the id of the localization of interest.
3681  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3682  *          having the id \a locId.
3683  *  \throw If there is no a localization with id \a locId.
3684  */
3685 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3686 {
3687   return contentNotNull()->getLocalizationFromId(locId);
3688 }
3689
3690 /*!
3691  * Returns a localization object, apt for modification, by its name.
3692  *  \param [in] locName - the name of the localization of interest.
3693  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3694  *          having the name \a locName.
3695  *  \throw If there is no a localization named \a locName.
3696  */
3697 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3698 {
3699   return contentNotNull()->getLocalization(locName);
3700 }
3701
3702 /*!
3703  * Returns a profile array, apt for modification, by its name.
3704  *  \param [in] pflName - the name of the profile of interest.
3705  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3706  *  \throw If there is no a profile named \a pflName.
3707  */
3708 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3709 {
3710   return contentNotNull()->getProfile(pflName);
3711 }
3712
3713 /*!
3714  * Returns a profile array, apt for modification, by its id.
3715  *  \param [in] pflId - the id of the profile of interest.
3716  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3717  *  \throw If there is no a profile with id \a pflId.
3718  */
3719 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3720 {
3721   return contentNotNull()->getProfileFromId(pflId);
3722 }
3723
3724 /*!
3725  * Removes profiles given by their ids. No data is updated to track this removal.
3726  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3727  */
3728 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3729 {
3730   contentNotNull()->killProfileIds(pflIds);
3731 }
3732
3733 /*!
3734  * Removes localizations given by their ids. No data is updated to track this removal.
3735  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3736  */
3737 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3738 {
3739   contentNotNull()->killLocalizationIds(locIds);
3740 }
3741
3742 /*!
3743  * Stores a profile array.
3744  *  \param [in] pfl - the profile array to store.
3745  *  \throw If the name of \a pfl is empty.
3746  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3747  *         different ids.
3748  */
3749 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3750 {
3751   contentNotNull()->appendProfile(pfl);
3752 }
3753
3754 /*!
3755  * Adds a new localization of Gauss points.
3756  *  \param [in] locName - the name of the new localization.
3757  *  \param [in] geoType - a geometrical type of the reference cell.
3758  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3759  *         must be \c nbOfNodesPerCell * \c dimOfType.
3760  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3761  *         must be  _wg_.size() * \c dimOfType.
3762  *  \param [in] w - the weights of Gauss points.
3763  *  \throw If \a locName is empty.
3764  *  \throw If a localization with the name \a locName already exists but is
3765  *         different form the new one.
3766  */
3767 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3768 {
3769   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3770 }
3771
3772 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3773 {
3774   MEDFileFieldGlobs *g(_globals);
3775   if(!g)
3776     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3777   return g;
3778 }
3779
3780 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3781 {
3782   const MEDFileFieldGlobs *g(_globals);
3783   if(!g)
3784     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3785   return g;
3786 }
3787
3788 //= MEDFileFieldNameScope
3789
3790 MEDFileFieldNameScope::MEDFileFieldNameScope()
3791 {
3792 }
3793
3794 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3795 {
3796 }
3797
3798 /*!
3799  * Returns the name of \a this field.
3800  *  \return std::string - a string containing the field name.
3801  */
3802 std::string MEDFileFieldNameScope::getName() const
3803 {
3804   return _name;
3805 }
3806
3807 /*!
3808  * Sets name of \a this field
3809  *  \param [in] name - the new field name.
3810  */
3811 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3812 {
3813   _name=fieldName;
3814 }
3815
3816 std::string MEDFileFieldNameScope::getDtUnit() const
3817 {
3818   return _dt_unit;
3819 }
3820
3821 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3822 {
3823   _dt_unit=dtUnit;
3824 }
3825
3826 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3827 {
3828   _name=other._name;
3829   _dt_unit=other._dt_unit;
3830 }
3831
3832 //= MEDFileAnyTypeField1TSWithoutSDA
3833
3834 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3835 {
3836   _field_per_mesh.resize(other._field_per_mesh.size());
3837   std::size_t i=0;
3838   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3839     {
3840       if((const MEDFileFieldPerMesh *)*it)
3841         _field_per_mesh[i]=(*it)->deepCopy(this);
3842     }
3843 }
3844
3845 /*!
3846  * Prints a string describing \a this field into a stream. This string is outputted 
3847  * by \c print Python command.
3848  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3849  *  \param [in,out] oss - the out stream.
3850  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3851  *          info id printed, else, not.
3852  */
3853 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3854 {
3855   std::string startOfLine(bkOffset,' ');
3856   oss << startOfLine << "Field ";
3857   if(bkOffset==0)
3858     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3859   oss << "on one time Step ";
3860   if(f1tsId>=0)
3861     oss << "(" << f1tsId << ") ";
3862   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3863   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3864   const DataArray *arr=getUndergroundDataArray();
3865   if(arr)
3866     {
3867       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3868       if(f1tsId<0)
3869         {
3870           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3871           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3872             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3873         }
3874       if(arr->isAllocated())
3875         {
3876           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3877         }
3878       else
3879         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3880     }
3881   else
3882     {
3883       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3884     }
3885   oss << startOfLine << "----------------------" << std::endl;
3886   if(!_field_per_mesh.empty())
3887     {
3888       int i=0;
3889       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3890         {
3891           const MEDFileFieldPerMesh *cur=(*it2);
3892           if(cur)
3893             cur->simpleRepr(bkOffset,oss,i);
3894           else
3895             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3896         }
3897     }
3898   else
3899     {
3900       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3901     }
3902   oss << startOfLine << "----------------------" << std::endl;
3903 }
3904
3905 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3906 {
3907   const DataArray *arr(getUndergroundDataArray());
3908   if(!arr)
3909     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3910   int nbOfCompo=arr->getNumberOfComponents();
3911   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3912   for(int i=0;i<nbOfCompo;i++)
3913     {
3914       ret[i]=deepCopy();
3915       std::vector<int> v(1,i);
3916       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3917       ret[i]->setArray(arr2);
3918     }
3919   return ret;
3920 }
3921
3922 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3923 {
3924 }
3925
3926 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3927 {
3928 }
3929
3930 /*!
3931  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3932  * empty. Returns -1 if this in on nodes.
3933  *  \return int - the dimension of \a this.
3934  */
3935 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3936 {
3937   int ret=-2;
3938   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3939     (*it)->getDimension(ret);
3940   return ret;
3941 }
3942
3943 /*!
3944  * Returns the mesh name.
3945  *  \return std::string - a string holding the mesh name.
3946  *  \throw If \c _field_per_mesh.empty()
3947  */
3948 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3949 {
3950   if(_field_per_mesh.empty())
3951     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3952   return _field_per_mesh[0]->getMeshName();
3953 }
3954
3955 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3956 {
3957   std::string oldName(getMeshName());
3958   std::vector< std::pair<std::string,std::string> > v(1);
3959   v[0].first=oldName; v[0].second=newMeshName;
3960   changeMeshNames(v);
3961 }
3962
3963 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3964 {
3965   bool ret=false;
3966   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3967     {
3968       MEDFileFieldPerMesh *cur(*it);
3969       if(cur)
3970         ret=cur->changeMeshNames(modifTab) || ret;
3971     }
3972   return ret;
3973 }
3974
3975 /*!
3976  * Returns the number of iteration of the state of underlying mesh.
3977  *  \return int - the iteration number.
3978  *  \throw If \c _field_per_mesh.empty()
3979  */
3980 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3981 {
3982   if(_field_per_mesh.empty())
3983     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3984   return _field_per_mesh[0]->getMeshIteration();
3985 }
3986
3987 /*!
3988  * Returns the order number of iteration of the state of underlying mesh.
3989  *  \return int - the order number.
3990  *  \throw If \c _field_per_mesh.empty()
3991  */
3992 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3993 {
3994   if(_field_per_mesh.empty())
3995     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3996   return _field_per_mesh[0]->getMeshOrder();
3997 }
3998
3999 /*!
4000  * Checks if \a this field is tagged by a given iteration number and a given
4001  * iteration order number.
4002  *  \param [in] iteration - the iteration number of interest.
4003  *  \param [in] order - the iteration order number of interest.
4004  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4005  *          \a this->getOrder() == \a order.
4006  */
4007 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4008 {
4009   return iteration==_iteration && order==_order;
4010 }
4011
4012 /*!
4013  * Returns number of iteration and order number of iteration when
4014  * \a this field has been calculated.
4015  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4016  *          order number.
4017  */
4018 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4019 {
4020   std::pair<int,int> p;
4021   fillIteration(p);
4022   return p;
4023 }
4024
4025 /*!
4026  * Returns number of iteration and order number of iteration when
4027  * \a this field has been calculated.
4028  *  \param [in,out] p - a pair returning the iteration number and the iteration
4029  *          order number.
4030  */
4031 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4032 {
4033   p.first=_iteration;
4034   p.second=_order;
4035 }
4036
4037 /*!
4038  * Returns all types of spatial discretization of \a this field.
4039  *  \param [in,out] types - a sequence of types of \a this field.
4040  */
4041 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4042 {
4043   std::set<TypeOfField> types2;
4044   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4045     {
4046       (*it)->fillTypesOfFieldAvailable(types2);
4047     }
4048   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4049   std::copy(types2.begin(),types2.end(),bi);
4050 }
4051
4052 /*!
4053  * Returns all types of spatial discretization of \a this field.
4054  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4055  *          of \a this field.
4056  */
4057 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4058 {
4059   std::vector<TypeOfField> ret;
4060   fillTypesOfFieldAvailable(ret);
4061   return ret;
4062 }
4063
4064 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4065 {
4066   std::vector<std::string> ret;
4067   std::set<std::string> ret2;
4068   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4069     {
4070       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4071       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4072         if(ret2.find(*it2)==ret2.end())
4073           {
4074             ret.push_back(*it2);
4075             ret2.insert(*it2);
4076           }
4077     }
4078   return ret;
4079 }
4080
4081 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4082 {
4083   std::vector<std::string> ret;
4084   std::set<std::string> ret2;
4085   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4086     {
4087       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4088       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4089         if(ret2.find(*it2)==ret2.end())
4090           {
4091             ret.push_back(*it2);
4092             ret2.insert(*it2);
4093           }
4094     }
4095   return ret;
4096 }
4097
4098 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4099 {
4100   std::vector<std::string> ret;
4101   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4102     {
4103       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4104       ret.insert(ret.end(),tmp.begin(),tmp.end());
4105     }
4106   return ret;
4107 }
4108
4109 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4110 {
4111   std::vector<std::string> ret;
4112   std::set<std::string> ret2;
4113   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4114     {
4115       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4116       ret.insert(ret.end(),tmp.begin(),tmp.end());
4117     }
4118   return ret;
4119 }
4120
4121 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4122 {
4123   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4124     (*it)->changePflsRefsNamesGen(mapOfModif);
4125 }
4126
4127 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4128 {
4129   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4130     (*it)->changeLocsRefsNamesGen(mapOfModif);
4131 }
4132
4133 /*!
4134  * Returns all attributes of parts of \a this field lying on a given mesh.
4135  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4136  * item of every of returned sequences refers to the _i_-th part of \a this field.
4137  * Thus all sequences returned by this method are of the same length equal to number
4138  * of different types of supporting entities.<br>
4139  * A field part can include sub-parts with several different spatial discretizations,
4140  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4141  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4142  * of a nested sequence corresponds to a type of spatial discretization.<br>
4143  * This method allows for iteration over MEDFile DataStructure without any overhead.
4144  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4145  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4146  *          not checked if \a mname == \c NULL).
4147  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4148  *          a field part is returned. 
4149  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4150  *          This sequence is of the same length as \a types. 
4151  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4152  *          discretization. A profile name can be empty.
4153  *          Length of this and of nested sequences is the same as that of \a typesF.
4154  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4155  *          discretization. A localization name can be empty.
4156  *          Length of this and of nested sequences is the same as that of \a typesF.
4157  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4158  *          of ids of tuples within the data array, per each type of spatial
4159  *          discretization within one mesh entity type. 
4160  *          Length of this and of nested sequences is the same as that of \a typesF.
4161  *  \throw If no field is lying on \a mname.
4162  */
4163 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
4164 {
4165   int meshId=0;
4166   if(!mname.empty())
4167     meshId=getMeshIdFromMeshName(mname);
4168   else
4169     if(_field_per_mesh.empty())
4170       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4171   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4172 }
4173
4174 /*!
4175  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4176  * maximal absolute dimension and values returned via the out parameter \a levs are 
4177  * dimensions relative to the maximal absolute dimension. <br>
4178  * This method is designed for MEDFileField1TS instances that have a discretization
4179  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4180  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4181  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4182  * Only these 3 discretizations will be taken into account here. If \a this is
4183  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4184  * This method is useful to make the link between the dimension of the underlying mesh
4185  * and the levels of \a this, because it is possible that the highest dimension of \a this
4186  * field is not equal to the dimension of the underlying mesh.
4187  * 
4188  * Let's consider the following case:
4189  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4190  * TETRA4, HEXA8, TRI3 and SEG2.
4191  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4192  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4193  *
4194  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4195  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4196  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4197  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4198  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4199  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4200  * For example<br>
4201  * to retrieve the highest level of
4202  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4203  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4204  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4205  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4206  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4207  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4208  *          not checked if \a mname == \c NULL).
4209  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4210  *          absolute one. They are in decreasing order. This sequence is cleared before
4211  *          filling it in.
4212  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4213  *  \throw If no field is lying on \a mname.
4214  */
4215 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4216 {
4217   levs.clear();
4218   int meshId=getMeshIdFromMeshName(mname);
4219   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4220   std::vector< std::vector<TypeOfField> > typesF;
4221   std::vector< std::vector<std::string> > pfls, locs;
4222   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4223   if(types.empty())
4224     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4225   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4226   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4227     return -1;
4228   st.erase(INTERP_KERNEL::NORM_ERROR);
4229   std::set<int> ret1;
4230   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4231     {
4232       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4233       ret1.insert((int)cm.getDimension());
4234     }
4235   int ret=*std::max_element(ret1.begin(),ret1.end());
4236   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4237   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4238   return ret;
4239 }
4240
4241 /*!
4242  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4243  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
4244  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4245  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4246  */
4247 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4248 {
4249   int mid=getMeshIdFromMeshName(mName);
4250   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4251 }
4252
4253 /*!
4254  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4255  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
4256  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4257  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4258  */
4259 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4260 {
4261   int mid=getMeshIdFromMeshName(mName);
4262   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4263 }
4264
4265 /*!
4266  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4267  */
4268 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4269 {
4270   if(_field_per_mesh.empty())
4271     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4272   if(mName.empty())
4273     return 0;
4274   std::string mName2(mName);
4275   int ret=0;
4276   std::vector<std::string> msg;
4277   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4278     if(mName2==(*it)->getMeshName())
4279       return ret;
4280     else
4281       msg.push_back((*it)->getMeshName());
4282   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4283   oss << "Possible meshes are : ";
4284   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4285     oss << "\"" << (*it2) << "\" ";
4286   throw INTERP_KERNEL::Exception(oss.str());
4287 }
4288
4289 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4290 {
4291   if(!mesh)
4292     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4293   std::string tmp(mesh->getName());
4294   if(tmp.empty())
4295     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4296   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4297   int i=0;
4298   for(;it!=_field_per_mesh.end();it++,i++)
4299     {
4300       if((*it)->getMeshName()==tmp)
4301         return i;
4302     }
4303   int sz=_field_per_mesh.size();
4304   _field_per_mesh.resize(sz+1);
4305   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4306   return sz;
4307 }
4308
4309 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4310                                                                    MEDFileFieldGlobsReal& glob)
4311 {
4312   bool ret=false;
4313   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4314     {
4315       MEDFileFieldPerMesh *fpm(*it);
4316       if(fpm)
4317         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4318     }
4319   return ret;
4320 }
4321
4322 /*!
4323  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4324  * splitting that leads to single spatial discretization of this.
4325  *
4326  * \sa splitMultiDiscrPerGeoTypes
4327  */
4328 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4329 {
4330   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4331   std::vector< std::vector<TypeOfField> > typesF;
4332   std::vector< std::vector<std::string> > pfls,locs;
4333   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4334   std::set<TypeOfField> allEnt;
4335   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4336     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4337       allEnt.insert(*it2);
4338   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4339   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4340   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4341     {
4342       std::vector< std::pair<int,int> > its;
4343       ret[i]=shallowCpy();
4344       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4345       ret[i]->updateData(newLgth,its);
4346     }
4347   return ret;
4348 }
4349
4350 /*!
4351  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4352  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4353  *
4354  * \sa splitDiscretizations
4355  */
4356 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4357 {
4358   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4359   std::vector< std::vector<TypeOfField> > typesF;
4360   std::vector< std::vector<std::string> > pfls,locs;
4361   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4362   std::set<TypeOfField> allEnt;
4363   std::size_t nbOfMDPGT(0),ii(0);
4364   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4365     {
4366       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4367       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4368         allEnt.insert(*it2);
4369     }
4370   if(allEnt.size()!=1)
4371     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4372   if(nbOfMDPGT==0)
4373     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4374   if(nbOfMDPGT==1)
4375     {
4376       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4377       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4378       return ret0;
4379     }
4380   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4381   for(std::size_t i=0;i<nbOfMDPGT;i++)
4382     {
4383       std::vector< std::pair<int,int> > its;
4384       ret[i]=shallowCpy();
4385       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4386       ret[i]->updateData(newLgth,its);
4387     }
4388   return ret;
4389 }
4390
4391 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4392 {
4393   int globalCounter(0);
4394   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4395     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4396   return globalCounter;
4397 }
4398
4399 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4400 {
4401   int globalCounter(0);
4402   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4403     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4404   return globalCounter;
4405 }
4406
4407 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4408 {
4409   if(_nb_of_tuples_to_be_allocated>=0)
4410     {
4411       _nb_of_tuples_to_be_allocated=newLgth;
4412       const DataArray *oldArr(getUndergroundDataArray());
4413       if(oldArr)
4414         {
4415           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4416           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4417           setArray(newArr);
4418           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4419         }
4420       return ;
4421     }
4422   if(_nb_of_tuples_to_be_allocated==-1)
4423     return ;
4424   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4425     {
4426       const DataArray *oldArr(getUndergroundDataArray());
4427       if(!oldArr || !oldArr->isAllocated())
4428         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4429       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4430       newArr->alloc(newLgth,getNumberOfComponents());
4431       if(oldArr)
4432         newArr->copyStringInfoFrom(*oldArr);
4433       int pos=0;
4434       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4435         {
4436           if((*it).second<(*it).first)
4437             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4438           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4439           pos+=(*it).second-(*it).first;
4440         }
4441       setArray(newArr);
4442       return ;
4443     }
4444   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4445 }
4446
4447 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4448 {
4449   if(_field_per_mesh.empty())
4450     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4451   if(_field_per_mesh.size()>1)
4452     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4453   _field_per_mesh[0]->copyOptionsFrom(opts);
4454   _field_per_mesh[0]->writeLL(fid,nasc);
4455 }
4456
4457 /*!
4458  * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated.
4459  * If false is returned the memory allocation is not required.
4460  */
4461 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4462 {
4463   if(_nb_of_tuples_to_be_allocated>=0)
4464     {
4465       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4466       _nb_of_tuples_to_be_allocated=-2;
4467       return true;
4468     }
4469   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4470     return false;
4471   if(_nb_of_tuples_to_be_allocated==-1)
4472     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4473   if(_nb_of_tuples_to_be_allocated<-3)
4474     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4475   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4476 }
4477
4478 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4479 {
4480   med_int numdt,numit;
4481   med_float dt;
4482   med_int nmesh;
4483   med_bool localMesh;
4484   med_int meshnumdt,meshnumit;
4485   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4486   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4487   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4488   if(_iteration!=numdt || _order!=numit)
4489     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4490   _field_per_mesh.resize(nmesh);
4491   //
4492   MEDFileMesh *mm(0);
4493   if(ms)
4494     {
4495       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4496       mm=ms->getMeshWithName(meshNameCpp);
4497     }
4498   //
4499   for(int i=0;i<nmesh;i++)
4500     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4501   _nb_of_tuples_to_be_allocated=0;
4502   for(int i=0;i<nmesh;i++)
4503     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4504 }
4505
4506 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4507 {
4508   allocIfNecessaryTheArrayToReceiveDataFromFile();
4509   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4510     (*it)->loadBigArraysRecursively(fid,nasc);
4511 }
4512
4513 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4514 {
4515   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4516     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4517       (*it)->loadBigArraysRecursively(fid,nasc);
4518 }
4519
4520 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4521 {
4522   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4523   loadBigArraysRecursively(fid,nasc);
4524 }
4525
4526 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4527 {
4528   DataArray *thisArr(getUndergroundDataArray());
4529   if(thisArr && thisArr->isAllocated())
4530     {
4531       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4532       thisArr->desallocate();
4533     }
4534 }
4535
4536 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4537 {
4538   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4539 }
4540
4541 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4542 {
4543   std::vector<const BigMemoryObject *> ret;
4544   if(getUndergroundDataArray())
4545     ret.push_back(getUndergroundDataArray());
4546   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4547     ret.push_back((const MEDFileFieldPerMesh *)*it);
4548   return ret;
4549 }
4550
4551 /*!
4552  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4553  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4554  * "Sort By Type"), if not, an exception is thrown. 
4555  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4556  *  \param [in] arr - the array of values.
4557  *  \param [in,out] glob - the global data where profiles and localization present in
4558  *          \a field, if any, are added.
4559  *  \throw If the name of \a field is empty.
4560  *  \throw If the data array of \a field is not set.
4561  *  \throw If \a this->_arr is already allocated but has different number of components
4562  *         than \a field.
4563  *  \throw If the underlying mesh of \a field has no name.
4564  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4565  */
4566 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4567 {
4568   const MEDCouplingMesh *mesh=field->getMesh();
4569   //
4570   TypeOfField type=field->getTypeOfField();
4571   std::vector<DataArrayInt *> dummy;
4572   int start=copyTinyInfoFrom(field,arr);
4573   int pos=addNewEntryIfNecessary(mesh);
4574   if(type!=ON_NODES)
4575     {
4576       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4577       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4578     }
4579   else
4580     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4581 }
4582
4583 /*!
4584  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4585  * of a given mesh are used as the support of the given field (a real support is not used). 
4586  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4587  * Order of underlying mesh entities of the given field specified by \a profile parameter
4588  * is not prescribed; this method permutes field values to have them sorted by element
4589  * type as required for writing to MED file. A new profile is added only if no equal
4590  * profile is missing. 
4591  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4592  *  \param [in] arrOfVals - the values of the field \a field used.
4593  *  \param [in] mesh - the supporting mesh of \a field.
4594  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4595  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4596  *  \param [in,out] glob - the global data where profiles and localization present in
4597  *          \a field, if any, are added.
4598  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4599  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4600  *  \throw If the data array of \a field is not set.
4601  *  \throw If \a this->_arr is already allocated but has different number of components
4602  *         than \a field.
4603  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4604  *  \sa setFieldNoProfileSBT()
4605  */
4606 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4607 {
4608   if(!field)
4609     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4610   if(!arrOfVals || !arrOfVals->isAllocated())
4611     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4612   TypeOfField type=field->getTypeOfField();
4613   std::vector<DataArrayInt *> idsInPflPerType;
4614   std::vector<DataArrayInt *> idsPerType;
4615   std::vector<int> code,code2;
4616   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4617   if(type!=ON_NODES)
4618     {
4619       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4620       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4621       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4622       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4623       // start of check
4624       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4625       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4626       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4627         {
4628           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4629           throw INTERP_KERNEL::Exception(oss.str());
4630         }
4631       // end of check
4632       int start=copyTinyInfoFrom(field,arrOfVals);
4633       code2=m->getDistributionOfTypes();
4634       //
4635       int pos=addNewEntryIfNecessary(m);
4636       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4637     }
4638   else
4639     {
4640       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4641         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4642       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4643       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4644       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4645       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4646         {
4647           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4648           throw INTERP_KERNEL::Exception(oss.str());
4649         }
4650       int start=copyTinyInfoFrom(field,arrOfVals);
4651       int pos=addNewEntryIfNecessary(m);
4652       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4653     }
4654 }
4655
4656 /*!
4657  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4658  */
4659 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4660 {
4661   if(_nb_of_tuples_to_be_allocated>=0)
4662     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile : the object is expected to be appended to a data coming from a file but not loaded ! Load before appending data !");
4663   DataArray *arr(getOrCreateAndGetArray());
4664   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4665   _nb_of_tuples_to_be_allocated=-3;
4666 }
4667
4668 /*!
4669  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4670  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4671  * larger by the size of \a field. Returns an id of the first not filled
4672  * tuple of \a this->_arr.
4673  *  \param [in] field - the field to copy the info on components and the name from.
4674  *  \return int - the id of first not initialized tuple of \a this->_arr.
4675  *  \throw If the name of \a field is empty.
4676  *  \throw If the data array of \a field is not set.
4677  *  \throw If \a this->_arr is already allocated but has different number of components
4678  *         than \a field.
4679  */
4680 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4681 {
4682   if(!field)
4683     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4684   std::string name(field->getName());
4685   setName(name.c_str());
4686   setDtUnit(field->getTimeUnit());
4687   if(name.empty())
4688     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4689   if(!arr)
4690     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4691   if(!arr->isAllocated())
4692     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4693   _dt=field->getTime(_iteration,_order);
4694   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4695   if(!getOrCreateAndGetArray()->isAllocated())
4696     {
4697       allocNotFromFile(arr->getNumberOfTuples());
4698       return 0;
4699     }
4700   else
4701     {
4702       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4703       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4704       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4705       _nb_of_tuples_to_be_allocated=-3;
4706       return oldNbOfTuples;
4707     }
4708 }
4709
4710 /*!
4711  * Returns number of components in \a this field
4712  *  \return int - the number of components.
4713  */
4714 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4715 {
4716   return getOrCreateAndGetArray()->getNumberOfComponents();
4717 }
4718
4719 /*!
4720  * Change info on components in \a this.
4721  * \throw If size of \a infos is not equal to the number of components already in \a this.
4722  */
4723 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4724 {
4725   DataArray *arr=getOrCreateAndGetArray();
4726   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4727 }
4728
4729 /*!
4730  * Returns info on components of \a this field.
4731  *  \return const std::vector<std::string>& - a sequence of strings each being an
4732  *          information on _i_-th component.
4733  */
4734 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4735 {
4736   const DataArray *arr=getOrCreateAndGetArray();
4737   return arr->getInfoOnComponents();
4738 }
4739
4740 /*!
4741  * Returns a mutable info on components of \a this field.
4742  *  \return std::vector<std::string>& - a sequence of strings each being an
4743  *          information on _i_-th component.
4744  */
4745 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4746 {
4747   DataArray *arr=getOrCreateAndGetArray();
4748   return arr->getInfoOnComponents();
4749 }
4750
4751 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4752 {
4753   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4754     {
4755       const MEDFileFieldPerMesh *fpm(*it);
4756       if(!fpm)
4757         continue;
4758       if(fpm->presenceOfMultiDiscPerGeoType())
4759         return true;
4760     }
4761   return false;
4762 }
4763
4764 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4765 {
4766   static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with  \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
4767   if(_field_per_mesh.empty())
4768     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4769   if(_field_per_mesh.size()>1)
4770     throw INTERP_KERNEL::Exception(MSG0);
4771   if(_field_per_mesh[0].isNull())
4772     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4773   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4774   std::set<TypeOfField> types;
4775   pm->fillTypesOfFieldAvailable(types);
4776   if(types.size()!=1)
4777     throw INTERP_KERNEL::Exception(MSG0);
4778   TypeOfField type(*types.begin());
4779   int meshDimRelToMax(0);
4780   if(type==ON_NODES)
4781     meshDimRelToMax=0;
4782   else
4783     {
4784       int myDim(std::numeric_limits<int>::max());
4785       bool isUnique(pm->isUniqueLevel(myDim));
4786       if(!isUnique)
4787         throw INTERP_KERNEL::Exception(MSG0);
4788       meshDimRelToMax=myDim-mesh->getMeshDimension();
4789       if(meshDimRelToMax>0)
4790         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4791     }
4792   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4793 }
4794
4795 /*!
4796  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4797  *  \param [in] type - a spatial discretization of the new field.
4798  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4799  *  \param [in] mName - a name of the supporting mesh.
4800  *  \param [in] renumPol - specifies how to permute values of the result field according to
4801  *          the optional numbers of cells and nodes, if any. The valid values are
4802  *          - 0 - do not permute.
4803  *          - 1 - permute cells.
4804  *          - 2 - permute nodes.
4805  *          - 3 - permute cells and nodes.
4806  *
4807  *  \param [in] glob - the global data storing profiles and localization.
4808  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4809  *          caller is to delete this field using decrRef() as it is no more needed. 
4810  *  \throw If the MED file is not readable.
4811  *  \throw If there is no mesh named \a mName in the MED file.
4812  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4813  *  \throw If no field of \a this is lying on the mesh \a mName.
4814  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4815  */
4816 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4817 {
4818   MCAuto<MEDFileMesh> mm;
4819   if(mName.empty())
4820     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4821   else
4822     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4823   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4824 }
4825
4826 /*!
4827  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4828  *  \param [in] type - a spatial discretization of the new field.
4829  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4830  *  \param [in] renumPol - specifies how to permute values of the result field according to
4831  *          the optional numbers of cells and nodes, if any. The valid values are
4832  *          - 0 - do not permute.
4833  *          - 1 - permute cells.
4834  *          - 2 - permute nodes.
4835  *          - 3 - permute cells and nodes.
4836  *
4837  *  \param [in] glob - the global data storing profiles and localization.
4838  *  \param [in] mesh - the supporting mesh.
4839  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4840  *          caller is to delete this field using decrRef() as it is no more needed. 
4841  *  \throw If the MED file is not readable.
4842  *  \throw If no field of \a this is lying on \a mesh.
4843  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4844  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4845  */
4846 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4847 {
4848   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4849   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4850   if(meshDimRelToMax==1)
4851     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4852   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4853 }
4854
4855 /*!
4856  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4857  * given mesh. 
4858  *  \param [in] type - a spatial discretization of the new field.
4859  *  \param [in] mName - a name of the supporting mesh.
4860  *  \param [in] renumPol - specifies how to permute values of the result field according to
4861  *          the optional numbers of cells and nodes, if any. The valid values are
4862  *          - 0 - do not permute.
4863  *          - 1 - permute cells.
4864  *          - 2 - permute nodes.
4865  *          - 3 - permute cells and nodes.
4866  *
4867  *  \param [in] glob - the global data storing profiles and localization.
4868  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4869  *          caller is to delete this field using decrRef() as it is no more needed. 
4870  *  \throw If the MED file is not readable.
4871  *  \throw If there is no mesh named \a mName in the MED file.
4872  *  \throw If there are no mesh entities in the mesh.
4873  *  \throw If no field values of the given \a type are available.
4874  */
4875 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4876 {
4877   MCAuto<MEDFileMesh> mm;
4878   if(mName.empty())
4879     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4880   else
4881     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4882   int absDim=getDimension();
4883   int meshDimRelToMax=absDim-mm->getMeshDimension();
4884   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4885 }
4886
4887 /*!
4888  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4889  *  \param [in] type - a spatial discretization of the new field.
4890  *  \param [in] renumPol - specifies how to permute values of the result field according to
4891  *          the optional numbers of cells and nodes, if any. The valid values are
4892  *          - 0 - do not permute.
4893  *          - 1 - permute cells.
4894  *          - 2 - permute nodes.
4895  *          - 3 - permute cells and nodes.
4896  *
4897  *  \param [in] glob - the global data storing profiles and localization.
4898  *  \param [in] mesh - the supporting mesh.
4899  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4900  *         field according to \a renumPol.
4901  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4902  *         field according to \a renumPol.
4903  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4904  *          caller is to delete this field using decrRef() as it is no more needed. 
4905  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4906  *  \throw If no field of \a this is lying on \a mesh.
4907  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4908  */
4909 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4910 {
4911   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4912   int meshId=getMeshIdFromMeshName(mesh->getName());
4913   bool isPfl=false;
4914   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4915   switch(renumPol)
4916   {
4917     case 0:
4918       {
4919         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4920         return ret.retn();
4921       }
4922     case 3:
4923     case 1:
4924       {
4925         if(isPfl)
4926           throw INTERP_KERNEL::Exception(msg1);
4927         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4928         if(cellRenum)
4929           {
4930             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4931               {
4932                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4933                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4934                 throw INTERP_KERNEL::Exception(oss.str());
4935               }
4936             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4937             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4938             std::vector<DataArray *> arrOut2(1,arrOut);
4939             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4940             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4941             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4942           }
4943         if(renumPol==1)
4944           return ret.retn();
4945       }
4946     case 2:
4947       {
4948         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4949         if(isPfl)
4950           throw INTERP_KERNEL::Exception(msg1);
4951         if(nodeRenum)
4952           {
4953             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4954               {
4955                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4956                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4957                 throw INTERP_KERNEL::Exception(oss.str());
4958               }
4959             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4960             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4961               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4962             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4963           }
4964         return ret.retn();
4965       }
4966     default:
4967       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4968   }
4969 }
4970
4971 /*!
4972  * Returns values and a profile of the field of a given type lying on a given support.
4973  *  \param [in] type - a spatial discretization of the field.
4974  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4975  *  \param [in] mesh - the supporting mesh.
4976  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4977  *          field of interest lies on. If the field lies on all entities of the given
4978  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4979  *          using decrRef() as it is no more needed.  
4980  *  \param [in] glob - the global data storing profiles and localization.
4981  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4982  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4983  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4984  *  \throw If no field of \a this is lying on \a mesh.
4985  *  \throw If no field values of the given \a type are available.
4986  */
4987 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4988 {
4989   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4990   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4991   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4992   ret->setName(nasc.getName().c_str());
4993   return ret.retn();
4994 }
4995
4996 //= MEDFileField1TSWithoutSDA
4997
4998 /*!
4999  * Throws if a given value is not a valid (non-extended) relative dimension.
5000  *  \param [in] meshDimRelToMax - the relative dimension value.
5001  *  \throw If \a meshDimRelToMax > 0.
5002  */
5003 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5004 {
5005   if(meshDimRelToMax>0)
5006     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5007 }
5008
5009 /*!
5010  * Checks if elements of a given mesh are in the order suitable for writing 
5011  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5012  * vector describing types of elements and their number.
5013  *  \param [in] mesh - the mesh to check.
5014  *  \return std::vector<int> - a vector holding for each element type (1) item of
5015  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5016  *          These values are in full-interlace mode.
5017  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5018  */
5019 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5020 {
5021   if(!mesh)
5022     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5023   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5024   int nbOfTypes=geoTypes.size();
5025   std::vector<int> code(3*nbOfTypes);
5026   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5027   arr1->alloc(nbOfTypes,1);
5028   int *arrPtr=arr1->getPointer();
5029   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5030   for(int i=0;i<nbOfTypes;i++,it++)
5031     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5032   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5033   const int *arrPtr2=arr2->getConstPointer();
5034   int i=0;
5035   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5036     {
5037       int pos=arrPtr2[i];
5038       int nbCells=mesh->getNumberOfCellsWithType(*it);
5039       code[3*pos]=(int)(*it);
5040       code[3*pos+1]=nbCells;
5041       code[3*pos+2]=-1;//no profiles
5042     }
5043   std::vector<const DataArrayInt *> idsPerType;//no profiles
5044   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5045   if(da)
5046     {
5047       da->decrRef();
5048       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5049     }
5050   return code;
5051 }
5052
5053 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5054 {
5055   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5056 }
5057
5058 /*!
5059  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5060  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5061  * item of every of returned sequences refers to the _i_-th part of \a this field.
5062  * Thus all sequences returned by this method are of the same length equal to number
5063  * of different types of supporting entities.<br>
5064  * A field part can include sub-parts with several different spatial discretizations,
5065  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5066  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5067  * of a nested sequence corresponds to a type of spatial discretization.<br>
5068  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5069  * The overhead is due to selecting values into new instances of DataArrayDouble.
5070  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5071  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5072  *          not checked if \a mname == \c NULL).
5073  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5074  *          a field part is returned. 
5075  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5076  *          A field part can include sub-parts with several different spatial discretizations,
5077  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5078  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5079  *          This sequence is of the same length as \a types. 
5080  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5081  *          discretization. A profile name can be empty.
5082  *          Length of this and of nested sequences is the same as that of \a typesF.
5083  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5084  *          discretization. A localization name can be empty.
5085  *          Length of this and of nested sequences is the same as that of \a typesF.
5086  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5087  *          per each type of spatial discretization within one mesh entity type.
5088  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5089  *          Length of this and of nested sequences is the same as that of \a typesF.
5090  *  \throw If no field is lying on \a mname.
5091  */
5092 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5093 {
5094   int meshId=0;
5095   if(!mname.empty())
5096     meshId=getMeshIdFromMeshName(mname);
5097   else
5098     if(_field_per_mesh.empty())
5099       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5100   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5101   int nbOfRet=ret0.size();
5102   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5103   for(int i=0;i<nbOfRet;i++)
5104     {
5105       const std::vector< std::pair<int,int> >& p=ret0[i];
5106       int nbOfRet1=p.size();
5107       ret[i].resize(nbOfRet1);
5108       for(int j=0;j<nbOfRet1;j++)
5109         {
5110           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5111           ret[i][j]=tmp;
5112         }
5113     }
5114   return ret;
5115 }
5116
5117 /*!
5118  * Returns a pointer to the underground DataArrayDouble instance. So the
5119  * caller should not decrRef() it. This method allows for a direct access to the field
5120  * values. This method is quite unusable if there is more than a nodal field or a cell
5121  * field on single geometric cell type. 
5122  *  \return DataArrayDouble * - the pointer to the field values array.
5123  */
5124 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5125 {
5126   const DataArrayDouble *ret=_arr;
5127   if(ret)
5128     return const_cast<DataArrayDouble *>(ret);
5129   else
5130     return 0;
5131 }
5132
5133 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5134 {
5135   return TYPE_STR;
5136 }
5137
5138 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5139 {
5140   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5141   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5142   ret->deepCpyLeavesFrom(*this);
5143   const DataArrayDouble *arr(_arr);
5144   if(arr)
5145     {
5146       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5147       ret->setArray(arr2);
5148     }
5149   return ret.retn();
5150 }
5151
5152 /*!
5153  * Returns a pointer to the underground DataArrayDouble instance. So the
5154  * caller should not decrRef() it. This method allows for a direct access to the field
5155  * values. This method is quite unusable if there is more than a nodal field or a cell
5156  * field on single geometric cell type. 
5157  *  \return DataArrayDouble * - the pointer to the field values array.
5158  */
5159 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5160 {
5161   return getUndergroundDataArrayDouble();
5162 }
5163
5164 /*!
5165  * Returns a pointer to the underground DataArrayDouble instance and a
5166  * sequence describing parameters of a support of each part of \a this field. The
5167  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5168  * direct access to the field values. This method is intended for the field lying on one
5169  * mesh only.
5170  *  \param [in,out] entries - the sequence describing parameters of a support of each
5171  *         part of \a this field. Each item of this sequence consists of two parts. The
5172  *         first part describes a type of mesh entity and an id of discretization of a
5173  *         current field part. The second part describes a range of values [begin,end)
5174  *         within the returned array relating to the current field part.
5175  *  \return DataArrayDouble * - the pointer to the field values array.
5176  *  \throw If the number of underlying meshes is not equal to 1.
5177  *  \throw If no field values are available.
5178  *  \sa getUndergroundDataArray()
5179  */
5180 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5181 {
5182   if(_field_per_mesh.size()!=1)
5183     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5184   if(_field_per_mesh[0]==0)
5185     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5186   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5187   return getUndergroundDataArrayDouble();
5188 }
5189
5190 /*!
5191  * Returns a pointer to the underground DataArrayDouble instance and a
5192  * sequence describing parameters of a support of each part of \a this field. The
5193  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5194  * direct access to the field values. This method is intended for the field lying on one
5195  * mesh only.
5196  *  \param [in,out] entries - the sequence describing parameters of a support of each
5197  *         part of \a this field. Each item of this sequence consists of two parts. The
5198  *         first part describes a type of mesh entity and an id of discretization of a
5199  *         current field part. The second part describes a range of values [begin,end)
5200  *         within the returned array relating to the current field part.
5201  *  \return DataArrayDouble * - the pointer to the field values array.
5202  *  \throw If the number of underlying meshes is not equal to 1.
5203  *  \throw If no field values are available.
5204  *  \sa getUndergroundDataArray()
5205  */
5206 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5207 {
5208   return getUndergroundDataArrayDoubleExt(entries);
5209 }
5210
5211 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5212 {
5213   DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5214   arr->setInfoAndChangeNbOfCompo(infos);
5215 }
5216
5217 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5218 {
5219 }
5220
5221 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5222 {
5223   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5224   ret->deepCpyLeavesFrom(*this);
5225   return ret.retn();
5226 }
5227
5228 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5229 {
5230   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5231   if((const DataArrayDouble *)_arr)
5232     ret->_arr=_arr->deepCopy();
5233   return ret.retn();
5234 }
5235
5236 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5237 {
5238   if(!arr)
5239     {
5240       _nb_of_tuples_to_be_allocated=-1;
5241       _arr=0;
5242       return ;
5243     }
5244   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5245   if(!arrC)
5246     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5247   else
5248     _nb_of_tuples_to_be_allocated=-3;
5249   arrC->incrRef();
5250   _arr=arrC;
5251 }
5252
5253 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5254 {
5255   return DataArrayDouble::New();
5256 }
5257
5258 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5259 {
5260   DataArrayDouble *ret=_arr;
5261   if(ret)
5262     return ret;
5263   _arr=DataArrayDouble::New();
5264   return _arr;
5265 }
5266
5267 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5268 {
5269   return getOrCreateAndGetArrayDouble();
5270 }
5271
5272 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5273 {
5274   const DataArrayDouble *ret=_arr;
5275   if(ret)
5276     return ret;
5277   DataArrayDouble *ret2=DataArrayDouble::New();
5278   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5279   return ret2;
5280 }
5281
5282 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5283 {
5284   return getOrCreateAndGetArrayDouble();
5285 }
5286
5287 //= MEDFileIntField1TSWithoutSDA
5288
5289 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5290 {
5291   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5292 }
5293
5294 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5295 {
5296 }
5297
5298 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5299                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5300 {
5301   DataArrayInt *arr(getOrCreateAndGetArrayInt());
5302   arr->setInfoAndChangeNbOfCompo(infos);
5303 }
5304
5305 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5306 {
5307   return TYPE_STR;
5308 }
5309
5310 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5311 {
5312   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5313   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5314   ret->deepCpyLeavesFrom(*this);
5315   const DataArrayInt *arr(_arr);
5316   if(arr)
5317     {
5318       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5319       ret->setArray(arr2);
5320     }
5321   return ret.retn();
5322 }
5323
5324 /*!
5325  * Returns a pointer to the underground DataArrayInt instance. So the
5326  * caller should not decrRef() it. This method allows for a direct access to the field
5327  * values. This method is quite unusable if there is more than a nodal field or a cell
5328  * field on single geometric cell type. 
5329  *  \return DataArrayInt * - the pointer to the field values array.
5330  */
5331 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5332 {
5333   return getUndergroundDataArrayInt();
5334 }
5335
5336 /*!
5337  * Returns a pointer to the underground DataArrayInt instance. So the
5338  * caller should not decrRef() it. This method allows for a direct access to the field
5339  * values. This method is quite unusable if there is more than a nodal field or a cell
5340  * field on single geometric cell type. 
5341  *  \return DataArrayInt * - the pointer to the field values array.
5342  */
5343 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5344 {
5345   const DataArrayInt *ret=_arr;
5346   if(ret)
5347     return const_cast<DataArrayInt *>(ret);
5348   else
5349     return 0;
5350 }
5351
5352 /*!
5353  * Returns a pointer to the underground DataArrayInt instance and a
5354  * sequence describing parameters of a support of each part of \a this field. The
5355  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5356  * direct access to the field values. This method is intended for the field lying on one
5357  * mesh only.
5358  *  \param [in,out] entries - the sequence describing parameters of a support of each
5359  *         part of \a this field. Each item of this sequence consists of two parts. The
5360  *         first part describes a type of mesh entity and an id of discretization of a
5361  *         current field part. The second part describes a range of values [begin,end)
5362  *         within the returned array relating to the current field part.
5363  *  \return DataArrayInt * - the pointer to the field values array.
5364  *  \throw If the number of underlying meshes is not equal to 1.
5365  *  \throw If no field values are available.
5366  *  \sa getUndergroundDataArray()
5367  */
5368 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5369 {
5370   return getUndergroundDataArrayIntExt(entries);
5371 }
5372
5373 /*!
5374  * Returns a pointer to the underground DataArrayInt instance and a
5375  * sequence describing parameters of a support of each part of \a this field. The
5376  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5377  * direct access to the field values. This method is intended for the field lying on one
5378  * mesh only.
5379  *  \param [in,out] entries - the sequence describing parameters of a support of each
5380  *         part of \a this field. Each item of this sequence consists of two parts. The
5381  *         first part describes a type of mesh entity and an id of discretization of a
5382  *         current field part. The second part describes a range of values [begin,end)
5383  *         within the returned array relating to the current field part.
5384  *  \return DataArrayInt * - the pointer to the field values array.
5385  *  \throw If the number of underlying meshes is not equal to 1.
5386  *  \throw If no field values are available.
5387  *  \sa getUndergroundDataArray()
5388  */
5389 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5390 {
5391   if(_field_per_mesh.size()!=1)
5392     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5393   if(_field_per_mesh[0]==0)
5394     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5395   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5396   return getUndergroundDataArrayInt();
5397 }
5398
5399 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5400 {
5401   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5402   ret->deepCpyLeavesFrom(*this);
5403   return ret.retn();
5404 }
5405
5406 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5407 {
5408   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5409   if((const DataArrayInt *)_arr)
5410     ret->_arr=_arr->deepCopy();
5411   return ret.retn();
5412 }
5413
5414 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5415 {
5416   if(!arr)
5417     {
5418       _nb_of_tuples_to_be_allocated=-1;
5419       _arr=0;
5420       return ;
5421     }
5422   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5423   if(!arrC)
5424     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5425   else
5426     _nb_of_tuples_to_be_allocated=-3;
5427   arrC->incrRef();
5428   _arr=arrC;
5429 }
5430
5431 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5432 {
5433   return DataArrayInt::New();
5434 }
5435
5436 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5437 {
5438   DataArrayInt *ret=_arr;
5439   if(ret)
5440     return ret;
5441   _arr=DataArrayInt::New();
5442   return _arr;
5443 }
5444
5445 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5446 {
5447   return getOrCreateAndGetArrayInt();
5448 }
5449
5450 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5451 {
5452   const DataArrayInt *ret=_arr;
5453   if(ret)
5454     return ret;
5455   DataArrayInt *ret2=DataArrayInt::New();
5456   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5457   return ret2;
5458 }
5459
5460 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5461 {
5462   return getOrCreateAndGetArrayInt();
5463 }
5464
5465 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5466 {
5467 }
5468
5469 //= MEDFileAnyTypeField1TS
5470
5471 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5472 {
5473   med_field_type typcha;
5474   //
5475   std::vector<std::string> infos;
5476   std::string dtunit,fieldName;
5477   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5478   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5479   switch(typcha)
5480   {
5481     case MED_FLOAT64:
5482       {
5483         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5484         break;
5485       }
5486     case MED_INT32:
5487       {
5488         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5489         break;
5490       }
5491     default:
5492       {
5493         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5494         throw INTERP_KERNEL::Exception(oss.str());
5495       }
5496   }
5497   ret->setDtUnit(dtunit.c_str());
5498   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5499   //
5500   med_int numdt,numit;
5501   med_float dt;
5502   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5503   ret->setTime(numdt,numit,dt);
5504   ret->_csit=1;
5505   if(loadAll)
5506     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5507   else
5508     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5509   return ret.retn();
5510 }
5511
5512 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5513 try:MEDFileFieldGlobsReal(fileName)
5514 {
5515   MEDFileUtilities::CheckFileForRead(fileName);
5516   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5517   _content=BuildContentFrom(fid,fileName,loadAll,ms);
5518   loadGlobals(fid);
5519 }
5520 catch(INTERP_KERNEL::Exception& e)
5521 {
5522     throw e;
5523 }
5524
5525 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5526 {
5527   med_field_type typcha;
5528   std::vector<std::string> infos;
5529   std::string dtunit;
5530   int iii=-1;
5531   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5532   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5533   switch(typcha)
5534   {
5535     case MED_FLOAT64:
5536       {
5537         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5538         break;
5539       }
5540     case MED_INT32:
5541       {
5542         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5543         break;
5544       }
5545     default:
5546       {
5547         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5548         throw INTERP_KERNEL::Exception(oss.str());
5549       }
5550   }
5551   ret->setDtUnit(dtunit.c_str());
5552   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5553   //
5554   if(nbSteps<1)
5555     {
5556       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5557       throw INTERP_KERNEL::Exception(oss.str());
5558     }
5559   //
5560   med_int numdt,numit;
5561   med_float dt;
5562   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5563   ret->setTime(numdt,numit,dt);
5564   ret->_csit=1;
5565   if(loadAll)
5566     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5567   else
5568     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5569   return ret.retn();
5570 }
5571
5572 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5573 try:MEDFileFieldGlobsReal(fileName)
5574 {
5575   MEDFileUtilities::CheckFileForRead(fileName);
5576   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5577   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5578   loadGlobals(fid);
5579 }
5580 catch(INTERP_KERNEL::Exception& e)
5581 {
5582     throw e;
5583 }
5584
5585 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5586 {
5587   if(!c)
5588     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5589   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5590     {
5591       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5592       ret->setFileName(fileName);
5593       ret->_content=c; c->incrRef();
5594       return ret.retn();
5595     }
5596   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5597     {
5598       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5599       ret->setFileName(fileName);
5600       ret->_content=c; c->incrRef();
5601       return ret.retn();
5602     }
5603   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5604 }
5605
5606 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5607 {
5608   MEDFileUtilities::CheckFileForRead(fileName);
5609   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5610   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5611   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5612   ret->loadGlobals(fid);
5613   return ret.retn();
5614 }
5615
5616 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5617 {
5618   MEDFileUtilities::CheckFileForRead(fileName);
5619   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5620   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5621   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5622   ret->loadGlobals(fid);
5623   return ret.retn();
5624 }
5625
5626 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5627 {
5628   MEDFileUtilities::CheckFileForRead(fileName);
5629   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5630   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5631   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5632   ret->loadGlobals(fid);
5633   return ret.retn();
5634 }
5635
5636 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5637 {
5638   med_field_type typcha;
5639   std::vector<std::string> infos;
5640   std::string dtunit;
5641   int iii=-1;
5642   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5643   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5644   switch(typcha)
5645   {
5646     case MED_FLOAT64:
5647       {
5648         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5649         break;
5650       }
5651     case MED_INT32:
5652       {
5653         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5654         break;
5655       }
5656     default:
5657       {
5658         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5659         throw INTERP_KERNEL::Exception(oss.str());
5660       }
5661   }
5662   ret->setDtUnit(dtunit.c_str());
5663   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5664   //
5665   bool found=false;
5666   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5667   for(int i=0;i<nbOfStep2 && !found;i++)
5668     {
5669       med_int numdt,numit;
5670       med_float dt;
5671       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5672       if(numdt==iteration && numit==order)
5673         {
5674           found=true;
5675           ret->_csit=i+1;
5676         }
5677       else
5678         dtits[i]=std::pair<int,int>(numdt,numit);
5679     }
5680   if(!found)
5681     {
5682       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5683       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5684         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5685       throw INTERP_KERNEL::Exception(oss.str());
5686     }
5687   if(loadAll)
5688     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5689   else
5690     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5691   return ret.retn();
5692 }
5693
5694 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5695 try:MEDFileFieldGlobsReal(fileName)
5696 {
5697   MEDFileUtilities::CheckFileForRead(fileName);
5698   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5699   _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5700   loadGlobals(fid);
5701 }
5702 catch(INTERP_KERNEL::Exception& e)
5703 {
5704     throw e;
5705 }
5706
5707 /*!
5708  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5709  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5710  *
5711  * \warning this is a shallow copy constructor
5712  */
5713 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5714 {
5715   if(!shallowCopyOfContent)
5716     {
5717       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5718       otherPtr->incrRef();
5719       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5720     }
5721   else
5722     {
5723       _content=other.shallowCpy();
5724     }
5725 }
5726
5727 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5728 {
5729   if(checkFieldId)
5730     {
5731       int nbFields=MEDnField(fid);
5732       if(fieldIdCFormat>=nbFields)
5733         {
5734           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5735           throw INTERP_KERNEL::Exception(oss.str());
5736         }
5737     }
5738   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5739   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5740   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5741   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5742   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5743   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5744   med_bool localMesh;
5745   int nbOfStep;
5746   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5747   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5748   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5749   infos.clear(); infos.resize(ncomp);
5750   for(int j=0;j<ncomp;j++)
5751     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5752   return nbOfStep;
5753 }
5754
5755 /*!
5756  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5757  * 
5758  * \param [out]
5759  * \return in case of success the number of time steps available for the field with name \a fieldName.
5760  */
5761 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5762 {
5763   int nbFields=MEDnField(fid);
5764   bool found=false;
5765   std::vector<std::string> fns(nbFields);
5766   int nbOfStep2=-1;
5767   for(int i=0;i<nbFields && !found;i++)
5768     {
5769       std::string tmp;
5770       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5771       fns[i]=tmp;
5772       found=(tmp==fieldName);
5773       if(found)
5774         posCFormat=i;
5775     }
5776   if(!found)
5777     {
5778       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5779       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5780         oss << "\"" << *it << "\" ";
5781       throw INTERP_KERNEL::Exception(oss.str());
5782     }
5783   return nbOfStep2;
5784 }
5785
5786 /*!
5787  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5788  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5789  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5790  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5791  * to keep a valid instance.
5792  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5793  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5794  * If \b newPflName already exists and that \b forceRenameOnGlob is false (the default) an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newPflName.
5795  *
5796  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5797  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5798  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5799  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5800  * \param [in] newLocName is the new localization name.
5801  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newPflName already exists. If true, the renaming is done without check. It can lead to major bug.
5802  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5803  */
5804 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5805 {
5806   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5807   std::string oldPflName=disc->getProfile();
5808   std::vector<std::string> vv=getPflsReallyUsedMulti();
5809   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5810   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5811     {
5812       disc->setProfile(newPflName);
5813       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5814       pfl->setName(newPflName);
5815     }
5816   else
5817     {
5818       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5819       throw INTERP_KERNEL::Exception(oss.str());
5820     }
5821 }
5822
5823 /*!
5824  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5825  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5826  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5827  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5828  * to keep a valid instance.
5829  * If \b this do not have any leaf that correspond to the request of the input parameter (\b mName, \b typ, \b locId) an INTERP_KERNEL::Exception will be thrown.
5830  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5831  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5832  * If \b newLocName already exists an INTERP_KERNEL::Exception will be thrown to avoid big confusion. In this case the called should rename before the profile name with name \b newLocName.
5833  *
5834  * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
5835  * \param [in] typ is for the geometric cell type (or INTERP_KERNEL::NORM_ERROR for node field) entry to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set.
5836  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5837  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5838  * \param [in] newLocName is the new localization name.
5839  * \param [in] forceRenameOnGlob specifies the behaviour in case of profile \b newLocName already exists. If true, the renaming is done without check. It can lead to major bug.
5840  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5841  */
5842 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5843 {
5844   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5845   std::string oldLocName=disc->getLocalization();
5846   std::vector<std::string> vv=getLocsReallyUsedMulti();
5847   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5848   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5849     {
5850       disc->setLocalization(newLocName);
5851       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5852       loc.setName(newLocName);
5853     }
5854   else
5855     {
5856       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5857       throw INTERP_KERNEL::Exception(oss.str());
5858     }
5859 }
5860
5861 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5862 {
5863   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5864   if(!ret)
5865     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5866   return ret;
5867 }
5868
5869 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5870 {
5871   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5872   if(!ret)
5873     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5874   return ret;
5875 }
5876
5877 /*!
5878  * Writes \a this field into a MED file specified by its name.
5879  *  \param [in] fileName - the MED file name.
5880  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5881  * - 2 - erase; an existing file is removed.
5882  * - 1 - append; same data should not be present in an existing file.
5883  * - 0 - overwrite; same data present in an existing file is overwritten.
5884  *  \throw If the field name is not set.
5885  *  \throw If no field data is set.
5886  *  \throw If \a mode == 1 and the same data is present in an existing file.
5887  */
5888 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5889 {
5890   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5891   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5892   writeLL(fid);
5893 }
5894
5895 /*!
5896  * This method alloc the arrays and load potentially huge arrays contained in this field.
5897  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5898  * This method can be also called to refresh or reinit values from a file.
5899  * 
5900  * \throw If the fileName is not set or points to a non readable MED file.
5901  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5902  */
5903 void MEDFileAnyTypeField1TS::loadArrays()
5904 {
5905   if(getFileName().empty())
5906     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5907   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5908   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5909 }
5910
5911 /*!
5912  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5913  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5914  * this method does not throw if \a this does not come from file read.
5915  * 
5916  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5917  */
5918 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5919 {
5920   if(!getFileName().empty())
5921     {
5922       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5923       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5924     }
5925 }
5926
5927 /*!
5928  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5929  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5930  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5931  * 
5932  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5933  */
5934 void MEDFileAnyTypeField1TS::unloadArrays()
5935 {
5936   contentNotNullBase()->unloadArrays();
5937 }
5938
5939 /*!
5940  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
5941  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5942  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5943  * 
5944  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5945  */
5946 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5947 {
5948   if(!getFileName().empty())
5949     contentNotNullBase()->unloadArrays();
5950 }
5951
5952 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5953 {
5954   int nbComp=getNumberOfComponents();
5955   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5956   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5957   for(int i=0;i<nbComp;i++)
5958     {
5959       std::string info=getInfo()[i];
5960       std::string c,u;
5961       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5962       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5963       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5964     }
5965   if(getName().empty())
5966     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5967   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5968   writeGlobals(fid,*this);
5969   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5970 }
5971
5972 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5973 {
5974   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5975 }
5976
5977 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5978 {
5979   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5980   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5981   return ret;
5982 }
5983
5984 /*!
5985  * Returns a string describing \a this field. This string is outputted 
5986  * by \c print Python command.
5987  */
5988 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5989 {
5990   std::ostringstream oss;
5991   contentNotNullBase()->simpleRepr(0,oss,-1);
5992   simpleReprGlobs(oss);
5993   return oss.str();
5994 }
5995
5996 /*!
5997  * This method returns all profiles whose name is non empty used.
5998  * \b WARNING If profile is used several times it will be reported \b only \b once.
5999  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6000  */
6001 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6002 {
6003   return contentNotNullBase()->getPflsReallyUsed2();
6004 }
6005
6006 /*!
6007  * This method returns all localizations whose name is non empty used.
6008  * \b WARNING If localization is used several times it will be reported \b only \b once.
6009  */
6010 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6011 {
6012   return contentNotNullBase()->getLocsReallyUsed2();
6013 }
6014
6015 /*!
6016  * This method returns all profiles whose name is non empty used.
6017  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6018  */
6019 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6020 {
6021   return contentNotNullBase()->getPflsReallyUsedMulti2();
6022 }
6023
6024 /*!
6025  * This method returns all localizations whose name is non empty used.
6026  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6027  */
6028 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6029 {
6030   return contentNotNullBase()->getLocsReallyUsedMulti2();
6031 }
6032
6033 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6034 {
6035   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6036 }
6037
6038 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6039 {
6040   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6041 }
6042
6043 int MEDFileAnyTypeField1TS::getDimension() const
6044 {
6045   return contentNotNullBase()->getDimension();
6046 }
6047
6048 int MEDFileAnyTypeField1TS::getIteration() const
6049 {
6050   return contentNotNullBase()->getIteration();
6051 }
6052
6053 int MEDFileAnyTypeField1TS::getOrder() const
6054 {
6055   return contentNotNullBase()->getOrder();
6056 }
6057
6058 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6059 {
6060   return contentNotNullBase()->getTime(iteration,order);
6061 }
6062
6063 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6064 {
6065   contentNotNullBase()->setTime(iteration,order,val);
6066 }
6067
6068 std::string MEDFileAnyTypeField1TS::getName() const
6069 {
6070   return contentNotNullBase()->getName();
6071 }
6072
6073 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6074 {
6075   contentNotNullBase()->setName(name);
6076 }
6077
6078 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6079 {
6080   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6081 }
6082
6083 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6084 {
6085   return contentNotNullBase()->getDtUnit();
6086 }
6087
6088 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6089 {
6090   contentNotNullBase()->setDtUnit(dtUnit);
6091 }
6092
6093 std::string MEDFileAnyTypeField1TS::getMeshName() const
6094 {
6095   return contentNotNullBase()->getMeshName();
6096 }
6097
6098 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6099 {
6100   contentNotNullBase()->setMeshName(newMeshName);
6101 }
6102
6103 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6104 {
6105   return contentNotNullBase()->changeMeshNames(modifTab);
6106 }
6107
6108 int MEDFileAnyTypeField1TS::getMeshIteration() const
6109 {
6110   return contentNotNullBase()->getMeshIteration();
6111 }
6112
6113 int MEDFileAnyTypeField1TS::getMeshOrder() const
6114 {
6115   return contentNotNullBase()->getMeshOrder();
6116 }
6117
6118 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6119 {
6120   return contentNotNullBase()->getNumberOfComponents();
6121 }
6122
6123 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6124 {
6125   return contentNotNullBase()->isDealingTS(iteration,order);
6126 }
6127
6128 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6129 {
6130   return contentNotNullBase()->getDtIt();
6131 }
6132
6133 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6134 {
6135   contentNotNullBase()->fillIteration(p);
6136 }
6137
6138 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6139 {
6140   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6141 }
6142
6143 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6144 {
6145   contentNotNullBase()->setInfo(infos);
6146 }
6147
6148 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6149 {
6150   return contentNotNullBase()->getInfo();
6151 }
6152 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6153 {
6154   return contentNotNullBase()->getInfo();
6155 }
6156
6157 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6158 {
6159   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6160 }
6161
6162 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6163 {
6164   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6165 }
6166
6167 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6168 {
6169   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6170 }
6171
6172 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6173 {
6174   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6175 }
6176
6177 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6178 {
6179   return contentNotNullBase()->getTypesOfFieldAvailable();
6180 }
6181
6182 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6183                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6184 {
6185   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6186 }
6187
6188 /*!
6189  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6190  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6191  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6192  */
6193 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6194 {
6195   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6196   if(!content)
6197     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6198   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6199   std::size_t sz(contentsSplit.size());
6200   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6201   for(std::size_t i=0;i<sz;i++)
6202     {
6203       ret[i]=shallowCpy();
6204       ret[i]->_content=contentsSplit[i];
6205     }
6206   return ret;
6207 }
6208
6209 /*!
6210  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6211  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6212  */
6213 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6214 {
6215   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6216   if(!content)
6217     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6218   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6219   std::size_t sz(contentsSplit.size());
6220   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6221   for(std::size_t i=0;i<sz;i++)
6222     {
6223       ret[i]=shallowCpy();
6224       ret[i]->_content=contentsSplit[i];
6225     }
6226   return ret;
6227 }
6228
6229 /*!
6230  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6231  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6232  */
6233 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6234 {
6235   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6236   if(!content)
6237     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6238   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6239   std::size_t sz(contentsSplit.size());
6240   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6241   for(std::size_t i=0;i<sz;i++)
6242     {
6243       ret[i]=shallowCpy();
6244       ret[i]->_content=contentsSplit[i];
6245     }
6246   return ret;
6247 }
6248
6249 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6250 {
6251   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6252   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6253     ret->_content=_content->deepCopy();
6254   ret->deepCpyGlobs(*this);
6255   return ret.retn();
6256 }
6257
6258 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6259 {
6260   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6261 }
6262
6263 //= MEDFileField1TS
6264
6265 /*!
6266  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6267  * the first field that has been read from a specified MED file.
6268  *  \param [in] fileName - the name of the MED file to read.
6269  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6270  *          is to delete this field using decrRef() as it is no more needed.
6271  *  \throw If reading the file fails.
6272  */
6273 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6274 {
6275   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6276   ret->contentNotNull();
6277   return ret.retn();
6278 }
6279
6280 /*!
6281  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6282  * a given field that has been read from a specified MED file.
6283  *  \param [in] fileName - the name of the MED file to read.
6284  *  \param [in] fieldName - the name of the field to read.
6285  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6286  *          is to delete this field using decrRef() as it is no more needed.
6287  *  \throw If reading the file fails.
6288  *  \throw If there is no field named \a fieldName in the file.
6289  */
6290 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6291 {
6292   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6293   ret->contentNotNull();
6294   return ret.retn();
6295 }
6296
6297 /*!
6298  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6299  * a given field that has been read from a specified MED file.
6300  *  \param [in] fileName - the name of the MED file to read.
6301  *  \param [in] fieldName - the name of the field to read.
6302  *  \param [in] iteration - the iteration number of a required time step.
6303  *  \param [in] order - the iteration order number of required time step.
6304  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6305  *          is to delete this field using decrRef() as it is no more needed.
6306  *  \throw If reading the file fails.
6307  *  \throw If there is no field named \a fieldName in the file.
6308  *  \throw If the required time step is missing from the file.
6309  */
6310 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6311 {
6312   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6313   ret->contentNotNull();
6314   return ret.retn();
6315 }
6316
6317 /*!
6318  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6319  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6320  *
6321  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6322  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6323  * \warning this is a shallow copy constructor
6324  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6325  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6326  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6327  *          is to delete this field using decrRef() as it is no more needed.
6328  */
6329 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6330 {
6331   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6332   ret->contentNotNull();
6333   return ret.retn();
6334 }
6335
6336 /*!
6337  * Returns a new empty instance of MEDFileField1TS.
6338  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6339  *          is to delete this field using decrRef() as it is no more needed.
6340  */
6341 MEDFileField1TS *MEDFileField1TS::New()
6342 {
6343   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6344   ret->contentNotNull();
6345   return ret.retn();
6346 }
6347
6348 /*!
6349  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6350  * following the given input policy.
6351  *
6352  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6353  *                            By default (true) the globals are deeply copied.
6354  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6355  */
6356 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6357 {
6358   MCAuto<MEDFileIntField1TS> ret;
6359   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6360   if(content)
6361     {
6362       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6363       if(!contc)
6364         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6365       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6366       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6367     }
6368   else
6369     ret=MEDFileIntField1TS::New();
6370   if(isDeepCpyGlobs)
6371     ret->deepCpyGlobs(*this);
6372   else
6373     ret->shallowCpyGlobs(*this);
6374   return ret.retn();
6375 }
6376
6377 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6378 {
6379   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6380   if(!pt)
6381     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6382   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6383   if(!ret)
6384     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6385   return ret;
6386 }
6387
6388 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6389 {
6390   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6391   if(!pt)
6392     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6393   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6394   if(!ret)
6395     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is not null but it is not of type double ! Reason is maybe that the read field has not the type FLOAT64 !");
6396   return ret;
6397 }
6398
6399 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6400 {
6401   if(!f)
6402     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6403   if(arr.isNull())
6404     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6405   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6406   if(!arrOutC)
6407     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6408   f->setArray(arrOutC);
6409 }
6410
6411 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6412 {
6413   if(arr.isNull())
6414     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6415   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6416   if(!arrOutC)
6417     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6418   arrOutC->incrRef();
6419   return arrOutC;
6420 }
6421
6422 /*!
6423  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6424  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6425  *
6426  * \return A new object that the caller is responsible to deallocate.
6427  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6428  */
6429 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6430 {
6431   if(!mm)
6432     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6433   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6434   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6435   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6436     {
6437       if((*it0)!=ON_NODES)
6438         {
6439           std::vector<int> levs;
6440           getNonEmptyLevels(mm->getName(),levs);
6441           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6442             {
6443               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6444               if(it2!=extractDef.end())
6445                 {
6446                   MCAuto<DataArrayInt> t((*it2).second);
6447                   if(t.isNull())
6448                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6449                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6450                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6451                   ret->setFieldNoProfileSBT(fOut);
6452                 }
6453             }
6454         }
6455       else
6456         {
6457           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6458           if(it2==extractDef.end())
6459             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6460           MCAuto<DataArrayInt> t((*it2).second);
6461           if(t.isNull())
6462             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6463           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6464           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6465           DataArrayDouble *arr(f->getArray());
6466           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6467           fOut->setArray(newArr);
6468           ret->setFieldNoProfileSBT(fOut);
6469         }
6470     }
6471   return ret.retn();
6472 }
6473
6474 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6475 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6476 {
6477 }
6478 catch(INTERP_KERNEL::Exception& e)
6479 { throw e; }
6480
6481 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6482 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6483 {
6484 }
6485 catch(INTERP_KERNEL::Exception& e)
6486 { throw e; }
6487
6488 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6489 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6490 {
6491 }
6492 catch(INTERP_KERNEL::Exception& e)
6493 { throw e; }
6494
6495 /*!
6496  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6497  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6498  *
6499  * \warning this is a shallow copy constructor
6500  */
6501 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6502 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6503 {
6504 }
6505 catch(INTERP_KERNEL::Exception& e)
6506 { throw e; }
6507
6508 MEDFileField1TS::MEDFileField1TS()
6509 {
6510   _content=new MEDFileField1TSWithoutSDA;
6511 }
6512
6513 /*!
6514  * 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
6515  * method should be called (getFieldOnMeshAtLevel for example).
6516  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6517  *
6518  * \param [in] mesh - the mesh the field is lying on
6519  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6520  *          caller is to delete this field using decrRef() as it is no more needed. 
6521  */
6522 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6523 {
6524   MCAuto<DataArray> arrOut;
6525   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6526   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6527   return ret.retn();
6528 }
6529
6530 /*!
6531  * Returns a new MEDCouplingFieldDouble of a given type lying on
6532  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6533  * has not been constructed via file reading, an exception is thrown.
6534  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6535  *  \param [in] type - a spatial discretization of interest.
6536  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6537  *  \param [in] renumPol - specifies how to permute values of the result field according to
6538  *          the optional numbers of cells and nodes, if any. The valid values are
6539  *          - 0 - do not permute.
6540  *          - 1 - permute cells.
6541  *          - 2 - permute nodes.
6542  *          - 3 - permute cells and nodes.
6543  *
6544  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6545  *          caller is to delete this field using decrRef() as it is no more needed. 
6546  *  \throw If \a this field has not been constructed via file reading.
6547  *  \throw If the MED file is not readable.
6548  *  \throw If there is no mesh in the MED file.
6549  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6550  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6551  *  \sa getFieldOnMeshAtLevel()
6552  */
6553 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6554 {
6555   if(getFileName().empty())
6556     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6557   MCAuto<DataArray> arrOut;
6558   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6559   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6560   return ret.retn();
6561 }
6562
6563 /*!
6564  * Returns a new MEDCouplingFieldDouble of a given type lying on
6565  * the top level cells of the first mesh in MED file. If \a this field 
6566  * has not been constructed via file reading, an exception is thrown.
6567  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6568  *  \param [in] type - a spatial discretization of interest.
6569  *  \param [in] renumPol - specifies how to permute values of the result field according to
6570  *          the optional numbers of cells and nodes, if any. The valid values are
6571  *          - 0 - do not permute.
6572  *          - 1 - permute cells.
6573  *          - 2 - permute nodes.
6574  *          - 3 - permute cells and nodes.
6575  *
6576  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6577  *          caller is to delete this field using decrRef() as it is no more needed. 
6578  *  \throw If \a this field has not been constructed via file reading.
6579  *  \throw If the MED file is not readable.
6580  *  \throw If there is no mesh in the MED file.
6581  *  \throw If no field values of the given \a type.
6582  *  \throw If no field values lying on the top level support.
6583  *  \sa getFieldAtLevel()
6584  */
6585 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6586 {
6587   if(getFileName().empty())
6588     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6589   MCAuto<DataArray> arrOut;
6590   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6591   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6592   return ret.retn();
6593 }
6594
6595 /*!
6596  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6597  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6598  *  \param [in] type - a spatial discretization of the new field.
6599  *  \param [in] mesh - the supporting mesh.
6600  *  \param [in] renumPol - specifies how to permute values of the result field according to
6601  *          the optional numbers of cells and nodes, if any. The valid values are
6602  *          - 0 - do not permute.
6603  *          - 1 - permute cells.
6604  *          - 2 - permute nodes.
6605  *          - 3 - permute cells and nodes.
6606  *
6607  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6608  *          caller is to delete this field using decrRef() as it is no more needed. 
6609  *  \throw If no field of \a this is lying on \a mesh.
6610  *  \throw If the mesh is empty.
6611  *  \throw If no field values of the given \a type are available.
6612  *  \sa getFieldAtLevel()
6613  *  \sa getFieldOnMeshAtLevel() 
6614  */
6615 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6616 {
6617   MCAuto<DataArray> arrOut;
6618   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6619   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6620   return ret.retn();
6621 }
6622
6623 /*!
6624  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6625  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6626  *  \param [in] type - a spatial discretization of interest.
6627  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6628  *  \param [in] mesh - the supporting mesh.
6629  *  \param [in] renumPol - specifies how to permute values of the result field according to
6630  *          the optional numbers of cells and nodes, if any. The valid values are
6631  *          - 0 - do not permute.
6632  *          - 1 - permute cells.
6633  *          - 2 - permute nodes.
6634  *          - 3 - permute cells and nodes.
6635  *
6636  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6637  *          caller is to delete this field using decrRef() as it is no more needed. 
6638  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6639  *  \throw If no field of \a this is lying on \a mesh.
6640  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6641  *  \sa getFieldAtLevel()
6642  *  \sa getFieldOnMeshAtLevel() 
6643  */
6644 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6645 {
6646   MCAuto<DataArray> arrOut;
6647   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6648   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6649   return ret.retn();
6650 }
6651
6652 /*!
6653  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6654  * This method is called "Old" because in MED3 norm a field has only one meshName
6655  * attached, so this method is for readers of MED2 files. If \a this field 
6656  * has not been constructed via file reading, an exception is thrown.
6657  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6658  *  \param [in] type - a spatial discretization of interest.
6659  *  \param [in] mName - a name of the supporting mesh.
6660  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6661  *  \param [in] renumPol - specifies how to permute values of the result field according to
6662  *          the optional numbers of cells and nodes, if any. The valid values are
6663  *          - 0 - do not permute.
6664  *          - 1 - permute cells.
6665  *          - 2 - permute nodes.
6666  *          - 3 - permute cells and nodes.
6667  *
6668  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6669  *          caller is to delete this field using decrRef() as it is no more needed. 
6670  *  \throw If the MED file is not readable.
6671  *  \throw If there is no mesh named \a mName in the MED file.
6672  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6673  *  \throw If \a this field has not been constructed via file reading.
6674  *  \throw If no field of \a this is lying on the mesh named \a mName.
6675  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6676  *  \sa getFieldAtLevel()
6677  */
6678 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6679 {
6680   if(getFileName().empty())
6681     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6682   MCAuto<DataArray> arrOut;
6683   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6684   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6685   return ret.retn();
6686 }
6687
6688 /*!
6689  * Returns values and a profile of the field of a given type lying on a given support.
6690  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6691  *  \param [in] type - a spatial discretization of the field.
6692  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6693  *  \param [in] mesh - the supporting mesh.
6694  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6695  *          field of interest lies on. If the field lies on all entities of the given
6696  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6697  *          using decrRef() as it is no more needed.  
6698  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6699  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6700  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6701  *  \throw If no field of \a this is lying on \a mesh.
6702  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6703  */
6704 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6705 {
6706   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6707   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6708 }
6709
6710 /*!
6711  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6712  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6713  * "Sort By Type"), if not, an exception is thrown. 
6714  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6715  *  \param [in] field - the field to add to \a this.
6716  *  \throw If the name of \a field is empty.
6717  *  \throw If the data array of \a field is not set.
6718  *  \throw If the data array is already allocated but has different number of components
6719  *         than \a field.
6720  *  \throw If the underlying mesh of \a field has no name.
6721  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6722  */
6723 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6724 {
6725   setFileName("");
6726   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6727 }
6728
6729 /*!
6730  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6731  * can be an aggregation of several MEDCouplingFieldDouble instances.
6732  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6733  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6734  * and \a profile.
6735  *
6736  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6737  * A new profile is added only if no equal profile is missing.
6738  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6739  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6740  *  \param [in] mesh - the supporting mesh of \a field.
6741  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6742  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6743  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6744  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6745  *  \throw If the data array of \a field is not set.
6746  *  \throw If the data array of \a this is already allocated but has different number of
6747  *         components than \a field.
6748  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6749  *  \sa setFieldNoProfileSBT()
6750  */
6751 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6752 {
6753   setFileName("");
6754   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6755 }
6756
6757 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6758 {
6759   return new MEDFileField1TS(*this);
6760 }
6761
6762 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6763 {
6764   return contentNotNull()->getUndergroundDataArrayDouble();
6765 }
6766
6767 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6768 {
6769   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6770 }
6771
6772 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6773                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6774 {
6775   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6776 }
6777
6778 //= MEDFileIntField1TS
6779
6780 MEDFileIntField1TS *MEDFileIntField1TS::New()
6781 {
6782   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6783   ret->contentNotNull();
6784   return ret.retn();
6785 }
6786
6787 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6788 {
6789   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6790   ret->contentNotNull();
6791   return ret.retn();
6792 }
6793
6794 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6795 {
6796   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6797   ret->contentNotNull();
6798   return ret.retn();
6799 }
6800
6801 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6802 {
6803   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6804   ret->contentNotNull();
6805   return ret.retn();
6806 }
6807
6808 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6809 {
6810   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6811   ret->contentNotNull();
6812   return ret.retn();
6813 }
6814
6815 MEDFileIntField1TS::MEDFileIntField1TS()
6816 {
6817   _content=new MEDFileIntField1TSWithoutSDA;
6818 }
6819
6820 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6821 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6822 {
6823 }
6824 catch(INTERP_KERNEL::Exception& e)
6825 { throw e; }
6826
6827 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6828 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6829 {
6830 }
6831 catch(INTERP_KERNEL::Exception& e)
6832 { throw e; }
6833
6834 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6835 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6836 {
6837 }
6838 catch(INTERP_KERNEL::Exception& e)
6839 { throw e; }
6840
6841 /*!
6842  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6843  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6844  *
6845  * \warning this is a shallow copy constructor
6846  */
6847 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6848 {
6849 }
6850
6851 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6852 {
6853   return new MEDFileIntField1TS(*this);
6854 }
6855
6856 /*!
6857  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6858  * following the given input policy.
6859  *
6860  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6861  *                            By default (true) the globals are deeply copied.
6862  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6863  */
6864 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6865 {
6866   MCAuto<MEDFileField1TS> ret;
6867   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6868   if(content)
6869     {
6870       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6871       if(!contc)
6872         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6873       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6874       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6875     }
6876   else
6877     ret=MEDFileField1TS::New();
6878   if(isDeepCpyGlobs)
6879     ret->deepCpyGlobs(*this);
6880   else
6881     ret->shallowCpyGlobs(*this);
6882   return ret.retn();
6883 }
6884
6885 /*!
6886  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6887  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6888  * "Sort By Type"), if not, an exception is thrown. 
6889  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6890  *  \param [in] field - the field to add to \a this.
6891  *  \throw If the name of \a field is empty.
6892  *  \throw If the data array of \a field is not set.
6893  *  \throw If the data array is already allocated but has different number of components
6894  *         than \a field.
6895  *  \throw If the underlying mesh of \a field has no name.
6896  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6897  */
6898 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6899 {
6900   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6901   setFileName("");
6902   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6903 }
6904
6905 /*!
6906  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6907  * can be an aggregation of several MEDCouplingFieldDouble instances.
6908  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6909  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6910  * and \a profile.
6911  *
6912  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6913  * A new profile is added only if no equal profile is missing.
6914  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6915  *  \param [in] field - the field to add to \a this.
6916  *  \param [in] mesh - the supporting mesh of \a field.
6917  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6918  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6919  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6920  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6921  *  \throw If the data array of \a field is not set.
6922  *  \throw If the data array of \a this is already allocated but has different number of
6923  *         components than \a field.
6924  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6925  *  \sa setFieldNoProfileSBT()
6926  */
6927 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6928 {
6929   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6930   setFileName("");
6931   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6932 }
6933
6934 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6935 {
6936   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6937   if(!pt)
6938     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6939   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6940   if(!ret)
6941     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 !");
6942   return ret;
6943 }
6944
6945 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6946 {
6947   if(getFileName().empty())
6948     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6949   MCAuto<DataArray> arrOut;
6950   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6951   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6952   return ret2.retn();
6953 }
6954
6955 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6956 {
6957   if(arr.isNull())
6958     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6959   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6960   if(!arrC)
6961     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6962   arrC->incrRef();
6963   return arrC;
6964 }
6965
6966 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6967 {
6968   int t1,t2;
6969   double t0(f->getTime(t1,t2));
6970   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6971   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6972   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6973   ret->setTime(t0,t1,t2); ret->setArray(arr2);
6974   return ret.retn();
6975 }
6976
6977 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6978 {
6979   if(!f)
6980     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6981   int t1,t2;
6982   double t0(f->getTime(t1,t2));
6983   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6984   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6985   ret->setTime(t0,t1,t2);
6986   return ret;
6987 }
6988
6989 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6990 {
6991   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6992 }
6993
6994 /*!
6995  * 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
6996  * method should be called (getFieldOnMeshAtLevel for example).
6997  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6998  *
6999  * \param [in] mesh - the mesh the field is lying on
7000  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7001  *          caller is to delete this field using decrRef() as it is no more needed. 
7002  */
7003 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7004 {
7005   MCAuto<DataArray> arrOut;
7006   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7007   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7008   return ret2.retn();
7009 }
7010
7011 /*!
7012  * Returns a new MEDCouplingFieldInt of a given type lying on
7013  * the top level cells of the first mesh in MED file. If \a this field 
7014  * has not been constructed via file reading, an exception is thrown.
7015  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7016  *  \param [in] type - a spatial discretization of interest.
7017  *  \param [in] renumPol - specifies how to permute values of the result field according to
7018  *          the optional numbers of cells and nodes, if any. The valid values are
7019  *          - 0 - do not permute.
7020  *          - 1 - permute cells.
7021  *          - 2 - permute nodes.
7022  *          - 3 - permute cells and nodes.
7023  *
7024  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7025  *          caller is to delete this field using decrRef() as it is no more needed. 
7026  *  \throw If \a this field has not been constructed via file reading.
7027  *  \throw If the MED file is not readable.
7028  *  \throw If there is no mesh in the MED file.
7029  *  \throw If no field values of the given \a type.
7030  *  \throw If no field values lying on the top level support.
7031  *  \sa getFieldAtLevel()
7032  */
7033 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7034 {
7035   if(getFileName().empty())
7036     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7037   MCAuto<DataArray> arrOut;
7038   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7039   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7040   return ret2.retn();
7041 }
7042
7043 /*!
7044  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7045  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7046  *  \param [in] type - a spatial discretization of the new field.
7047  *  \param [in] mesh - the supporting mesh.
7048  *  \param [in] renumPol - specifies how to permute values of the result field according to
7049  *          the optional numbers of cells and nodes, if any. The valid values are
7050  *          - 0 - do not permute.
7051  *          - 1 - permute cells.
7052  *          - 2 - permute nodes.
7053  *          - 3 - permute cells and nodes.
7054  *
7055  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7056  *          caller is to delete this field using decrRef() as it is no more needed. 
7057  *  \throw If no field of \a this is lying on \a mesh.
7058  *  \throw If the mesh is empty.
7059  *  \throw If no field values of the given \a type are available.
7060  *  \sa getFieldAtLevel()
7061  *  \sa getFieldOnMeshAtLevel() 
7062  */
7063 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7064 {
7065   MCAuto<DataArray> arrOut;
7066   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7067   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7068   return ret2.retn();
7069 }
7070
7071 /*!
7072  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7073  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7074  *  \param [in] type - a spatial discretization of interest.
7075  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7076  *  \param [in] mesh - the supporting mesh.
7077  *  \param [in] renumPol - specifies how to permute values of the result field according to
7078  *          the optional numbers of cells and nodes, if any. The valid values are
7079  *          - 0 - do not permute.
7080  *          - 1 - permute cells.
7081  *          - 2 - permute nodes.
7082  *          - 3 - permute cells and nodes.
7083  *
7084  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7085  *          caller is to delete this field using decrRef() as it is no more needed. 
7086  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7087  *  \throw If no field of \a this is lying on \a mesh.
7088  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7089  *  \sa getFieldAtLevel()
7090  *  \sa getFieldOnMeshAtLevel() 
7091  */
7092 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7093 {
7094   MCAuto<DataArray> arrOut;
7095   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7096   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7097   return ret2.retn();
7098 }
7099
7100 /*!
7101  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7102  * This method is called "Old" because in MED3 norm a field has only one meshName
7103  * attached, so this method is for readers of MED2 files. If \a this field 
7104  * has not been constructed via file reading, an exception is thrown.
7105  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7106  *  \param [in] type - a spatial discretization of interest.
7107  *  \param [in] mName - a name of the supporting mesh.
7108  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7109  *  \param [in] renumPol - specifies how to permute values of the result field according to
7110  *          the optional numbers of cells and nodes, if any. The valid values are
7111  *          - 0 - do not permute.
7112  *          - 1 - permute cells.
7113  *          - 2 - permute nodes.
7114  *          - 3 - permute cells and nodes.
7115  *
7116  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7117  *          caller is to delete this field using decrRef() as it is no more needed. 
7118  *  \throw If the MED file is not readable.
7119  *  \throw If there is no mesh named \a mName in the MED file.
7120  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7121  *  \throw If \a this field has not been constructed via file reading.
7122  *  \throw If no field of \a this is lying on the mesh named \a mName.
7123  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7124  *  \sa getFieldAtLevel()
7125  */
7126 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7127 {
7128   if(getFileName().empty())
7129     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7130   MCAuto<DataArray> arrOut;
7131   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7132   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7133   return ret2.retn();
7134 }
7135
7136 /*!
7137  * Returns values and a profile of the field of a given type lying on a given support.
7138  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7139  *  \param [in] type - a spatial discretization of the field.
7140  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7141  *  \param [in] mesh - the supporting mesh.
7142  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7143  *          field of interest lies on. If the field lies on all entities of the given
7144  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7145  *          using decrRef() as it is no more needed.  
7146  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7147  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7148  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7149  *  \throw If no field of \a this is lying on \a mesh.
7150  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7151  */
7152 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7153 {
7154   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7155   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7156 }
7157
7158 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7159 {
7160   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7161   if(!pt)
7162     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7163   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7164   if(!ret)
7165     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 !");
7166   return ret;
7167 }
7168
7169 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7170 {
7171   return contentNotNull()->getUndergroundDataArrayInt();
7172 }
7173
7174 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7175
7176 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7177 {
7178 }
7179
7180 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7181 {
7182 }
7183
7184 /*!
7185  * \param [in] fieldId field id in C mode
7186  */
7187 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7188 {
7189   med_field_type typcha;
7190   std::string dtunitOut;
7191   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7192   setDtUnit(dtunitOut.c_str());
7193   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7194 }
7195
7196 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7197 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7198 {
7199   setDtUnit(dtunit.c_str());
7200   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7201 }
7202 catch(INTERP_KERNEL::Exception& e)
7203 {
7204     throw e;
7205 }
7206
7207 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7208 {
7209   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7210   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7211     ret+=(*it).capacity();
7212   return ret;
7213 }
7214
7215 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7216 {
7217   std::vector<const BigMemoryObject *> ret;
7218   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7219     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7220   return ret;
7221 }
7222
7223 /*!
7224  * 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
7225  * NULL.
7226  */
7227 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7228 {
7229   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7230   ret->setInfo(_infos);
7231   int sz=(int)_time_steps.size();
7232   for(const int *id=startIds;id!=endIds;id++)
7233     {
7234       if(*id>=0 && *id<sz)
7235         {
7236           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7237           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7238           if(tse)
7239             {
7240               tse->incrRef();
7241               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7242             }
7243           ret->pushBackTimeStep(tse2);
7244         }
7245       else
7246         {
7247           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7248           oss << " ! Should be in [0," << sz << ") !";
7249           throw INTERP_KERNEL::Exception(oss.str());
7250         }
7251     }
7252   if(ret->getNumberOfTS()>0)
7253     ret->synchronizeNameScope();
7254   ret->copyNameScope(*this);
7255   return ret.retn();
7256 }
7257
7258 /*!
7259  * 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
7260  * NULL.
7261  */
7262 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7263 {
7264   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7265   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7266   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7267   ret->setInfo(_infos);
7268   int sz=(int)_time_steps.size();
7269   int j=bg;
7270   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7271     {
7272       if(j>=0 && j<sz)
7273         {
7274           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7275           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7276           if(tse)
7277             {
7278               tse->incrRef();
7279               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7280             }
7281           ret->pushBackTimeStep(tse2);
7282         }
7283       else
7284         {
7285           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7286           oss << " ! Should be in [0," << sz << ") !";
7287           throw INTERP_KERNEL::Exception(oss.str());
7288         }
7289     }
7290   if(ret->getNumberOfTS()>0)
7291     ret->synchronizeNameScope();
7292   ret->copyNameScope(*this);
7293   return ret.retn();
7294 }
7295
7296 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7297 {
7298   int id=0;
7299   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7300   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7301     {
7302       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7303       if(!cur)
7304         continue;
7305       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7306       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7307         ids->pushBackSilent(id);
7308     }
7309   return buildFromTimeStepIds(ids->begin(),ids->end());
7310 }
7311
7312 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7313 {
7314   int id=0;
7315   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7316   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7317     {
7318       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7319       if(!cur)
7320         continue;
7321       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7322       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7323         ids->pushBackSilent(id);
7324     }
7325   return buildFromTimeStepIds(ids->begin(),ids->end());
7326 }
7327
7328 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7329 {
7330   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7331     {
7332       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7333       if(!cur)
7334         continue;
7335       if(cur->presenceOfMultiDiscPerGeoType())
7336         return true;
7337     }
7338   return false;
7339 }
7340
7341 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7342 {
7343   return _infos;
7344 }
7345
7346 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7347 {
7348   _infos=info;
7349 }
7350
7351 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7352 {
7353   int ret=0;
7354   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7355     {
7356       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7357       if(pt->isDealingTS(iteration,order))
7358         return ret;
7359     }
7360   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7361   std::vector< std::pair<int,int> > vp=getIterations();
7362   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7363     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7364   throw INTERP_KERNEL::Exception(oss.str());
7365 }
7366
7367 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7368 {
7369   return *_time_steps[getTimeStepPos(iteration,order)];
7370 }
7371
7372 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7373 {
7374   return *_time_steps[getTimeStepPos(iteration,order)];
7375 }
7376
7377 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7378 {
7379   if(_time_steps.empty())
7380     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7381   return _time_steps[0]->getMeshName();
7382 }
7383
7384 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7385 {
7386   std::string oldName(getMeshName());
7387   std::vector< std::pair<std::string,std::string> > v(1);
7388   v[0].first=oldName; v[0].second=newMeshName;
7389   changeMeshNames(v);
7390 }
7391
7392 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7393 {
7394   bool ret=false;
7395   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7396     {
7397       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7398       if(cur)
7399         ret=cur->changeMeshNames(modifTab) || ret;
7400     }
7401   return ret;
7402 }
7403
7404 /*!
7405  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7406  */
7407 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7408 {
7409   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7410 }
7411
7412 /*!
7413  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7414  */
7415 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7416 {
7417   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7418 }
7419
7420 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7421                                                                        MEDFileFieldGlobsReal& glob)
7422 {
7423   bool ret=false;
7424   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7425     {
7426       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7427       if(f1ts)
7428         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7429     }
7430   return ret;
7431 }
7432
7433 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7434 {
7435   std::string startLine(bkOffset,' ');
7436   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7437   if(fmtsId>=0)
7438     oss << " (" << fmtsId << ")";
7439   oss << " has the following name: \"" << _name << "\"." << std::endl;
7440   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7441   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7442     {
7443       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7444     }
7445   int i=0;
7446   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7447     {
7448       std::string chapter(17,'0'+i);
7449       oss << startLine << chapter << std::endl;
7450       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7451       if(cur)
7452         cur->simpleRepr(bkOffset+2,oss,i);
7453       else
7454         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7455       oss << startLine << chapter << std::endl;
7456     }
7457 }
7458
7459 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7460 {
7461   std::size_t sz=_time_steps.size();
7462   std::vector< std::pair<int,int> > ret(sz);
7463   ret1.resize(sz);
7464   for(std::size_t i=0;i<sz;i++)
7465     {
7466       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7467       if(f1ts)
7468         {
7469           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7470         }
7471       else
7472         {
7473           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7474           throw INTERP_KERNEL::Exception(oss.str());
7475         }
7476     }
7477   return ret;
7478 }
7479
7480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7481 {
7482   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7483   if(!tse2)
7484     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7485   checkCoherencyOfType(tse2);
7486   if(_time_steps.empty())
7487     {
7488       setName(tse2->getName().c_str());
7489       setInfo(tse2->getInfo());
7490     }
7491   checkThatComponentsMatch(tse2->getInfo());
7492   _time_steps.push_back(tse);
7493 }
7494
7495 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7496 {
7497   std::size_t nbOfCompo=_infos.size();
7498   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7499     {
7500       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7501       if(cur)
7502         {
7503           if((cur->getInfo()).size()!=nbOfCompo)
7504             {
7505               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7506               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7507               throw INTERP_KERNEL::Exception(oss.str());
7508             }
7509           cur->copyNameScope(*this);
7510         }
7511     }
7512 }
7513
7514 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7515 {
7516   _time_steps.resize(nbPdt);
7517   for(int i=0;i<nbPdt;i++)
7518     {
7519       std::vector< std::pair<int,int> > ts;
7520       med_int numdt=0,numo=0;
7521       med_int meshIt=0,meshOrder=0;
7522       med_float dt=0.0;
7523       MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7524       switch(fieldTyp)
7525       {
7526         case MED_FLOAT64:
7527           {
7528             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7529             break;
7530           }
7531         case MED_INT32:
7532           {
7533             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7534             break;
7535           }
7536         default:
7537           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7538       }
7539       if(loadAll)
7540         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7541       else
7542         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7543     }
7544 }
7545
7546 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7547 {
7548   if(_time_steps.empty())
7549     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7550   checkThatNbOfCompoOfTSMatchThis();
7551   std::vector<std::string> infos(getInfo());
7552   int nbComp=infos.size();
7553   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7554   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7555   for(int i=0;i<nbComp;i++)
7556     {
7557       std::string info=infos[i];
7558       std::string c,u;
7559       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7560       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7561       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7562     }
7563   if(_name.empty())
7564     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7565   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7566   int nbOfTS=_time_steps.size();
7567   for(int i=0;i<nbOfTS;i++)
7568     _time_steps[i]->writeLL(fid,opts,*this);
7569 }
7570
7571 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7572 {
7573   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7574     {
7575       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7576       if(elt)
7577         elt->loadBigArraysRecursively(fid,nasc);
7578     }
7579 }
7580
7581 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7582 {
7583   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7584     {
7585       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7586       if(elt)
7587         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7588     }
7589 }
7590
7591 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7592 {
7593   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7594     {
7595       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7596       if(elt)
7597         elt->unloadArrays();
7598     }
7599 }
7600
7601 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7602 {
7603   return _time_steps.size();
7604 }
7605
7606 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7607 {
7608   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7609   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7610     {
7611       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7612       if(tmp)
7613         newTS.push_back(*it);
7614     }
7615   _time_steps=newTS;
7616 }
7617
7618 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7619 {
7620   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7621   int maxId=(int)_time_steps.size();
7622   int ii=0;
7623   std::set<int> idsToDel;
7624   for(const int *id=startIds;id!=endIds;id++,ii++)
7625     {
7626       if(*id>=0 && *id<maxId)
7627         {
7628           idsToDel.insert(*id);
7629         }
7630       else
7631         {
7632           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7633           throw INTERP_KERNEL::Exception(oss.str());
7634         }
7635     }
7636   for(int iii=0;iii<maxId;iii++)
7637     if(idsToDel.find(iii)==idsToDel.end())
7638       newTS.push_back(_time_steps[iii]);
7639   _time_steps=newTS;
7640 }
7641
7642 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7643 {
7644   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7645   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7646   if(nbOfEntriesToKill==0)
7647     return ;
7648   std::size_t sz=_time_steps.size();
7649   std::vector<bool> b(sz,true);
7650   int j=bg;
7651   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7652     b[j]=false;
7653   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7654   for(std::size_t i=0;i<sz;i++)
7655     if(b[i])
7656       newTS.push_back(_time_steps[i]);
7657   _time_steps=newTS;
7658 }
7659
7660 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7661 {
7662   int ret=0;
7663   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7664   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7665     {
7666       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7667       if(tmp)
7668         {
7669           int it2,ord;
7670           tmp->getTime(it2,ord);
7671           if(it2==iteration && order==ord)
7672             return ret;
7673           else
7674             oss << "(" << it2 << ","  << ord << "), ";
7675         }
7676     }
7677   throw INTERP_KERNEL::Exception(oss.str());
7678 }
7679
7680 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7681 {
7682   int ret=0;
7683   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7684   oss.precision(15);
7685   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7686     {
7687       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7688       if(tmp)
7689         {
7690           int it2,ord;
7691           double ti=tmp->getTime(it2,ord);
7692           if(fabs(time-ti)<eps)
7693             return ret;
7694           else
7695             oss << ti << ", ";
7696         }
7697     }
7698   throw INTERP_KERNEL::Exception(oss.str());
7699 }
7700
7701 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7702 {
7703   int lgth=_time_steps.size();
7704   std::vector< std::pair<int,int> > ret(lgth);
7705   for(int i=0;i<lgth;i++)
7706     _time_steps[i]->fillIteration(ret[i]);
7707   return ret;
7708 }
7709
7710 /*!
7711  * 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'
7712  * This method returns two things.
7713  * - The absolute dimension of 'this' in first parameter. 
7714  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7715  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7716  *
7717  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7718  * Only these 3 discretizations will be taken into account here.
7719  *
7720  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7721  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7722  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7723  *
7724  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7725  * 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'.
7726  * 
7727  * Let's consider the typical following case :
7728  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7729  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7730  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7731  *   TETRA4 and SEG2
7732  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7733  *
7734  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7735  * 
7736  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7737  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7738  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7739  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7740  */
7741 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7742 {
7743   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7744 }
7745
7746 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7747 {
7748   if(pos<0 || pos>=(int)_time_steps.size())
7749     {
7750       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7751       throw INTERP_KERNEL::Exception(oss.str());
7752     }
7753   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7754   if(item==0)
7755     {
7756       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7757       oss << "\nTry to use following method eraseEmptyTS !";
7758       throw INTERP_KERNEL::Exception(oss.str());
7759     }
7760   return item;
7761 }
7762
7763 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7764 {
7765   if(pos<0 || pos>=(int)_time_steps.size())
7766     {
7767       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7768       throw INTERP_KERNEL::Exception(oss.str());
7769     }
7770   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7771   if(item==0)
7772     {
7773       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7774       oss << "\nTry to use following method eraseEmptyTS !";
7775       throw INTERP_KERNEL::Exception(oss.str());
7776     }
7777   return item;
7778 }
7779
7780 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7781 {
7782   std::vector<std::string> ret;
7783   std::set<std::string> ret2;
7784   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7785     {
7786       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7787       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7788         if(ret2.find(*it2)==ret2.end())
7789           {
7790             ret.push_back(*it2);
7791             ret2.insert(*it2);
7792           }
7793     }
7794   return ret;
7795 }
7796
7797 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7798 {
7799   std::vector<std::string> ret;
7800   std::set<std::string> ret2;
7801   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7802     {
7803       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7804       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7805         if(ret2.find(*it2)==ret2.end())
7806           {
7807             ret.push_back(*it2);
7808             ret2.insert(*it2);
7809           }
7810     }
7811   return ret;
7812 }
7813
7814 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7815 {
7816   std::vector<std::string> ret;
7817   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7818     {
7819       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7820       ret.insert(ret.end(),tmp.begin(),tmp.end());
7821     }
7822   return ret;
7823 }
7824
7825 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7826 {
7827   std::vector<std::string> ret;
7828   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7829     {
7830       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7831       ret.insert(ret.end(),tmp.begin(),tmp.end());
7832     }
7833   return ret;
7834 }
7835
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7837 {
7838   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7839     (*it)->changePflsRefsNamesGen2(mapOfModif);
7840 }
7841
7842 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7843 {
7844   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7845     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7846 }
7847
7848 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7849 {
7850   int lgth=_time_steps.size();
7851   std::vector< std::vector<TypeOfField> > ret(lgth);
7852   for(int i=0;i<lgth;i++)
7853     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7854   return ret;
7855 }
7856
7857 /*!
7858  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7859  */
7860 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
7861 {
7862   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7863 }
7864
7865 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7866 {
7867   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7868   std::size_t i=0;
7869   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7870     {
7871       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7872         ret->_time_steps[i]=(*it)->deepCopy();
7873     }
7874   return ret.retn();
7875 }
7876
7877 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7878 {
7879   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7880   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7881   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7882   for(std::size_t i=0;i<sz;i++)
7883     {
7884       ret[i]=shallowCpy();
7885       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7886     }
7887   for(std::size_t i=0;i<sz2;i++)
7888     {
7889       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7890       if(ret1.size()!=sz)
7891         {
7892           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7893           throw INTERP_KERNEL::Exception(oss.str());
7894         }
7895       ts[i]=ret1;
7896     }
7897   for(std::size_t i=0;i<sz;i++)
7898     for(std::size_t j=0;j<sz2;j++)
7899       ret[i]->_time_steps[j]=ts[j][i];
7900   return ret;
7901 }
7902
7903 /*!
7904  * This method splits into discretization each time steps in \a this.
7905  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7906  */
7907 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7908 {
7909   std::size_t sz(_time_steps.size());
7910   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7911   for(std::size_t i=0;i<sz;i++)
7912     {
7913       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7914       if(!timeStep)
7915         {
7916           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7917           throw INTERP_KERNEL::Exception(oss.str());
7918         }
7919       items[i]=timeStep->splitDiscretizations();  
7920     }
7921   //
7922   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7923   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7924   std::vector< TypeOfField > types;
7925   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7926     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7927       {
7928         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7929         if(ts.size()!=1)
7930           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7931         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7932         if(it2==types.end())
7933           types.push_back(ts[0]);
7934       }
7935   ret.resize(types.size()); ret2.resize(types.size());
7936   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7937     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7938       {
7939         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7940         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7941         ret2[pos].push_back(*it1);
7942       }
7943   for(std::size_t i=0;i<types.size();i++)
7944     {
7945       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7946       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7947         elt->pushBackTimeStep(*it1);//also updates infos in elt
7948       ret[i]=elt;
7949       elt->MEDFileFieldNameScope::operator=(*this);
7950     }
7951   return ret;
7952 }
7953
7954 /*!
7955  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7956  */
7957 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7958 {
7959   std::size_t sz(_time_steps.size());
7960   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7961   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7962   for(std::size_t i=0;i<sz;i++)
7963     {
7964       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7965       if(!timeStep)
7966         {
7967           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7968           throw INTERP_KERNEL::Exception(oss.str());
7969         }
7970       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7971       if(szOut==std::numeric_limits<std::size_t>::max())
7972         szOut=items[i].size();
7973       else
7974         if(items[i].size()!=szOut)
7975           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7976     }
7977   if(szOut==std::numeric_limits<std::size_t>::max())
7978     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7979   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7980   for(std::size_t i=0;i<szOut;i++)
7981     {
7982       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7983       for(std::size_t j=0;j<sz;j++)
7984         elt->pushBackTimeStep(items[j][i]);
7985       ret[i]=elt;
7986       elt->MEDFileFieldNameScope::operator=(*this);
7987     }
7988   return ret;
7989 }
7990
7991 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7992 {
7993   _name=field->getName();
7994   if(_name.empty())
7995     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7996   if(!arr)
7997     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7998   _infos=arr->getInfoOnComponents();
7999 }
8000
8001 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8002 {
8003   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8004   if(_name!=field->getName())
8005     {
8006       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8007       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8008       throw INTERP_KERNEL::Exception(oss.str());
8009     }
8010   if(!arr)
8011     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8012   checkThatComponentsMatch(arr->getInfoOnComponents());
8013 }
8014
8015 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8016 {
8017   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8018   if(getInfo().size()!=compos.size())
8019     {
8020       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8021       oss << " number of components of element to append (" << compos.size() << ") !";
8022       throw INTERP_KERNEL::Exception(oss.str());
8023     }
8024   if(_infos!=compos)
8025     {
8026       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8027       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8028       oss << " But compo in input fields are : ";
8029       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8030       oss << " !";
8031       throw INTERP_KERNEL::Exception(oss.str());
8032     }
8033 }
8034
8035 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8036 {
8037   std::size_t sz=_infos.size();
8038   int j=0;
8039   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8040     {
8041       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8042       if(elt)
8043         if(elt->getInfo().size()!=sz)
8044           {
8045             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8046             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8047             throw INTERP_KERNEL::Exception(oss.str());
8048           }
8049     }
8050 }
8051
8052 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8053 {
8054   if(!field)
8055     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8056   if(!_time_steps.empty())
8057     checkCoherencyOfTinyInfo(field,arr);
8058   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8059   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8060   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8061   copyTinyInfoFrom(field,arr);
8062   _time_steps.push_back(obj);
8063 }
8064
8065 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8066 {
8067   if(!field)
8068     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8069   if(!_time_steps.empty())
8070     checkCoherencyOfTinyInfo(field,arr);
8071   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8072   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8073   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8074   copyTinyInfoFrom(field,arr);
8075   _time_steps.push_back(obj);
8076 }
8077
8078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8079 {
8080   int sz=(int)_time_steps.size();
8081   if(i<0 || i>=sz)
8082     {
8083       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8084       throw INTERP_KERNEL::Exception(oss.str());
8085     }
8086   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8087   if(tsPtr)
8088     {
8089       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8090         {
8091           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8092           throw INTERP_KERNEL::Exception(oss.str());
8093         }
8094     }
8095   _time_steps[i]=ts;
8096 }
8097
8098 //= MEDFileFieldMultiTSWithoutSDA
8099
8100 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8101 {
8102   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8103 }
8104
8105 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8106 {
8107 }
8108
8109 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8110 {
8111 }
8112
8113 /*!
8114  * \param [in] fieldId field id in C mode
8115  */
8116 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8117 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8118 {
8119 }
8120 catch(INTERP_KERNEL::Exception& e)
8121 { throw e; }
8122
8123 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8124 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8125 {
8126 }
8127 catch(INTERP_KERNEL::Exception& e)
8128 { throw e; }
8129
8130 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8131 {
8132   return new MEDFileField1TSWithoutSDA;
8133 }
8134
8135 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8136 {
8137   if(!f1ts)
8138     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8139   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8140   if(!f1tsC)
8141     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8142 }
8143
8144 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8145 {
8146   return MEDFileField1TSWithoutSDA::TYPE_STR;
8147 }
8148
8149 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8150 {
8151   return new MEDFileFieldMultiTSWithoutSDA(*this);
8152 }
8153
8154 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8155 {
8156   return new MEDFileFieldMultiTSWithoutSDA;
8157 }
8158
8159 /*!
8160  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8161  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8162  */
8163 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
8164 {
8165   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8166   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8167   if(!myF1TSC)
8168     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8169   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8170 }
8171
8172 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8173 {
8174   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8175   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8176   int i=0;
8177   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8178     {
8179       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8180       if(eltToConv)
8181         {
8182           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8183           if(!eltToConvC)
8184             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8185           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8186           ret->setIteration(i,elt);
8187         }
8188     }
8189   return ret.retn();
8190 }
8191
8192 //= MEDFileAnyTypeFieldMultiTS
8193
8194 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8195 {
8196 }
8197
8198 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8199 try:MEDFileFieldGlobsReal(fileName)
8200 {
8201   MEDFileUtilities::CheckFileForRead(fileName);
8202   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8203   _content=BuildContentFrom(fid,fileName,loadAll,ms);
8204   loadGlobals(fid);
8205 }
8206 catch(INTERP_KERNEL::Exception& e)
8207 {
8208     throw e;
8209 }
8210
8211 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8212 {
8213   med_field_type typcha;
8214   std::vector<std::string> infos;
8215   std::string dtunit;
8216   int i=-1;
8217   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8218   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8219   switch(typcha)
8220   {
8221     case MED_FLOAT64:
8222       {
8223         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8224         break;
8225       }
8226     case MED_INT32:
8227       {
8228         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8229         break;
8230       }
8231     default:
8232       {
8233         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8234         throw INTERP_KERNEL::Exception(oss.str());
8235       }
8236   }
8237   ret->setDtUnit(dtunit.c_str());
8238   return ret.retn();
8239 }
8240
8241 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8242 {
8243   med_field_type typcha;
8244   //
8245   std::vector<std::string> infos;
8246   std::string dtunit,fieldName;
8247   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8248   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8249   switch(typcha)
8250   {
8251     case MED_FLOAT64:
8252       {
8253         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8254         break;
8255       }
8256     case MED_INT32:
8257       {
8258         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8259         break;
8260       }
8261     default:
8262       {
8263         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8264         throw INTERP_KERNEL::Exception(oss.str());
8265       }
8266   }
8267   ret->setDtUnit(dtunit.c_str());
8268   return ret.retn();
8269 }
8270
8271 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8272 {
8273   if(!c)
8274     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8275   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8276     {
8277       MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8278       ret->setFileName(fileName);
8279       ret->_content=c;  c->incrRef();
8280       return ret.retn();
8281     }
8282   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8283     {
8284       MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8285       ret->setFileName(fileName);
8286       ret->_content=c;  c->incrRef();
8287       return ret.retn();
8288     }
8289   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8290 }
8291
8292 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8293 try:MEDFileFieldGlobsReal(fileName)
8294 {
8295   MEDFileUtilities::CheckFileForRead(fileName);
8296   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8297   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8298   loadGlobals(fid);
8299 }
8300 catch(INTERP_KERNEL::Exception& e)
8301 {
8302     throw e;
8303 }
8304
8305 //= MEDFileIntFieldMultiTSWithoutSDA
8306
8307 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8308 {
8309   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8310 }
8311
8312 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8313 {
8314 }
8315
8316 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8317 {
8318 }
8319
8320 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8321 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8322 {
8323 }
8324 catch(INTERP_KERNEL::Exception& e)
8325 { throw e; }
8326
8327 /*!
8328  * \param [in] fieldId field id in C mode
8329  */
8330 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8331 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8332 {
8333 }
8334 catch(INTERP_KERNEL::Exception& e)
8335 { throw e; }
8336
8337 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8338 {
8339   return new MEDFileIntField1TSWithoutSDA;
8340 }
8341
8342 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8343 {
8344   if(!f1ts)
8345     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8346   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8347   if(!f1tsC)
8348     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8349 }
8350
8351 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8352 {
8353   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8354 }
8355
8356 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8357 {
8358   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8359 }
8360
8361 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8362 {
8363   return new MEDFileIntFieldMultiTSWithoutSDA;
8364 }
8365
8366 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8367 {
8368   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8369   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8370   int i=0;
8371   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8372     {
8373       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8374       if(eltToConv)
8375         {
8376           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8377           if(!eltToConvC)
8378             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8379           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8380           ret->setIteration(i,elt);
8381         }
8382     }
8383   return ret.retn();
8384 }
8385
8386 //= MEDFileAnyTypeFieldMultiTS
8387
8388 /*!
8389  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8390  * that has been read from a specified MED file.
8391  *  \param [in] fileName - the name of the MED file to read.
8392  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8393  *          is to delete this field using decrRef() as it is no more needed.
8394  *  \throw If reading the file fails.
8395  */
8396 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8397 {
8398   MEDFileUtilities::CheckFileForRead(fileName);
8399   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8400   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8401   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8402   ret->loadGlobals(fid);
8403   return ret.retn();
8404 }
8405
8406 /*!
8407  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8408  * that has been read from a specified MED file.
8409  *  \param [in] fileName - the name of the MED file to read.
8410  *  \param [in] fieldName - the name of the field to read.
8411  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8412  *          is to delete this field using decrRef() as it is no more needed.
8413  *  \throw If reading the file fails.
8414  *  \throw If there is no field named \a fieldName in the file.
8415  */
8416 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8417 {
8418   MEDFileUtilities::CheckFileForRead(fileName);
8419   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8420   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8421   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8422   ret->loadGlobals(fid);
8423   return ret.retn();
8424 }
8425
8426 /*!
8427  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8428  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8429  *
8430  * \warning this is a shallow copy constructor
8431  */
8432 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8433 {
8434   if(!shallowCopyOfContent)
8435     {
8436       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8437       otherPtr->incrRef();
8438       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8439     }
8440   else
8441     {
8442       _content=other.shallowCpy();
8443     }
8444 }
8445
8446 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8447 {
8448   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8449   if(!ret)
8450     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8451   return ret;
8452 }
8453
8454 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8455 {
8456   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8457   if(!ret)
8458     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8459   return ret;
8460 }
8461
8462 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8463 {
8464   return contentNotNullBase()->getPflsReallyUsed2();
8465 }
8466
8467 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8468 {
8469   return contentNotNullBase()->getLocsReallyUsed2();
8470 }
8471
8472 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8473 {
8474   return contentNotNullBase()->getPflsReallyUsedMulti2();
8475 }
8476
8477 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8478 {
8479   return contentNotNullBase()->getLocsReallyUsedMulti2();
8480 }
8481
8482 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8483 {
8484   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8485 }
8486
8487 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8488 {
8489   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8490 }
8491
8492 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8493 {
8494   return contentNotNullBase()->getNumberOfTS();
8495 }
8496
8497 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8498 {
8499   contentNotNullBase()->eraseEmptyTS();
8500 }
8501
8502 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8503 {
8504   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8505 }
8506
8507 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8508 {
8509   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8510 }
8511
8512 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8513 {
8514   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8515   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8516   ret->_content=c;
8517   return ret.retn();
8518 }
8519
8520 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8521 {
8522   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8523   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8524   ret->_content=c;
8525   return ret.retn();
8526 }
8527
8528 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8529 {
8530   return contentNotNullBase()->getIterations();
8531 }
8532
8533 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8534 {
8535   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8536     pushBackTimeStep(*it);
8537 }
8538
8539 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8540 {
8541   if(!fmts)
8542     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8543   int nbOfTS(fmts->getNumberOfTS());
8544   for(int i=0;i<nbOfTS;i++)
8545     {
8546       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8547       pushBackTimeStep(elt);
8548     }
8549 }
8550
8551 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8552 {
8553   if(!f1ts)
8554     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8555   checkCoherencyOfType(f1ts);
8556   f1ts->incrRef();
8557   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8558   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8559   c->incrRef();
8560   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8561   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8562     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8563   _content->pushBackTimeStep(cSafe);
8564   appendGlobs(*f1ts,1e-12);
8565 }
8566
8567 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8568 {
8569   contentNotNullBase()->synchronizeNameScope();
8570 }
8571
8572 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8573 {
8574   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8575 }
8576
8577 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8578 {
8579   return contentNotNullBase()->getPosGivenTime(time,eps);
8580 }
8581
8582 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8583 {
8584   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8585 }
8586
8587 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8588 {
8589   return contentNotNullBase()->getTypesOfFieldAvailable();
8590 }
8591
8592 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
8593 {
8594   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8595 }
8596
8597 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8598 {
8599   return contentNotNullBase()->getName();
8600 }
8601
8602 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8603 {
8604   contentNotNullBase()->setName(name);
8605 }
8606
8607 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8608 {
8609   return contentNotNullBase()->getDtUnit();
8610 }
8611
8612 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8613 {
8614   contentNotNullBase()->setDtUnit(dtUnit);
8615 }
8616
8617 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8618 {
8619   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8620 }
8621
8622 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8623 {
8624   return contentNotNullBase()->getTimeSteps(ret1);
8625 }
8626
8627 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8628 {
8629   return contentNotNullBase()->getMeshName();
8630 }
8631
8632 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8633 {
8634   contentNotNullBase()->setMeshName(newMeshName);
8635 }
8636
8637 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8638 {
8639   return contentNotNullBase()->changeMeshNames(modifTab);
8640 }
8641
8642 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8643 {
8644   return contentNotNullBase()->getInfo();
8645 }
8646
8647 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8648 {
8649   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8650 }
8651
8652 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8653 {
8654   return contentNotNullBase()->setInfo(info);
8655 }
8656
8657 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8658 {
8659   const std::vector<std::string> ret=getInfo();
8660   return (int)ret.size();
8661 }
8662
8663 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8664 {
8665   writeGlobals(fid,*this);
8666   contentNotNullBase()->writeLL(fid,*this);
8667 }
8668
8669 /*!
8670  * Writes \a this field into a MED file specified by its name.
8671  *  \param [in] fileName - the MED file name.
8672  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8673  * - 2 - erase; an existing file is removed.
8674  * - 1 - append; same data should not be present in an existing file.
8675  * - 0 - overwrite; same data present in an existing file is overwritten.
8676  *  \throw If the field name is not set.
8677  *  \throw If no field data is set.
8678  *  \throw If \a mode == 1 and the same data is present in an existing file.
8679  */
8680 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8681 {
8682   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8683   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8684   writeLL(fid);
8685 }
8686
8687 /*!
8688  * This method alloc the arrays and load potentially huge arrays contained in this field.
8689  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8690  * This method can be also called to refresh or reinit values from a file.
8691  * 
8692  * \throw If the fileName is not set or points to a non readable MED file.
8693  */
8694 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8695 {
8696   if(getFileName().empty())
8697     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8698   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8699   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8700 }
8701
8702 /*!
8703  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8704  * But once data loaded once, this method does nothing.
8705  * 
8706  * \throw If the fileName is not set or points to a non readable MED file.
8707  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8708  */
8709 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8710 {
8711   if(!getFileName().empty())
8712     {
8713       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8714       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8715     }
8716 }
8717
8718 /*!
8719  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8720  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8721  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8722  * 
8723  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8724  */
8725 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8726 {
8727   contentNotNullBase()->unloadArrays();
8728 }
8729
8730 /*!
8731  * 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.
8732  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8733  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8734  * 
8735  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8736  */
8737 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8738 {
8739   if(!getFileName().empty())
8740     contentNotNullBase()->unloadArrays();
8741 }
8742
8743 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8744 {
8745   std::ostringstream oss;
8746   contentNotNullBase()->simpleRepr(0,oss,-1);
8747   simpleReprGlobs(oss);
8748   return oss.str();
8749 }
8750
8751 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8752 {
8753   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8754 }
8755
8756 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8757 {
8758   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8759   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8760   return ret;
8761 }
8762
8763 /*!
8764  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8765  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8766  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8767  */
8768 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8769 {
8770   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8771   if(!content)
8772     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8773   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8774   std::size_t sz(contentsSplit.size());
8775   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8776   for(std::size_t i=0;i<sz;i++)
8777     {
8778       ret[i]=shallowCpy();
8779       ret[i]->_content=contentsSplit[i];
8780     }
8781   return ret;
8782 }
8783
8784 /*!
8785  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8786  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8787  */
8788 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8789 {
8790   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8791   if(!content)
8792     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8793   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8794   std::size_t sz(contentsSplit.size());
8795   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8796   for(std::size_t i=0;i<sz;i++)
8797     {
8798       ret[i]=shallowCpy();
8799       ret[i]->_content=contentsSplit[i];
8800     }
8801   return ret;
8802 }
8803
8804 /*!
8805  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8806  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8807  */
8808 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8809 {
8810   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8811   if(!content)
8812     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8813   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8814   std::size_t sz(contentsSplit.size());
8815   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8816   for(std::size_t i=0;i<sz;i++)
8817     {
8818       ret[i]=shallowCpy();
8819       ret[i]->_content=contentsSplit[i];
8820     }
8821   return ret;
8822 }
8823
8824 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8825 {
8826   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8827   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8828     ret->_content=_content->deepCopy();
8829   ret->deepCpyGlobs(*this);
8830   return ret.retn();
8831 }
8832
8833 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8834 {
8835   return _content;
8836 }
8837
8838 /*!
8839  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8840  *  \param [in] iteration - the iteration number of a required time step.
8841  *  \param [in] order - the iteration order number of required time step.
8842  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8843  *          delete this field using decrRef() as it is no more needed.
8844  *  \throw If there is no required time step in \a this field.
8845  */
8846 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8847 {
8848   int pos=getPosOfTimeStep(iteration,order);
8849   return getTimeStepAtPos(pos);
8850 }
8851
8852 /*!
8853  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8854  *  \param [in] time - the time of the time step of interest.
8855  *  \param [in] eps - a precision used to compare time values.
8856  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8857  *          delete this field using decrRef() as it is no more needed.
8858  *  \throw If there is no required time step in \a this field.
8859  */
8860 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8861 {
8862   int pos=getPosGivenTime(time,eps);
8863   return getTimeStepAtPos(pos);
8864 }
8865
8866 /*!
8867  * 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.
8868  * The float64 value of time attached to the pair of integers are not considered here.
8869  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8870  *
8871  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8872  * \throw If there is a null pointer in \a vectFMTS.
8873  */
8874 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8875 {
8876   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8877   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8878   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8879   while(!lstFMTS.empty())
8880     {
8881       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8882       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8883       if(!curIt)
8884         throw INTERP_KERNEL::Exception(msg);
8885       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8886       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8887       elt.push_back(curIt); it=lstFMTS.erase(it);
8888       while(it!=lstFMTS.end())
8889         {
8890           curIt=*it;
8891           if(!curIt)
8892             throw INTERP_KERNEL::Exception(msg);
8893           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8894           if(refIts==curIts)
8895             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8896           else
8897             it++;
8898         }
8899       ret.push_back(elt);
8900     }
8901   return ret;
8902 }
8903
8904 /*!
8905  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8906  * All returned instances in a subvector can be safely loaded, rendered along time
8907  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8908  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8909  * 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).
8910  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8911  * 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.
8912  *
8913  * \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().
8914  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8915  * \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.
8916  * \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.
8917  *
8918  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8919  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8920  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8921  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8922  * \throw If mesh is null.
8923  * \throw If an element in \a vectFMTS is null.
8924  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8925  */
8926 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8927 {
8928   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8929   if(!mesh)
8930     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8931   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8932   if(vectFMTS.empty())
8933     return ret;
8934   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8935   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8936   if(!frstElt)
8937     throw INTERP_KERNEL::Exception(msg);
8938   std::size_t i=0;
8939   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8940   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8941   for(;it!=vectFMTS.end();it++,i++)
8942     {
8943       if(!(*it))
8944         throw INTERP_KERNEL::Exception(msg);
8945       TypeOfField tof0,tof1;
8946       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8947         {
8948           if(tof1!=ON_NODES)
8949             vectFMTSNotNodes.push_back(*it);
8950           else
8951             vectFMTSNodes.push_back(*it);
8952         }
8953       else
8954         vectFMTSNotNodes.push_back(*it);
8955     }
8956   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8957   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8958   ret=retCell;
8959   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8960     {
8961       i=0;
8962       bool isFetched(false);
8963       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8964         {
8965           if((*it0).empty())
8966             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8967           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8968             { ret[i].push_back(*it2); isFetched=true; }
8969         }
8970       if(!isFetched)
8971         {
8972           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8973           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8974           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8975         }
8976     }
8977   fsc=cmps;
8978   return ret;
8979 }
8980
8981 /*!
8982  * 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.
8983  * \param [out] cmps - same size than the returned vector.
8984  */
8985 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8986 {
8987   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8988   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8989   while(!lstFMTS.empty())
8990     {
8991       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8992       MEDFileAnyTypeFieldMultiTS *ref(*it);
8993       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8994       elt.push_back(ref); it=lstFMTS.erase(it);
8995       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8996       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8997       while(it!=lstFMTS.end())
8998         {
8999           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9000           if(cmp->isEqual(curIt))
9001             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9002           else
9003             it++;
9004         }
9005       ret.push_back(elt); cmps.push_back(cmp);
9006     }
9007   return ret;
9008 }
9009
9010 /*!
9011  * 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.
9012  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9013  *
9014  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9015  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9016  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9017  * \thorw If \a f0 and \a f1 do not have the same times steps.
9018  * \throw If mesh is null.
9019  * \throw If \a f0 or \a f1 is null.
9020  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9021  */
9022 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9023 {
9024   if(!mesh)
9025     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9026   if(!f0 || !f1)
9027     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9028   if(f0->getMeshName()!=mesh->getName())
9029     {
9030       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9031       throw INTERP_KERNEL::Exception(oss.str());
9032     }
9033   if(f1->getMeshName()!=mesh->getName())
9034     {
9035       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9036       throw INTERP_KERNEL::Exception(oss.str());
9037     }
9038   int nts=f0->getNumberOfTS();
9039   if(nts!=f1->getNumberOfTS())
9040     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9041   if(nts==0)
9042     return nts;
9043   for(int i=0;i<nts;i++)
9044     {
9045       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9046       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9047       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9048       if(tofs0.size()!=1 || tofs1.size()!=1)
9049         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9050       if(i!=0)
9051         {
9052           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9053             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9054         }
9055       else
9056         { tof0=tofs0[0]; tof1=tofs1[0]; }
9057       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9058         {
9059           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() << ") !";
9060           throw INTERP_KERNEL::Exception(oss.str());
9061         }
9062       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9063         {
9064           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() << ") !";
9065           throw INTERP_KERNEL::Exception(oss.str());
9066         }
9067       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9068         {
9069           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() << ") !";
9070           throw INTERP_KERNEL::Exception(oss.str());
9071         }
9072     }
9073   return nts;
9074 }
9075
9076 /*!
9077  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9078  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9079  *
9080  * \return A new object that the caller is responsible to deallocate.
9081  */
9082 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9083 {
9084   if(!mm)
9085     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9086   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9087   int nbTS(getNumberOfTS());
9088   for(int i=0;i<nbTS;i++)
9089     {
9090       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9091       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9092       fmtsOut->pushBackTimeStep(f1tsOut);
9093     }
9094   return fmtsOut.retn();
9095 }
9096
9097 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9098 {
9099   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9100 }
9101
9102 //= MEDFileFieldMultiTS
9103
9104 /*!
9105  * Returns a new empty instance of MEDFileFieldMultiTS.
9106  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9107  *          is to delete this field using decrRef() as it is no more needed.
9108  */
9109 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9110 {
9111   return new MEDFileFieldMultiTS;
9112 }
9113
9114 /*!
9115  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9116  * that has been read from a specified MED file.
9117  *  \param [in] fileName - the name of the MED file to read.
9118  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9119  *          is to delete this field using decrRef() as it is no more needed.
9120  *  \throw If reading the file fails.
9121  */
9122 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9123 {
9124   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
9125   ret->contentNotNull();//to check that content type matches with \a this type.
9126   return ret.retn();
9127 }
9128
9129 /*!
9130  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9131  * that has been read from a specified MED file.
9132  *  \param [in] fileName - the name of the MED file to read.
9133  *  \param [in] fieldName - the name of the field to read.
9134  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9135  *          is to delete this field using decrRef() as it is no more needed.
9136  *  \throw If reading the file fails.
9137  *  \throw If there is no field named \a fieldName in the file.
9138  */
9139 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9140 {
9141   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9142   ret->contentNotNull();//to check that content type matches with \a this type.
9143   return ret.retn();
9144 }
9145
9146 /*!
9147  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9148  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9149  *
9150  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9151  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9152  * \warning this is a shallow copy constructor
9153  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9154  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9155  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9156  *          is to delete this field using decrRef() as it is no more needed.
9157  */
9158 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9159 {
9160   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9161 }
9162
9163 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9164 {
9165   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9166   ret->contentNotNull();//to check that content type matches with \a this type.
9167   return ret.retn();
9168 }
9169
9170 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9171 {
9172   return new MEDFileFieldMultiTS(*this);
9173 }
9174
9175 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9176 {
9177   if(!f1ts)
9178     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9179   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9180   if(!f1tsC)
9181     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9182 }
9183
9184 /*!
9185  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9186  * following the given input policy.
9187  *
9188  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9189  *                            By default (true) the globals are deeply copied.
9190  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9191  */
9192 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9193 {
9194   MCAuto<MEDFileIntFieldMultiTS> ret;
9195   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9196   if(content)
9197     {
9198       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9199       if(!contc)
9200         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9201       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9202       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9203     }
9204   else
9205     ret=MEDFileIntFieldMultiTS::New();
9206   if(isDeepCpyGlobs)
9207     ret->deepCpyGlobs(*this);
9208   else
9209     ret->shallowCpyGlobs(*this);
9210   return ret.retn();
9211 }
9212
9213 /*!
9214  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9215  *  \param [in] pos - a time step id.
9216  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9217  *          delete this field using decrRef() as it is no more needed.
9218  *  \throw If \a pos is not a valid time step id.
9219  */
9220 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9221 {
9222   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9223   if(!item)
9224     {
9225       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9226       throw INTERP_KERNEL::Exception(oss.str());
9227     }
9228   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9229   if(itemC)
9230     {
9231       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9232       ret->shallowCpyGlobs(*this);
9233       return ret.retn();
9234     }
9235   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9236   throw INTERP_KERNEL::Exception(oss.str());
9237 }
9238
9239 /*!
9240  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9241  * mesh entities of a given dimension of the first mesh in MED file.
9242  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9243  *  \param [in] type - a spatial discretization of interest.
9244  *  \param [in] iteration - the iteration number of a required time step.
9245  *  \param [in] order - the iteration order number of required time step.
9246  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9247  *  \param [in] renumPol - specifies how to permute values of the result field according to
9248  *          the optional numbers of cells and nodes, if any. The valid values are
9249  *          - 0 - do not permute.
9250  *          - 1 - permute cells.
9251  *          - 2 - permute nodes.
9252  *          - 3 - permute cells and nodes.
9253  *
9254  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9255  *          caller is to delete this field using decrRef() as it is no more needed. 
9256  *  \throw If the MED file is not readable.
9257  *  \throw If there is no mesh in the MED file.
9258  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9259  *  \throw If no field values of the required parameters are available.
9260  */
9261 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9262 {
9263   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9264   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9265   if(!myF1TSC)
9266     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9267   MCAuto<DataArray> arrOut;
9268   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9269   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9270   return ret.retn();
9271 }
9272
9273 /*!
9274  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9275  * the top level cells of the first mesh in MED file.
9276  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9277  *  \param [in] type - a spatial discretization of interest.
9278  *  \param [in] iteration - the iteration number of a required time step.
9279  *  \param [in] order - the iteration order number of required time step.
9280  *  \param [in] renumPol - specifies how to permute values of the result field according to
9281  *          the optional numbers of cells and nodes, if any. The valid values are
9282  *          - 0 - do not permute.
9283  *          - 1 - permute cells.
9284  *          - 2 - permute nodes.
9285  *          - 3 - permute cells and nodes.
9286  *
9287  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9288  *          caller is to delete this field using decrRef() as it is no more needed. 
9289  *  \throw If the MED file is not readable.
9290  *  \throw If there is no mesh in the MED file.
9291  *  \throw If no field values of the required parameters are available.
9292  */
9293 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9294 {
9295   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9296   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9297   if(!myF1TSC)
9298     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9299   MCAuto<DataArray> arrOut;
9300   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9301   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9302   return ret.retn();
9303 }
9304
9305 /*!
9306  * 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
9307  * method should be called (getFieldOnMeshAtLevel for example).
9308  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9309  *
9310  * \param [in] iteration - the iteration number of a required time step.
9311  * \param [in] order - the iteration order number of required time step.
9312  * \param [in] mesh - the mesh the field is lying on
9313  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9314  *          caller is to delete this field using decrRef() as it is no more needed. 
9315  */
9316 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9317 {
9318   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9319   MCAuto<DataArray> arrOut;
9320   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9321   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9322   return ret.retn();
9323 }
9324
9325 /*!
9326  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9327  * a given support.
9328  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9329  *  \param [in] type - a spatial discretization of interest.
9330  *  \param [in] iteration - the iteration number of a required time step.
9331  *  \param [in] order - the iteration order number of required time step.
9332  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9333  *  \param [in] mesh - the supporting mesh.
9334  *  \param [in] renumPol - specifies how to permute values of the result field according to
9335  *          the optional numbers of cells and nodes, if any. The valid values are
9336  *          - 0 - do not permute.
9337  *          - 1 - permute cells.
9338  *          - 2 - permute nodes.
9339  *          - 3 - permute cells and nodes.
9340  *
9341  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9342  *          caller is to delete this field using decrRef() as it is no more needed. 
9343  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9344  *  \throw If no field of \a this is lying on \a mesh.
9345  *  \throw If no field values of the required parameters are available.
9346  */
9347 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9348 {
9349   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9350   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9351   if(!myF1TSC)
9352     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9353   MCAuto<DataArray> arrOut;
9354   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9355   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9356   return ret.retn();
9357 }
9358
9359 /*!
9360  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9361  * given support. 
9362  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9363  *  \param [in] type - a spatial discretization of the new field.
9364  *  \param [in] iteration - the iteration number of a required time step.
9365  *  \param [in] order - the iteration order number of required time step.
9366  *  \param [in] mesh - the supporting mesh.
9367  *  \param [in] renumPol - specifies how to permute values of the result field according to
9368  *          the optional numbers of cells and nodes, if any. The valid values are
9369  *          - 0 - do not permute.
9370  *          - 1 - permute cells.
9371  *          - 2 - permute nodes.
9372  *          - 3 - permute cells and nodes.
9373  *
9374  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9375  *          caller is to delete this field using decrRef() as it is no more needed. 
9376  *  \throw If no field of \a this is lying on \a mesh.
9377  *  \throw If no field values of the required parameters are available.
9378  */
9379 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9380 {
9381   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9382   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9383   if(!myF1TSC)
9384     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9385   MCAuto<DataArray> arrOut;
9386   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9387   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9388   return ret.retn();
9389 }
9390
9391 /*!
9392  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9393  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9394  * This method is useful for MED2 file format when field on different mesh was autorized.
9395  */
9396 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9397 {
9398   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9399   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9400   if(!myF1TSC)
9401     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9402   MCAuto<DataArray> arrOut;
9403   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9404   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9405   return ret.retn();
9406 }
9407
9408 /*!
9409  * Returns values and a profile of the field of a given type, of a given time step,
9410  * lying on a given support.
9411  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9412  *  \param [in] type - a spatial discretization of the field.
9413  *  \param [in] iteration - the iteration number of a required time step.
9414  *  \param [in] order - the iteration order number of required time step.
9415  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9416  *  \param [in] mesh - the supporting mesh.
9417  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9418  *          field of interest lies on. If the field lies on all entities of the given
9419  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9420  *          using decrRef() as it is no more needed.  
9421  *  \param [in] glob - the global data storing profiles and localization.
9422  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9423  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9424  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9425  *  \throw If no field of \a this is lying on \a mesh.
9426  *  \throw If no field values of the required parameters are available.
9427  */
9428 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9429 {
9430   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9431   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9432   if(!myF1TSC)
9433     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9434   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9435   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9436 }
9437
9438 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9439 {
9440   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9441   if(!pt)
9442     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9443   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9444   if(!ret)
9445     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 !");
9446   return ret;
9447 }
9448
9449 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9450 {
9451   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9452   if(!pt)
9453     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9454   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9455   if(!ret)
9456     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 !");
9457   return ret;
9458 }
9459
9460 /*!
9461  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9462  * the given field is checked if its elements are sorted suitable for writing to MED file
9463  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9464  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9465  *  \param [in] field - the field to add to \a this.
9466  *  \throw If the name of \a field is empty.
9467  *  \throw If the data array of \a field is not set.
9468  *  \throw If existing time steps have different name or number of components than \a field.
9469  *  \throw If the underlying mesh of \a field has no name.
9470  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9471  */
9472 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9473 {
9474   const DataArrayDouble *arr=0;
9475   if(field)
9476     arr=field->getArray();
9477   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9478 }
9479
9480 /*!
9481  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9482  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9483  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9484  * and \a profile.
9485  *
9486  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9487  * A new profile is added only if no equal profile is missing.
9488  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9489  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9490  *  \param [in] mesh - the supporting mesh of \a field.
9491  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9492  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9493  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9494  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9495  *  \throw If the data array of \a field is not set.
9496  *  \throw If the data array of \a this is already allocated but has different number of
9497  *         components than \a field.
9498  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9499  *  \sa setFieldNoProfileSBT()
9500  */
9501 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9502 {
9503   const DataArrayDouble *arr=0;
9504   if(field)
9505     arr=field->getArray();
9506   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9507 }
9508
9509 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9510 {
9511   _content=new MEDFileFieldMultiTSWithoutSDA;
9512 }
9513
9514 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9515 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9516 {
9517 }
9518 catch(INTERP_KERNEL::Exception& e)
9519 { throw e; }
9520
9521 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9522 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9523 {
9524 }
9525 catch(INTERP_KERNEL::Exception& e)
9526 { throw e; }
9527
9528 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9529 {
9530 }
9531
9532 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
9533 {
9534   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9535 }
9536
9537 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9538 {
9539   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9540 }
9541
9542 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9543 {
9544   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9545 }
9546
9547 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9548 {
9549   return MEDFileFieldMultiTS::New();
9550 }
9551
9552 //= MEDFileAnyTypeFieldMultiTSIterator
9553
9554 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9555 {
9556   if(fmts)
9557     {
9558       fmts->incrRef();
9559       _nb_iter=fmts->getNumberOfTS();
9560     }
9561 }
9562
9563 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9564 {
9565 }
9566
9567 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9568 {
9569   if(_iter_id<_nb_iter)
9570     {
9571       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9572       if(fmts)
9573         return fmts->getTimeStepAtPos(_iter_id++);
9574       else
9575         return 0;
9576     }
9577   else
9578     return 0;
9579 }
9580
9581 //= MEDFileIntFieldMultiTS
9582
9583 /*!
9584  * Returns a new empty instance of MEDFileFieldMultiTS.
9585  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9586  *          is to delete this field using decrRef() as it is no more needed.
9587  */
9588 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9589 {
9590   return new MEDFileIntFieldMultiTS;
9591 }
9592
9593 /*!
9594  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9595  * that has been read from a specified MED file.
9596  *  \param [in] fileName - the name of the MED file to read.
9597  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9598  *          is to delete this field using decrRef() as it is no more needed.
9599  *  \throw If reading the file fails.
9600  */
9601 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9602 {
9603   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9604   ret->contentNotNull();//to check that content type matches with \a this type.
9605   return ret.retn();
9606 }
9607
9608 /*!
9609  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9610  * that has been read from a specified MED file.
9611  *  \param [in] fileName - the name of the MED file to read.
9612  *  \param [in] fieldName - the name of the field to read.
9613  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9614  *          is to delete this field using decrRef() as it is no more needed.
9615  *  \throw If reading the file fails.
9616  *  \throw If there is no field named \a fieldName in the file.
9617  */
9618 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9619 {
9620   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9621   ret->contentNotNull();//to check that content type matches with \a this type.
9622   return ret.retn();
9623 }
9624
9625 /*!
9626  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9627  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9628  *
9629  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9630  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9631  * \warning this is a shallow copy constructor
9632  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9633  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9634  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9635  *          is to delete this field using decrRef() as it is no more needed.
9636  */
9637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9638 {
9639   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9640 }
9641
9642 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9643 {
9644   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9645   ret->contentNotNull();//to check that content type matches with \a this type.
9646   return ret.retn();
9647 }
9648
9649 /*!
9650  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9651  * following the given input policy.
9652  *
9653  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9654  *                            By default (true) the globals are deeply copied.
9655  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9656  */
9657 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9658 {
9659   MCAuto<MEDFileFieldMultiTS> ret;
9660   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9661   if(content)
9662     {
9663       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9664       if(!contc)
9665         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9666       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9667       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9668     }
9669   else
9670     ret=MEDFileFieldMultiTS::New();
9671   if(isDeepCpyGlobs)
9672     ret->deepCpyGlobs(*this);
9673   else
9674     ret->shallowCpyGlobs(*this);
9675   return ret.retn();
9676 }
9677
9678 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9679 {
9680   return new MEDFileIntFieldMultiTS(*this);
9681 }
9682
9683 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9684 {
9685   if(!f1ts)
9686     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9687   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9688   if(!f1tsC)
9689     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9690 }
9691
9692 /*!
9693  * 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
9694  * method should be called (getFieldOnMeshAtLevel for example).
9695  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9696  *
9697  * \param [in] iteration - the iteration number of a required time step.
9698  * \param [in] order - the iteration order number of required time step.
9699  * \param [in] mesh - the mesh the field is lying on
9700  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9701  *          caller is to delete this field using decrRef() as it is no more needed. 
9702  */
9703 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9704 {
9705   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9706   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9707   if(!myF1TSC)
9708     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9709   MCAuto<DataArray> arrOut;
9710   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9711   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9712   return ret2.retn();
9713 }
9714
9715 /*!
9716  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9717  * mesh entities of a given dimension of the first mesh in MED file.
9718  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9719  *  \param [in] type - a spatial discretization of interest.
9720  *  \param [in] iteration - the iteration number of a required time step.
9721  *  \param [in] order - the iteration order number of required time step.
9722  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9723  *  \param [in] renumPol - specifies how to permute values of the result field according to
9724  *          the optional numbers of cells and nodes, if any. The valid values are
9725  *          - 0 - do not permute.
9726  *          - 1 - permute cells.
9727  *          - 2 - permute nodes.
9728  *          - 3 - permute cells and nodes.
9729  *
9730  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9731  *          caller is to delete this field using decrRef() as it is no more needed. 
9732  *  \throw If the MED file is not readable.
9733  *  \throw If there is no mesh in the MED file.
9734  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9735  *  \throw If no field values of the required parameters are available.
9736  */
9737 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9738 {
9739   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9740   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9741   if(!myF1TSC)
9742     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9743   MCAuto<DataArray> arr;
9744   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9745   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9746   return ret2.retn();
9747 }
9748
9749 /*!
9750  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9751  * the top level cells of the first mesh in MED file.
9752  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9753  *  \param [in] type - a spatial discretization of interest.
9754  *  \param [in] iteration - the iteration number of a required time step.
9755  *  \param [in] order - the iteration order number of required time step.
9756  *  \param [in] renumPol - specifies how to permute values of the result field according to
9757  *          the optional numbers of cells and nodes, if any. The valid values are
9758  *          - 0 - do not permute.
9759  *          - 1 - permute cells.
9760  *          - 2 - permute nodes.
9761  *          - 3 - permute cells and nodes.
9762  *
9763  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9764  *          caller is to delete this field using decrRef() as it is no more needed. 
9765  *  \throw If the MED file is not readable.
9766  *  \throw If there is no mesh in the MED file.
9767  *  \throw If no field values of the required parameters are available.
9768  */
9769 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9770 {
9771   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9772   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9773   if(!myF1TSC)
9774     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9775   MCAuto<DataArray> arr;
9776   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9777   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9778   return ret2.retn();
9779 }
9780
9781 /*!
9782  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9783  * a given support.
9784  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9785  *  \param [in] type - a spatial discretization of interest.
9786  *  \param [in] iteration - the iteration number of a required time step.
9787  *  \param [in] order - the iteration order number of required time step.
9788  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9789  *  \param [in] mesh - the supporting mesh.
9790  *  \param [in] renumPol - specifies how to permute values of the result field according to
9791  *          the optional numbers of cells and nodes, if any. The valid values are
9792  *          - 0 - do not permute.
9793  *          - 1 - permute cells.
9794  *          - 2 - permute nodes.
9795  *          - 3 - permute cells and nodes.
9796  *
9797  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9798  *          caller is to delete this field using decrRef() as it is no more needed. 
9799  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9800  *  \throw If no field of \a this is lying on \a mesh.
9801  *  \throw If no field values of the required parameters are available.
9802  */
9803 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9804 {
9805   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9806   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9807   if(!myF1TSC)
9808     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9809   MCAuto<DataArray> arr;
9810   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9811   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9812   return ret2.retn();
9813 }
9814
9815 /*!
9816  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9817  * given support. 
9818  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9819  *  \param [in] type - a spatial discretization of the new field.
9820  *  \param [in] iteration - the iteration number of a required time step.
9821  *  \param [in] order - the iteration order number of required time step.
9822  *  \param [in] mesh - the supporting mesh.
9823  *  \param [out] arrOut - the DataArrayInt containing values of field.
9824  *  \param [in] renumPol - specifies how to permute values of the result field according to
9825  *          the optional numbers of cells and nodes, if any. The valid values are
9826  *          - 0 - do not permute.
9827  *          - 1 - permute cells.
9828  *          - 2 - permute nodes.
9829  *          - 3 - permute cells and nodes.
9830  *
9831  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9832  *          caller is to delete this field using decrRef() as it is no more needed. 
9833  *  \throw If no field of \a this is lying on \a mesh.
9834  *  \throw If no field values of the required parameters are available.
9835  */
9836 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9837 {
9838   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9839   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9840   if(!myF1TSC)
9841     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9842   MCAuto<DataArray> arr;
9843   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9844   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9845   return ret2.retn();
9846 }
9847
9848 /*!
9849  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9850  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9851  * This method is useful for MED2 file format when field on different mesh was autorized.
9852  */
9853 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9854 {
9855   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9856   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9857   if(!myF1TSC)
9858     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9859   MCAuto<DataArray> arr;
9860   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9861   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9862   return ret2.retn();
9863 }
9864
9865 /*!
9866  * Returns values and a profile of the field of a given type, of a given time step,
9867  * lying on a given support.
9868  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9869  *  \param [in] type - a spatial discretization of the field.
9870  *  \param [in] iteration - the iteration number of a required time step.
9871  *  \param [in] order - the iteration order number of required time step.
9872  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9873  *  \param [in] mesh - the supporting mesh.
9874  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9875  *          field of interest lies on. If the field lies on all entities of the given
9876  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9877  *          using decrRef() as it is no more needed.  
9878  *  \param [in] glob - the global data storing profiles and localization.
9879  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9880  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9881  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9882  *  \throw If no field of \a this is lying on \a mesh.
9883  *  \throw If no field values of the required parameters are available.
9884  */
9885 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9886 {
9887   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9888   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9889   if(!myF1TSC)
9890     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9891   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9892   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9893 }
9894
9895 /*!
9896  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9897  *  \param [in] pos - a time step id.
9898  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9899  *          delete this field using decrRef() as it is no more needed.
9900  *  \throw If \a pos is not a valid time step id.
9901  */
9902 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9903 {
9904   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9905   if(!item)
9906     {
9907       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9908       throw INTERP_KERNEL::Exception(oss.str());
9909     }
9910   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9911   if(itemC)
9912     {
9913       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9914       ret->shallowCpyGlobs(*this);
9915       return ret.retn();
9916     }
9917   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9918   throw INTERP_KERNEL::Exception(oss.str());
9919 }
9920
9921 /*!
9922  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9923  * the given field is checked if its elements are sorted suitable for writing to MED file
9924  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9925  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9926  *  \param [in] field - the field to add to \a this.
9927  *  \throw If the name of \a field is empty.
9928  *  \throw If the data array of \a field is not set.
9929  *  \throw If existing time steps have different name or number of components than \a field.
9930  *  \throw If the underlying mesh of \a field has no name.
9931  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9932  */
9933 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9934 {
9935   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9936   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
9937 }
9938
9939 /*!
9940  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
9941  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9942  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9943  * and \a profile.
9944  *
9945  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9946  * A new profile is added only if no equal profile is missing.
9947  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9948  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9949  *  \param [in] arrOfVals - the values of the field \a field used.
9950  *  \param [in] mesh - the supporting mesh of \a field.
9951  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9952  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9953  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9954  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9955  *  \throw If the data array of \a field is not set.
9956  *  \throw If the data array of \a this is already allocated but has different number of
9957  *         components than \a field.
9958  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9959  *  \sa setFieldNoProfileSBT()
9960  */
9961 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9962 {
9963   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9964   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
9965 }
9966
9967 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9968 {
9969   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9970   if(!pt)
9971     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9972   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9973   if(!ret)
9974     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 !");
9975   return ret;
9976 }
9977
9978 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9979 {
9980   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9981   if(!pt)
9982     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9983   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9984   if(!ret)
9985     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 !");
9986   return ret;
9987 }
9988
9989 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9990 {
9991   _content=new MEDFileIntFieldMultiTSWithoutSDA;
9992 }
9993
9994 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9995 {
9996 }
9997
9998 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9999 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
10000 {
10001 }
10002 catch(INTERP_KERNEL::Exception& e)
10003 { throw e; }
10004
10005 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10006 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
10007 {
10008 }
10009 catch(INTERP_KERNEL::Exception& e)
10010 { throw e; }
10011
10012 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10013 {
10014   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10015 }
10016
10017 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10018 {
10019   return MEDFileIntFieldMultiTS::New();
10020 }
10021
10022 //= MEDFileFields
10023
10024 MEDFileFields *MEDFileFields::New()
10025 {
10026   return new MEDFileFields;
10027 }
10028
10029 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10030 {
10031   return new MEDFileFields(fileName,loadAll,0,0);
10032 }
10033
10034 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10035 {
10036   return new MEDFileFields(fileName,loadAll,ms,0);
10037 }
10038
10039 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10040 {
10041   return new MEDFileFields(fileName,loadAll,0,&entities);
10042 }
10043
10044 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10045 {
10046   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10047   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10048   return ret;
10049 }
10050
10051 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10052 {
10053   std::vector<const BigMemoryObject *> ret;
10054   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10055     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10056   return ret;
10057 }
10058
10059 MEDFileFields *MEDFileFields::deepCopy() const
10060 {
10061   MCAuto<MEDFileFields> ret=shallowCpy();
10062   std::size_t i=0;
10063   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10064     {
10065       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10066         ret->_fields[i]=(*it)->deepCopy();
10067     }
10068   ret->deepCpyGlobs(*this);
10069   return ret.retn();
10070 }
10071
10072 MEDFileFields *MEDFileFields::shallowCpy() const
10073 {
10074   return new MEDFileFields(*this);
10075 }
10076
10077 /*!
10078  * 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
10079  * 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.
10080  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10081  *
10082  * \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.
10083  * \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.
10084  * 
10085  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10086  */
10087 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10088 {
10089   std::set< std::pair<int,int> > s;
10090   bool firstShot=true;
10091   areThereSomeForgottenTS=false;
10092   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10093     {
10094       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10095         continue;
10096       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10097       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10098       if(firstShot)
10099         { s=s1; firstShot=false; }
10100       else
10101         {
10102           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10103           if(s!=s2)
10104             areThereSomeForgottenTS=true;
10105           s=s2;
10106         }
10107     }
10108   std::vector< std::pair<int,int> > ret;
10109   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10110   return ret;
10111 }
10112
10113 int MEDFileFields::getNumberOfFields() const
10114 {
10115   return _fields.size();
10116 }
10117
10118 std::vector<std::string> MEDFileFields::getFieldsNames() const
10119 {
10120   std::vector<std::string> ret(_fields.size());
10121   int i=0;
10122   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10123     {
10124       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10125       if(f)
10126         {
10127           ret[i]=f->getName();
10128         }
10129       else
10130         {
10131           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10132           throw INTERP_KERNEL::Exception(oss.str());
10133         }
10134     }
10135   return ret;
10136 }
10137
10138 std::vector<std::string> MEDFileFields::getMeshesNames() const
10139 {
10140   std::vector<std::string> ret;
10141   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10142     {
10143       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10144       if(cur)
10145         ret.push_back(cur->getMeshName());
10146     }
10147   return ret;
10148 }
10149
10150 std::string MEDFileFields::simpleRepr() const
10151 {
10152   std::ostringstream oss;
10153   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10154   simpleRepr(0,oss);
10155   return oss.str();
10156 }
10157
10158 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10159 {
10160   int nbOfFields=getNumberOfFields();
10161   std::string startLine(bkOffset,' ');
10162   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10163   int i=0;
10164   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10165     {
10166       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10167       if(cur)
10168         {
10169           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10170         }
10171       else
10172         {
10173           oss << startLine << "  - not defined !" << std::endl;
10174         }
10175     }
10176   i=0;
10177   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10178     {
10179       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10180       std::string chapter(17,'0'+i);
10181       oss << startLine << chapter << std::endl;
10182       if(cur)
10183         {
10184           cur->simpleRepr(bkOffset+2,oss,i);
10185         }
10186       else
10187         {
10188           oss << startLine << "  - not defined !" << std::endl;
10189         }
10190       oss << startLine << chapter << std::endl;
10191     }
10192   simpleReprGlobs(oss);
10193 }
10194
10195 MEDFileFields::MEDFileFields()
10196 {
10197 }
10198
10199 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10200 try:MEDFileFieldGlobsReal(fileName)
10201 {
10202   MEDFileUtilities::CheckFileForRead(fileName);
10203   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10204   int nbFields(MEDnField(fid));
10205   _fields.resize(nbFields);
10206   med_field_type typcha;
10207   for(int i=0;i<nbFields;i++)
10208     {
10209       std::vector<std::string> infos;
10210       std::string fieldName,dtunit;
10211       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10212       switch(typcha)
10213       {
10214         case MED_FLOAT64:
10215           {
10216             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10217             break;
10218           }
10219         case MED_INT32:
10220           {
10221             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10222             break;
10223           }
10224         default:
10225           {
10226             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10227             throw INTERP_KERNEL::Exception(oss.str());
10228           }
10229       }
10230     }
10231   loadAllGlobals(fid);
10232 }
10233 catch(INTERP_KERNEL::Exception& e)
10234 {
10235     throw e;
10236 }
10237
10238 void MEDFileFields::writeLL(med_idt fid) const
10239 {
10240   int i=0;
10241   writeGlobals(fid,*this);
10242   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10243     {
10244       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10245       if(!elt)
10246         {
10247           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10248           throw INTERP_KERNEL::Exception(oss.str());
10249         }
10250       elt->writeLL(fid,*this);
10251     }
10252 }
10253
10254 void MEDFileFields::write(const std::string& fileName, int mode) const
10255 {
10256   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10257   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10258   writeLL(fid);
10259 }
10260
10261 /*!
10262  * This method alloc the arrays and load potentially huge arrays contained in this field.
10263  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10264  * This method can be also called to refresh or reinit values from a file.
10265  * 
10266  * \throw If the fileName is not set or points to a non readable MED file.
10267  */
10268 void MEDFileFields::loadArrays()
10269 {
10270   if(getFileName().empty())
10271     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10272   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10273   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10274     {
10275       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10276       if(elt)
10277         elt->loadBigArraysRecursively(fid,*elt);
10278     }
10279 }
10280
10281 /*!
10282  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10283  * But once data loaded once, this method does nothing.
10284  * 
10285  * \throw If the fileName is not set or points to a non readable MED file.
10286  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10287  */
10288 void MEDFileFields::loadArraysIfNecessary()
10289 {
10290   if(!getFileName().empty())
10291     {
10292       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10293       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10294         {
10295           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10296           if(elt)
10297             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10298         }
10299     }
10300 }
10301
10302 /*!
10303  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10304  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10305  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10306  * 
10307  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10308  */
10309 void MEDFileFields::unloadArrays()
10310 {
10311   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10312     {
10313       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10314       if(elt)
10315         elt->unloadArrays();
10316     }
10317 }
10318
10319 /*!
10320  * 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.
10321  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10322  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10323  * 
10324  * \sa MEDFileFields::loadArraysIfNecessary
10325  */
10326 void MEDFileFields::unloadArraysWithoutDataLoss()
10327 {
10328   if(!getFileName().empty())
10329     unloadArrays();
10330 }
10331
10332 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10333 {
10334   std::vector<std::string> ret;
10335   std::set<std::string> ret2;
10336   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10337     {
10338       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10339       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10340         if(ret2.find(*it2)==ret2.end())
10341           {
10342             ret.push_back(*it2);
10343             ret2.insert(*it2);
10344           }
10345     }
10346   return ret;
10347 }
10348
10349 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10350 {
10351   std::vector<std::string> ret;
10352   std::set<std::string> ret2;
10353   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10354     {
10355       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10356       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10357         if(ret2.find(*it2)==ret2.end())
10358           {
10359             ret.push_back(*it2);
10360             ret2.insert(*it2);
10361           }
10362     }
10363   return ret;
10364 }
10365
10366 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10367 {
10368   std::vector<std::string> ret;
10369   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10370     {
10371       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10372       ret.insert(ret.end(),tmp.begin(),tmp.end());
10373     }
10374   return ret;
10375 }
10376
10377 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10378 {
10379   std::vector<std::string> ret;
10380   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10381     {
10382       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10383       ret.insert(ret.end(),tmp.begin(),tmp.end());
10384     }
10385   return ret;
10386 }
10387
10388 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10389 {
10390   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10391     (*it)->changePflsRefsNamesGen2(mapOfModif);
10392 }
10393
10394 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10395 {
10396   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10397     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10398 }
10399
10400 void MEDFileFields::resize(int newSize)
10401 {
10402   _fields.resize(newSize);
10403 }
10404
10405 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10406 {
10407   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10408     pushField(*it);
10409 }
10410
10411 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10412 {
10413   if(!field)
10414     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10415   _fields.push_back(field->getContent());
10416   appendGlobs(*field,1e-12);
10417 }
10418
10419 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10420 {
10421   if(!field)
10422     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10423   if(i>=(int)_fields.size())
10424     _fields.resize(i+1);
10425   _fields[i]=field->getContent();
10426   appendGlobs(*field,1e-12);
10427 }
10428
10429 void MEDFileFields::destroyFieldAtPos(int i)
10430 {
10431   destroyFieldsAtPos(&i,&i+1);
10432 }
10433
10434 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10435 {
10436   std::vector<bool> b(_fields.size(),true);
10437   for(const int *i=startIds;i!=endIds;i++)
10438     {
10439       if(*i<0 || *i>=(int)_fields.size())
10440         {
10441           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10442           throw INTERP_KERNEL::Exception(oss.str());
10443         }
10444       b[*i]=false;
10445     }
10446   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10447   std::size_t j=0;
10448   for(std::size_t i=0;i<_fields.size();i++)
10449     if(b[i])
10450       fields[j++]=_fields[i];
10451   _fields=fields;
10452 }
10453
10454 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10455 {
10456   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10457   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10458   std::vector<bool> b(_fields.size(),true);
10459   int k=bg;
10460   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10461     {
10462       if(k<0 || k>=(int)_fields.size())
10463         {
10464           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10465           throw INTERP_KERNEL::Exception(oss.str());
10466         }
10467       b[k]=false;
10468     }
10469   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10470   std::size_t j=0;
10471   for(std::size_t i=0;i<_fields.size();i++)
10472     if(b[i])
10473       fields[j++]=_fields[i];
10474   _fields=fields;
10475 }
10476
10477 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10478 {
10479   bool ret=false;
10480   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10481     {
10482       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10483       if(cur)
10484         ret=cur->changeMeshNames(modifTab) || ret;
10485     }
10486   return ret;
10487 }
10488
10489 /*!
10490  * \param [in] meshName the name of the mesh that will be renumbered.
10491  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10492  *             This code corresponds to the distribution of types in the corresponding mesh.
10493  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10494  * \param [in] renumO2N the old to new renumber array.
10495  * \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 
10496  *         field in \a this.
10497  */
10498 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10499 {
10500   bool ret=false;
10501   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10502     {
10503       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10504       if(fmts)
10505         {
10506           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10507         }
10508     }
10509   return ret;
10510 }
10511
10512 /*!
10513  * Return an extraction of \a this using \a extractDef map to specify the extraction.
10514  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10515  *
10516  * \return A new object that the caller is responsible to deallocate.
10517  */
10518 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10519 {
10520   if(!mm)
10521     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10522   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10523   int nbFields(getNumberOfFields());
10524   for(int i=0;i<nbFields;i++)
10525     {
10526       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10527       if(!fmts)
10528         {
10529           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10530           throw INTERP_KERNEL::Exception(oss.str());
10531         }
10532       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10533       fsOut->pushField(fmtsOut);
10534     }
10535   return fsOut.retn();
10536 }
10537
10538 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10539 {
10540   if(i<0 || i>=(int)_fields.size())
10541     {
10542       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10543       throw INTERP_KERNEL::Exception(oss.str());
10544     }
10545   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10546   if(!fmts)
10547     return 0;
10548   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10549   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10550   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10551   if(fmtsC)
10552     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10553   else if(fmtsC2)
10554     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10555   else
10556     {
10557       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10558       throw INTERP_KERNEL::Exception(oss.str());
10559     }
10560   ret->shallowCpyGlobs(*this);
10561   return ret.retn();
10562 }
10563
10564 /*!
10565  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10566  * This method is accessible in python using __getitem__ with a list in input.
10567  * \return a new object that the caller should deal with.
10568  */
10569 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10570 {
10571   MCAuto<MEDFileFields> ret=shallowCpy();
10572   std::size_t sz=std::distance(startIds,endIds);
10573   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10574   int j=0;
10575   for(const int *i=startIds;i!=endIds;i++,j++)
10576     {
10577       if(*i<0 || *i>=(int)_fields.size())
10578         {
10579           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10580           throw INTERP_KERNEL::Exception(oss.str());
10581         }
10582       fields[j]=_fields[*i];
10583     }
10584   ret->_fields=fields;
10585   return ret.retn();
10586 }
10587
10588 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10589 {
10590   return getFieldAtPos(getPosFromFieldName(fieldName));
10591 }
10592
10593 /*!
10594  * This method removes, if any, fields in \a this having no time steps.
10595  * 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.
10596  * 
10597  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10598  */
10599 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10600 {
10601   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10602   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10603     {
10604       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10605       if(elt)
10606         {
10607           if(elt->getNumberOfTS()>0)
10608             newFields.push_back(*it);
10609         }
10610     }
10611   if(_fields.size()==newFields.size())
10612     return false;
10613   _fields=newFields;
10614   return true;
10615 }
10616
10617 /*!
10618  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10619  * This method can be seen as a filter applied on \a this, that returns an object containing
10620  * 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
10621  * shallow copied from \a this.
10622  * 
10623  * \param [in] meshName - the name of the mesh on w
10624  * \return a new object that the caller should deal with.
10625  */
10626 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10627 {
10628   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10629   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10630     {
10631       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10632       if(!cur)
10633         continue;
10634       if(cur->getMeshName()==meshName)
10635         {
10636           cur->incrRef();
10637           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10638           ret->_fields.push_back(cur2);
10639         }
10640     }
10641   ret->shallowCpyOnlyUsedGlobs(*this);
10642   return ret.retn();
10643 }
10644
10645 /*!
10646  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10647  * Input time steps are specified using a pair of integer (iteration, order).
10648  * 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,
10649  * but for each multitimestep only the time steps in \a timeSteps are kept.
10650  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10651  * 
10652  * The returned object points to shallow copy of elements in \a this.
10653  * 
10654  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10655  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10656  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10657  */
10658 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10659 {
10660   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10661   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10662     {
10663       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10664       if(!cur)
10665         continue;
10666       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10667       ret->_fields.push_back(elt);
10668     }
10669   ret->shallowCpyOnlyUsedGlobs(*this);
10670   return ret.retn();
10671 }
10672
10673 /*!
10674  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10675  */
10676 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10677 {
10678   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10679   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10680     {
10681       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10682       if(!cur)
10683         continue;
10684       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10685       if(elt->getNumberOfTS()!=0)
10686         ret->_fields.push_back(elt);
10687     }
10688   ret->shallowCpyOnlyUsedGlobs(*this);
10689   return ret.retn();
10690 }
10691
10692 MEDFileFieldsIterator *MEDFileFields::iterator()
10693 {
10694   return new MEDFileFieldsIterator(this);
10695 }
10696
10697 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10698 {
10699   std::string tmp(fieldName);
10700   std::vector<std::string> poss;
10701   for(std::size_t i=0;i<_fields.size();i++)
10702     {
10703       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10704       if(f)
10705         {
10706           std::string fname(f->getName());
10707           if(tmp==fname)
10708             return i;
10709           else
10710             poss.push_back(fname);
10711         }
10712     }
10713   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10714   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10715   oss << " !";
10716   throw INTERP_KERNEL::Exception(oss.str());
10717 }
10718
10719 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10720 {
10721   if(fs)
10722     {
10723       fs->incrRef();
10724       _nb_iter=fs->getNumberOfFields();
10725     }
10726 }
10727
10728 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10729 {
10730 }
10731
10732 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10733 {
10734   if(_iter_id<_nb_iter)
10735     {
10736       MEDFileFields *fs(_fs);
10737       if(fs)
10738         return fs->getFieldAtPos(_iter_id++);
10739       else
10740         return 0;
10741     }
10742   else
10743     return 0;
10744 }