]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Structure element inside Gauss Points management
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27 #include "MEDFileBlowStrEltUp.hxx"
28
29 #include "MEDCouplingFieldDouble.hxx"
30 #include "MEDCouplingFieldTemplate.hxx"
31 #include "MEDCouplingFieldDiscretization.hxx"
32
33 #include "InterpKernelAutoPtr.hxx"
34 #include "CellModel.hxx"
35
36 #include <algorithm>
37 #include <iterator>
38
39 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
40 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
41 extern med_geometry_type typmainoeud[1];
42 extern med_geometry_type typmai3[34];
43
44 using namespace MEDCoupling;
45
46 template class MEDFileField1TSTemplateWithoutSDA<int>;
47 template class MEDFileField1TSTemplateWithoutSDA<double>;
48
49 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
50 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51
52 MEDFileGTKeeper::~MEDFileGTKeeper()
53 {
54 }
55
56 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
57 {
58   return new MEDFileGTKeeperSta(_geo_type);
59 }
60
61 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
62 {
63   return _geo_type;
64 }
65
66 std::string MEDFileGTKeeperSta::getRepr() const
67 {
68   return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
69 }
70
71 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
72 {
73   const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
74   if(!otherC)
75     return false;
76   return _geo_type==otherC->_geo_type;
77 }
78
79 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
80 {
81   if(mesh)
82     mesh->incrRef();
83   if(section)
84     section->incrRef();
85   if(se)
86     se->incrRef();
87   if(_mesh.isNull() || _section.isNull() || _se.isNull())
88     throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
89 }
90
91 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
92 {
93   return new MEDFileGTKeeperDyn(_mesh,_section,_se);
94 }
95
96 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
97 {
98   throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
99 }
100
101 std::string MEDFileGTKeeperDyn::getRepr() const
102 {
103   std::ostringstream oss;
104   oss << _se->getDynGT();
105   return oss.str();
106 }
107
108 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
109 {
110   const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
111   if(!otherC)
112     return false;
113   return this==otherC;
114 }
115
116 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
117 {
118   return new MEDFileFieldLoc(fid,locName);
119 }
120
121 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
122 {
123   return new MEDFileFieldLoc(fid,id,entities);
124 }
125
126 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)
127 {
128   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
129 }
130
131 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
132 {
133   med_geometry_type geotype;
134   med_geometry_type sectiongeotype;
135   int nsectionmeshcell;
136   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
137   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
138   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
139   _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
140   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
141   _nb_node_per_cell=cm.getNumberOfNodes();
142   _ref_coo.resize(_dim*_nb_node_per_cell);
143   _gs_coo.resize(_dim*_nb_gauss_pt);
144   _w.resize(_nb_gauss_pt);
145   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
146 }
147
148 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
149 {
150   med_geometry_type geotype;
151   med_geometry_type sectiongeotype;
152   int nsectionmeshcell;
153   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
154   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
155   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
156   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
157   _name=locName;
158   std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
159   if(sectionName.empty())
160     {
161       _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
162       const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
163       _nb_node_per_cell=cm.getNumberOfNodes();
164     }
165   else
166     {
167       const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
168       if(!entities2)
169         {
170           std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
171           throw INTERP_KERNEL::Exception(oss.str());
172         }
173       const MEDFileStructureElement *se(entities2->getWithGT(geotype));
174       const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
175       const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
176       _gt=new MEDFileGTKeeperDyn(um,section,se);
177       {
178         int dummy;
179         MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
180       }
181     }
182   _ref_coo.resize(_dim*_nb_node_per_cell);
183   _gs_coo.resize(_dim*_nb_gauss_pt);
184   _w.resize(_nb_gauss_pt);
185   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
186 }
187
188 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
189                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_gt(new MEDFileGTKeeperSta(geoType)),_ref_coo(refCoo),_gs_coo(gsCoo),_w(w)
190 {
191   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
192   _dim=cm.getDimension();
193   _nb_node_per_cell=cm.getNumberOfNodes();
194   _nb_gauss_pt=_w.size();
195 }
196
197
198 MEDFileFieldLoc::MEDFileFieldLoc(const MEDFileFieldLoc& other):_dim(other._dim),_nb_gauss_pt(other._nb_gauss_pt),_gt(other._gt->deepCopy()),_nb_node_per_cell(other._nb_node_per_cell),_name(other._name),_ref_coo(other._ref_coo),_gs_coo(other._gs_coo),_w(other._w)
199 {
200 }
201
202 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
203 {
204   return new MEDFileFieldLoc(*this);
205 }
206
207 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
208 {
209   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
210 }
211
212 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
213 {
214   return std::vector<const BigMemoryObject *>();
215 }
216
217 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
218 {
219   static const char OFF7[]="\n    ";
220   oss << "\"" << _name << "\"" << OFF7;
221   oss << "GeoType=" << _gt->getRepr() << OFF7;
222   oss << "Dimension=" << _dim << OFF7;
223   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
224   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
225   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
226   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
227   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
228 }
229
230 void MEDFileFieldLoc::setName(const std::string& name)
231 {
232   _name=name;
233 }
234
235 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
236 {
237   if(_name!=other._name)
238     return false;
239   if(_dim!=other._dim)
240     return false;
241   if(_nb_gauss_pt!=other._nb_gauss_pt)
242     return false;
243   if(_nb_node_per_cell!=other._nb_node_per_cell)
244     return false;
245   if(!_gt->isEqual(other._gt))
246     return false;
247   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
248     return false;
249   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
250     return false;
251   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
252     return false;
253
254   return true;
255 }
256
257 void MEDFileFieldLoc::writeLL(med_idt fid) const
258 {
259   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)getGeoType()],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
260 }
261
262 std::string MEDFileFieldLoc::repr() const
263 {
264   std::ostringstream oss; oss.precision(15);
265   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
266   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
267   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
268   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
269   oss << "\n  - Ref coords are : ";
270   int sz=_ref_coo.size();
271   if(sz%_dim==0)
272     {
273       int nbOfTuples=sz/_dim;
274       for(int i=0;i<nbOfTuples;i++)
275         {
276           oss << "(";
277           for(int j=0;j<_dim;j++)
278             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
279           oss << ") ";
280         }
281     }
282   else
283     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
284   oss << "\n  - Gauss coords in reference element : ";
285   sz=_gs_coo.size();
286   if(sz%_dim==0)
287     {
288       int nbOfTuples=sz/_dim;
289       for(int i=0;i<nbOfTuples;i++)
290         {
291           oss << "(";
292           for(int j=0;j<_dim;j++)
293             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
294           oss << ") ";
295         }
296     }
297   else
298     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
299   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
300   return oss.str();
301 }
302
303 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
304 {
305   _type=field->getTypeOfField();
306   _start=start;
307   switch(_type)
308   {
309     case ON_CELLS:
310       {
311         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
312         _end=_start+nbOfCells;
313         _nval=nbOfCells;
314         break;
315       }
316     case ON_GAUSS_NE:
317       {
318         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
319         const int *arrPtr=arr->getConstPointer();
320         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
321         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
322         _nval=nbOfCells;
323         break;
324       }
325     case ON_GAUSS_PT:
326       {
327         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
328         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
329         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
330         if(!disc2)
331           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
332         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
333         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
334         const int *dai2Ptr(dai2->getConstPointer());
335         int nbi(gsLoc.getWeights().size());
336         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
337         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
338         const int *da3Ptr(da3->getConstPointer());
339         if(da3->getNumberOfTuples()!=nbOfCells)
340           {//profile : for gauss even in NoProfile !!!
341             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
342             _profile=oss.str();
343             da3->setName(_profile.c_str());
344             glob.appendProfile(da3);
345           }
346         MCAuto<DataArrayInt> da4(DataArrayInt::New());
347         _nval=da3->getNbOfElems();
348         da4->alloc(_nval*nbi,1);
349         int *da4Ptr(da4->getPointer());
350         for(int i=0;i<_nval;i++)
351           {
352             int ref=dai2Ptr[offset+da3Ptr[i]];
353             for(int j=0;j<nbi;j++)
354               *da4Ptr++=ref+j;
355           }
356         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
357         _localization=oss2.str();
358         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
359         _end=_start+_nval*nbi;
360         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
361         break;
362       }
363     default:
364       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
365   }
366   start=_end;
367 }
368
369 /*!
370  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
371  * \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).
372  * \param [in] multiTypePfl is the end user profile specified in high level API
373  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
374  * \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.
375  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
376  * \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.
377  */
378 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)
379 {
380   _profile.clear();
381   _type=field->getTypeOfField();
382   std::string pflName(multiTypePfl->getName());
383   std::ostringstream oss; oss << pflName;
384   if(_type!=ON_NODES)
385     {
386       if(!isPflAlone)
387         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
388     }
389   else
390     { oss << "_NODE"; }
391   if(locIds)
392     {
393       if(pflName.empty())
394         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
395       if(_type!=ON_GAUSS_PT)
396         {
397           locIds->setName(oss.str());
398           glob.appendProfile(locIds);
399           _profile=oss.str();
400         }
401     }
402   _start=start;
403   switch(_type)
404   {
405     case ON_NODES:
406       {
407         _nval=idsInPfl->getNumberOfTuples();
408         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
409         _end=_start+_nval;
410         break;
411       }
412     case ON_CELLS:
413       {
414         _nval=idsInPfl->getNumberOfTuples();
415         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
416         _end=_start+_nval;
417         break;
418       }
419     case ON_GAUSS_NE:
420       {
421         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
422         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
423         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
424         arr3->computeOffsetsFull();
425         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
426         int trueNval=tmp->getNumberOfTuples();
427         _nval=idsInPfl->getNumberOfTuples();
428         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
429         _end=_start+trueNval;
430         break;
431       }
432     case ON_GAUSS_PT:
433       {
434         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
435         if(!disc2)
436           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
437         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
438         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
439         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
440         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
441         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
442         //
443         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
444         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
445         //
446         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
447         int trueNval=0;
448         for(const int *pt=da4->begin();pt!=da4->end();pt++)
449           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
450         tmp->alloc(trueNval,1);
451         int *tmpPtr=tmp->getPointer();
452         for(const int *pt=da4->begin();pt!=da4->end();pt++)
453           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
454             *tmpPtr++=j;
455         //
456         _nval=da4->getNumberOfTuples();
457         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
458         _end=_start+trueNval;
459         oss << "_loc_" << _loc_id;
460         if(locIds)
461           {
462             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
463             da5->setName(oss.str());
464             glob.appendProfile(da5);
465             _profile=oss.str();
466           }
467         else
468           {
469             if(!da3->isIota(nbOfEltsInWholeMesh))
470               {
471                 da3->setName(oss.str());
472                 glob.appendProfile(da3);
473                 _profile=oss.str();
474               }
475           }
476         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
477         _localization=oss2.str();
478         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
479         break;
480       }
481     default:
482       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
483   }
484   start=_end;
485 }
486
487 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
488 {
489   _start=start;
490   _nval=arrr->getNumberOfTuples();
491   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
492   _end=_start+_nval;
493   start=_end;
494 }
495
496 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
497 {
498   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
499 }
500
501 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
502 {
503   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
504 }
505
506 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
507 {
508   return new MEDFileFieldPerMeshPerTypePerDisc(other);
509 }
510
511 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
512 {
513   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
514 }
515
516 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
517 {
518   std::vector<const BigMemoryObject *> ret(1);
519   ret[0]=(const PartDefinition*)_pd;
520   return ret;
521 }
522
523 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
524 {
525   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
526   ret->_father=father;
527   return ret.retn();
528 }
529
530 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
531 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
532 {
533   if(pd)
534     pd->incrRef();
535 }
536 catch(INTERP_KERNEL::Exception& e)
537 {
538     throw e;
539 }
540
541 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
542 {
543 }
544
545 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)
546 {
547 }
548
549 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
550     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
551 {
552 }
553
554 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)
555 {
556   const PartDefinition *pd(_pd);
557   if(!pd)
558     {
559       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
560       int nbi,tmp1;
561       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
562       if(_end-_start!=nbValsInFile*nbi)
563         {
564           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 !";
565           throw INTERP_KERNEL::Exception(oss.str());
566         }
567       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
568     }
569   else
570     {
571       if(!_profile.empty())
572         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
573       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
574       int profilesize,nbi;
575       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
576       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
577       if(spd)
578         {
579           int start,stop,step;
580           spd->getSlice(start,stop,step);
581           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
582           med_filter filter=MED_FILTER_INIT;
583           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
584                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
585                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
586                                    /*lastblocksize=useless because count=1*/0,&filter);
587           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
588           MEDfilterClose(&filter);
589           return ;
590         }
591       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
592       if(dpd)
593         {
594           dpd->checkConsistencyLight();
595           MCAuto<DataArrayInt> myIds(dpd->toDAI());
596           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
597           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
598           myIds->applyLin(1,-a);
599           int nbOfEltsToLoad(b-a+1);
600           med_filter filter=MED_FILTER_INIT;
601           {//TODO : manage int32 !
602             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
603             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
604             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
605                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
606                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
607                                      /*lastblocksize=useless because count=1*/0,&filter);
608             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
609             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
610             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
611             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
612           }
613           MEDfilterClose(&filter);
614         }
615       else
616         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
617     }
618 }
619
620 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
621 {
622   return _father;
623 }
624
625 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
626 {
627   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
628   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
629   std::string fieldName(nasc.getName()),meshName(getMeshName());
630   int iteration(getIteration()),order(getOrder()),profilesize,nbi;
631   TypeOfField type(getType());
632   med_geometry_type mgeoti;
633   med_entity_type menti;
634   _father->entriesForMEDfile(type,mgeoti,menti);
635   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
636   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
637   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
638   const PartDefinition *pd(_pd);
639   if(!pd)
640     {
641       _nval=zeNVal;
642     }
643   else
644     {
645       if(!_profile.empty())
646         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
647       _nval=pd->getNumberOfElems();
648     }
649   _start=start;
650   _end=start+_nval*nbi;
651   start=_end;
652   if(type==ON_CELLS && !_localization.empty())
653     {
654       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
655         setType(ON_GAUSS_PT);
656       else
657         {
658           setType(ON_GAUSS_NE);
659           _localization.clear();
660         }
661     }
662 }
663
664 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
665 {
666   std::string fieldName(nasc.getName()),meshName(getMeshName());
667   int iteration(getIteration()),order(getOrder());
668   TypeOfField type(getType());
669   med_geometry_type mgeoti;
670   med_entity_type menti;
671   _father->entriesForMEDfile(type,mgeoti,menti);
672   if(_start>_end)
673     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
674   if(_start==_end)
675     return ;
676   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
677   if(_start<0 || _start>=arr->getNumberOfTuples())
678     {
679       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
680       throw INTERP_KERNEL::Exception(oss.str());
681     }
682   if(_end<0 || _end>arr->getNumberOfTuples())
683     {
684       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
685       throw INTERP_KERNEL::Exception(oss.str());
686     }
687   int nbOfCompo(arr->getNumberOfComponents());
688   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
689   if(arrD)
690     {
691       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
692       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
693       return ;
694     }
695   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
696   if(arrI)
697     {
698       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
699       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
700       return ;
701     }
702   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
703 }
704
705 /*!
706  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
707  */
708 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
709 {
710   int delta=_end-_start;
711   _start=newValueOfStart;
712   _end=_start+delta;
713 }
714
715 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
716 {
717   return _father->getIteration();
718 }
719
720 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
721 {
722   return _father->getOrder();
723 }
724
725 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
726 {
727   return _father->getTime();
728 }
729
730 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
731 {
732   return _father->getMeshName();
733 }
734
735 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
736 {
737   const char startLine[]="    ## ";
738   std::string startLine2(bkOffset,' ');
739   startLine2+=startLine;
740   INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
741   oss << startLine2 << "Localization #" << id << "." << std::endl;
742   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
743   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
744   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
745   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
746 }
747
748 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
749 {
750   return _type;
751 }
752
753 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
754 {
755   return _father->getGeoType();
756 }
757
758 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
759 {
760   types.insert(_type);
761 }
762
763 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
764 {
765   _type=newType;
766 }
767
768 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
769 {
770   return _father->getNumberOfComponents();
771 }
772
773 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
774 {
775   return _end-_start;
776 }
777
778 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
779 {
780   return _father->getOrCreateAndGetArray();
781 }
782
783 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
784 {
785   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
786   return fath->getOrCreateAndGetArray();
787 }
788
789 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
790 {
791   return _father->getInfo();
792 }
793
794 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
795 {
796   return _profile;
797 }
798
799 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
800 {
801   _profile=newPflName;
802 }
803
804 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
805 {
806   return _localization;
807 }
808
809 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
810 {
811   _localization=newLocName;
812 }
813
814 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
815 {
816   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
817     {
818       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
819         {
820           _profile=(*it2).second;
821           return;
822         }
823     }
824 }
825
826 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
827 {
828   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
829     {
830       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
831         {
832           _localization=(*it2).second;
833           return;
834         }
835     }
836 }
837
838 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
839 {
840   if(type!=_type)
841     return ;
842   dads.push_back(std::pair<int,int>(_start,_end));
843   geoTypes.push_back(getGeoType());
844   if(_profile.empty())
845     pfls.push_back(0);
846   else
847     {
848       pfls.push_back(glob->getProfile(_profile.c_str()));
849     }
850   if(_localization.empty())
851     locs.push_back(-1);
852   else
853     {
854       locs.push_back(glob->getLocalizationId(_localization.c_str()));
855     }
856 }
857
858 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
859 {
860   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));
861   startEntryId++;
862 }
863
864 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
865 {
866   TypeOfField type=getType();
867   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
868   med_geometry_type mgeoti;
869   med_entity_type menti;
870   _father->entriesForMEDfile(getType(),mgeoti,menti);
871   const DataArray *arr(getOrCreateAndGetArray());
872   if(!arr)
873     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
874   if(!arr->isAllocated())
875     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
876   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
877   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
878   const unsigned char *locToWrite=0;
879   if(arrD)
880     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
881   else if(arrI)
882     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
883   else
884     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
885   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
886                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
887                                                    locToWrite));
888 }
889
890 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
891 {
892   type=_type;
893   pfl=_profile;
894   loc=_localization;
895   dad.first=_start; dad.second=_end;
896 }
897
898 /*!
899  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
900  *             This code corresponds to the distribution of types in the corresponding mesh.
901  * \param [out] ptToFill memory zone where the output will be stored.
902  * \return the size of data pushed into output param \a ptToFill
903  */
904 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
905 {
906   _loc_id=offset;
907   std::ostringstream oss;
908   std::size_t nbOfType=codeOfMesh.size()/3;
909   int found=-1;
910   for(std::size_t i=0;i<nbOfType && found==-1;i++)
911     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
912       found=(int)i;
913   if(found==-1)
914     {
915       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
916       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
917       throw INTERP_KERNEL::Exception(oss.str());
918     }
919   int *work=ptToFill;
920   if(_profile.empty())
921     {
922       if(_nval!=codeOfMesh[3*found+1])
923         {
924           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
925           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
926           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
927           throw INTERP_KERNEL::Exception(oss.str());
928         }
929       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
930         *work++=ii;
931     }
932   else
933     {
934       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
935       if(pfl->getNumberOfTuples()!=_nval)
936         {
937           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
938           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
939           oss << _nval;
940           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
941           throw INTERP_KERNEL::Exception(oss.str());
942         }
943       int offset2=codeOfMesh[3*found+2];
944       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
945         {
946           if(*pflId<codeOfMesh[3*found+1])
947             *work++=offset2+*pflId;
948         }
949     }
950   return _nval;
951 }
952
953 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
954 {
955   for(int i=_start;i<_end;i++)
956     *ptToFill++=i;
957   return _end-_start;
958 }
959
960 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
961 {
962   switch(type)
963   {
964     case ON_CELLS:
965       return -2;
966     case ON_GAUSS_NE:
967       return -1;
968     case ON_GAUSS_PT:
969       return locId;
970     default:
971       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
972   }
973 }
974
975 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
976 {
977   int id=0;
978   std::map<std::pair<std::string,TypeOfField>,int> m;
979   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
980   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
981     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
982       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
983   ret.resize(id);
984   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
985     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
986   return ret;
987 }
988
989 /*!
990  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
991  * 
992  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
993  * \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.
994  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
995  * \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)
996  * \param [in,out] glob if necessary by the method, new profiles can be added to it
997  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
998  * \param [out] result All new entries will be appended on it.
999  * \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 !)
1000  */
1001 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1002                                                        const DataArrayInt *explicitIdsInMesh,
1003                                                        const std::vector<int>& newCode,
1004                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1005                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1006 {
1007   if(entriesOnSameDisc.empty())
1008     return false;
1009   TypeOfField type=entriesOnSameDisc[0]->getType();
1010   int szEntities=0,szTuples=0;
1011   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1012     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1013   int nbi=szTuples/szEntities;
1014   if(szTuples%szEntities!=0)
1015     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1016   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1017   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1018   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1019   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1020   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1021   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1022   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1023   int id=0;
1024   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1025     {
1026       int startOfEltIdOfChunk=(*it)->_start;
1027       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1028       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1029       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1030       //
1031       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1032       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1033       //
1034       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1035       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1036     }
1037   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1038   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1039   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1040   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1041   //
1042   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1043   //
1044   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1045   arrPart->renumberInPlace(renumTupleIds->begin());
1046   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1047   bool ret=false;
1048   const int *idIt=diffVals->begin();
1049   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1050   int offset2=0;
1051   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1052     {
1053       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1054       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1055       int nbEntityElts=subIds->getNumberOfTuples();
1056       bool ret2;
1057       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1058           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1059                                       offset+offset2,
1060                                       li,glob,ret2);
1061       ret=ret || ret2;
1062       result.push_back(eltToAdd);
1063       offset2+=nbEntityElts*nbi;
1064     }
1065   ret=ret || li.empty();
1066   return ret;
1067 }
1068
1069 /*!
1070  * \param [in] typeF type of field of new chunk
1071  * \param [in] geoType the geometric type of the chunk
1072  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1073  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1074  * \param [in] nbi number of integration points
1075  * \param [in] offset The offset in the **global array of data**.
1076  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1077  *                 to the new chunk to create.
1078  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1079  * \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
1080  *              and corresponding entry erased from \a entriesOnSameDisc.
1081  * \return a newly allocated chunk
1082  */
1083 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1084                                                                                                   bool isPfl, int nbi, int offset,
1085                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1086                                                                                                   MEDFileFieldGlobsReal& glob,
1087                                                                                                   bool &notInExisting)
1088 {
1089   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1090   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1091   for(;it!=entriesOnSameDisc.end();it++)
1092     {
1093       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1094         {
1095           if(!isPfl)
1096             {
1097               if((*it)->_profile.empty())
1098                 break;
1099               else
1100                 if(!(*it)->_profile.empty())
1101                   {
1102                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1103                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1104                       break;
1105                   }
1106             }
1107         }
1108     }
1109   if(it==entriesOnSameDisc.end())
1110     {
1111       notInExisting=true;
1112       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1113       ret->_type=typeF;
1114       ret->_loc_id=(int)geoType;
1115       ret->_nval=nbMeshEntities;
1116       ret->_start=offset;
1117       ret->_end=ret->_start+ret->_nval*nbi;
1118       if(isPfl)
1119         {
1120           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1121           glob.appendProfile(idsOfMeshElt);
1122           ret->_profile=idsOfMeshElt->getName();
1123         }
1124       //tony treatment of localization
1125       return ret;
1126     }
1127   else
1128     {
1129       notInExisting=false;
1130       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1131       ret->_loc_id=(int)geoType;
1132       ret->setNewStart(offset);
1133       entriesOnSameDisc.erase(it);
1134       return ret;
1135     }
1136
1137 }
1138
1139 ////////////////////////////////////
1140
1141 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1142  {
1143  }
1144
1145 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1146 {
1147   _father=father;
1148 }
1149
1150 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1151 {
1152   std::size_t i=0;
1153   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1154     {
1155       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1156         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1157     }
1158 }
1159
1160 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1161 {
1162   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1163 }
1164
1165 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1166 {
1167   std::vector<const BigMemoryObject *> ret;
1168   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1169     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1170   return ret;
1171 }
1172
1173 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1174 {
1175   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1176   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1177     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1178 }
1179
1180 /*!
1181  * This method is the most general one. No optimization is done here.
1182  * \param [in] multiTypePfl is the end user profile specified in high level API
1183  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1184  * \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.
1185  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1186  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1187  * \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.
1188  */
1189 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1190 {
1191   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1192   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1193     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1194 }
1195
1196 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1197 {
1198   _field_pm_pt_pd.resize(1);
1199   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1200   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1201 }
1202
1203 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1204 {
1205   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1206   if(!arr || !arr->isAllocated())
1207     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1208   _field_pm_pt_pd.resize(1);
1209   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1210   _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.
1211 }
1212
1213 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1214 {
1215   TypeOfField type=field->getTypeOfField();
1216   if(type!=ON_GAUSS_PT)
1217     {
1218       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1219       int sz=_field_pm_pt_pd.size();
1220       bool found=false;
1221       for(int j=0;j<sz && !found;j++)
1222         {
1223           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1224             {
1225               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1226               found=true;
1227             }
1228         }
1229       if(!found)
1230         {
1231           _field_pm_pt_pd.resize(sz+1);
1232           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1233         }
1234       std::vector<int> ret(1,(int)sz);
1235       return ret;
1236     }
1237   else
1238     {
1239       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1240       int sz2=ret2.size();
1241       std::vector<int> ret3(sz2);
1242       int k=0;
1243       for(int i=0;i<sz2;i++)
1244         {
1245           int sz=_field_pm_pt_pd.size();
1246           int locIdToFind=ret2[i];
1247           bool found=false;
1248           for(int j=0;j<sz && !found;j++)
1249             {
1250               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1251                 {
1252                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1253                   ret3[k++]=j;
1254                   found=true;
1255                 }
1256             }
1257           if(!found)
1258             {
1259               _field_pm_pt_pd.resize(sz+1);
1260               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1261               ret3[k++]=sz;
1262             }
1263         }
1264       return ret3;
1265     }
1266 }
1267
1268 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1269 {
1270   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1271   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1272   if(!disc2)
1273     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1274   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1275   if(!da)
1276     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1277   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1278   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1279   if(retTmp->presenceOfValue(-1))
1280     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1281   std::vector<int> ret(retTmp->begin(),retTmp->end());
1282   return ret;
1283 }
1284
1285 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1286 {
1287   TypeOfField type=field->getTypeOfField();
1288   if(type!=ON_GAUSS_PT)
1289     {
1290       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1291       int sz=_field_pm_pt_pd.size();
1292       bool found=false;
1293       for(int j=0;j<sz && !found;j++)
1294         {
1295           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1296             {
1297               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1298               found=true;
1299             }
1300         }
1301       if(!found)
1302         {
1303           _field_pm_pt_pd.resize(sz+1);
1304           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1305         }
1306       std::vector<int> ret(1,0);
1307       return ret;
1308     }
1309   else
1310     {
1311       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1312       int sz2=ret2.size();
1313       std::vector<int> ret3(sz2);
1314       int k=0;
1315       for(int i=0;i<sz2;i++)
1316         {
1317           int sz=_field_pm_pt_pd.size();
1318           int locIdToFind=ret2[i];
1319           bool found=false;
1320           for(int j=0;j<sz && !found;j++)
1321             {
1322               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1323                 {
1324                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1325                   ret3[k++]=j;
1326                   found=true;
1327                 }
1328             }
1329           if(!found)
1330             {
1331               _field_pm_pt_pd.resize(sz+1);
1332               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1333               ret3[k++]=sz;
1334             }
1335         }
1336       return ret3;
1337     }
1338 }
1339
1340 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1341 {
1342   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1343   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1344   if(!disc2)
1345     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1346   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1347   if(!da)
1348     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1349   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1350   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1351   if(retTmp->presenceOfValue(-1))
1352     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1353   std::vector<int> ret(retTmp->begin(),retTmp->end());
1354   return ret;
1355 }
1356
1357 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1358 {
1359   return _father;
1360 }
1361
1362 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1363 {
1364   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1365   int curDim((int)cm.getDimension());
1366   if(dim!=std::numeric_limits<int>::max())
1367     {
1368       if(dim!=curDim)
1369         return false;
1370     }
1371   else
1372     dim=curDim;
1373   return true;
1374 }
1375
1376 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1377 {
1378   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1379     {
1380       (*it)->fillTypesOfFieldAvailable(types);
1381     }
1382 }
1383
1384 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1385 {
1386   int sz=_field_pm_pt_pd.size();
1387   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1388   for(int i=0;i<sz;i++)
1389     {
1390       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1391     }
1392 }
1393
1394 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1395 {
1396   return _father->getIteration();
1397 }
1398
1399 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1400 {
1401   return _father->getOrder();
1402 }
1403
1404 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1405 {
1406   return _father->getTime();
1407 }
1408
1409 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1410 {
1411   return _father->getMeshName();
1412 }
1413
1414 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1415 {
1416   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1417     {
1418       globalSz+=(*it)->getNumberOfTuples();
1419     }
1420   nbOfEntries+=(int)_field_pm_pt_pd.size();
1421 }
1422
1423 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1424 {
1425   return _father->getNumberOfComponents();
1426 }
1427
1428 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1429 {
1430   std::size_t nb(0);
1431   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1432     {
1433       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1434       if(fmtd)
1435         nb++;
1436     }
1437   return nb>1;
1438 }
1439
1440 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1441 {
1442   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1443   elt.takeRef(disc);
1444   _field_pm_pt_pd.push_back(elt);
1445 }
1446
1447 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1448 {
1449   return _father->getOrCreateAndGetArray();
1450 }
1451
1452 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1453 {
1454   const MEDFileFieldPerMesh *fath=_father;
1455   return fath->getOrCreateAndGetArray();
1456 }
1457
1458 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1459 {
1460   return _father->getInfo();
1461 }
1462
1463 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1464 {
1465   std::vector<std::string> ret;
1466   std::set<std::string> ret2;
1467   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1468     {
1469       std::string tmp=(*it1)->getProfile();
1470       if(!tmp.empty())
1471         if(ret2.find(tmp)==ret2.end())
1472           {
1473             ret.push_back(tmp);
1474             ret2.insert(tmp);
1475           }
1476     }
1477   return ret;
1478 }
1479
1480 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1481 {
1482   std::vector<std::string> ret;
1483   std::set<std::string> ret2;
1484   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1485     {
1486       std::string tmp=(*it1)->getLocalization();
1487       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1488         if(ret2.find(tmp)==ret2.end())
1489           {
1490             ret.push_back(tmp);
1491             ret2.insert(tmp);
1492           }
1493     }
1494   return ret;
1495 }
1496
1497 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1498 {
1499   std::vector<std::string> ret;
1500   std::set<std::string> ret2;
1501   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1502     {
1503       std::string tmp=(*it1)->getProfile();
1504       if(!tmp.empty())
1505         ret.push_back(tmp);
1506     }
1507   return ret;
1508 }
1509
1510 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1511 {
1512   std::vector<std::string> ret;
1513   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1514     {
1515       std::string tmp=(*it1)->getLocalization();
1516       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1517         ret.push_back(tmp);
1518     }
1519   return ret;
1520 }
1521
1522 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1523 {
1524   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1525     (*it1)->changePflsRefsNamesGen(mapOfModif);
1526 }
1527
1528 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1529 {
1530   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1531     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1532 }
1533
1534 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1535 {
1536   if(_field_pm_pt_pd.empty())
1537     {
1538       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1539       throw INTERP_KERNEL::Exception(oss.str());
1540     }
1541   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1542     return _field_pm_pt_pd[locId];
1543   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1544   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1545   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1546   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1547 }
1548
1549 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1550 {
1551   if(_field_pm_pt_pd.empty())
1552     {
1553       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1554       throw INTERP_KERNEL::Exception(oss.str());
1555     }
1556   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1557     return _field_pm_pt_pd[locId];
1558   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1559   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1560   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1561   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1562 }
1563
1564 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1565 {
1566   int i=0;
1567   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1568     {
1569       (*it)->fillValues(i,startEntryId,entries);
1570     }
1571 }
1572
1573 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1574 {
1575   _field_pm_pt_pd=leaves;
1576   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1577     (*it)->setFather(this);
1578 }
1579
1580 /*!
1581  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1582  *  \param [out] its - list of pair (start,stop) kept
1583  *  \return bool - false if the type of field \a tof is not contained in \a this.
1584  */
1585 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1586 {
1587   bool ret(false);
1588   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1589   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1590     if((*it)->getType()==tof)
1591       {
1592         newPmPtPd.push_back(*it);
1593         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1594         (*it)->setNewStart(globalNum);
1595         globalNum=(*it)->getEnd();
1596         its.push_back(bgEnd);
1597         ret=true;
1598       }
1599   if(ret)
1600     _field_pm_pt_pd=newPmPtPd;
1601   return ret;
1602 }
1603
1604 /*!
1605  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1606  *  \param [out] its - list of pair (start,stop) kept
1607  *  \return bool - false if the type of field \a tof is not contained in \a this.
1608  */
1609 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1610 {
1611   if(_field_pm_pt_pd.size()<=idOfDisc)
1612     return false;
1613   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1614   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1615   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1616   elt->setNewStart(globalNum);
1617   globalNum=elt->getEnd();
1618   its.push_back(bgEnd);
1619   _field_pm_pt_pd=newPmPtPd;
1620   return true;
1621 }
1622
1623 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1624 {
1625   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1626     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1627 }
1628
1629 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1630 {
1631   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1632     (*it)->loadBigArray(fid,nasc);
1633 }
1634
1635 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1636 {
1637   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1638     {
1639       (*it)->copyOptionsFrom(*this);
1640       (*it)->writeLL(fid,nasc);
1641     }
1642 }
1643
1644 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1645 {
1646   switch(ikType)
1647   {
1648     case ON_CELLS:
1649       medfGeoType=typmai3[(int)ikGeoType];
1650       return MED_CELL;
1651     case ON_NODES:
1652       medfGeoType=MED_NONE;
1653       return MED_NODE;
1654     case ON_GAUSS_NE:
1655       medfGeoType=typmai3[(int)ikGeoType];
1656       return MED_NODE_ELEMENT;
1657     case ON_GAUSS_PT:
1658       medfGeoType=typmai3[(int)ikGeoType];
1659       return MED_CELL;
1660     default:
1661       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1662   }
1663   return MED_UNDEF_ENTITY_TYPE;
1664 }
1665
1666 //////////////////////////////////////////////////
1667
1668 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1669 {
1670   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1671 }
1672
1673 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1674 {
1675   return new MEDFileFieldPerMeshPerType(fath,geoType);
1676 }
1677
1678 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1679 {
1680   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1681   ret->setFather(father);
1682   ret->deepCopyElements();
1683   return ret.retn();
1684 }
1685
1686 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
1687 {
1688   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1689     {
1690       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1691       if(meshDim!=(int)cm.getDimension())
1692         return ;
1693     }
1694   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1695     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1696 }
1697
1698 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1699 {
1700   return _geo_type;
1701 }
1702
1703 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1704 {
1705   ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1706 }
1707
1708 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1709 {
1710   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1711   int curDim((int)cm.getDimension());
1712   dim=std::max(dim,curDim);
1713 }
1714
1715 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1716 {
1717   const char startLine[]="  ## ";
1718   std::string startLine2(bkOffset,' ');
1719   std::string startLine3(startLine2);
1720   startLine3+=startLine;
1721   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1722     {
1723       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1724       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1725     }
1726   else
1727     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1728   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1729   int i=0;
1730   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1731     {
1732       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1733       if(cur)
1734         cur->simpleRepr(bkOffset,oss,i);
1735       else
1736         {
1737           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1738         }
1739     }
1740 }
1741
1742 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1743 {
1744   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1745   return std::string(cm.getRepr());
1746 }
1747
1748 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1749 {
1750 }
1751
1752 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1753 {
1754   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1755   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1756   med_geometry_type mgeoti;
1757   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1758   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1759   _field_pm_pt_pd.resize(nbProfiles);
1760   for(int i=0;i<nbProfiles;i++)
1761     {
1762       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1763     }
1764   if(type==ON_CELLS)
1765     {
1766       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1767       for(int i=0;i<nbProfiles2;i++)
1768         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1769     }
1770 }
1771
1772 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1773 {
1774   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1775   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1776   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1777     {
1778       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1779         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1780     }
1781   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1782     {
1783       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1784       ret->_field_pm_pt_pd.push_back(agg);
1785     }
1786   return ret;
1787 }
1788
1789 //////////////////////////////////////////////////
1790
1791 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1792 {
1793   if(!entities)
1794     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1795   const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1796   if(!entities2)
1797     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1798   const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1799   return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1800 }
1801
1802 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1803 {
1804   _se.takeRef(se);
1805   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1806   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1807   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1808   _field_pm_pt_pd.resize(nbProfiles);
1809   for(int i=0;i<nbProfiles;i++)
1810     {
1811       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1812     }
1813 }
1814
1815 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1816 {
1817   return _se->getDynGT();
1818 }
1819
1820 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1821 {
1822   return _se->getName();
1823 }
1824
1825 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1826 {
1827   throw INTERP_KERNEL::Exception("not implemented yet !");
1828 }
1829
1830 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1831 {
1832   gt=getDynGT();
1833   ent=MED_STRUCT_ELEMENT;
1834 }
1835
1836 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1837 {
1838   throw INTERP_KERNEL::Exception("not implemented yet !");
1839 }
1840
1841 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1842 {
1843   const char startLine[]="  ## ";
1844   std::string startLine2(bkOffset,' ');
1845   std::string startLine3(startLine2);
1846   startLine3+=startLine;
1847   oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1848   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1849   int i=0;
1850   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1851     {
1852       if((*it).isNotNull())
1853         (*it)->simpleRepr(bkOffset,oss,i);
1854       else
1855         {
1856           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1857         }
1858     }
1859 }
1860
1861 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1862 {
1863   throw INTERP_KERNEL::Exception("not implemented yet !");
1864 }
1865
1866 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1867 {
1868   MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1869   ret->setFather(father);
1870   ret->deepCopyElements();
1871   return ret.retn();
1872 }
1873
1874 void MEDFileFieldPerMeshPerTypeDyn::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1875 {
1876   throw INTERP_KERNEL::Exception("not implemented yet !");
1877 }
1878
1879 //////////////////////////////////////////////////
1880
1881 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1882 {
1883   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1884 }
1885
1886 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1887 {
1888   return new MEDFileFieldPerMesh(fath,mesh);
1889 }
1890
1891 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1892 {
1893   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1894 }
1895
1896 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1897 {
1898   std::vector<const BigMemoryObject *> ret;
1899   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1900     ret.push_back(*it);
1901   return ret;
1902 }
1903
1904 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1905 {
1906   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1907   ret->_father=father;
1908   std::size_t i=0;
1909   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1910     {
1911       if((*it).isNotNull())
1912         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1913     }
1914   return ret.retn();
1915 }
1916
1917 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1918 {
1919   std::string startLine(bkOffset,' ');
1920   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1921   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1922   int i=0;
1923   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1924     {
1925       if((*it).isNotNull())
1926         (*it)->simpleRepr(bkOffset,oss,i);
1927       else
1928         {
1929           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1930         }
1931     }
1932 }
1933
1934 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1935 {
1936   _mesh_name=mesh->getName();
1937   mesh->getTime(_mesh_iteration,_mesh_order);
1938 }
1939
1940 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1941 {
1942   int nbOfTypes=code.size()/3;
1943   int offset=0;
1944   for(int i=0;i<nbOfTypes;i++)
1945     {
1946       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1947       int nbOfCells=code[3*i+1];
1948       int pos=addNewEntryIfNecessary(type);
1949       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1950       offset+=nbOfCells;
1951     }
1952 }
1953
1954 /*!
1955  * This method is the most general one. No optimization is done here.
1956  * \param [in] multiTypePfl is the end user profile specified in high level API
1957  * \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].
1958  * \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.
1959  * \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.
1960  * \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.
1961  * \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.
1962  */
1963 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)
1964 {
1965   int nbOfTypes(code.size()/3);
1966   for(int i=0;i<nbOfTypes;i++)
1967     {
1968       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1969       int pos=addNewEntryIfNecessary(type);
1970       DataArrayInt *pfl=0;
1971       if(code[3*i+2]!=-1)
1972         pfl=idsPerType[code[3*i+2]];
1973       int nbOfTupes2=code2.size()/3;
1974       int found=0;
1975       for(;found<nbOfTupes2;found++)
1976         if(code[3*i]==code2[3*found])
1977           break;
1978       if(found==nbOfTupes2)
1979         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1980       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1981     }
1982 }
1983
1984 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1985 {
1986   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1987   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1988 }
1989
1990 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1991 {
1992   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1993   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1994 }
1995
1996 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1997 {
1998   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1999     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2000 }
2001
2002 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2003 {
2004   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2005     (*it)->loadBigArraysRecursively(fid,nasc);
2006 }
2007
2008 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2009 {
2010   int nbOfTypes=_field_pm_pt.size();
2011   for(int i=0;i<nbOfTypes;i++)
2012     {
2013       _field_pm_pt[i]->copyOptionsFrom(*this);
2014       _field_pm_pt[i]->writeLL(fid,nasc);
2015     }
2016 }
2017
2018 void MEDFileFieldPerMesh::getDimension(int& dim) const
2019 {
2020   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2021     (*it)->getDimension(dim);
2022 }
2023
2024 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2025 {
2026   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2027     if(!(*it)->isUniqueLevel(dim))
2028       return false;
2029   return true;
2030 }
2031
2032 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2033 {
2034   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2035     (*it)->fillTypesOfFieldAvailable(types);
2036 }
2037
2038 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
2039 {
2040   int sz=_field_pm_pt.size();
2041   std::vector< std::vector<std::pair<int,int> > > ret(sz);
2042   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2043   for(int i=0;i<sz;i++)
2044     {
2045       types[i]=_field_pm_pt[i]->getGeoType();
2046       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2047     }
2048   return ret;
2049 }
2050
2051 double MEDFileFieldPerMesh::getTime() const
2052 {
2053   int tmp1,tmp2;
2054   return _father->getTime(tmp1,tmp2);
2055 }
2056
2057 int MEDFileFieldPerMesh::getIteration() const
2058 {
2059   return _father->getIteration();
2060 }
2061
2062 int MEDFileFieldPerMesh::getOrder() const
2063 {
2064   return _father->getOrder();
2065 }
2066
2067 int MEDFileFieldPerMesh::getNumberOfComponents() const
2068 {
2069   return _father->getNumberOfComponents();
2070 }
2071
2072 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2073 {
2074   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2075     {
2076       if((*it).isNull())
2077         continue;
2078       if((*it)->presenceOfMultiDiscPerGeoType())
2079         return true;
2080     }
2081   return false;
2082 }
2083
2084 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2085 {
2086   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2087     if((*it).isNotNull())
2088       {
2089         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2090         if(pt)
2091           return true;
2092       }
2093   return false;
2094 }
2095
2096 bool MEDFileFieldPerMesh::onlyStructureElements() const
2097 {
2098   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2099     if((*it).isNotNull())
2100       {
2101         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2102         if(!pt)
2103           return false;
2104       }
2105   return true;
2106 }
2107
2108 void MEDFileFieldPerMesh::killStructureElements()
2109 {
2110   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2111   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2112     {
2113       if((*it).isNotNull())
2114         {
2115           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2116           if(!pt)
2117             res.push_back(*it);
2118         }
2119     }
2120   _field_pm_pt=res;
2121 }
2122
2123 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2124 {
2125   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2126   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2127     {
2128       if((*it).isNotNull())
2129         {
2130           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2131           if(pt)
2132             res.push_back(*it);
2133         }
2134     }
2135   _field_pm_pt=res;
2136 }
2137
2138 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2139 {
2140   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2141   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2142     {
2143       if((*it).isNotNull())
2144         {
2145           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2146           if(!pt)
2147             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2148           if(pt->getModelName()==seName)
2149             res.push_back(*it);
2150         }
2151     }
2152   _field_pm_pt=res;
2153 }
2154
2155 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2156 {
2157   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158     {
2159       if((*it).isNotNull())
2160         {
2161           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2162           if(pt)
2163             {
2164               ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2165             }
2166           else
2167             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2168         }
2169     }
2170 }
2171
2172 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2173 {
2174   if(!_father)
2175     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2176   return _father->getOrCreateAndGetArray();
2177 }
2178
2179 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2180 {
2181   if(!_father)
2182     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2183   return _father->getOrCreateAndGetArray();
2184 }
2185
2186 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2187 {
2188   return _father->getInfo();
2189 }
2190
2191 /*!
2192  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2193  * 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.
2194  * It returns 2 output vectors :
2195  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2196  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2197  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2198  */
2199 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)
2200 {
2201   int notNullPflsSz=0;
2202   int nbOfArrs=geoTypes.size();
2203   for(int i=0;i<nbOfArrs;i++)
2204     if(pfls[i])
2205       notNullPflsSz++;
2206   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2207   int nbOfDiffGeoTypes=geoTypes3.size();
2208   code.resize(3*nbOfDiffGeoTypes);
2209   notNullPfls.resize(notNullPflsSz);
2210   notNullPflsSz=0;
2211   int j=0;
2212   for(int i=0;i<nbOfDiffGeoTypes;i++)
2213     {
2214       int startZone=j;
2215       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2216       std::vector<const DataArrayInt *> notNullTmp;
2217       if(pfls[j])
2218         notNullTmp.push_back(pfls[j]);
2219       j++;
2220       for(;j<nbOfArrs;j++)
2221         if(geoTypes[j]==refType)
2222           {
2223             if(pfls[j])
2224               notNullTmp.push_back(pfls[j]);
2225           }
2226         else
2227           break;
2228       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2229       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2230       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2231       code[3*i]=(int)refType;
2232       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2233       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2234       if(notNullTmp.empty())
2235         code[3*i+2]=-1;
2236       else
2237         {
2238           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2239           code[3*i+2]=notNullPflsSz++;
2240         }
2241     }
2242 }
2243
2244 /*!
2245  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2246  */
2247 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)
2248 {
2249   int sz=dads.size();
2250   int ret=0;
2251   for(int i=0;i<sz;i++)
2252     {
2253       if(locs[i]==-1)
2254         {
2255           if(type!=ON_GAUSS_NE)
2256             ret+=dads[i].second-dads[i].first;
2257           else
2258             {
2259               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2260               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2261             }
2262         }
2263       else
2264         {
2265           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2266           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2267         }
2268     }
2269   return ret;
2270 }
2271
2272 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2273 {
2274   std::vector<std::string> ret;
2275   std::set<std::string> ret2;
2276   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2277     {
2278       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2279       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2280         if(ret2.find(*it2)==ret2.end())
2281           {
2282             ret.push_back(*it2);
2283             ret2.insert(*it2);
2284           }
2285     }
2286   return ret;
2287 }
2288
2289 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2290 {
2291   std::vector<std::string> ret;
2292   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2293     {
2294       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2295       ret.insert(ret.end(),tmp.begin(),tmp.end());
2296     }
2297   return ret;
2298 }
2299
2300 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2301 {
2302   std::vector<std::string> ret;
2303   std::set<std::string> ret2;
2304   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2305     {
2306       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2307       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2308         if(ret2.find(*it2)==ret2.end())
2309           {
2310             ret.push_back(*it2);
2311             ret2.insert(*it2);
2312           }
2313     }
2314   return ret;
2315 }
2316
2317 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2318 {
2319   std::vector<std::string> ret;
2320   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2321     {
2322       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2323       ret.insert(ret.end(),tmp.begin(),tmp.end());
2324     }
2325   return ret;
2326 }
2327
2328 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2329 {
2330   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2331     {
2332       if((*it).first==_mesh_name)
2333         {
2334           _mesh_name=(*it).second;
2335           return true;
2336         }
2337     }
2338   return false;
2339 }
2340
2341 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2342 {
2343   if(_field_pm_pt.size()!=1)
2344     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2345   if(_field_pm_pt[0].isNull())
2346     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2347   MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2348   if(!pt)
2349     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2350   if(pt->getNumberOfLoc()!=1)
2351     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2352   const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2353   if(!disc)
2354     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2355   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2356   disc2->setType(ON_NODES);
2357   MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2358   disc2->setFather(pt2);
2359   pt2->setFather(this);
2360   pt2->pushDiscretization(disc2);
2361   _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2362 }
2363
2364 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2365                                                       MEDFileFieldGlobsReal& glob)
2366 {
2367   if(_mesh_name!=meshName)
2368     return false;
2369   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2370   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2371   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2372   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2373   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2374   getUndergroundDataArrayExt(entries);
2375   DataArray *arr0(getOrCreateAndGetArray());//tony
2376   if(!arr0)
2377     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2378   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2379   if(!arr0)
2380     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2381   int sz=0;
2382   if(!arr)
2383     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2384   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2385     {
2386       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2387         {
2388           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2389           sz+=(*it).second.second-(*it).second.first;
2390         }
2391       else
2392         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2393     }
2394   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2395   ////////////////////
2396   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2397   int *workI2=explicitIdsOldInMesh->getPointer();
2398   int sz1=0,sz2=0,sid=1;
2399   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2400   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2401   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2402     {
2403       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2404       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2405       int *workI=explicitIdsOldInArr->getPointer();
2406       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2407         {
2408           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2409           (*itL2)->setLocId(sz2);
2410           (*itL2)->_tmp_work1=(*itL2)->getStart();
2411           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2412         }
2413       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2414     }
2415   explicitIdsOldInMesh->reAlloc(sz2);
2416   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2417   ////////////////////
2418   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2419   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2420   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2421   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2422     {
2423       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2424       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2425       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2426     }
2427   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2428   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2429   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2430     {
2431       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2432       int newStart=elt->getLocId();
2433       elt->setLocId((*it)->getGeoType());
2434       elt->setNewStart(newStart);
2435       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2436       entriesKeptNew.push_back(elt);
2437       entriesKeptNew2.push_back(elt);
2438     }
2439   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2440   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2441   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2442   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2443   bool ret=false;
2444   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2445     {
2446       sid=0;
2447       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2448         {
2449           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2450           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2451           }*/
2452       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2453                                                             glob,arr2,otherEntriesNew) || ret;
2454     }
2455   if(!ret)
2456     return false;
2457   // Assign new dispatching
2458   assignNewLeaves(otherEntriesNew);
2459   arr->deepCopyFrom(*arr2);
2460   return true;
2461 }
2462
2463 /*!
2464  * \param [in,out] globalNum a global numbering counter for the renumbering.
2465  * \param [out] its - list of pair (start,stop) kept
2466  */
2467 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2468 {
2469   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2470   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2471     {
2472       std::vector< std::pair<int,int> > its2;
2473       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2474         {
2475           ret.push_back(*it);
2476           its.insert(its.end(),its2.begin(),its2.end());
2477         }
2478     }
2479   _field_pm_pt=ret;
2480 }
2481
2482 /*!
2483  * \param [in,out] globalNum a global numbering counter for the renumbering.
2484  * \param [out] its - list of pair (start,stop) kept
2485  */
2486 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2487 {
2488   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2489   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2490     {
2491       std::vector< std::pair<int,int> > its2;
2492       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2493         {
2494           ret.push_back(*it);
2495           its.insert(its.end(),its2.begin(),its2.end());
2496         }
2497     }
2498   _field_pm_pt=ret;
2499 }
2500
2501 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2502 {
2503   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2504   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2505     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2506   //
2507   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2508   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2509   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2510   for(;it1!=types.end();it1++,it2++)
2511     {
2512       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2513       elt->setLeaves((*it1).second);
2514       MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2515       *it2=elt2;
2516     }
2517   _field_pm_pt=fieldPmPt;
2518 }
2519
2520 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2521 {
2522   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2523     (*it)->changePflsRefsNamesGen(mapOfModif);
2524 }
2525
2526 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2527 {
2528   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2529     (*it)->changeLocsRefsNamesGen(mapOfModif);
2530 }
2531
2532 /*!
2533  * \param [in] mesh is the whole mesh
2534  */
2535 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2536 {
2537   if(_field_pm_pt.empty())
2538     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2539   //
2540   std::vector< std::pair<int,int> > dads;
2541   std::vector<const DataArrayInt *> pfls;
2542   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2543   std::vector<int> locs,code;
2544   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2545   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2546     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2547   // Sort by types
2548   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2549   if(code.empty())
2550     {
2551       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2552       throw INTERP_KERNEL::Exception(oss.str());
2553     }
2554   //
2555   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2556   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2557   if(type!=ON_NODES)
2558     {
2559       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2560       if(!arr)
2561         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2562       else
2563         {
2564           MCAuto<DataArrayInt> arr2(arr);
2565           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2566         }
2567     }
2568   else
2569     {
2570       if(code.size()!=3)
2571         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2572       int nb=code[1];
2573       if(code[2]==-1)
2574         {
2575           if(nb!=mesh->getNumberOfNodes())
2576             {
2577               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2578               oss << " nodes in mesh !";
2579               throw INTERP_KERNEL::Exception(oss.str());
2580             }
2581           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2582         }
2583       else
2584         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2585     }
2586 }
2587
2588 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2589 {
2590   if(_field_pm_pt.empty())
2591     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2592   //
2593   std::vector<std::pair<int,int> > dads;
2594   std::vector<const DataArrayInt *> pfls;
2595   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2596   std::vector<int> locs,code;
2597   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2598   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2599     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2600   // Sort by types
2601   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2602   if(code.empty())
2603     {
2604       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2605       throw INTERP_KERNEL::Exception(oss.str());
2606     }
2607   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2608   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2609   if(type!=ON_NODES)
2610     {
2611       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2612       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2613     }
2614   else
2615     {
2616       if(code.size()!=3)
2617         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2618       int nb=code[1];
2619       if(code[2]==-1)
2620         {
2621           if(nb!=mesh->getNumberOfNodes())
2622             {
2623               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2624               oss << " nodes in mesh !";
2625               throw INTERP_KERNEL::Exception(oss.str());
2626             }
2627         }
2628       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2629     }
2630   //
2631   return 0;
2632 }
2633
2634 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2635 {
2636   int globalSz=0;
2637   int nbOfEntries=0;
2638   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2639     {
2640       (*it)->getSizes(globalSz,nbOfEntries);
2641     }
2642   entries.resize(nbOfEntries);
2643   nbOfEntries=0;
2644   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2645     {
2646       (*it)->fillValues(nbOfEntries,entries);
2647     }
2648 }
2649
2650 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2651 {
2652   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2653     {
2654       if((*it)->getGeoType()==typ)
2655         return (*it)->getLeafGivenLocId(locId);
2656     }
2657   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2658   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2659   oss << "Possiblities are : ";
2660   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2661     {
2662       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2663       oss << "\"" << cm2.getRepr() << "\", ";
2664     }
2665   throw INTERP_KERNEL::Exception(oss.str());
2666 }
2667
2668 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2669 {
2670   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2671     {
2672       if((*it)->getGeoType()==typ)
2673         return (*it)->getLeafGivenLocId(locId);
2674     }
2675   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2676   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2677   oss << "Possiblities are : ";
2678   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2679     {
2680       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2681       oss << "\"" << cm2.getRepr() << "\", ";
2682     }
2683   throw INTERP_KERNEL::Exception(oss.str());
2684 }
2685
2686 /*!
2687  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2688  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2689  * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
2690  * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
2691  */
2692 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2693 {
2694   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2695   if(pms.empty())
2696     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2697   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2698     {
2699       if(!(*it).second)
2700         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2701       if(!(*it).second->getProfile().empty())
2702         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2703       if(!(*it).second->getLocalization().empty())
2704         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2705     }
2706   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2707   std::size_t i(0);
2708   std::vector< std::pair<int,int> > filteredDTS;
2709   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2710     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2711       if((*it2).first==gt)
2712         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2713   if(pms.size()!=filteredDTS.size())
2714     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2715   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2716   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2717   int zeStart(start),nval(0);
2718   for(;it1!=pms.end();it1++,it2++)
2719     {
2720       if((*it1).first!=(*it2).first)
2721         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2722       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2723       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2724       start+=e1-s1;
2725       nval+=((*it1).second)->getNumberOfVals();
2726     }
2727   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2728   return ret;
2729 }
2730
2731 MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2732 {
2733   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2734   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2735   std::size_t i(0);
2736   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2737     {
2738       const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2739       for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2740         {
2741           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2742           const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2743           if(!elt)
2744             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2745           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2746         }
2747     }
2748   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2749     {
2750       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2751       MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2752       ret->_field_pm_pt.push_back(agg2);
2753     }
2754   return ret;
2755 }
2756
2757 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2758 {
2759   int i=0;
2760   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2761   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2762   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2763     {
2764       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2765       if(type==curType)
2766         return i;
2767       else
2768         {
2769           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2770           if(pos>pos2)
2771             it2=it+1;
2772         }
2773     }
2774   int ret=std::distance(_field_pm_pt.begin(),it2);
2775   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2776   return ret;
2777 }
2778
2779 /*!
2780  * 'dads' and 'locs' input parameters have the same number of elements
2781  * \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
2782  */
2783 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2784                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2785                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2786 {
2787   isPfl=false;
2788   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2789   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2790   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2791   const std::vector<std::string>& infos=getInfo();
2792   da->setInfoOnComponents(infos);
2793   da->setName("");
2794   if(type==ON_GAUSS_PT)
2795     {
2796       int offset=0;
2797       int nbOfArrs=dads.size();
2798       for(int i=0;i<nbOfArrs;i++)
2799         {
2800           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2801           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2802           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2803           MCAuto<DataArrayInt> di=DataArrayInt::New();
2804           di->alloc(nbOfElems,1);
2805           di->iota(offset);
2806           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2807           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2808           offset+=nbOfElems;
2809         }
2810     }
2811   arrOut=da;
2812   return ret.retn();
2813 }
2814
2815 /*!
2816  * 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.
2817  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2818  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2819  * The order of cells in the returned field is those imposed by the profile.
2820  * \param [in] mesh is the global mesh.
2821  */
2822 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2823                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2824                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2825                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2826 {
2827   if(da->isIota(mesh->getNumberOfCells()))
2828     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2829   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2830   m2->setName(mesh->getName().c_str());
2831   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2832   isPfl=true;
2833   return ret.retn();
2834 }
2835
2836 /*!
2837  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2838  */
2839 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2840                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2841                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2842 {
2843   if(da->isIota(mesh->getNumberOfNodes()))
2844     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2845   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2846   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2847   if(meshu)
2848     {
2849       if(meshu->getNodalConnectivity()==0)
2850         {
2851           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2852           int nb=da->getNbOfElems();
2853           const int *ptr=da->getConstPointer();
2854           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2855           meshuc->allocateCells(nb);
2856           for(int i=0;i<nb;i++)
2857             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2858           meshuc->finishInsertingCells();
2859           ret->setMesh(meshuc);
2860           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2861           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2862           disc->checkCoherencyBetween(meshuc,arrOut);
2863           return ret.retn();
2864         }
2865     }
2866   //
2867   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2868   isPfl=true;
2869   DataArrayInt *arr2=0;
2870   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2871   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2872   MCAuto<DataArrayInt> arr3(arr2);
2873   int nnodes=mesh2->getNumberOfNodes();
2874   if(nnodes==(int)da->getNbOfElems())
2875     {
2876       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2877       arrOut->renumberInPlace(da3->getConstPointer());
2878       mesh2->setName(mesh->getName().c_str());
2879       ret->setMesh(mesh2);
2880       return ret.retn();
2881     }
2882   else
2883     {
2884       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 !!!";
2885       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2886       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2887       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2888       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2889       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2890       throw INTERP_KERNEL::Exception(oss.str());
2891     }
2892   return 0;
2893 }
2894
2895 /*!
2896  * This method is the most light method of field retrieving.
2897  */
2898 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2899 {
2900   if(!pflIn)
2901     {
2902       pflOut=DataArrayInt::New();
2903       pflOut->alloc(nbOfElems,1);
2904       pflOut->iota(0);
2905     }
2906   else
2907     {
2908       pflOut=const_cast<DataArrayInt*>(pflIn);
2909       pflOut->incrRef();
2910     }
2911   MCAuto<DataArrayInt> safePfl(pflOut);
2912   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2913   const std::vector<std::string>& infos=getInfo();
2914   int nbOfComp=infos.size();
2915   for(int i=0;i<nbOfComp;i++)
2916     da->setInfoOnComponent(i,infos[i].c_str());
2917   safePfl->incrRef();
2918   return da.retn();
2919 }
2920
2921
2922 /// @cond INTERNAL
2923
2924 class MFFPMIter
2925 {
2926 public:
2927   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2928   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2929   virtual ~MFFPMIter() { }
2930   virtual void begin() = 0;
2931   virtual bool finished() const = 0;
2932   virtual void next() = 0;
2933   virtual int current() const = 0;
2934 };
2935
2936 class MFFPMIterSimple : public MFFPMIter
2937 {
2938 public:
2939   MFFPMIterSimple():_pos(0) { }
2940   void begin() { _pos=0; }
2941   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2942   void next() { _pos++; }
2943   int current() const { return _pos; }
2944 private:
2945   int _pos;
2946 };
2947
2948 class MFFPMIter2 : public MFFPMIter
2949 {
2950 public:
2951   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2952   void begin() { _it=_ids.begin(); }
2953   bool finished() const { return _it==_ids.end(); }
2954   void next() { _it++; }
2955   int current() const { return *_it; }
2956 private:
2957   std::vector<int> _ids;
2958   std::vector<int>::const_iterator _it;
2959 };
2960
2961 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2962 {
2963   if(!entities)
2964     return new MFFPMIterSimple;
2965   else
2966     {
2967       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2968       if(entities2)
2969         {
2970           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2971           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2972           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2973             {
2974               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2975                 tmp.push_back((*it).second);
2976             }
2977           return new MFFPMIter2(tmp);
2978         }
2979       return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2980     }
2981 }
2982
2983 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2984 {
2985   if(!entities)
2986     return true;
2987   else
2988     {
2989       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2990       if(entities2)
2991         {
2992           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2993           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2994             if((*it).first==ON_NODES)
2995               return true;
2996           return false;
2997         }
2998       return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2999     }
3000 }
3001
3002 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3003 {
3004   std::size_t sz(cts.size());
3005   _ids.resize(sz);
3006   for(std::size_t i=0;i<sz;i++)
3007     {
3008       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3009       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3010         _ids[i]=(int)std::distance(typmai2,loc);
3011       else
3012         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3013     }
3014 }
3015
3016 /// @endcond
3017
3018 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
3019     _father(fath)
3020 {
3021   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3022   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3023   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3024   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3025   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3026   for(iter0->begin();!iter0->finished();iter0->next())
3027     {
3028       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3029       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3030       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3031       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3032       if(nbProfile>0 || nbProfile2>0)
3033         {
3034           const PartDefinition *pd(0);
3035           if(mmu)
3036             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3037           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3038           if(nbProfile>0)
3039             _mesh_name=name0;
3040           else
3041             _mesh_name=name1;
3042         }
3043     }
3044   if(MFFPMIter::IsPresenceOfNode(entities))
3045     {
3046       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3047       if(nbProfile>0)
3048         {
3049           const PartDefinition *pd(0);
3050           if(mmu)
3051             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3052           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3053           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3054         }
3055     }
3056   if(!entities)
3057     return ;
3058   std::vector<int> dynGT(entities->getDynGTAvail());
3059   for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3060     {
3061       int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3062       if(nbPfl>0)
3063         {
3064           _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3065           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3066         }
3067     }
3068 }
3069
3070 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3071 {
3072   copyTinyInfoFrom(mesh);
3073 }
3074
3075 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3076 {
3077   if(id>=(int)_pfls.size())
3078     _pfls.resize(id+1);
3079   _pfls[id]=DataArrayInt::New();
3080   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3081   _pfls[id]->setName(pflName);
3082   _pfls[id]->alloc(lgth,1);
3083   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3084   _pfls[id]->applyLin(1,-1,0);//Converting into C format
3085 }
3086
3087 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3088 {
3089   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3090   int sz;
3091   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3092   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3093   if(i>=(int)_pfls.size())
3094     _pfls.resize(i+1);
3095   _pfls[i]=DataArrayInt::New();
3096   _pfls[i]->alloc(sz,1);
3097   _pfls[i]->setName(pflCpp.c_str());
3098   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3099   _pfls[i]->applyLin(1,-1,0);//Converting into C format
3100 }
3101
3102 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3103 {
3104   int nbOfPfls=_pfls.size();
3105   for(int i=0;i<nbOfPfls;i++)
3106     {
3107       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3108       cpy->applyLin(1,1,0);
3109       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3110       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3111       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3112     }
3113   //
3114   int nbOfLocs=_locs.size();
3115   for(int i=0;i<nbOfLocs;i++)
3116     _locs[i]->writeLL(fid);
3117 }
3118
3119 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3120 {
3121   std::vector<std::string> pfls=getPfls();
3122   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3123     {
3124       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3125       if(it2==pfls.end())
3126         {
3127           _pfls.push_back(*it);
3128         }
3129       else
3130         {
3131           int id=std::distance(pfls.begin(),it2);
3132           if(!(*it)->isEqual(*_pfls[id]))
3133             {
3134               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3135               throw INTERP_KERNEL::Exception(oss.str());
3136             }
3137         }
3138     }
3139   std::vector<std::string> locs=getLocs();
3140   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3141     {
3142       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3143       if(it2==locs.end())
3144         {
3145           _locs.push_back(*it);
3146         }
3147       else
3148         {
3149           int id=std::distance(locs.begin(),it2);
3150           if(!(*it)->isEqual(*_locs[id],eps))
3151             {
3152               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3153               throw INTERP_KERNEL::Exception(oss.str());
3154             }
3155         }
3156     }
3157 }
3158
3159 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3160 {
3161   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3162     getProfile((*it).c_str());
3163 }
3164
3165 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3166 {
3167   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3168     getLocalization((*it).c_str());
3169 }
3170
3171 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3172 {
3173   std::vector<std::string> profiles=real.getPflsReallyUsed();
3174   int sz=profiles.size();
3175   _pfls.resize(sz);
3176   for(int i=0;i<sz;i++)
3177     loadProfileInFile(fid,i,profiles[i].c_str());
3178   //
3179   std::vector<std::string> locs=real.getLocsReallyUsed();
3180   sz=locs.size();
3181   _locs.resize(sz);
3182   for(int i=0;i<sz;i++)
3183     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3184 }
3185
3186 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3187 {
3188   int nProfil=MEDnProfile(fid);
3189   for(int i=0;i<nProfil;i++)
3190     loadProfileInFile(fid,i);
3191   int sz=MEDnLocalization(fid);
3192   _locs.resize(sz);
3193   for(int i=0;i<sz;i++)
3194     {
3195       _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3196     }
3197 }
3198
3199 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3200 {
3201   return new MEDFileFieldGlobs(fid);
3202 }
3203
3204 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3205 {
3206   return new MEDFileFieldGlobs;
3207 }
3208
3209 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3210 {
3211   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3212 }
3213
3214 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3215 {
3216   std::vector<const BigMemoryObject *> ret;
3217   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3218     ret.push_back((const DataArrayInt *)*it);
3219   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3220     ret.push_back((const MEDFileFieldLoc *)*it);
3221   return ret;
3222 }
3223
3224 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3225 {
3226   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3227   std::size_t i=0;
3228   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3229     {
3230       if((const DataArrayInt *)*it)
3231         ret->_pfls[i]=(*it)->deepCopy();
3232     }
3233   i=0;
3234   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3235     {
3236       if((const MEDFileFieldLoc*)*it)
3237         ret->_locs[i]=(*it)->deepCopy();
3238     }
3239   return ret.retn();
3240 }
3241
3242 /*!
3243  * \throw if a profile in \a pfls in not in \a this.
3244  * \throw if a localization in \a locs in not in \a this.
3245  * \sa MEDFileFieldGlobs::deepCpyPart
3246  */
3247 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3248 {
3249   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3250   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3251     {
3252       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3253       if(!pfl)
3254         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3255       pfl->incrRef();
3256       MCAuto<DataArrayInt> pfl2(pfl);
3257       ret->_pfls.push_back(pfl2);
3258     }
3259   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3260     {
3261       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3262       if(!loc)
3263         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3264       loc->incrRef();
3265       MCAuto<MEDFileFieldLoc> loc2(loc);
3266       ret->_locs.push_back(loc2);
3267     }
3268   ret->setFileName(getFileName());
3269   return ret.retn();
3270 }
3271
3272 /*!
3273  * \throw if a profile in \a pfls in not in \a this.
3274  * \throw if a localization in \a locs in not in \a this.
3275  * \sa MEDFileFieldGlobs::shallowCpyPart
3276  */
3277 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3278 {
3279   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3280   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3281     {
3282       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3283       if(!pfl)
3284         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3285       ret->_pfls.push_back(pfl->deepCopy());
3286     }
3287   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3288     {
3289       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3290       if(!loc)
3291         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3292       ret->_locs.push_back(loc->deepCopy());
3293     }
3294   ret->setFileName(getFileName());
3295   return ret.retn();
3296 }
3297
3298 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3299 {
3300 }
3301
3302 MEDFileFieldGlobs::MEDFileFieldGlobs()
3303 {
3304 }
3305
3306 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3307 {
3308 }
3309
3310 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3311 {
3312   oss << "Profiles :\n";
3313   std::size_t n=_pfls.size();
3314   for(std::size_t i=0;i<n;i++)
3315     {
3316       oss << "  - #" << i << " ";
3317       const DataArrayInt *pfl=_pfls[i];
3318       if(pfl)
3319         oss << "\"" << pfl->getName() << "\"\n";
3320       else
3321         oss << "EMPTY !\n";
3322     }
3323   n=_locs.size();
3324   oss << "Localizations :\n";
3325   for(std::size_t i=0;i<n;i++)
3326     {
3327       oss << "  - #" << i << " ";
3328       const MEDFileFieldLoc *loc=_locs[i];
3329       if(loc)
3330         loc->simpleRepr(oss);
3331       else
3332         oss<< "EMPTY !\n";
3333     }
3334 }
3335
3336 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3337 {
3338   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3339     {
3340       DataArrayInt *elt(*it);
3341       if(elt)
3342         {
3343           std::string name(elt->getName());
3344           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3345             {
3346               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3347                 {
3348                   elt->setName((*it2).second.c_str());
3349                   return;
3350                 }
3351             }
3352         }
3353     }
3354 }
3355
3356 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3357 {
3358   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3359     {
3360       MEDFileFieldLoc *elt(*it);
3361       if(elt)
3362         {
3363           std::string name(elt->getName());
3364           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3365             {
3366               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3367                 {
3368                   elt->setName((*it2).second.c_str());
3369                   return;
3370                 }
3371             }
3372         }
3373     }
3374 }
3375
3376 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3377 {
3378   if(locId<0 || locId>=(int)_locs.size())
3379     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3380   return _locs[locId]->getNbOfGaussPtPerCell();
3381 }
3382
3383 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3384 {
3385   return getLocalizationFromId(getLocalizationId(locName));
3386 }
3387
3388 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3389 {
3390   if(locId<0 || locId>=(int)_locs.size())
3391     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3392   return *_locs[locId];
3393 }
3394
3395 /// @cond INTERNAL
3396 namespace MEDCouplingImpl
3397 {
3398   class LocFinder
3399   {
3400   public:
3401     LocFinder(const std::string& loc):_loc(loc) { }
3402     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3403   private:
3404     const std::string &_loc;
3405   };
3406
3407   class PflFinder
3408   {
3409   public:
3410     PflFinder(const std::string& pfl):_pfl(pfl) { }
3411     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3412   private:
3413     const std::string& _pfl;
3414   };
3415 }
3416 /// @endcond
3417
3418 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3419 {
3420   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3421   if(it==_locs.end())
3422     {
3423       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3424       for(it=_locs.begin();it!=_locs.end();it++)
3425         oss << "\"" << (*it)->getName() << "\", ";
3426       throw INTERP_KERNEL::Exception(oss.str());
3427     }
3428   return std::distance(_locs.begin(),it);
3429 }
3430
3431 /*!
3432  * The returned value is never null.
3433  */
3434 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3435 {
3436   std::string pflNameCpp(pflName);
3437   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3438   if(it==_pfls.end())
3439     {
3440       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3441       for(it=_pfls.begin();it!=_pfls.end();it++)
3442         oss << "\"" << (*it)->getName() << "\", ";
3443       throw INTERP_KERNEL::Exception(oss.str());
3444     }
3445   return *it;
3446 }
3447
3448 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3449 {
3450   if(pflId<0 || pflId>=(int)_pfls.size())
3451     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3452   return _pfls[pflId];
3453 }
3454
3455 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3456 {
3457   if(locId<0 || locId>=(int)_locs.size())
3458     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3459   return *_locs[locId];
3460 }
3461
3462 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3463 {
3464   return getLocalizationFromId(getLocalizationId(locName));
3465 }
3466
3467 /*!
3468  * The returned value is never null.
3469  */
3470 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3471 {
3472   std::string pflNameCpp(pflName);
3473   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3474   if(it==_pfls.end())
3475     {
3476       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3477       for(it=_pfls.begin();it!=_pfls.end();it++)
3478         oss << "\"" << (*it)->getName() << "\", ";
3479       throw INTERP_KERNEL::Exception(oss.str());
3480     }
3481   return *it;
3482 }
3483
3484 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3485 {
3486   if(pflId<0 || pflId>=(int)_pfls.size())
3487     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3488   return _pfls[pflId];
3489 }
3490
3491 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3492 {
3493   std::vector< MCAuto<DataArrayInt> > newPfls;
3494   int i=0;
3495   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3496     {
3497       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3498         newPfls.push_back(*it);
3499     }
3500   _pfls=newPfls;
3501 }
3502
3503 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3504 {
3505   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3506   int i=0;
3507   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3508     {
3509       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3510         newLocs.push_back(*it);
3511     }
3512   _locs=newLocs;
3513 }
3514
3515 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3516 {
3517   int sz=_pfls.size();
3518   std::vector<std::string> ret(sz);
3519   for(int i=0;i<sz;i++)
3520     ret[i]=_pfls[i]->getName();
3521   return ret;
3522 }
3523
3524 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3525 {
3526   int sz=_locs.size();
3527   std::vector<std::string> ret(sz);
3528   for(int i=0;i<sz;i++)
3529     ret[i]=_locs[i]->getName();
3530   return ret;
3531 }
3532
3533 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3534 {
3535   std::vector<std::string> v=getPfls();
3536   std::string s(pflName);
3537   return std::find(v.begin(),v.end(),s)!=v.end();
3538 }
3539
3540 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3541 {
3542   std::vector<std::string> v=getLocs();
3543   std::string s(locName);
3544   return std::find(v.begin(),v.end(),s)!=v.end();
3545 }
3546
3547 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3548 {
3549   std::map<int,std::vector<int> > m;
3550   int i=0;
3551   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3552     {
3553       const DataArrayInt *tmp=(*it);
3554       if(tmp)
3555         {
3556           m[tmp->getHashCode()].push_back(i);
3557         }
3558     }
3559   std::vector< std::vector<int> > ret;
3560   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3561     {
3562       if((*it2).second.size()>1)
3563         {
3564           std::vector<int> ret0;
3565           bool equalityOrNot=false;
3566           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3567             {
3568               std::vector<int>::const_iterator it4=it3; it4++;
3569               for(;it4!=(*it2).second.end();it4++)
3570                 {
3571                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3572                     {
3573                       if(!equalityOrNot)
3574                         ret0.push_back(*it3);
3575                       ret0.push_back(*it4);
3576                       equalityOrNot=true;
3577                     }
3578                 }
3579             }
3580           if(!ret0.empty())
3581             ret.push_back(ret0);
3582         }
3583     }
3584   return ret;
3585 }
3586
3587 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3588 {
3589   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3590 }
3591
3592 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3593 {
3594   std::string name(pfl->getName());
3595   if(name.empty())
3596     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3597   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3598     if(name==(*it)->getName())
3599       {
3600         if(!pfl->isEqual(*(*it)))
3601           {
3602             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3603             throw INTERP_KERNEL::Exception(oss.str());
3604           }
3605       }
3606   pfl->incrRef();
3607   _pfls.push_back(pfl);
3608 }
3609
3610 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)
3611 {
3612   std::string name(locName);
3613   if(name.empty())
3614     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3615   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3616   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3617     if((*it)->isName(locName))
3618       {
3619         if(!(*it)->isEqual(*obj,1e-12))
3620           {
3621             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3622             throw INTERP_KERNEL::Exception(oss.str());
3623           }
3624       }
3625   _locs.push_back(obj);
3626 }
3627
3628 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3629 {
3630   std::vector<std::string> names=getPfls();
3631   return CreateNewNameNotIn("NewPfl_",names);
3632 }
3633
3634 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3635 {
3636   std::vector<std::string> names=getLocs();
3637   return CreateNewNameNotIn("NewLoc_",names);
3638 }
3639
3640 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3641 {
3642   for(std::size_t sz=0;sz<100000;sz++)
3643     {
3644       std::ostringstream tryName;
3645       tryName << prefix << sz;
3646       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3647         return tryName.str();
3648     }
3649   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3650 }
3651
3652 /*!
3653  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3654  *  \param [in] fname - the file name.
3655  */
3656 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3657 {
3658 }
3659
3660 /*!
3661  * Creates an empty MEDFileFieldGlobsReal.
3662  */
3663 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3664 {
3665 }
3666
3667 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3668 {
3669   return 0;
3670 }
3671
3672 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3673 {
3674   std::vector<const BigMemoryObject *> ret;
3675   ret.push_back((const MEDFileFieldGlobs *)_globals);
3676   return ret;
3677 }
3678
3679 /*!
3680  * Returns a string describing profiles and Gauss points held in \a this.
3681  *  \return std::string - the description string.
3682  */
3683 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3684 {
3685   const MEDFileFieldGlobs *glob=_globals;
3686   std::ostringstream oss2; oss2 << glob;
3687   std::string stars(oss2.str().length(),'*');
3688   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3689   if(glob)
3690     glob->simpleRepr(oss);
3691   else
3692     oss << "NO GLOBAL INFORMATION !\n";
3693 }
3694
3695 void MEDFileFieldGlobsReal::resetContent()
3696 {
3697   _globals=MEDFileFieldGlobs::New();
3698 }
3699
3700 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3701 {
3702 }
3703
3704 /*!
3705  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3706  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3707  */
3708 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3709 {
3710   _globals=other._globals;
3711 }
3712
3713 /*!
3714  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3715  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3716  */
3717 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3718 {
3719   const MEDFileFieldGlobs *otherg(other._globals);
3720   if(!otherg)
3721     return ;
3722   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3723 }
3724
3725 /*!
3726  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3727  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3728  */
3729 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3730 {
3731   const MEDFileFieldGlobs *otherg(other._globals);
3732   if(!otherg)
3733     return ;
3734   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3735 }
3736
3737 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3738 {
3739   _globals=other._globals;
3740   if((const MEDFileFieldGlobs *)_globals)
3741     _globals=other._globals->deepCopy();
3742 }
3743
3744 /*!
3745  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3746  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3747  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3748  *         \a this and \a other MEDFileFieldGlobsReal.
3749  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3750  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3751  */
3752 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3753 {
3754   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3755   if(thisGlobals==otherGlobals)
3756     return ;
3757   if(!thisGlobals)
3758     {
3759       _globals=other._globals;
3760       return ;
3761     }
3762   _globals->appendGlobs(*other._globals,eps);
3763 }
3764
3765 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3766 {
3767   checkGlobsPflsPartCoherency();
3768   checkGlobsLocsPartCoherency();
3769 }
3770
3771 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3772 {
3773   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3774 }
3775
3776 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3777 {
3778   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3779 }
3780
3781 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3782 {
3783   contentNotNull()->loadProfileInFile(fid,id,pflName);
3784 }
3785
3786 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3787 {
3788   contentNotNull()->loadProfileInFile(fid,id);
3789 }
3790
3791 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3792 {
3793   contentNotNull()->loadGlobals(fid,*this);
3794 }
3795
3796 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3797 {
3798   contentNotNull()->loadAllGlobals(fid,entities);
3799 }
3800
3801 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3802 {
3803   contentNotNull()->writeGlobals(fid,opt);
3804 }
3805
3806 /*!
3807  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3808  * or getPflsReallyUsedMulti().
3809  *  \return std::vector<std::string> - a sequence of names of all profiles.
3810  */
3811 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3812 {
3813   return contentNotNull()->getPfls();
3814 }
3815
3816 /*!
3817  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3818  * or getLocsReallyUsedMulti().
3819  *  \return std::vector<std::string> - a sequence of names of all localizations.
3820  */
3821 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3822 {
3823   return contentNotNull()->getLocs();
3824 }
3825
3826 /*!
3827  * Checks if the profile with a given name exists.
3828  *  \param [in] pflName - the profile name of interest.
3829  *  \return bool - \c true if the profile named \a pflName exists.
3830  */
3831 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3832 {
3833   return contentNotNull()->existsPfl(pflName);
3834 }
3835
3836 /*!
3837  * Checks if the localization with a given name exists.
3838  *  \param [in] locName - the localization name of interest.
3839  *  \return bool - \c true if the localization named \a locName exists.
3840  */
3841 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3842 {
3843   return contentNotNull()->existsLoc(locName);
3844 }
3845
3846 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3847 {
3848   return contentNotNull()->createNewNameOfPfl();
3849 }
3850
3851 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3852 {
3853   return contentNotNull()->createNewNameOfLoc();
3854 }
3855
3856 /*!
3857  * Sets the name of a MED file.
3858  *  \param [inout] fileName - the file name.
3859  */
3860 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3861 {
3862   contentNotNull()->setFileName(fileName);
3863 }
3864
3865 /*!
3866  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3867  * in the same order.
3868  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3869  *          Each item of this sequence is a vector containing ids of equal profiles.
3870  */
3871 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3872 {
3873   return contentNotNull()->whichAreEqualProfiles();
3874 }
3875
3876 /*!
3877  * Finds equal localizations.
3878  *  \param [in] eps - a precision used to compare real values of the localizations.
3879  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3880  *          Each item of this sequence is a vector containing ids of equal localizations.
3881  */
3882 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3883 {
3884   return contentNotNull()->whichAreEqualLocs(eps);
3885 }
3886
3887 /*!
3888  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3889  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3890  *        this sequence is a pair whose 
3891  *        - the first item is a vector of profile names to replace by the second item,
3892  *        - the second item is a profile name to replace every profile name of the first item.
3893  */
3894 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3895 {
3896   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3897 }
3898
3899 /*!
3900  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3901  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3902  *        this sequence is a pair whose 
3903  *        - the first item is a vector of localization names to replace by the second item,
3904  *        - the second item is a localization name to replace every localization name of the first item.
3905  */
3906 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3907 {
3908   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3909 }
3910
3911 /*!
3912  * Replaces references to some profiles (a reference is a profile name) by references
3913  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3914  * them-selves accordingly. <br>
3915  * This method is a generalization of changePflName().
3916  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3917  *        this sequence is a pair whose 
3918  *        - the first item is a vector of profile names to replace by the second item,
3919  *        - the second item is a profile name to replace every profile of the first item.
3920  * \sa changePflsRefsNamesGen()
3921  * \sa changePflName()
3922  */
3923 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3924 {
3925   changePflsRefsNamesGen(mapOfModif);
3926   changePflsNamesInStruct(mapOfModif);
3927 }
3928
3929 /*!
3930  * Replaces references to some localizations (a reference is a localization name) by references
3931  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3932  * them-selves accordingly. <br>
3933  * This method is a generalization of changeLocName().
3934  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3935  *        this sequence is a pair whose 
3936  *        - the first item is a vector of localization names to replace by the second item,
3937  *        - the second item is a localization name to replace every localization of the first item.
3938  * \sa changeLocsRefsNamesGen()
3939  * \sa changeLocName()
3940  */
3941 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3942 {
3943   changeLocsRefsNamesGen(mapOfModif);
3944   changeLocsNamesInStruct(mapOfModif);
3945 }
3946
3947 /*!
3948  * Renames the profile having a given name and updates references to this profile.
3949  *  \param [in] oldName - the name of the profile to rename.
3950  *  \param [in] newName - a new name of the profile.
3951  * \sa changePflsNames().
3952  */
3953 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3954 {
3955   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3956   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3957   mapOfModif[0]=p;
3958   changePflsNames(mapOfModif);
3959 }
3960
3961 /*!
3962  * Renames the localization having a given name and updates references to this localization.
3963  *  \param [in] oldName - the name of the localization to rename.
3964  *  \param [in] newName - a new name of the localization.
3965  * \sa changeLocsNames().
3966  */
3967 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3968 {
3969   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3970   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3971   mapOfModif[0]=p;
3972   changeLocsNames(mapOfModif);
3973 }
3974
3975 /*!
3976  * Removes duplicated profiles. Returns a map used to update references to removed 
3977  * profiles via changePflsRefsNamesGen().
3978  * Equal profiles are found using whichAreEqualProfiles().
3979  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3980  *          a sequence describing the performed replacements of profiles. Each element of
3981  *          this sequence is a pair whose
3982  *          - the first item is a vector of profile names replaced by the second item,
3983  *          - the second item is a profile name replacing every profile of the first item.
3984  */
3985 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3986 {
3987   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3988   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3989   int i=0;
3990   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3991     {
3992       std::vector< std::string > tmp((*it).size());
3993       int j=0;
3994       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3995         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3996       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3997       ret[i]=p;
3998       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3999       killProfileIds(tmp2);
4000     }
4001   changePflsRefsNamesGen(ret);
4002   return ret;
4003 }
4004
4005 /*!
4006  * Removes duplicated localizations. Returns a map used to update references to removed 
4007  * localizations via changeLocsRefsNamesGen().
4008  * Equal localizations are found using whichAreEqualLocs().
4009  *  \param [in] eps - a precision used to compare real values of the localizations.
4010  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
4011  *          a sequence describing the performed replacements of localizations. Each element of
4012  *          this sequence is a pair whose
4013  *          - the first item is a vector of localization names replaced by the second item,
4014  *          - the second item is a localization name replacing every localization of the first item.
4015  */
4016 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4017 {
4018   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4019   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4020   int i=0;
4021   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4022     {
4023       std::vector< std::string > tmp((*it).size());
4024       int j=0;
4025       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4026         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4027       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4028       ret[i]=p;
4029       std::vector<int> tmp2((*it).begin()+1,(*it).end());
4030       killLocalizationIds(tmp2);
4031     }
4032   changeLocsRefsNamesGen(ret);
4033   return ret;
4034 }
4035
4036 /*!
4037  * Returns number of Gauss points per cell in a given localization.
4038  *  \param [in] locId - an id of the localization of interest.
4039  *  \return int - the number of the Gauss points per cell.
4040  */
4041 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4042 {
4043   return contentNotNull()->getNbOfGaussPtPerCell(locId);
4044 }
4045
4046 /*!
4047  * Returns an id of a localization by its name.
4048  *  \param [in] loc - the localization name of interest.
4049  *  \return int - the id of the localization.
4050  *  \throw If there is no a localization named \a loc.
4051  */
4052 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4053 {
4054   return contentNotNull()->getLocalizationId(loc);
4055 }
4056
4057 /*!
4058  * Returns the name of the MED file.
4059  *  \return const std::string&  - the MED file name.
4060  */
4061 std::string MEDFileFieldGlobsReal::getFileName() const
4062 {
4063   return contentNotNull()->getFileName();
4064 }
4065
4066 /*!
4067  * Returns a localization object by its name.
4068  *  \param [in] locName - the name of the localization of interest.
4069  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4070  *  \throw If there is no a localization named \a locName.
4071  */
4072 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4073 {
4074   return contentNotNull()->getLocalization(locName);
4075 }
4076
4077 /*!
4078  * Returns a localization object by its id.
4079  *  \param [in] locId - the id of the localization of interest.
4080  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4081  *  \throw If there is no a localization with id \a locId.
4082  */
4083 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4084 {
4085   return contentNotNull()->getLocalizationFromId(locId);
4086 }
4087
4088 /*!
4089  * Returns a profile array by its name.
4090  *  \param [in] pflName - the name of the profile of interest.
4091  *  \return const DataArrayInt * - the profile array having the name \a pflName.
4092  *  \throw If there is no a profile named \a pflName.
4093  */
4094 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4095 {
4096   return contentNotNull()->getProfile(pflName);
4097 }
4098
4099 /*!
4100  * Returns a profile array by its id.
4101  *  \param [in] pflId - the id of the profile of interest.
4102  *  \return const DataArrayInt * - the profile array having the id \a pflId.
4103  *  \throw If there is no a profile with id \a pflId.
4104  */
4105 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4106 {
4107   return contentNotNull()->getProfileFromId(pflId);
4108 }
4109
4110 /*!
4111  * Returns a localization object, apt for modification, by its id.
4112  *  \param [in] locId - the id of the localization of interest.
4113  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4114  *          having the id \a locId.
4115  *  \throw If there is no a localization with id \a locId.
4116  */
4117 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4118 {
4119   return contentNotNull()->getLocalizationFromId(locId);
4120 }
4121
4122 /*!
4123  * Returns a localization object, apt for modification, by its name.
4124  *  \param [in] locName - the name of the localization of interest.
4125  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4126  *          having the name \a locName.
4127  *  \throw If there is no a localization named \a locName.
4128  */
4129 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4130 {
4131   return contentNotNull()->getLocalization(locName);
4132 }
4133
4134 /*!
4135  * Returns a profile array, apt for modification, by its name.
4136  *  \param [in] pflName - the name of the profile of interest.
4137  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4138  *  \throw If there is no a profile named \a pflName.
4139  */
4140 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4141 {
4142   return contentNotNull()->getProfile(pflName);
4143 }
4144
4145 /*!
4146  * Returns a profile array, apt for modification, by its id.
4147  *  \param [in] pflId - the id of the profile of interest.
4148  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4149  *  \throw If there is no a profile with id \a pflId.
4150  */
4151 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4152 {
4153   return contentNotNull()->getProfileFromId(pflId);
4154 }
4155
4156 /*!
4157  * Removes profiles given by their ids. No data is updated to track this removal.
4158  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
4159  */
4160 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4161 {
4162   contentNotNull()->killProfileIds(pflIds);
4163 }
4164
4165 /*!
4166  * Removes localizations given by their ids. No data is updated to track this removal.
4167  *  \param [in] locIds - a sequence of ids of the localizations to remove.
4168  */
4169 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4170 {
4171   contentNotNull()->killLocalizationIds(locIds);
4172 }
4173
4174 /*!
4175  * Stores a profile array.
4176  *  \param [in] pfl - the profile array to store.
4177  *  \throw If the name of \a pfl is empty.
4178  *  \throw If a profile with the same name as that of \a pfl already exists but contains
4179  *         different ids.
4180  */
4181 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4182 {
4183   contentNotNull()->appendProfile(pfl);
4184 }
4185
4186 /*!
4187  * Adds a new localization of Gauss points.
4188  *  \param [in] locName - the name of the new localization.
4189  *  \param [in] geoType - a geometrical type of the reference cell.
4190  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4191  *         must be \c nbOfNodesPerCell * \c dimOfType.
4192  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4193  *         must be  _wg_.size() * \c dimOfType.
4194  *  \param [in] w - the weights of Gauss points.
4195  *  \throw If \a locName is empty.
4196  *  \throw If a localization with the name \a locName already exists but is
4197  *         different form the new one.
4198  */
4199 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)
4200 {
4201   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4202 }
4203
4204 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4205 {
4206   MEDFileFieldGlobs *g(_globals);
4207   if(!g)
4208     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4209   return g;
4210 }
4211
4212 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4213 {
4214   const MEDFileFieldGlobs *g(_globals);
4215   if(!g)
4216     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4217   return g;
4218 }
4219
4220 //= MEDFileFieldNameScope
4221
4222 MEDFileFieldNameScope::MEDFileFieldNameScope()
4223 {
4224 }
4225
4226 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4227 {
4228 }
4229
4230 /*!
4231  * Returns the name of \a this field.
4232  *  \return std::string - a string containing the field name.
4233  */
4234 std::string MEDFileFieldNameScope::getName() const
4235 {
4236   return _name;
4237 }
4238
4239 /*!
4240  * Sets name of \a this field
4241  *  \param [in] name - the new field name.
4242  */
4243 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4244 {
4245   _name=fieldName;
4246 }
4247
4248 std::string MEDFileFieldNameScope::getDtUnit() const
4249 {
4250   return _dt_unit;
4251 }
4252
4253 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4254 {
4255   _dt_unit=dtUnit;
4256 }
4257
4258 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4259 {
4260   _name=other._name;
4261   _dt_unit=other._dt_unit;
4262 }
4263
4264 //= MEDFileAnyTypeField1TSWithoutSDA
4265
4266 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4267 {
4268   _field_per_mesh.resize(other._field_per_mesh.size());
4269   std::size_t i=0;
4270   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4271     {
4272       if((const MEDFileFieldPerMesh *)*it)
4273         _field_per_mesh[i]=(*it)->deepCopy(this);
4274     }
4275 }
4276
4277 /*!
4278  * Prints a string describing \a this field into a stream. This string is outputted 
4279  * by \c print Python command.
4280  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4281  *  \param [in,out] oss - the out stream.
4282  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4283  *          info id printed, else, not.
4284  */
4285 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4286 {
4287   std::string startOfLine(bkOffset,' ');
4288   oss << startOfLine << "Field ";
4289   if(bkOffset==0)
4290     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4291   oss << "on one time Step ";
4292   if(f1tsId>=0)
4293     oss << "(" << f1tsId << ") ";
4294   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4295   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4296   const DataArray *arr=getUndergroundDataArray();
4297   if(arr)
4298     {
4299       const std::vector<std::string> &comps=arr->getInfoOnComponents();
4300       if(f1tsId<0)
4301         {
4302           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4303           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4304             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
4305         }
4306       if(arr->isAllocated())
4307         {
4308           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4309         }
4310       else
4311         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4312     }
4313   else
4314     {
4315       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4316     }
4317   oss << startOfLine << "----------------------" << std::endl;
4318   if(!_field_per_mesh.empty())
4319     {
4320       int i=0;
4321       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4322         {
4323           const MEDFileFieldPerMesh *cur=(*it2);
4324           if(cur)
4325             cur->simpleRepr(bkOffset,oss,i);
4326           else
4327             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4328         }
4329     }
4330   else
4331     {
4332       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4333     }
4334   oss << startOfLine << "----------------------" << std::endl;
4335 }
4336
4337 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4338 {
4339   const DataArray *arr(getUndergroundDataArray());
4340   if(!arr)
4341     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4342   int nbOfCompo=arr->getNumberOfComponents();
4343   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4344   for(int i=0;i<nbOfCompo;i++)
4345     {
4346       ret[i]=deepCopy();
4347       std::vector<int> v(1,i);
4348       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4349       ret[i]->setArray(arr2);
4350     }
4351   return ret;
4352 }
4353
4354 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)
4355 {
4356 }
4357
4358 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4359 {
4360 }
4361
4362 /*!
4363  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4364  * empty. Returns -1 if this in on nodes.
4365  *  \return int - the dimension of \a this.
4366  */
4367 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4368 {
4369   int ret=-2;
4370   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4371     (*it)->getDimension(ret);
4372   return ret;
4373 }
4374
4375 /*!
4376  * Returns the mesh name.
4377  *  \return std::string - a string holding the mesh name.
4378  *  \throw If \c _field_per_mesh.empty()
4379  */
4380 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4381 {
4382   if(_field_per_mesh.empty())
4383     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4384   return _field_per_mesh[0]->getMeshName();
4385 }
4386
4387 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4388 {
4389   std::string oldName(getMeshName());
4390   std::vector< std::pair<std::string,std::string> > v(1);
4391   v[0].first=oldName; v[0].second=newMeshName;
4392   changeMeshNames(v);
4393 }
4394
4395 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4396 {
4397   bool ret=false;
4398   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4399     {
4400       MEDFileFieldPerMesh *cur(*it);
4401       if(cur)
4402         ret=cur->changeMeshNames(modifTab) || ret;
4403     }
4404   return ret;
4405 }
4406
4407 /*!
4408  * Returns the number of iteration of the state of underlying mesh.
4409  *  \return int - the iteration number.
4410  *  \throw If \c _field_per_mesh.empty()
4411  */
4412 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4413 {
4414   if(_field_per_mesh.empty())
4415     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4416   return _field_per_mesh[0]->getMeshIteration();
4417 }
4418
4419 /*!
4420  * Returns the order number of iteration of the state of underlying mesh.
4421  *  \return int - the order number.
4422  *  \throw If \c _field_per_mesh.empty()
4423  */
4424 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4425 {
4426   if(_field_per_mesh.empty())
4427     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4428   return _field_per_mesh[0]->getMeshOrder();
4429 }
4430
4431 /*!
4432  * Checks if \a this field is tagged by a given iteration number and a given
4433  * iteration order number.
4434  *  \param [in] iteration - the iteration number of interest.
4435  *  \param [in] order - the iteration order number of interest.
4436  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4437  *          \a this->getOrder() == \a order.
4438  */
4439 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4440 {
4441   return iteration==_iteration && order==_order;
4442 }
4443
4444 /*!
4445  * Returns number of iteration and order number of iteration when
4446  * \a this field has been calculated.
4447  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4448  *          order number.
4449  */
4450 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4451 {
4452   std::pair<int,int> p;
4453   fillIteration(p);
4454   return p;
4455 }
4456
4457 /*!
4458  * Returns number of iteration and order number of iteration when
4459  * \a this field has been calculated.
4460  *  \param [in,out] p - a pair returning the iteration number and the iteration
4461  *          order number.
4462  */
4463 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4464 {
4465   p.first=_iteration;
4466   p.second=_order;
4467 }
4468
4469 /*!
4470  * Returns all types of spatial discretization of \a this field.
4471  *  \param [in,out] types - a sequence of types of \a this field.
4472  */
4473 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4474 {
4475   std::set<TypeOfField> types2;
4476   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4477     {
4478       (*it)->fillTypesOfFieldAvailable(types2);
4479     }
4480   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4481   std::copy(types2.begin(),types2.end(),bi);
4482 }
4483
4484 /*!
4485  * Returns all types of spatial discretization of \a this field.
4486  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4487  *          of \a this field.
4488  */
4489 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4490 {
4491   std::vector<TypeOfField> ret;
4492   fillTypesOfFieldAvailable(ret);
4493   return ret;
4494 }
4495
4496 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4497 {
4498   std::vector<std::string> ret;
4499   std::set<std::string> ret2;
4500   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4501     {
4502       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4503       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4504         if(ret2.find(*it2)==ret2.end())
4505           {
4506             ret.push_back(*it2);
4507             ret2.insert(*it2);
4508           }
4509     }
4510   return ret;
4511 }
4512
4513 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4514 {
4515   std::vector<std::string> ret;
4516   std::set<std::string> ret2;
4517   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4518     {
4519       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4520       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4521         if(ret2.find(*it2)==ret2.end())
4522           {
4523             ret.push_back(*it2);
4524             ret2.insert(*it2);
4525           }
4526     }
4527   return ret;
4528 }
4529
4530 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4531 {
4532   std::vector<std::string> ret;
4533   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4534     {
4535       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4536       ret.insert(ret.end(),tmp.begin(),tmp.end());
4537     }
4538   return ret;
4539 }
4540
4541 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4542 {
4543   std::vector<std::string> ret;
4544   std::set<std::string> ret2;
4545   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4546     {
4547       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4548       ret.insert(ret.end(),tmp.begin(),tmp.end());
4549     }
4550   return ret;
4551 }
4552
4553 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4554 {
4555   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4556     (*it)->changePflsRefsNamesGen(mapOfModif);
4557 }
4558
4559 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4560 {
4561   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4562     (*it)->changeLocsRefsNamesGen(mapOfModif);
4563 }
4564
4565 /*!
4566  * Returns all attributes of parts of \a this field lying on a given mesh.
4567  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4568  * item of every of returned sequences refers to the _i_-th part of \a this field.
4569  * Thus all sequences returned by this method are of the same length equal to number
4570  * of different types of supporting entities.<br>
4571  * A field part can include sub-parts with several different spatial discretizations,
4572  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4573  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4574  * of a nested sequence corresponds to a type of spatial discretization.<br>
4575  * This method allows for iteration over MEDFile DataStructure without any overhead.
4576  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4577  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4578  *          not checked if \a mname == \c NULL).
4579  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4580  *          a field part is returned. 
4581  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4582  *          This sequence is of the same length as \a types. 
4583  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4584  *          discretization. A profile name can be empty.
4585  *          Length of this and of nested sequences is the same as that of \a typesF.
4586  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4587  *          discretization. A localization name can be empty.
4588  *          Length of this and of nested sequences is the same as that of \a typesF.
4589  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4590  *          of ids of tuples within the data array, per each type of spatial
4591  *          discretization within one mesh entity type. 
4592  *          Length of this and of nested sequences is the same as that of \a typesF.
4593  *  \throw If no field is lying on \a mname.
4594  */
4595 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
4596 {
4597   int meshId=0;
4598   if(!mname.empty())
4599     meshId=getMeshIdFromMeshName(mname);
4600   else
4601     if(_field_per_mesh.empty())
4602       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4603   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4604 }
4605
4606 /*!
4607  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4608  * maximal absolute dimension and values returned via the out parameter \a levs are 
4609  * dimensions relative to the maximal absolute dimension. <br>
4610  * This method is designed for MEDFileField1TS instances that have a discretization
4611  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4612  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4613  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4614  * Only these 3 discretizations will be taken into account here. If \a this is
4615  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4616  * This method is useful to make the link between the dimension of the underlying mesh
4617  * and the levels of \a this, because it is possible that the highest dimension of \a this
4618  * field is not equal to the dimension of the underlying mesh.
4619  * 
4620  * Let's consider the following case:
4621  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4622  * TETRA4, HEXA8, TRI3 and SEG2.
4623  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4624  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4625  *
4626  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4627  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4628  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4629  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4630  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4631  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4632  * For example<br>
4633  * to retrieve the highest level of
4634  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4635  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4636  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4637  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4638  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4639  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4640  *          not checked if \a mname == \c NULL).
4641  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4642  *          absolute one. They are in decreasing order. This sequence is cleared before
4643  *          filling it in.
4644  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4645  *  \throw If no field is lying on \a mname.
4646  */
4647 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4648 {
4649   levs.clear();
4650   int meshId=getMeshIdFromMeshName(mname);
4651   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4652   std::vector< std::vector<TypeOfField> > typesF;
4653   std::vector< std::vector<std::string> > pfls, locs;
4654   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4655   if(types.empty())
4656     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4657   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4658   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4659     return -1;
4660   st.erase(INTERP_KERNEL::NORM_ERROR);
4661   std::set<int> ret1;
4662   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4663     {
4664       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4665       ret1.insert((int)cm.getDimension());
4666     }
4667   int ret=*std::max_element(ret1.begin(),ret1.end());
4668   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4669   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4670   return ret;
4671 }
4672
4673 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4674 {
4675   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4676     if((*it).isNotNull())
4677       (*it)->convertMedBallIntoClassic();
4678 }
4679
4680 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4681 {
4682   if(!pfl)
4683     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4684   std::string name(pfl->getName());
4685   pfl->checkAllocated();
4686   if(pfl->getNumberOfComponents()!=1)
4687     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4688   if(name.empty())
4689     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4690   if(_field_per_mesh.size()!=1)
4691     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4692   MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4693   if(fpm.isNull())
4694     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4695   MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4696   if(disc->getType()!=tof)
4697     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4698   int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4699   DataArray *arr(getUndergroundDataArray());
4700   int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4701   if(delta<0)
4702     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4703   MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4704   MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4705   MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4706   arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4707   arrOut->copyStringInfoFrom(*arr);
4708   arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4709   arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4710   arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4711   setArray(arrOut);
4712   disc->setEnd(e-delta);
4713   disc->setProfile(name);
4714 }
4715
4716 /*!
4717  * \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.
4718  * \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.
4719  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4720  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4721  */
4722 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4723 {
4724   int mid=getMeshIdFromMeshName(mName);
4725   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4726 }
4727
4728 /*!
4729  * \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.
4730  * \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.
4731  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4732  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4733  */
4734 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4735 {
4736   int mid=getMeshIdFromMeshName(mName);
4737   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4738 }
4739
4740 /*!
4741  * \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.
4742  */
4743 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4744 {
4745   if(_field_per_mesh.empty())
4746     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4747   if(mName.empty())
4748     return 0;
4749   std::string mName2(mName);
4750   int ret=0;
4751   std::vector<std::string> msg;
4752   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4753     if(mName2==(*it)->getMeshName())
4754       return ret;
4755     else
4756       msg.push_back((*it)->getMeshName());
4757   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4758   oss << "Possible meshes are : ";
4759   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4760     oss << "\"" << (*it2) << "\" ";
4761   throw INTERP_KERNEL::Exception(oss.str());
4762 }
4763
4764 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4765 {
4766   if(!mesh)
4767     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4768   std::string tmp(mesh->getName());
4769   if(tmp.empty())
4770     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4771   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4772   int i=0;
4773   for(;it!=_field_per_mesh.end();it++,i++)
4774     {
4775       if((*it)->getMeshName()==tmp)
4776         return i;
4777     }
4778   int sz=_field_per_mesh.size();
4779   _field_per_mesh.resize(sz+1);
4780   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4781   return sz;
4782 }
4783
4784 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4785                                                                    MEDFileFieldGlobsReal& glob)
4786 {
4787   bool ret=false;
4788   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4789     {
4790       MEDFileFieldPerMesh *fpm(*it);
4791       if(fpm)
4792         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4793     }
4794   return ret;
4795 }
4796
4797 /*!
4798  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4799  * splitting that leads to single spatial discretization of this.
4800  *
4801  * \sa splitMultiDiscrPerGeoTypes
4802  */
4803 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4804 {
4805   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4806   std::vector< std::vector<TypeOfField> > typesF;
4807   std::vector< std::vector<std::string> > pfls,locs;
4808   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4809   std::set<TypeOfField> allEnt;
4810   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4811     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4812       allEnt.insert(*it2);
4813   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4814   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4815   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4816     {
4817       std::vector< std::pair<int,int> > its;
4818       ret[i]=shallowCpy();
4819       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4820       ret[i]->updateData(newLgth,its);
4821     }
4822   return ret;
4823 }
4824
4825 /*!
4826  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4827  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4828  *
4829  * \sa splitDiscretizations
4830  */
4831 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4832 {
4833   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4834   std::vector< std::vector<TypeOfField> > typesF;
4835   std::vector< std::vector<std::string> > pfls,locs;
4836   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4837   std::set<TypeOfField> allEnt;
4838   std::size_t nbOfMDPGT(0),ii(0);
4839   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4840     {
4841       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4842       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4843         allEnt.insert(*it2);
4844     }
4845   if(allEnt.size()!=1)
4846     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4847   if(nbOfMDPGT==0)
4848     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4849   if(nbOfMDPGT==1)
4850     {
4851       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4852       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4853       return ret0;
4854     }
4855   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4856   for(std::size_t i=0;i<nbOfMDPGT;i++)
4857     {
4858       std::vector< std::pair<int,int> > its;
4859       ret[i]=shallowCpy();
4860       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4861       ret[i]->updateData(newLgth,its);
4862     }
4863   return ret;
4864 }
4865
4866 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4867 {
4868   int globalCounter(0);
4869   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4870     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4871   return globalCounter;
4872 }
4873
4874 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4875 {
4876   int globalCounter(0);
4877   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4878     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4879   return globalCounter;
4880 }
4881
4882 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4883 {
4884   if(_nb_of_tuples_to_be_allocated>=0)
4885     {
4886       _nb_of_tuples_to_be_allocated=newLgth;
4887       const DataArray *oldArr(getUndergroundDataArray());
4888       if(oldArr)
4889         {
4890           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4891           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4892           setArray(newArr);
4893           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4894         }
4895       return ;
4896     }
4897   if(_nb_of_tuples_to_be_allocated==-1)
4898     return ;
4899   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4900     {
4901       const DataArray *oldArr(getUndergroundDataArray());
4902       if(!oldArr || !oldArr->isAllocated())
4903         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4904       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4905       newArr->alloc(newLgth,getNumberOfComponents());
4906       if(oldArr)
4907         newArr->copyStringInfoFrom(*oldArr);
4908       int pos=0;
4909       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4910         {
4911           if((*it).second<(*it).first)
4912             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4913           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4914           pos+=(*it).second-(*it).first;
4915         }
4916       setArray(newArr);
4917       return ;
4918     }
4919   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4920 }
4921
4922 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4923 {
4924   if(_field_per_mesh.empty())
4925     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4926   if(_field_per_mesh.size()>1)
4927     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4928   _field_per_mesh[0]->copyOptionsFrom(opts);
4929   _field_per_mesh[0]->writeLL(fid,nasc);
4930 }
4931
4932 /*!
4933  * 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.
4934  * If false is returned the memory allocation is not required.
4935  */
4936 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4937 {
4938   if(_nb_of_tuples_to_be_allocated>=0)
4939     {
4940       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4941       _nb_of_tuples_to_be_allocated=-2;
4942       return true;
4943     }
4944   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4945     return false;
4946   if(_nb_of_tuples_to_be_allocated==-1)
4947     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4948   if(_nb_of_tuples_to_be_allocated<-3)
4949     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4950   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4951 }
4952
4953 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4954 {
4955   med_int numdt,numit;
4956   med_float dt;
4957   med_int nmesh;
4958   med_bool localMesh;
4959   med_int meshnumdt,meshnumit;
4960   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4961   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4962   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4963   if(_iteration!=numdt || _order!=numit)
4964     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4965   _field_per_mesh.resize(nmesh);
4966   //
4967   MEDFileMesh *mm(0);
4968   if(ms)
4969     {
4970       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4971       mm=ms->getMeshWithName(meshNameCpp);
4972     }
4973   //
4974   for(int i=0;i<nmesh;i++)
4975     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4976   _nb_of_tuples_to_be_allocated=0;
4977   for(int i=0;i<nmesh;i++)
4978     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4979 }
4980
4981 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4982 {
4983   allocIfNecessaryTheArrayToReceiveDataFromFile();
4984   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4985     (*it)->loadBigArraysRecursively(fid,nasc);
4986 }
4987
4988 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4989 {
4990   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4991     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4992       (*it)->loadBigArraysRecursively(fid,nasc);
4993 }
4994
4995 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4996 {
4997   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4998   loadBigArraysRecursively(fid,nasc);
4999 }
5000
5001 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5002 {
5003   DataArray *thisArr(getUndergroundDataArray());
5004   if(thisArr && thisArr->isAllocated())
5005     {
5006       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5007       thisArr->desallocate();
5008     }
5009 }
5010
5011 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5012 {
5013   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5014 }
5015
5016 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5017 {
5018   std::vector<const BigMemoryObject *> ret;
5019   if(getUndergroundDataArray())
5020     ret.push_back(getUndergroundDataArray());
5021   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5022     ret.push_back((const MEDFileFieldPerMesh *)*it);
5023   return ret;
5024 }
5025
5026 /*!
5027  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5028  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5029  * "Sort By Type"), if not, an exception is thrown. 
5030  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
5031  *  \param [in] arr - the array of values.
5032  *  \param [in,out] glob - the global data where profiles and localization present in
5033  *          \a field, if any, are added.
5034  *  \throw If the name of \a field is empty.
5035  *  \throw If the data array of \a field is not set.
5036  *  \throw If \a this->_arr is already allocated but has different number of components
5037  *         than \a field.
5038  *  \throw If the underlying mesh of \a field has no name.
5039  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5040  */
5041 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5042 {
5043   const MEDCouplingMesh *mesh=field->getMesh();
5044   //
5045   TypeOfField type=field->getTypeOfField();
5046   std::vector<DataArrayInt *> dummy;
5047   int start=copyTinyInfoFrom(field,arr);
5048   int pos=addNewEntryIfNecessary(mesh);
5049   if(type!=ON_NODES)
5050     {
5051       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5052       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5053     }
5054   else
5055     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5056 }
5057
5058 /*!
5059  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5060  * of a given mesh are used as the support of the given field (a real support is not used). 
5061  * Elements of the given mesh must be sorted suitable for writing to MED file. 
5062  * Order of underlying mesh entities of the given field specified by \a profile parameter
5063  * is not prescribed; this method permutes field values to have them sorted by element
5064  * type as required for writing to MED file. A new profile is added only if no equal
5065  * profile is missing. 
5066  *  \param [in] field - the field to add to \a this. The field double values are ignored.
5067  *  \param [in] arrOfVals - the values of the field \a field used.
5068  *  \param [in] mesh - the supporting mesh of \a field.
5069  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5070  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
5071  *  \param [in,out] glob - the global data where profiles and localization present in
5072  *          \a field, if any, are added.
5073  *  \throw If either \a field or \a mesh or \a profile has an empty name.
5074  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5075  *  \throw If the data array of \a field is not set.
5076  *  \throw If \a this->_arr is already allocated but has different number of components
5077  *         than \a field.
5078  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5079  *  \sa setFieldNoProfileSBT()
5080  */
5081 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5082 {
5083   if(!field)
5084     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5085   if(!arrOfVals || !arrOfVals->isAllocated())
5086     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5087   TypeOfField type=field->getTypeOfField();
5088   std::vector<DataArrayInt *> idsInPflPerType;
5089   std::vector<DataArrayInt *> idsPerType;
5090   std::vector<int> code,code2;
5091   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5092   if(type!=ON_NODES)
5093     {
5094       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5095       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5096       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
5097       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5098       // start of check
5099       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5100       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5101       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5102         {
5103           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5104           throw INTERP_KERNEL::Exception(oss.str());
5105         }
5106       // end of check
5107       int start=copyTinyInfoFrom(field,arrOfVals);
5108       code2=m->getDistributionOfTypes();
5109       //
5110       int pos=addNewEntryIfNecessary(m);
5111       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5112     }
5113   else
5114     {
5115       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5116         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5117       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5118       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5119       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5120       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5121         {
5122           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5123           throw INTERP_KERNEL::Exception(oss.str());
5124         }
5125       int start=copyTinyInfoFrom(field,arrOfVals);
5126       int pos=addNewEntryIfNecessary(m);
5127       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5128     }
5129 }
5130
5131 /*!
5132  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5133  */
5134 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5135 {
5136   if(_nb_of_tuples_to_be_allocated>=0)
5137     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 !");
5138   DataArray *arr(getOrCreateAndGetArray());
5139   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5140   _nb_of_tuples_to_be_allocated=-3;
5141 }
5142
5143 /*!
5144  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5145  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5146  * larger by the size of \a field. Returns an id of the first not filled
5147  * tuple of \a this->_arr.
5148  *  \param [in] field - the field to copy the info on components and the name from.
5149  *  \return int - the id of first not initialized tuple of \a this->_arr.
5150  *  \throw If the name of \a field is empty.
5151  *  \throw If the data array of \a field is not set.
5152  *  \throw If \a this->_arr is already allocated but has different number of components
5153  *         than \a field.
5154  */
5155 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5156 {
5157   if(!field)
5158     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5159   std::string name(field->getName());
5160   setName(name.c_str());
5161   setDtUnit(field->getTimeUnit());
5162   if(name.empty())
5163     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5164   if(!arr)
5165     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5166   if(!arr->isAllocated())
5167     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5168   _dt=field->getTime(_iteration,_order);
5169   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5170   if(!getOrCreateAndGetArray()->isAllocated())
5171     {
5172       allocNotFromFile(arr->getNumberOfTuples());
5173       return 0;
5174     }
5175   else
5176     {
5177       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5178       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5179       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5180       _nb_of_tuples_to_be_allocated=-3;
5181       return oldNbOfTuples;
5182     }
5183 }
5184
5185 /*!
5186  * Returns number of components in \a this field
5187  *  \return int - the number of components.
5188  */
5189 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5190 {
5191   return getOrCreateAndGetArray()->getNumberOfComponents();
5192 }
5193
5194 /*!
5195  * Change info on components in \a this.
5196  * \throw If size of \a infos is not equal to the number of components already in \a this.
5197  */
5198 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5199 {
5200   DataArray *arr=getOrCreateAndGetArray();
5201   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5202 }
5203
5204 /*!
5205  * Returns info on components of \a this field.
5206  *  \return const std::vector<std::string>& - a sequence of strings each being an
5207  *          information on _i_-th component.
5208  */
5209 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5210 {
5211   const DataArray *arr=getOrCreateAndGetArray();
5212   return arr->getInfoOnComponents();
5213 }
5214
5215 /*!
5216  * Returns a mutable info on components of \a this field.
5217  *  \return std::vector<std::string>& - a sequence of strings each being an
5218  *          information on _i_-th component.
5219  */
5220 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5221 {
5222   DataArray *arr=getOrCreateAndGetArray();
5223   return arr->getInfoOnComponents();
5224 }
5225
5226 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5227 {
5228   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5229     {
5230       const MEDFileFieldPerMesh *fpm(*it);
5231       if(!fpm)
5232         continue;
5233       if(fpm->presenceOfMultiDiscPerGeoType())
5234         return true;
5235     }
5236   return false;
5237 }
5238
5239 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5240 {
5241   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5242     if((*it).isNotNull())
5243       if((*it)->presenceOfStructureElements())
5244         return true;
5245   return false;
5246 }
5247
5248 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5249 {
5250   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5251     if((*it).isNotNull())
5252       if(!(*it)->onlyStructureElements())
5253         return false;
5254   return true;
5255 }
5256
5257 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5258 {
5259   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5260     if((*it).isNotNull())
5261       (*it)->killStructureElements();
5262 }
5263
5264 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5265 {
5266   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5267     if((*it).isNotNull())
5268       (*it)->keepOnlyStructureElements();
5269 }
5270
5271 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5272 {
5273   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5274     if((*it).isNotNull())
5275       (*it)->keepOnlyOnSE(seName);
5276 }
5277
5278 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5279 {
5280   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5281     if((*it).isNotNull())
5282       (*it)->getMeshSENames(ps);
5283 }
5284
5285 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5286 {
5287   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 !";
5288   if(_field_per_mesh.empty())
5289     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5290   if(_field_per_mesh.size()>1)
5291     throw INTERP_KERNEL::Exception(MSG0);
5292   if(_field_per_mesh[0].isNull())
5293     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5294   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5295   std::set<TypeOfField> types;
5296   pm->fillTypesOfFieldAvailable(types);
5297   if(types.size()!=1)
5298     throw INTERP_KERNEL::Exception(MSG0);
5299   TypeOfField type(*types.begin());
5300   int meshDimRelToMax(0);
5301   if(type==ON_NODES)
5302     meshDimRelToMax=0;
5303   else
5304     {
5305       int myDim(std::numeric_limits<int>::max());
5306       bool isUnique(pm->isUniqueLevel(myDim));
5307       if(!isUnique)
5308         throw INTERP_KERNEL::Exception(MSG0);
5309       meshDimRelToMax=myDim-mesh->getMeshDimension();
5310       if(meshDimRelToMax>0)
5311         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5312     }
5313   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5314 }
5315
5316 /*!
5317  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5318  *  \param [in] type - a spatial discretization of the new field.
5319  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5320  *  \param [in] mName - a name of the supporting mesh.
5321  *  \param [in] renumPol - specifies how to permute values of the result field according to
5322  *          the optional numbers of cells and nodes, if any. The valid values are
5323  *          - 0 - do not permute.
5324  *          - 1 - permute cells.
5325  *          - 2 - permute nodes.
5326  *          - 3 - permute cells and nodes.
5327  *
5328  *  \param [in] glob - the global data storing profiles and localization.
5329  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5330  *          caller is to delete this field using decrRef() as it is no more needed. 
5331  *  \throw If the MED file is not readable.
5332  *  \throw If there is no mesh named \a mName in the MED file.
5333  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5334  *  \throw If no field of \a this is lying on the mesh \a mName.
5335  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5336  */
5337 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5338 {
5339   MCAuto<MEDFileMesh> mm;
5340   if(mName.empty())
5341     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5342   else
5343     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5344   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5345 }
5346
5347 /*!
5348  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5349  *  \param [in] type - a spatial discretization of the new field.
5350  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5351  *  \param [in] renumPol - specifies how to permute values of the result field according to
5352  *          the optional numbers of cells and nodes, if any. The valid values are
5353  *          - 0 - do not permute.
5354  *          - 1 - permute cells.
5355  *          - 2 - permute nodes.
5356  *          - 3 - permute cells and nodes.
5357  *
5358  *  \param [in] glob - the global data storing profiles and localization.
5359  *  \param [in] mesh - the supporting mesh.
5360  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5361  *          caller is to delete this field using decrRef() as it is no more needed. 
5362  *  \throw If the MED file is not readable.
5363  *  \throw If no field of \a this is lying on \a mesh.
5364  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5365  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5366  */
5367 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5368 {
5369   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5370   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5371   if(meshDimRelToMax==1)
5372     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5373   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5374 }
5375
5376 /*!
5377  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5378  * given mesh. 
5379  *  \param [in] type - a spatial discretization of the new field.
5380  *  \param [in] mName - a name of the supporting mesh.
5381  *  \param [in] renumPol - specifies how to permute values of the result field according to
5382  *          the optional numbers of cells and nodes, if any. The valid values are
5383  *          - 0 - do not permute.
5384  *          - 1 - permute cells.
5385  *          - 2 - permute nodes.
5386  *          - 3 - permute cells and nodes.
5387  *
5388  *  \param [in] glob - the global data storing profiles and localization.
5389  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5390  *          caller is to delete this field using decrRef() as it is no more needed. 
5391  *  \throw If the MED file is not readable.
5392  *  \throw If there is no mesh named \a mName in the MED file.
5393  *  \throw If there are no mesh entities in the mesh.
5394  *  \throw If no field values of the given \a type are available.
5395  */
5396 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5397 {
5398   MCAuto<MEDFileMesh> mm;
5399   if(mName.empty())
5400     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5401   else
5402     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5403   int absDim=getDimension();
5404   int meshDimRelToMax=absDim-mm->getMeshDimension();
5405   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5406 }
5407
5408 /*!
5409  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5410  *  \param [in] type - a spatial discretization of the new field.
5411  *  \param [in] renumPol - specifies how to permute values of the result field according to
5412  *          the optional numbers of cells and nodes, if any. The valid values are
5413  *          - 0 - do not permute.
5414  *          - 1 - permute cells.
5415  *          - 2 - permute nodes.
5416  *          - 3 - permute cells and nodes.
5417  *
5418  *  \param [in] glob - the global data storing profiles and localization.
5419  *  \param [in] mesh - the supporting mesh.
5420  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5421  *         field according to \a renumPol.
5422  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5423  *         field according to \a renumPol.
5424  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5425  *          caller is to delete this field using decrRef() as it is no more needed. 
5426  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5427  *  \throw If no field of \a this is lying on \a mesh.
5428  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5429  */
5430 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
5431 {
5432   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5433   int meshId=getMeshIdFromMeshName(mesh->getName());
5434   bool isPfl=false;
5435   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5436   switch(renumPol)
5437   {
5438     case 0:
5439       {
5440         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5441         return ret.retn();
5442       }
5443     case 3:
5444     case 1:
5445       {
5446         if(isPfl)
5447           throw INTERP_KERNEL::Exception(msg1);
5448         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5449         if(cellRenum)
5450           {
5451             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5452               {
5453                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5454                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5455                 throw INTERP_KERNEL::Exception(oss.str());
5456               }
5457             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5458             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5459             std::vector<DataArray *> arrOut2(1,arrOut);
5460             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5461             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5462             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5463           }
5464         if(renumPol==1)
5465           return ret.retn();
5466       }
5467     case 2:
5468       {
5469         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5470         if(isPfl)
5471           throw INTERP_KERNEL::Exception(msg1);
5472         if(nodeRenum)
5473           {
5474             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5475               {
5476                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5477                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5478                 throw INTERP_KERNEL::Exception(oss.str());
5479               }
5480             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5481             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5482               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5483             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5484           }
5485         return ret.retn();
5486       }
5487     default:
5488       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5489   }
5490 }
5491
5492 /*!
5493  * Returns values and a profile of the field of a given type lying on a given support.
5494  *  \param [in] type - a spatial discretization of the field.
5495  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5496  *  \param [in] mesh - the supporting mesh.
5497  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5498  *          field of interest lies on. If the field lies on all entities of the given
5499  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5500  *          using decrRef() as it is no more needed.  
5501  *  \param [in] glob - the global data storing profiles and localization.
5502  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5503  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5504  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5505  *  \throw If no field of \a this is lying on \a mesh.
5506  *  \throw If no field values of the given \a type are available.
5507  */
5508 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5509 {
5510   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5511   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5512   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5513   ret->setName(nasc.getName().c_str());
5514   return ret.retn();
5515 }
5516
5517 //= MEDFileField1TSWithoutSDA
5518
5519 /*!
5520  * Throws if a given value is not a valid (non-extended) relative dimension.
5521  *  \param [in] meshDimRelToMax - the relative dimension value.
5522  *  \throw If \a meshDimRelToMax > 0.
5523  */
5524 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5525 {
5526   if(meshDimRelToMax>0)
5527     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5528 }
5529
5530 /*!
5531  * Checks if elements of a given mesh are in the order suitable for writing 
5532  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5533  * vector describing types of elements and their number.
5534  *  \param [in] mesh - the mesh to check.
5535  *  \return std::vector<int> - a vector holding for each element type (1) item of
5536  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5537  *          These values are in full-interlace mode.
5538  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5539  */
5540 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5541 {
5542   if(!mesh)
5543     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5544   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5545   int nbOfTypes=geoTypes.size();
5546   std::vector<int> code(3*nbOfTypes);
5547   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5548   arr1->alloc(nbOfTypes,1);
5549   int *arrPtr=arr1->getPointer();
5550   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5551   for(int i=0;i<nbOfTypes;i++,it++)
5552     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5553   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5554   const int *arrPtr2=arr2->getConstPointer();
5555   int i=0;
5556   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5557     {
5558       int pos=arrPtr2[i];
5559       int nbCells=mesh->getNumberOfCellsWithType(*it);
5560       code[3*pos]=(int)(*it);
5561       code[3*pos+1]=nbCells;
5562       code[3*pos+2]=-1;//no profiles
5563     }
5564   std::vector<const DataArrayInt *> idsPerType;//no profiles
5565   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5566   if(da)
5567     {
5568       da->decrRef();
5569       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5570     }
5571   return code;
5572 }
5573
5574 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5575 {
5576   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5577 }
5578
5579 /*!
5580  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5581  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5582  * item of every of returned sequences refers to the _i_-th part of \a this field.
5583  * Thus all sequences returned by this method are of the same length equal to number
5584  * of different types of supporting entities.<br>
5585  * A field part can include sub-parts with several different spatial discretizations,
5586  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5587  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5588  * of a nested sequence corresponds to a type of spatial discretization.<br>
5589  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5590  * The overhead is due to selecting values into new instances of DataArrayDouble.
5591  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5592  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5593  *          not checked if \a mname == \c NULL).
5594  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5595  *          a field part is returned. 
5596  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5597  *          A field part can include sub-parts with several different spatial discretizations,
5598  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5599  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5600  *          This sequence is of the same length as \a types. 
5601  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5602  *          discretization. A profile name can be empty.
5603  *          Length of this and of nested sequences is the same as that of \a typesF.
5604  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5605  *          discretization. A localization name can be empty.
5606  *          Length of this and of nested sequences is the same as that of \a typesF.
5607  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5608  *          per each type of spatial discretization within one mesh entity type.
5609  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5610  *          Length of this and of nested sequences is the same as that of \a typesF.
5611  *  \throw If no field is lying on \a mname.
5612  */
5613 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
5614 {
5615   int meshId=0;
5616   if(!mname.empty())
5617     meshId=getMeshIdFromMeshName(mname);
5618   else
5619     if(_field_per_mesh.empty())
5620       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5621   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5622   int nbOfRet=ret0.size();
5623   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5624   for(int i=0;i<nbOfRet;i++)
5625     {
5626       const std::vector< std::pair<int,int> >& p=ret0[i];
5627       int nbOfRet1=p.size();
5628       ret[i].resize(nbOfRet1);
5629       for(int j=0;j<nbOfRet1;j++)
5630         {
5631           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5632           ret[i][j]=tmp;
5633         }
5634     }
5635   return ret;
5636 }
5637
5638 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5639 {
5640   return TYPE_STR;
5641 }
5642
5643 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5644 {
5645   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5646   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5647   ret->deepCpyLeavesFrom(*this);
5648   const DataArrayDouble *arr(_arr);
5649   if(arr)
5650     {
5651       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5652       ret->setArray(arr2);
5653     }
5654   return ret.retn();
5655 }
5656
5657 /*!
5658  * Returns a pointer to the underground DataArrayDouble instance and a
5659  * sequence describing parameters of a support of each part of \a this field. The
5660  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5661  * direct access to the field values. This method is intended for the field lying on one
5662  * mesh only.
5663  *  \param [in,out] entries - the sequence describing parameters of a support of each
5664  *         part of \a this field. Each item of this sequence consists of two parts. The
5665  *         first part describes a type of mesh entity and an id of discretization of a
5666  *         current field part. The second part describes a range of values [begin,end)
5667  *         within the returned array relating to the current field part.
5668  *  \return DataArrayDouble * - the pointer to the field values array.
5669  *  \throw If the number of underlying meshes is not equal to 1.
5670  *  \throw If no field values are available.
5671  *  \sa getUndergroundDataArray()
5672  */
5673 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5674 {
5675   if(_field_per_mesh.size()!=1)
5676     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5677   if(_field_per_mesh[0]==0)
5678     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5679   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5680   return getUndergroundDataArrayTemplate();
5681 }
5682
5683 /*!
5684  * Returns a pointer to the underground DataArrayDouble instance and a
5685  * sequence describing parameters of a support of each part of \a this field. The
5686  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5687  * direct access to the field values. This method is intended for the field lying on one
5688  * mesh only.
5689  *  \param [in,out] entries - the sequence describing parameters of a support of each
5690  *         part of \a this field. Each item of this sequence consists of two parts. The
5691  *         first part describes a type of mesh entity and an id of discretization of a
5692  *         current field part. The second part describes a range of values [begin,end)
5693  *         within the returned array relating to the current field part.
5694  *  \return DataArrayDouble * - the pointer to the field values array.
5695  *  \throw If the number of underlying meshes is not equal to 1.
5696  *  \throw If no field values are available.
5697  *  \sa getUndergroundDataArray()
5698  */
5699 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5700 {
5701   return getUndergroundDataArrayDoubleExt(entries);
5702 }
5703
5704 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5705 {
5706   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5707   arr->setInfoAndChangeNbOfCompo(infos);
5708 }
5709
5710 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5711 {
5712 }
5713
5714 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5715 {
5716   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5717   ret->deepCpyLeavesFrom(*this);
5718   return ret.retn();
5719 }
5720
5721 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5722 {
5723   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5724   if(_arr.isNotNull())
5725     ret->_arr=_arr->deepCopy();
5726   return ret.retn();
5727 }
5728
5729 //= MEDFileIntField1TSWithoutSDA
5730
5731 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5732 {
5733   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5734 }
5735
5736 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5737 {
5738 }
5739
5740 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5741                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5742 {
5743   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5744   arr->setInfoAndChangeNbOfCompo(infos);
5745 }
5746
5747 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5748 {
5749   return TYPE_STR;
5750 }
5751
5752 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5753 {
5754   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5755   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5756   ret->deepCpyLeavesFrom(*this);
5757   const DataArrayInt *arr(_arr);
5758   if(arr)
5759     {
5760       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5761       ret->setArray(arr2);
5762     }
5763   return ret.retn();
5764 }
5765
5766 /*!
5767  * Returns a pointer to the underground DataArrayInt instance and a
5768  * sequence describing parameters of a support of each part of \a this field. The
5769  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5770  * direct access to the field values. This method is intended for the field lying on one
5771  * mesh only.
5772  *  \param [in,out] entries - the sequence describing parameters of a support of each
5773  *         part of \a this field. Each item of this sequence consists of two parts. The
5774  *         first part describes a type of mesh entity and an id of discretization of a
5775  *         current field part. The second part describes a range of values [begin,end)
5776  *         within the returned array relating to the current field part.
5777  *  \return DataArrayInt * - the pointer to the field values array.
5778  *  \throw If the number of underlying meshes is not equal to 1.
5779  *  \throw If no field values are available.
5780  *  \sa getUndergroundDataArray()
5781  */
5782 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5783 {
5784   return getUndergroundDataArrayIntExt(entries);
5785 }
5786
5787 /*!
5788  * Returns a pointer to the underground DataArrayInt instance and a
5789  * sequence describing parameters of a support of each part of \a this field. The
5790  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5791  * direct access to the field values. This method is intended for the field lying on one
5792  * mesh only.
5793  *  \param [in,out] entries - the sequence describing parameters of a support of each
5794  *         part of \a this field. Each item of this sequence consists of two parts. The
5795  *         first part describes a type of mesh entity and an id of discretization of a
5796  *         current field part. The second part describes a range of values [begin,end)
5797  *         within the returned array relating to the current field part.
5798  *  \return DataArrayInt * - the pointer to the field values array.
5799  *  \throw If the number of underlying meshes is not equal to 1.
5800  *  \throw If no field values are available.
5801  *  \sa getUndergroundDataArray()
5802  */
5803 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5804 {
5805   if(_field_per_mesh.size()!=1)
5806     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5807   if(_field_per_mesh[0]==0)
5808     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5809   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5810   return getUndergroundDataArrayTemplate();
5811 }
5812
5813 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5814 {
5815   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5816   ret->deepCpyLeavesFrom(*this);
5817   return ret.retn();
5818 }
5819
5820 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5821 {
5822   MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5823   if(_arr.isNotNull())
5824     ret->_arr=_arr->deepCopy();
5825   return ret.retn();
5826 }
5827
5828 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5829 {
5830 }
5831
5832 //= MEDFileAnyTypeField1TS
5833
5834 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5835 {
5836   med_field_type typcha;
5837   //
5838   std::vector<std::string> infos;
5839   std::string dtunit,fieldName;
5840   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5841   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5842   switch(typcha)
5843   {
5844     case MED_FLOAT64:
5845       {
5846         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5847         break;
5848       }
5849     case MED_INT32:
5850       {
5851         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5852         break;
5853       }
5854     default:
5855       {
5856         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5857         throw INTERP_KERNEL::Exception(oss.str());
5858       }
5859   }
5860   ret->setDtUnit(dtunit.c_str());
5861   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5862   //
5863   med_int numdt,numit;
5864   med_float dt;
5865   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5866   ret->setTime(numdt,numit,dt);
5867   ret->_csit=1;
5868   if(loadAll)
5869     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5870   else
5871     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5872   return ret.retn();
5873 }
5874
5875 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5876 try:MEDFileFieldGlobsReal(fid)
5877 {
5878   _content=BuildContentFrom(fid,loadAll,ms);
5879   loadGlobals(fid);
5880 }
5881 catch(INTERP_KERNEL::Exception& e)
5882 {
5883     throw e;
5884 }
5885
5886 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5887 {
5888   med_field_type typcha;
5889   std::vector<std::string> infos;
5890   std::string dtunit;
5891   int iii=-1;
5892   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5893   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5894   switch(typcha)
5895   {
5896     case MED_FLOAT64:
5897       {
5898         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5899         break;
5900       }
5901     case MED_INT32:
5902       {
5903         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5904         break;
5905       }
5906     default:
5907       {
5908         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5909         throw INTERP_KERNEL::Exception(oss.str());
5910       }
5911   }
5912   ret->setDtUnit(dtunit.c_str());
5913   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5914   //
5915   if(nbSteps<1)
5916     {
5917       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5918       throw INTERP_KERNEL::Exception(oss.str());
5919     }
5920   //
5921   med_int numdt,numit;
5922   med_float dt;
5923   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5924   ret->setTime(numdt,numit,dt);
5925   ret->_csit=1;
5926   if(loadAll)
5927     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5928   else
5929     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5930   return ret.retn();
5931 }
5932
5933 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5934 try:MEDFileFieldGlobsReal(fid)
5935 {
5936   _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5937   loadGlobals(fid);
5938 }
5939 catch(INTERP_KERNEL::Exception& e)
5940 {
5941     throw e;
5942 }
5943
5944 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5945 {
5946   if(!c)
5947     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5948   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5949     {
5950       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5951       ret->_content=c; c->incrRef();
5952       return ret.retn();
5953     }
5954   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5955     {
5956       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5957       ret->_content=c; c->incrRef();
5958       return ret.retn();
5959     }
5960   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5961 }
5962
5963 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5964 {
5965   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5966   ret->setFileName(FileNameFromFID(fid));
5967   return ret;
5968 }
5969
5970 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5971 {
5972   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5973   return New(fid,loadAll);
5974 }
5975
5976 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5977 {
5978   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5979   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5980   ret->loadGlobals(fid);
5981   return ret.retn();
5982 }
5983
5984 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5985 {
5986   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5987   return New(fid,fieldName,loadAll);
5988 }
5989
5990 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5991 {
5992   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5993   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5994   ret->loadGlobals(fid);
5995   return ret.retn();
5996 }
5997
5998 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5999 {
6000   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6001   return New(fid,fieldName,iteration,order,loadAll);
6002 }
6003
6004 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6005 {
6006   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
6007   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6008   ret->loadGlobals(fid);
6009   return ret.retn();
6010 }
6011
6012 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6013 {
6014   med_field_type typcha;
6015   std::vector<std::string> infos;
6016   std::string dtunit;
6017   int iii(-1);
6018   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
6019   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6020   switch(typcha)
6021   {
6022     case MED_FLOAT64:
6023       {
6024         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6025         break;
6026       }
6027     case MED_INT32:
6028       {
6029         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6030         break;
6031       }
6032     default:
6033       {
6034         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
6035         throw INTERP_KERNEL::Exception(oss.str());
6036       }
6037   }
6038   ret->setDtUnit(dtunit.c_str());
6039   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6040   //
6041   bool found=false;
6042   std::vector< std::pair<int,int> > dtits(nbOfStep2);
6043   for(int i=0;i<nbOfStep2 && !found;i++)
6044     {
6045       med_int numdt,numit;
6046       med_float dt;
6047       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6048       if(numdt==iteration && numit==order)
6049         {
6050           found=true;
6051           ret->_csit=i+1;
6052         }
6053       else
6054         dtits[i]=std::pair<int,int>(numdt,numit);
6055     }
6056   if(!found)
6057     {
6058       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6059       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6060         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6061       throw INTERP_KERNEL::Exception(oss.str());
6062     }
6063   if(loadAll)
6064     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
6065   else
6066     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
6067   return ret.retn();
6068 }
6069
6070 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6071 try:MEDFileFieldGlobsReal(fid)
6072 {
6073   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
6074   loadGlobals(fid);
6075 }
6076 catch(INTERP_KERNEL::Exception& e)
6077 {
6078     throw e;
6079 }
6080
6081 /*!
6082  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6083  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6084  *
6085  * \warning this is a shallow copy constructor
6086  */
6087 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6088 {
6089   if(!shallowCopyOfContent)
6090     {
6091       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6092       otherPtr->incrRef();
6093       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6094     }
6095   else
6096     {
6097       _content=other.shallowCpy();
6098     }
6099 }
6100
6101 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6102 {
6103   if(checkFieldId)
6104     {
6105       int nbFields=MEDnField(fid);
6106       if(fieldIdCFormat>=nbFields)
6107         {
6108           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6109           throw INTERP_KERNEL::Exception(oss.str());
6110         }
6111     }
6112   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6113   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6114   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6115   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6116   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6117   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6118   med_bool localMesh;
6119   int nbOfStep;
6120   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6121   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6122   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6123   infos.clear(); infos.resize(ncomp);
6124   for(int j=0;j<ncomp;j++)
6125     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6126   return nbOfStep;
6127 }
6128
6129 /*!
6130  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6131  * 
6132  * \param [out]
6133  * \return in case of success the number of time steps available for the field with name \a fieldName.
6134  */
6135 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6136 {
6137   int nbFields=MEDnField(fid);
6138   bool found=false;
6139   std::vector<std::string> fns(nbFields);
6140   int nbOfStep2(-1);
6141   for(int i=0;i<nbFields && !found;i++)
6142     {
6143       std::string tmp;
6144       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6145       fns[i]=tmp;
6146       found=(tmp==fieldName);
6147       if(found)
6148         posCFormat=i;
6149     }
6150   if(!found)
6151     {
6152       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6153       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6154         oss << "\"" << *it << "\" ";
6155       throw INTERP_KERNEL::Exception(oss.str());
6156     }
6157   return nbOfStep2;
6158 }
6159
6160 /*!
6161  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6162  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6163  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6164  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6165  * to keep a valid instance.
6166  * 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.
6167  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6168  * 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.
6169  *
6170  * \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.
6171  * \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.
6172  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6173  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6174  * \param [in] newLocName is the new localization name.
6175  * \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.
6176  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6177  */
6178 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6179 {
6180   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6181   std::string oldPflName=disc->getProfile();
6182   std::vector<std::string> vv=getPflsReallyUsedMulti();
6183   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6184   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6185     {
6186       disc->setProfile(newPflName);
6187       DataArrayInt *pfl=getProfile(oldPflName.c_str());
6188       pfl->setName(newPflName);
6189     }
6190   else
6191     {
6192       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6193       throw INTERP_KERNEL::Exception(oss.str());
6194     }
6195 }
6196
6197 /*!
6198  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6199  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6200  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6201  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6202  * to keep a valid instance.
6203  * 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.
6204  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6205  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6206  * 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.
6207  *
6208  * \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.
6209  * \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.
6210  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6211  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6212  * \param [in] newLocName is the new localization name.
6213  * \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.
6214  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6215  */
6216 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6217 {
6218   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6219   std::string oldLocName=disc->getLocalization();
6220   std::vector<std::string> vv=getLocsReallyUsedMulti();
6221   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6222   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6223     {
6224       disc->setLocalization(newLocName);
6225       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6226       loc.setName(newLocName);
6227     }
6228   else
6229     {
6230       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6231       throw INTERP_KERNEL::Exception(oss.str());
6232     }
6233 }
6234
6235 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6236 {
6237   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6238   if(!ret)
6239     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6240   return ret;
6241 }
6242
6243 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6244 {
6245   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6246   if(!ret)
6247     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6248   return ret;
6249 }
6250
6251 /*!
6252  * This method alloc the arrays and load potentially huge arrays contained in this field.
6253  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6254  * This method can be also called to refresh or reinit values from a file.
6255  * 
6256  * \throw If the fileName is not set or points to a non readable MED file.
6257  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6258  */
6259 void MEDFileAnyTypeField1TS::loadArrays()
6260 {
6261   if(getFileName().empty())
6262     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6263   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6264   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6265 }
6266
6267 /*!
6268  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6269  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6270  * this method does not throw if \a this does not come from file read.
6271  * 
6272  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6273  */
6274 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6275 {
6276   if(!getFileName().empty())
6277     {
6278       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6279       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6280     }
6281 }
6282
6283 /*!
6284  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6285  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6286  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6287  * 
6288  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6289  */
6290 void MEDFileAnyTypeField1TS::unloadArrays()
6291 {
6292   contentNotNullBase()->unloadArrays();
6293 }
6294
6295 /*!
6296  * 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.
6297  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6298  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6299  * 
6300  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6301  */
6302 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6303 {
6304   if(!getFileName().empty())
6305     contentNotNullBase()->unloadArrays();
6306 }
6307
6308 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6309 {
6310   int nbComp(getNumberOfComponents());
6311   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6312   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6313   for(int i=0;i<nbComp;i++)
6314     {
6315       std::string info=getInfo()[i];
6316       std::string c,u;
6317       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6318       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6319       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6320     }
6321   if(getName().empty())
6322     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6323   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6324   writeGlobals(fid,*this);
6325   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6326 }
6327
6328 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6329 {
6330   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6331 }
6332
6333 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6334 {
6335   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6336   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6337   return ret;
6338 }
6339
6340 /*!
6341  * Returns a string describing \a this field. This string is outputted 
6342  * by \c print Python command.
6343  */
6344 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6345 {
6346   std::ostringstream oss;
6347   contentNotNullBase()->simpleRepr(0,oss,-1);
6348   simpleReprGlobs(oss);
6349   return oss.str();
6350 }
6351
6352 /*!
6353  * This method returns all profiles whose name is non empty used.
6354  * \b WARNING If profile is used several times it will be reported \b only \b once.
6355  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6356  */
6357 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6358 {
6359   return contentNotNullBase()->getPflsReallyUsed2();
6360 }
6361
6362 /*!
6363  * This method returns all localizations whose name is non empty used.
6364  * \b WARNING If localization is used several times it will be reported \b only \b once.
6365  */
6366 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6367 {
6368   return contentNotNullBase()->getLocsReallyUsed2();
6369 }
6370
6371 /*!
6372  * This method returns all profiles whose name is non empty used.
6373  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6374  */
6375 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6376 {
6377   return contentNotNullBase()->getPflsReallyUsedMulti2();
6378 }
6379
6380 /*!
6381  * This method returns all localizations whose name is non empty used.
6382  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6383  */
6384 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6385 {
6386   return contentNotNullBase()->getLocsReallyUsedMulti2();
6387 }
6388
6389 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6390 {
6391   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6392 }
6393
6394 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6395 {
6396   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6397 }
6398
6399 int MEDFileAnyTypeField1TS::getDimension() const
6400 {
6401   return contentNotNullBase()->getDimension();
6402 }
6403
6404 int MEDFileAnyTypeField1TS::getIteration() const
6405 {
6406   return contentNotNullBase()->getIteration();
6407 }
6408
6409 int MEDFileAnyTypeField1TS::getOrder() const
6410 {
6411   return contentNotNullBase()->getOrder();
6412 }
6413
6414 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6415 {
6416   return contentNotNullBase()->getTime(iteration,order);
6417 }
6418
6419 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6420 {
6421   contentNotNullBase()->setTime(iteration,order,val);
6422 }
6423
6424 std::string MEDFileAnyTypeField1TS::getName() const
6425 {
6426   return contentNotNullBase()->getName();
6427 }
6428
6429 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6430 {
6431   contentNotNullBase()->setName(name);
6432 }
6433
6434 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6435 {
6436   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6437 }
6438
6439 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6440 {
6441   return contentNotNullBase()->getDtUnit();
6442 }
6443
6444 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6445 {
6446   contentNotNullBase()->setDtUnit(dtUnit);
6447 }
6448
6449 std::string MEDFileAnyTypeField1TS::getMeshName() const
6450 {
6451   return contentNotNullBase()->getMeshName();
6452 }
6453
6454 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6455 {
6456   contentNotNullBase()->setMeshName(newMeshName);
6457 }
6458
6459 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6460 {
6461   return contentNotNullBase()->changeMeshNames(modifTab);
6462 }
6463
6464 int MEDFileAnyTypeField1TS::getMeshIteration() const
6465 {
6466   return contentNotNullBase()->getMeshIteration();
6467 }
6468
6469 int MEDFileAnyTypeField1TS::getMeshOrder() const
6470 {
6471   return contentNotNullBase()->getMeshOrder();
6472 }
6473
6474 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6475 {
6476   return contentNotNullBase()->getNumberOfComponents();
6477 }
6478
6479 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6480 {
6481   return contentNotNullBase()->isDealingTS(iteration,order);
6482 }
6483
6484 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6485 {
6486   return contentNotNullBase()->getDtIt();
6487 }
6488
6489 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6490 {
6491   contentNotNullBase()->fillIteration(p);
6492 }
6493
6494 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6495 {
6496   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6497 }
6498
6499 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6500 {
6501   contentNotNullBase()->setInfo(infos);
6502 }
6503
6504 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6505 {
6506   return contentNotNullBase()->getInfo();
6507 }
6508 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6509 {
6510   return contentNotNullBase()->getInfo();
6511 }
6512
6513 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6514 {
6515   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6516 }
6517
6518 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6519 {
6520   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6521 }
6522
6523 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6524 {
6525   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6526 }
6527
6528 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6529 {
6530   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6531 }
6532
6533 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6534 {
6535   return contentNotNullBase()->convertMedBallIntoClassic();
6536 }
6537
6538 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6539 {
6540   return contentNotNullBase()->makeReduction(ct,tof,pfl);
6541 }
6542
6543 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6544 {
6545   return contentNotNullBase()->getTypesOfFieldAvailable();
6546 }
6547
6548 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,
6549                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6550 {
6551   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6552 }
6553
6554 /*!
6555  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6556  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6557  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6558  */
6559 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6560 {
6561   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6562   if(!content)
6563     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6564   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6565   std::size_t sz(contentsSplit.size());
6566   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6567   for(std::size_t i=0;i<sz;i++)
6568     {
6569       ret[i]=shallowCpy();
6570       ret[i]->_content=contentsSplit[i];
6571     }
6572   return ret;
6573 }
6574
6575 /*!
6576  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6577  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6578  */
6579 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6580 {
6581   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6582   if(!content)
6583     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6584   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6585   std::size_t sz(contentsSplit.size());
6586   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6587   for(std::size_t i=0;i<sz;i++)
6588     {
6589       ret[i]=shallowCpy();
6590       ret[i]->_content=contentsSplit[i];
6591     }
6592   return ret;
6593 }
6594
6595 /*!
6596  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6597  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6598  */
6599 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6600 {
6601   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6602   if(!content)
6603     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6604   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6605   std::size_t sz(contentsSplit.size());
6606   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6607   for(std::size_t i=0;i<sz;i++)
6608     {
6609       ret[i]=shallowCpy();
6610       ret[i]->_content=contentsSplit[i];
6611     }
6612   return ret;
6613 }
6614
6615 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6616 {
6617   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6618   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6619     ret->_content=_content->deepCopy();
6620   ret->deepCpyGlobs(*this);
6621   return ret.retn();
6622 }
6623
6624 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6625 {
6626   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6627 }
6628
6629 //= MEDFileField1TS
6630
6631 /*!
6632  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6633  * the first field that has been read from a specified MED file.
6634  *  \param [in] fileName - the name of the MED file to read.
6635  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6636  *          is to delete this field using decrRef() as it is no more needed.
6637  *  \throw If reading the file fails.
6638  */
6639 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6640 {
6641   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6642   return New(fid,loadAll);
6643 }
6644
6645 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6646 {
6647   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6648   ret->contentNotNull();
6649   return ret.retn();
6650 }
6651
6652 /*!
6653  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6654  * a given field that has been read from a specified MED file.
6655  *  \param [in] fileName - the name of the MED file to read.
6656  *  \param [in] fieldName - the name of the field to read.
6657  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6658  *          is to delete this field using decrRef() as it is no more needed.
6659  *  \throw If reading the file fails.
6660  *  \throw If there is no field named \a fieldName in the file.
6661  */
6662 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6663 {
6664   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6665   return New(fid,fieldName,loadAll);
6666 }
6667
6668 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6669 {
6670   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6671   ret->contentNotNull();
6672   return ret.retn();
6673 }
6674
6675 /*!
6676  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6677  * a given field that has been read from a specified MED file.
6678  *  \param [in] fileName - the name of the MED file to read.
6679  *  \param [in] fieldName - the name of the field to read.
6680  *  \param [in] iteration - the iteration number of a required time step.
6681  *  \param [in] order - the iteration order number of required time step.
6682  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6683  *          is to delete this field using decrRef() as it is no more needed.
6684  *  \throw If reading the file fails.
6685  *  \throw If there is no field named \a fieldName in the file.
6686  *  \throw If the required time step is missing from the file.
6687  */
6688 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6689 {
6690   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6691   return New(fid,fieldName,iteration,order,loadAll);
6692 }
6693
6694 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6695 {
6696   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6697   ret->contentNotNull();
6698   return ret.retn();
6699 }
6700
6701 /*!
6702  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6703  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6704  *
6705  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6706  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6707  * \warning this is a shallow copy constructor
6708  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6709  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6710  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6711  *          is to delete this field using decrRef() as it is no more needed.
6712  */
6713 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6714 {
6715   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6716   ret->contentNotNull();
6717   return ret.retn();
6718 }
6719
6720 /*!
6721  * Returns a new empty instance of MEDFileField1TS.
6722  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6723  *          is to delete this field using decrRef() as it is no more needed.
6724  */
6725 MEDFileField1TS *MEDFileField1TS::New()
6726 {
6727   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6728   ret->contentNotNull();
6729   return ret.retn();
6730 }
6731
6732 /*!
6733  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6734  * following the given input policy.
6735  *
6736  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6737  *                            By default (true) the globals are deeply copied.
6738  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6739  */
6740 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6741 {
6742   MCAuto<MEDFileIntField1TS> ret;
6743   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6744   if(content)
6745     {
6746       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6747       if(!contc)
6748         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6749       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6750       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6751     }
6752   else
6753     ret=MEDFileIntField1TS::New();
6754   if(isDeepCpyGlobs)
6755     ret->deepCpyGlobs(*this);
6756   else
6757     ret->shallowCpyGlobs(*this);
6758   return ret.retn();
6759 }
6760
6761 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6762 {
6763   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6764   if(!pt)
6765     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6766   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6767   if(!ret)
6768     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 !");
6769   return ret;
6770 }
6771
6772 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6773 {
6774   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6775   if(!pt)
6776     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6777   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6778   if(!ret)
6779     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 !");
6780   return ret;
6781 }
6782
6783 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6784 {
6785   if(!f)
6786     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6787   if(arr.isNull())
6788     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6789   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6790   if(!arrOutC)
6791     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6792   f->setArray(arrOutC);
6793 }
6794
6795 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6796 {
6797   if(arr.isNull())
6798     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6799   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6800   if(!arrOutC)
6801     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6802   arrOutC->incrRef();
6803   return arrOutC;
6804 }
6805
6806 /*!
6807  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6808  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6809  *
6810  * \return A new object that the caller is responsible to deallocate.
6811  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6812  */
6813 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6814 {
6815   if(!mm)
6816     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6817   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6818   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6819   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6820     {
6821       if((*it0)!=ON_NODES)
6822         {
6823           std::vector<int> levs;
6824           getNonEmptyLevels(mm->getName(),levs);
6825           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6826             {
6827               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6828               if(it2!=extractDef.end())
6829                 {
6830                   MCAuto<DataArrayInt> t((*it2).second);
6831                   if(t.isNull())
6832                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6833                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6834                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6835                   ret->setFieldNoProfileSBT(fOut);
6836                 }
6837             }
6838         }
6839       else
6840         {
6841           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6842           if(it2==extractDef.end())
6843             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6844           MCAuto<DataArrayInt> t((*it2).second);
6845           if(t.isNull())
6846             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6847           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6848           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6849           DataArrayDouble *arr(f->getArray());
6850           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6851           fOut->setArray(newArr);
6852           ret->setFieldNoProfileSBT(fOut);
6853         }
6854     }
6855   return ret.retn();
6856 }
6857
6858 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6859 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6860 {
6861 }
6862 catch(INTERP_KERNEL::Exception& e)
6863 { throw e; }
6864
6865 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6866 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6867 {
6868 }
6869 catch(INTERP_KERNEL::Exception& e)
6870 { throw e; }
6871
6872 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6873 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6874 {
6875 }
6876 catch(INTERP_KERNEL::Exception& e)
6877 { throw e; }
6878
6879 /*!
6880  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6881  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6882  *
6883  * \warning this is a shallow copy constructor
6884  */
6885 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6886 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6887 {
6888 }
6889 catch(INTERP_KERNEL::Exception& e)
6890 { throw e; }
6891
6892 MEDFileField1TS::MEDFileField1TS()
6893 {
6894   _content=new MEDFileField1TSWithoutSDA;
6895 }
6896
6897 /*!
6898  * 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
6899  * method should be called (getFieldOnMeshAtLevel for example).
6900  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6901  *
6902  * \param [in] mesh - the mesh the field is lying on
6903  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6904  *          caller is to delete this field using decrRef() as it is no more needed. 
6905  */
6906 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6907 {
6908   MCAuto<DataArray> arrOut;
6909   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6910   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6911   return ret.retn();
6912 }
6913
6914 /*!
6915  * Returns a new MEDCouplingFieldDouble of a given type lying on
6916  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6917  * has not been constructed via file reading, an exception is thrown.
6918  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6919  *  \param [in] type - a spatial discretization of interest.
6920  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6921  *  \param [in] renumPol - specifies how to permute values of the result field according to
6922  *          the optional numbers of cells and nodes, if any. The valid values are
6923  *          - 0 - do not permute.
6924  *          - 1 - permute cells.
6925  *          - 2 - permute nodes.
6926  *          - 3 - permute cells and nodes.
6927  *
6928  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6929  *          caller is to delete this field using decrRef() as it is no more needed. 
6930  *  \throw If \a this field has not been constructed via file reading.
6931  *  \throw If the MED file is not readable.
6932  *  \throw If there is no mesh in the MED file.
6933  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6934  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6935  *  \sa getFieldOnMeshAtLevel()
6936  */
6937 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6938 {
6939   if(getFileName().empty())
6940     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6941   MCAuto<DataArray> arrOut;
6942   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6943   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6944   return ret.retn();
6945 }
6946
6947 /*!
6948  * Returns a new MEDCouplingFieldDouble of a given type lying on
6949  * the top level cells of the first mesh in MED file. If \a this field 
6950  * has not been constructed via file reading, an exception is thrown.
6951  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6952  *  \param [in] type - a spatial discretization of interest.
6953  *  \param [in] renumPol - specifies how to permute values of the result field according to
6954  *          the optional numbers of cells and nodes, if any. The valid values are
6955  *          - 0 - do not permute.
6956  *          - 1 - permute cells.
6957  *          - 2 - permute nodes.
6958  *          - 3 - permute cells and nodes.
6959  *
6960  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6961  *          caller is to delete this field using decrRef() as it is no more needed. 
6962  *  \throw If \a this field has not been constructed via file reading.
6963  *  \throw If the MED file is not readable.
6964  *  \throw If there is no mesh in the MED file.
6965  *  \throw If no field values of the given \a type.
6966  *  \throw If no field values lying on the top level support.
6967  *  \sa getFieldAtLevel()
6968  */
6969 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6970 {
6971   if(getFileName().empty())
6972     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6973   MCAuto<DataArray> arrOut;
6974   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6975   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6976   return ret.retn();
6977 }
6978
6979 /*!
6980  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6981  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6982  *  \param [in] type - a spatial discretization of the new field.
6983  *  \param [in] mesh - the supporting mesh.
6984  *  \param [in] renumPol - specifies how to permute values of the result field according to
6985  *          the optional numbers of cells and nodes, if any. The valid values are
6986  *          - 0 - do not permute.
6987  *          - 1 - permute cells.
6988  *          - 2 - permute nodes.
6989  *          - 3 - permute cells and nodes.
6990  *
6991  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6992  *          caller is to delete this field using decrRef() as it is no more needed. 
6993  *  \throw If no field of \a this is lying on \a mesh.
6994  *  \throw If the mesh is empty.
6995  *  \throw If no field values of the given \a type are available.
6996  *  \sa getFieldAtLevel()
6997  *  \sa getFieldOnMeshAtLevel() 
6998  */
6999 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7000 {
7001   MCAuto<DataArray> arrOut;
7002   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7003   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7004   return ret.retn();
7005 }
7006
7007 /*!
7008  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7009  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7010  *  \param [in] type - a spatial discretization of interest.
7011  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7012  *  \param [in] mesh - the supporting mesh.
7013  *  \param [in] renumPol - specifies how to permute values of the result field according to
7014  *          the optional numbers of cells and nodes, if any. The valid values are
7015  *          - 0 - do not permute.
7016  *          - 1 - permute cells.
7017  *          - 2 - permute nodes.
7018  *          - 3 - permute cells and nodes.
7019  *
7020  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7021  *          caller is to delete this field using decrRef() as it is no more needed. 
7022  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7023  *  \throw If no field of \a this is lying on \a mesh.
7024  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7025  *  \sa getFieldAtLevel()
7026  *  \sa getFieldOnMeshAtLevel() 
7027  */
7028 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7029 {
7030   MCAuto<DataArray> arrOut;
7031   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7032   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7033   return ret.retn();
7034 }
7035
7036 /*!
7037  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7038  * This method is called "Old" because in MED3 norm a field has only one meshName
7039  * attached, so this method is for readers of MED2 files. If \a this field 
7040  * has not been constructed via file reading, an exception is thrown.
7041  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7042  *  \param [in] type - a spatial discretization of interest.
7043  *  \param [in] mName - a name of the supporting mesh.
7044  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7045  *  \param [in] renumPol - specifies how to permute values of the result field according to
7046  *          the optional numbers of cells and nodes, if any. The valid values are
7047  *          - 0 - do not permute.
7048  *          - 1 - permute cells.
7049  *          - 2 - permute nodes.
7050  *          - 3 - permute cells and nodes.
7051  *
7052  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7053  *          caller is to delete this field using decrRef() as it is no more needed. 
7054  *  \throw If the MED file is not readable.
7055  *  \throw If there is no mesh named \a mName in the MED file.
7056  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7057  *  \throw If \a this field has not been constructed via file reading.
7058  *  \throw If no field of \a this is lying on the mesh named \a mName.
7059  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7060  *  \sa getFieldAtLevel()
7061  */
7062 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7063 {
7064   if(getFileName().empty())
7065     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7066   MCAuto<DataArray> arrOut;
7067   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7068   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7069   return ret.retn();
7070 }
7071
7072 /*!
7073  * Returns values and a profile of the field of a given type lying on a given support.
7074  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7075  *  \param [in] type - a spatial discretization of the field.
7076  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7077  *  \param [in] mesh - the supporting mesh.
7078  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7079  *          field of interest lies on. If the field lies on all entities of the given
7080  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7081  *          using decrRef() as it is no more needed.  
7082  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7083  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7084  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7085  *  \throw If no field of \a this is lying on \a mesh.
7086  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7087  */
7088 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7089 {
7090   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7091   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7092 }
7093
7094 /*!
7095  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7096  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7097  * "Sort By Type"), if not, an exception is thrown. 
7098  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7099  *  \param [in] field - the field to add to \a this.
7100  *  \throw If the name of \a field is empty.
7101  *  \throw If the data array of \a field is not set.
7102  *  \throw If the data array is already allocated but has different number of components
7103  *         than \a field.
7104  *  \throw If the underlying mesh of \a field has no name.
7105  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7106  */
7107 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7108 {
7109   setFileName("");
7110   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7111 }
7112
7113 /*!
7114  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7115  * can be an aggregation of several MEDCouplingFieldDouble instances.
7116  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7117  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7118  * and \a profile.
7119  *
7120  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7121  * A new profile is added only if no equal profile is missing.
7122  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7123  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7124  *  \param [in] mesh - the supporting mesh of \a field.
7125  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7126  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7127  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7128  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7129  *  \throw If the data array of \a field is not set.
7130  *  \throw If the data array of \a this is already allocated but has different number of
7131  *         components than \a field.
7132  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7133  *  \sa setFieldNoProfileSBT()
7134  */
7135 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7136 {
7137   setFileName("");
7138   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7139 }
7140
7141 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7142 {
7143   return new MEDFileField1TS(*this);
7144 }
7145
7146 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7147 {
7148   return contentNotNull()->getUndergroundDataArrayTemplate();
7149 }
7150
7151 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7152 {
7153   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7154 }
7155
7156 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7157                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7158 {
7159   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7160 }
7161
7162 //= MEDFileIntField1TS
7163
7164 MEDFileIntField1TS *MEDFileIntField1TS::New()
7165 {
7166   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7167   ret->contentNotNull();
7168   return ret.retn();
7169 }
7170
7171 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7172 {
7173   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7174   return MEDFileIntField1TS::New(fid,loadAll);
7175 }
7176
7177 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7178 {
7179   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7180   ret->contentNotNull();
7181   return ret.retn();
7182 }
7183
7184 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7185 {
7186   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7187   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7188 }
7189
7190 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7191 {
7192   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7193   ret->contentNotNull();
7194   return ret.retn();
7195 }
7196
7197 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7198 {
7199   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7200   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7201 }
7202
7203 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7204 {
7205   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7206   ret->contentNotNull();
7207   return ret.retn();
7208 }
7209
7210 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7211 {
7212   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7213   ret->contentNotNull();
7214   return ret.retn();
7215 }
7216
7217 MEDFileIntField1TS::MEDFileIntField1TS()
7218 {
7219   _content=new MEDFileIntField1TSWithoutSDA;
7220 }
7221
7222 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7223 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7224 {
7225 }
7226 catch(INTERP_KERNEL::Exception& e)
7227 { throw e; }
7228
7229 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7230 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7231 {
7232 }
7233 catch(INTERP_KERNEL::Exception& e)
7234 { throw e; }
7235
7236 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7237 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7238 {
7239 }
7240 catch(INTERP_KERNEL::Exception& e)
7241 { throw e; }
7242
7243 /*!
7244  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7245  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7246  *
7247  * \warning this is a shallow copy constructor
7248  */
7249 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7250 {
7251 }
7252
7253 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7254 {
7255   return new MEDFileIntField1TS(*this);
7256 }
7257
7258 /*!
7259  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7260  * following the given input policy.
7261  *
7262  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7263  *                            By default (true) the globals are deeply copied.
7264  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7265  */
7266 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7267 {
7268   MCAuto<MEDFileField1TS> ret;
7269   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7270   if(content)
7271     {
7272       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7273       if(!contc)
7274         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7275       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7276       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7277     }
7278   else
7279     ret=MEDFileField1TS::New();
7280   if(isDeepCpyGlobs)
7281     ret->deepCpyGlobs(*this);
7282   else
7283     ret->shallowCpyGlobs(*this);
7284   return ret.retn();
7285 }
7286
7287 /*!
7288  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7289  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7290  * "Sort By Type"), if not, an exception is thrown. 
7291  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7292  *  \param [in] field - the field to add to \a this.
7293  *  \throw If the name of \a field is empty.
7294  *  \throw If the data array of \a field is not set.
7295  *  \throw If the data array is already allocated but has different number of components
7296  *         than \a field.
7297  *  \throw If the underlying mesh of \a field has no name.
7298  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7299  */
7300 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7301 {
7302   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7303   setFileName("");
7304   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7305 }
7306
7307 /*!
7308  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7309  * can be an aggregation of several MEDCouplingFieldDouble instances.
7310  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7311  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7312  * and \a profile.
7313  *
7314  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7315  * A new profile is added only if no equal profile is missing.
7316  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7317  *  \param [in] field - the field to add to \a this.
7318  *  \param [in] mesh - the supporting mesh of \a field.
7319  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7320  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7321  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7322  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7323  *  \throw If the data array of \a field is not set.
7324  *  \throw If the data array of \a this is already allocated but has different number of
7325  *         components than \a field.
7326  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7327  *  \sa setFieldNoProfileSBT()
7328  */
7329 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7330 {
7331   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7332   setFileName("");
7333   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7334 }
7335
7336 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7337 {
7338   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7339   if(!pt)
7340     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7341   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7342   if(!ret)
7343     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 !");
7344   return ret;
7345 }
7346
7347 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7348 {
7349   if(getFileName().empty())
7350     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7351   MCAuto<DataArray> arrOut;
7352   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7353   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7354   return ret2.retn();
7355 }
7356
7357 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7358 {
7359   if(arr.isNull())
7360     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7361   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7362   if(!arrC)
7363     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7364   arrC->incrRef();
7365   return arrC;
7366 }
7367
7368 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7369 {
7370   int t1,t2;
7371   double t0(f->getTime(t1,t2));
7372   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7373   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7374   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7375   ret->setTime(t0,t1,t2); ret->setArray(arr2);
7376   return ret.retn();
7377 }
7378
7379 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7380 {
7381   if(!f)
7382     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7383   int t1,t2;
7384   double t0(f->getTime(t1,t2));
7385   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7386   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7387   ret->setTime(t0,t1,t2);
7388   return ret;
7389 }
7390
7391 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7392 {
7393   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7394 }
7395
7396 /*!
7397  * 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
7398  * method should be called (getFieldOnMeshAtLevel for example).
7399  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7400  *
7401  * \param [in] mesh - the mesh the field is lying on
7402  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7403  *          caller is to delete this field using decrRef() as it is no more needed. 
7404  */
7405 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7406 {
7407   MCAuto<DataArray> arrOut;
7408   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7409   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7410   return ret2.retn();
7411 }
7412
7413 /*!
7414  * Returns a new MEDCouplingFieldInt of a given type lying on
7415  * the top level cells of the first mesh in MED file. If \a this field 
7416  * has not been constructed via file reading, an exception is thrown.
7417  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7418  *  \param [in] type - a spatial discretization of interest.
7419  *  \param [in] renumPol - specifies how to permute values of the result field according to
7420  *          the optional numbers of cells and nodes, if any. The valid values are
7421  *          - 0 - do not permute.
7422  *          - 1 - permute cells.
7423  *          - 2 - permute nodes.
7424  *          - 3 - permute cells and nodes.
7425  *
7426  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7427  *          caller is to delete this field using decrRef() as it is no more needed. 
7428  *  \throw If \a this field has not been constructed via file reading.
7429  *  \throw If the MED file is not readable.
7430  *  \throw If there is no mesh in the MED file.
7431  *  \throw If no field values of the given \a type.
7432  *  \throw If no field values lying on the top level support.
7433  *  \sa getFieldAtLevel()
7434  */
7435 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7436 {
7437   if(getFileName().empty())
7438     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7439   MCAuto<DataArray> arrOut;
7440   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7441   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7442   return ret2.retn();
7443 }
7444
7445 /*!
7446  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7447  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7448  *  \param [in] type - a spatial discretization of the new field.
7449  *  \param [in] mesh - the supporting mesh.
7450  *  \param [in] renumPol - specifies how to permute values of the result field according to
7451  *          the optional numbers of cells and nodes, if any. The valid values are
7452  *          - 0 - do not permute.
7453  *          - 1 - permute cells.
7454  *          - 2 - permute nodes.
7455  *          - 3 - permute cells and nodes.
7456  *
7457  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7458  *          caller is to delete this field using decrRef() as it is no more needed. 
7459  *  \throw If no field of \a this is lying on \a mesh.
7460  *  \throw If the mesh is empty.
7461  *  \throw If no field values of the given \a type are available.
7462  *  \sa getFieldAtLevel()
7463  *  \sa getFieldOnMeshAtLevel() 
7464  */
7465 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7466 {
7467   MCAuto<DataArray> arrOut;
7468   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7469   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7470   return ret2.retn();
7471 }
7472
7473 /*!
7474  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7475  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7476  *  \param [in] type - a spatial discretization of interest.
7477  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7478  *  \param [in] mesh - the supporting mesh.
7479  *  \param [in] renumPol - specifies how to permute values of the result field according to
7480  *          the optional numbers of cells and nodes, if any. The valid values are
7481  *          - 0 - do not permute.
7482  *          - 1 - permute cells.
7483  *          - 2 - permute nodes.
7484  *          - 3 - permute cells and nodes.
7485  *
7486  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7487  *          caller is to delete this field using decrRef() as it is no more needed. 
7488  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7489  *  \throw If no field of \a this is lying on \a mesh.
7490  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7491  *  \sa getFieldAtLevel()
7492  *  \sa getFieldOnMeshAtLevel() 
7493  */
7494 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7495 {
7496   MCAuto<DataArray> arrOut;
7497   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7498   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7499   return ret2.retn();
7500 }
7501
7502 /*!
7503  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7504  * This method is called "Old" because in MED3 norm a field has only one meshName
7505  * attached, so this method is for readers of MED2 files. If \a this field 
7506  * has not been constructed via file reading, an exception is thrown.
7507  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7508  *  \param [in] type - a spatial discretization of interest.
7509  *  \param [in] mName - a name of the supporting mesh.
7510  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7511  *  \param [in] renumPol - specifies how to permute values of the result field according to
7512  *          the optional numbers of cells and nodes, if any. The valid values are
7513  *          - 0 - do not permute.
7514  *          - 1 - permute cells.
7515  *          - 2 - permute nodes.
7516  *          - 3 - permute cells and nodes.
7517  *
7518  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7519  *          caller is to delete this field using decrRef() as it is no more needed. 
7520  *  \throw If the MED file is not readable.
7521  *  \throw If there is no mesh named \a mName in the MED file.
7522  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7523  *  \throw If \a this field has not been constructed via file reading.
7524  *  \throw If no field of \a this is lying on the mesh named \a mName.
7525  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7526  *  \sa getFieldAtLevel()
7527  */
7528 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7529 {
7530   if(getFileName().empty())
7531     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7532   MCAuto<DataArray> arrOut;
7533   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7534   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7535   return ret2.retn();
7536 }
7537
7538 /*!
7539  * Returns values and a profile of the field of a given type lying on a given support.
7540  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7541  *  \param [in] type - a spatial discretization of the field.
7542  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7543  *  \param [in] mesh - the supporting mesh.
7544  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7545  *          field of interest lies on. If the field lies on all entities of the given
7546  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7547  *          using decrRef() as it is no more needed.  
7548  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7549  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7550  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7551  *  \throw If no field of \a this is lying on \a mesh.
7552  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7553  */
7554 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7555 {
7556   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7557   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7558 }
7559
7560 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7561 {
7562   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7563   if(!pt)
7564     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7565   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7566   if(!ret)
7567     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 !");
7568   return ret;
7569 }
7570
7571 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7572 {
7573   return contentNotNull()->getUndergroundDataArrayTemplate();
7574 }
7575
7576 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7577
7578 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7579 {
7580 }
7581
7582 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7583 {
7584 }
7585
7586 /*!
7587  * \param [in] fieldId field id in C mode
7588  */
7589 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7590 {
7591   med_field_type typcha;
7592   std::string dtunitOut;
7593   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7594   setDtUnit(dtunitOut.c_str());
7595   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7596 }
7597
7598 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7599 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7600 {
7601   setDtUnit(dtunit.c_str());
7602   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7603 }
7604 catch(INTERP_KERNEL::Exception& e)
7605 {
7606     throw e;
7607 }
7608
7609 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7610 {
7611   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7612   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7613     ret+=(*it).capacity();
7614   return ret;
7615 }
7616
7617 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7618 {
7619   std::vector<const BigMemoryObject *> ret;
7620   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7621     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7622   return ret;
7623 }
7624
7625 /*!
7626  * 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
7627  * NULL.
7628  */
7629 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7630 {
7631   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7632   ret->setInfo(_infos);
7633   int sz=(int)_time_steps.size();
7634   for(const int *id=startIds;id!=endIds;id++)
7635     {
7636       if(*id>=0 && *id<sz)
7637         {
7638           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7639           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7640           if(tse)
7641             {
7642               tse->incrRef();
7643               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7644             }
7645           ret->pushBackTimeStep(tse2);
7646         }
7647       else
7648         {
7649           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7650           oss << " ! Should be in [0," << sz << ") !";
7651           throw INTERP_KERNEL::Exception(oss.str());
7652         }
7653     }
7654   if(ret->getNumberOfTS()>0)
7655     ret->synchronizeNameScope();
7656   ret->copyNameScope(*this);
7657   return ret.retn();
7658 }
7659
7660 /*!
7661  * 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
7662  * NULL.
7663  */
7664 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7665 {
7666   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7667   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7668   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7669   ret->setInfo(_infos);
7670   int sz=(int)_time_steps.size();
7671   int j=bg;
7672   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7673     {
7674       if(j>=0 && j<sz)
7675         {
7676           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7677           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7678           if(tse)
7679             {
7680               tse->incrRef();
7681               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7682             }
7683           ret->pushBackTimeStep(tse2);
7684         }
7685       else
7686         {
7687           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7688           oss << " ! Should be in [0," << sz << ") !";
7689           throw INTERP_KERNEL::Exception(oss.str());
7690         }
7691     }
7692   if(ret->getNumberOfTS()>0)
7693     ret->synchronizeNameScope();
7694   ret->copyNameScope(*this);
7695   return ret.retn();
7696 }
7697
7698 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7699 {
7700   int id=0;
7701   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7702   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7703     {
7704       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7705       if(!cur)
7706         continue;
7707       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7708       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7709         ids->pushBackSilent(id);
7710     }
7711   return buildFromTimeStepIds(ids->begin(),ids->end());
7712 }
7713
7714 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7715 {
7716   int id=0;
7717   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7718   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7719     {
7720       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7721       if(!cur)
7722         continue;
7723       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7724       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7725         ids->pushBackSilent(id);
7726     }
7727   return buildFromTimeStepIds(ids->begin(),ids->end());
7728 }
7729
7730 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7731 {
7732   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7733     if((*it).isNotNull())
7734       if((*it)->presenceOfStructureElements())
7735         return true;
7736   return false;
7737 }
7738
7739 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7740 {
7741   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7742     if((*it).isNotNull())
7743       if(!(*it)->onlyStructureElements())
7744         return false;
7745   return true;
7746 }
7747
7748 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7749 {
7750   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7751   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7752     if((*it).isNotNull())
7753       {
7754         if((*it)->presenceOfStructureElements())
7755           {
7756             if(!(*it)->onlyStructureElements())
7757               {
7758                 (*it)->killStructureElements();
7759                 ret.push_back(*it);
7760               }
7761           }
7762         else
7763           {
7764             ret.push_back(*it);
7765           }
7766       }
7767   _time_steps=ret;
7768 }
7769
7770 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7771 {
7772   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7773   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7774     if((*it).isNotNull())
7775       {
7776         if((*it)->presenceOfStructureElements())
7777           {
7778             if(!(*it)->onlyStructureElements())
7779               (*it)->keepOnlyStructureElements();
7780             ret.push_back(*it);
7781           }
7782       }
7783   _time_steps=ret;
7784 }
7785
7786 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7787 {
7788   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7789   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7790     if((*it).isNotNull())
7791       (*it)->keepOnlyOnSE(seName);
7792 }
7793
7794 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7795 {
7796   std::vector< std::pair<std::string,std::string> > ps2;
7797   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7798     if((*it).isNotNull())
7799       {
7800         (*it)->getMeshSENames(ps2);
7801         break;
7802       }
7803   if(ps2.empty())
7804     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7805   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7806     if((*it).isNotNull())
7807       {
7808         std::vector< std::pair<std::string,std::string> > ps3;
7809         (*it)->getMeshSENames(ps3);
7810         if(ps2!=ps3)
7811           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7812       }
7813   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7814     {
7815       std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7816       if(it2==ps.end())
7817         ps.push_back(*it);
7818     }
7819 }
7820
7821 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7822 {
7823   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7824     {
7825       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7826       if(!cur)
7827         continue;
7828       if(cur->presenceOfMultiDiscPerGeoType())
7829         return true;
7830     }
7831   return false;
7832 }
7833
7834 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7835 {
7836   return _infos;
7837 }
7838
7839 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7840 {
7841   _infos=info;
7842 }
7843
7844 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7845 {
7846   int ret=0;
7847   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7848     {
7849       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7850       if(pt->isDealingTS(iteration,order))
7851         return ret;
7852     }
7853   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7854   std::vector< std::pair<int,int> > vp=getIterations();
7855   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7856     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7857   throw INTERP_KERNEL::Exception(oss.str());
7858 }
7859
7860 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7861 {
7862   return *_time_steps[getTimeStepPos(iteration,order)];
7863 }
7864
7865 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7866 {
7867   return *_time_steps[getTimeStepPos(iteration,order)];
7868 }
7869
7870 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7871 {
7872   if(_time_steps.empty())
7873     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7874   return _time_steps[0]->getMeshName();
7875 }
7876
7877 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7878 {
7879   std::string oldName(getMeshName());
7880   std::vector< std::pair<std::string,std::string> > v(1);
7881   v[0].first=oldName; v[0].second=newMeshName;
7882   changeMeshNames(v);
7883 }
7884
7885 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7886 {
7887   bool ret=false;
7888   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7889     {
7890       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7891       if(cur)
7892         ret=cur->changeMeshNames(modifTab) || ret;
7893     }
7894   return ret;
7895 }
7896
7897 /*!
7898  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7899  */
7900 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7901 {
7902   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7903 }
7904
7905 /*!
7906  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7907  */
7908 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7909 {
7910   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7911 }
7912
7913 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7914                                                                        MEDFileFieldGlobsReal& glob)
7915 {
7916   bool ret=false;
7917   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7918     {
7919       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7920       if(f1ts)
7921         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7922     }
7923   return ret;
7924 }
7925
7926 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7927 {
7928   std::string startLine(bkOffset,' ');
7929   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7930   if(fmtsId>=0)
7931     oss << " (" << fmtsId << ")";
7932   oss << " has the following name: \"" << _name << "\"." << std::endl;
7933   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7934   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7935     {
7936       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7937     }
7938   int i=0;
7939   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7940     {
7941       std::string chapter(17,'0'+i);
7942       oss << startLine << chapter << std::endl;
7943       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7944       if(cur)
7945         cur->simpleRepr(bkOffset+2,oss,i);
7946       else
7947         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7948       oss << startLine << chapter << std::endl;
7949     }
7950 }
7951
7952 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7953 {
7954   std::size_t sz=_time_steps.size();
7955   std::vector< std::pair<int,int> > ret(sz);
7956   ret1.resize(sz);
7957   for(std::size_t i=0;i<sz;i++)
7958     {
7959       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7960       if(f1ts)
7961         {
7962           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7963         }
7964       else
7965         {
7966           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7967           throw INTERP_KERNEL::Exception(oss.str());
7968         }
7969     }
7970   return ret;
7971 }
7972
7973 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7974 {
7975   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7976   if(!tse2)
7977     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7978   checkCoherencyOfType(tse2);
7979   if(_time_steps.empty())
7980     {
7981       setName(tse2->getName().c_str());
7982       setInfo(tse2->getInfo());
7983     }
7984   checkThatComponentsMatch(tse2->getInfo());
7985   if(getDtUnit().empty() && !tse->getDtUnit().empty())
7986     setDtUnit(tse->getDtUnit());
7987   _time_steps.push_back(tse);
7988 }
7989
7990 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7991 {
7992   std::size_t nbOfCompo=_infos.size();
7993   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7994     {
7995       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7996       if(cur)
7997         {
7998           if((cur->getInfo()).size()!=nbOfCompo)
7999             {
8000               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
8001               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
8002               throw INTERP_KERNEL::Exception(oss.str());
8003             }
8004           cur->copyNameScope(*this);
8005         }
8006     }
8007 }
8008
8009 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8010 {
8011   _time_steps.resize(nbPdt);
8012   for(int i=0;i<nbPdt;i++)
8013     {
8014       std::vector< std::pair<int,int> > ts;
8015       med_int numdt=0,numo=0;
8016       med_float dt=0.0;
8017       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
8018       switch(fieldTyp)
8019       {
8020         case MED_FLOAT64:
8021           {
8022             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8023             break;
8024           }
8025         case MED_INT32:
8026           {
8027             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8028             break;
8029           }
8030         default:
8031           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
8032       }
8033       if(loadAll)
8034         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
8035       else
8036         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
8037       synchronizeNameScope();
8038     }
8039 }
8040
8041 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
8042 {
8043   if(_time_steps.empty())
8044     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
8045   checkThatNbOfCompoOfTSMatchThis();
8046   std::vector<std::string> infos(getInfo());
8047   int nbComp=infos.size();
8048   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8049   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8050   for(int i=0;i<nbComp;i++)
8051     {
8052       std::string info=infos[i];
8053       std::string c,u;
8054       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
8055       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8056       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8057     }
8058   if(_name.empty())
8059     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
8060   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
8061   int nbOfTS=_time_steps.size();
8062   for(int i=0;i<nbOfTS;i++)
8063     _time_steps[i]->writeLL(fid,opts,*this);
8064 }
8065
8066 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
8067 {
8068   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8069     {
8070       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8071       if(elt)
8072         elt->loadBigArraysRecursively(fid,nasc);
8073     }
8074 }
8075
8076 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
8077 {
8078   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8079     {
8080       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8081       if(elt)
8082         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
8083     }
8084 }
8085
8086 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8087 {
8088   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8089     {
8090       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8091       if(elt)
8092         elt->unloadArrays();
8093     }
8094 }
8095
8096 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8097 {
8098   return _time_steps.size();
8099 }
8100
8101 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8102 {
8103   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
8104   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8105     {
8106       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8107       if(tmp)
8108         newTS.push_back(*it);
8109     }
8110   _time_steps=newTS;
8111 }
8112
8113 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8114 {
8115   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8116   int maxId=(int)_time_steps.size();
8117   int ii=0;
8118   std::set<int> idsToDel;
8119   for(const int *id=startIds;id!=endIds;id++,ii++)
8120     {
8121       if(*id>=0 && *id<maxId)
8122         {
8123           idsToDel.insert(*id);
8124         }
8125       else
8126         {
8127           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8128           throw INTERP_KERNEL::Exception(oss.str());
8129         }
8130     }
8131   for(int iii=0;iii<maxId;iii++)
8132     if(idsToDel.find(iii)==idsToDel.end())
8133       newTS.push_back(_time_steps[iii]);
8134   _time_steps=newTS;
8135 }
8136
8137 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8138 {
8139   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8140   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8141   if(nbOfEntriesToKill==0)
8142     return ;
8143   std::size_t sz=_time_steps.size();
8144   std::vector<bool> b(sz,true);
8145   int j=bg;
8146   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8147     b[j]=false;
8148   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8149   for(std::size_t i=0;i<sz;i++)
8150     if(b[i])
8151       newTS.push_back(_time_steps[i]);
8152   _time_steps=newTS;
8153 }
8154
8155 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8156 {
8157   int ret=0;
8158   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
8159   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8160     {
8161       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8162       if(tmp)
8163         {
8164           int it2,ord;
8165           tmp->getTime(it2,ord);
8166           if(it2==iteration && order==ord)
8167             return ret;
8168           else
8169             oss << "(" << it2 << ","  << ord << "), ";
8170         }
8171     }
8172   throw INTERP_KERNEL::Exception(oss.str());
8173 }
8174
8175 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8176 {
8177   int ret=0;
8178   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8179   oss.precision(15);
8180   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8181     {
8182       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8183       if(tmp)
8184         {
8185           int it2,ord;
8186           double ti=tmp->getTime(it2,ord);
8187           if(fabs(time-ti)<eps)
8188             return ret;
8189           else
8190             oss << ti << ", ";
8191         }
8192     }
8193   throw INTERP_KERNEL::Exception(oss.str());
8194 }
8195
8196 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8197 {
8198   int lgth=_time_steps.size();
8199   std::vector< std::pair<int,int> > ret(lgth);
8200   for(int i=0;i<lgth;i++)
8201     _time_steps[i]->fillIteration(ret[i]);
8202   return ret;
8203 }
8204
8205 /*!
8206  * 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'
8207  * This method returns two things.
8208  * - The absolute dimension of 'this' in first parameter. 
8209  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8210  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
8211  *
8212  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8213  * Only these 3 discretizations will be taken into account here.
8214  *
8215  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8216  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8217  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8218  *
8219  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8220  * 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'.
8221  * 
8222  * Let's consider the typical following case :
8223  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8224  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8225  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8226  *   TETRA4 and SEG2
8227  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8228  *
8229  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8230  * 
8231  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8232  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8233  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8234  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8235  */
8236 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8237 {
8238   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8239 }
8240
8241 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8242 {
8243   if(pos<0 || pos>=(int)_time_steps.size())
8244     {
8245       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8246       throw INTERP_KERNEL::Exception(oss.str());
8247     }
8248   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8249   if(item==0)
8250     {
8251       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8252       oss << "\nTry to use following method eraseEmptyTS !";
8253       throw INTERP_KERNEL::Exception(oss.str());
8254     }
8255   return item;
8256 }
8257
8258 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8259 {
8260   if(pos<0 || pos>=(int)_time_steps.size())
8261     {
8262       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8263       throw INTERP_KERNEL::Exception(oss.str());
8264     }
8265   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8266   if(item==0)
8267     {
8268       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8269       oss << "\nTry to use following method eraseEmptyTS !";
8270       throw INTERP_KERNEL::Exception(oss.str());
8271     }
8272   return item;
8273 }
8274
8275 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8276 {
8277   std::vector<std::string> ret;
8278   std::set<std::string> ret2;
8279   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8280     {
8281       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8282       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8283         if(ret2.find(*it2)==ret2.end())
8284           {
8285             ret.push_back(*it2);
8286             ret2.insert(*it2);
8287           }
8288     }
8289   return ret;
8290 }
8291
8292 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8293 {
8294   std::vector<std::string> ret;
8295   std::set<std::string> ret2;
8296   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8297     {
8298       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8299       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8300         if(ret2.find(*it2)==ret2.end())
8301           {
8302             ret.push_back(*it2);
8303             ret2.insert(*it2);
8304           }
8305     }
8306   return ret;
8307 }
8308
8309 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8310 {
8311   std::vector<std::string> ret;
8312   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8313     {
8314       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8315       ret.insert(ret.end(),tmp.begin(),tmp.end());
8316     }
8317   return ret;
8318 }
8319
8320 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8321 {
8322   std::vector<std::string> ret;
8323   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8324     {
8325       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8326       ret.insert(ret.end(),tmp.begin(),tmp.end());
8327     }
8328   return ret;
8329 }
8330
8331 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8332 {
8333   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8334     (*it)->changePflsRefsNamesGen2(mapOfModif);
8335 }
8336
8337 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8338 {
8339   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8340     (*it)->changeLocsRefsNamesGen2(mapOfModif);
8341 }
8342
8343 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8344 {
8345   int lgth=_time_steps.size();
8346   std::vector< std::vector<TypeOfField> > ret(lgth);
8347   for(int i=0;i<lgth;i++)
8348     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8349   return ret;
8350 }
8351
8352 /*!
8353  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8354  */
8355 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
8356 {
8357   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8358 }
8359
8360 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8361 {
8362   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8363   std::size_t i=0;
8364   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8365     {
8366       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8367         ret->_time_steps[i]=(*it)->deepCopy();
8368     }
8369   return ret.retn();
8370 }
8371
8372 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8373 {
8374   std::size_t sz(_infos.size()),sz2(_time_steps.size());
8375   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8376   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8377   for(std::size_t i=0;i<sz;i++)
8378     {
8379       ret[i]=shallowCpy();
8380       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8381     }
8382   for(std::size_t i=0;i<sz2;i++)
8383     {
8384       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8385       if(ret1.size()!=sz)
8386         {
8387           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8388           throw INTERP_KERNEL::Exception(oss.str());
8389         }
8390       ts[i]=ret1;
8391     }
8392   for(std::size_t i=0;i<sz;i++)
8393     for(std::size_t j=0;j<sz2;j++)
8394       ret[i]->_time_steps[j]=ts[j][i];
8395   return ret;
8396 }
8397
8398 /*!
8399  * This method splits into discretization each time steps in \a this.
8400  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8401  */
8402 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8403 {
8404   std::size_t sz(_time_steps.size());
8405   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8406   for(std::size_t i=0;i<sz;i++)
8407     {
8408       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8409       if(!timeStep)
8410         {
8411           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
8412           throw INTERP_KERNEL::Exception(oss.str());
8413         }
8414       items[i]=timeStep->splitDiscretizations();  
8415     }
8416   //
8417   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8418   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8419   std::vector< TypeOfField > types;
8420   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8421     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8422       {
8423         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8424         if(ts.size()!=1)
8425           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8426         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8427         if(it2==types.end())
8428           types.push_back(ts[0]);
8429       }
8430   ret.resize(types.size()); ret2.resize(types.size());
8431   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8432     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8433       {
8434         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8435         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8436         ret2[pos].push_back(*it1);
8437       }
8438   for(std::size_t i=0;i<types.size();i++)
8439     {
8440       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8441       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8442         elt->pushBackTimeStep(*it1);//also updates infos in elt
8443       ret[i]=elt;
8444       elt->MEDFileFieldNameScope::operator=(*this);
8445     }
8446   return ret;
8447 }
8448
8449 /*!
8450  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8451  */
8452 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8453 {
8454   std::size_t sz(_time_steps.size());
8455   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8456   std::size_t szOut(std::numeric_limits<std::size_t>::max());
8457   for(std::size_t i=0;i<sz;i++)
8458     {
8459       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8460       if(!timeStep)
8461         {
8462           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8463           throw INTERP_KERNEL::Exception(oss.str());
8464         }
8465       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8466       if(szOut==std::numeric_limits<std::size_t>::max())
8467         szOut=items[i].size();
8468       else
8469         if(items[i].size()!=szOut)
8470           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8471     }
8472   if(szOut==std::numeric_limits<std::size_t>::max())
8473     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8474   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8475   for(std::size_t i=0;i<szOut;i++)
8476     {
8477       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8478       for(std::size_t j=0;j<sz;j++)
8479         elt->pushBackTimeStep(items[j][i]);
8480       ret[i]=elt;
8481       elt->MEDFileFieldNameScope::operator=(*this);
8482     }
8483   return ret;
8484 }
8485
8486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8487 {
8488   _name=field->getName();
8489   if(_name.empty())
8490     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8491   if(!arr)
8492     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8493   _infos=arr->getInfoOnComponents();
8494 }
8495
8496 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8497 {
8498   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8499   if(_name!=field->getName())
8500     {
8501       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8502       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8503       throw INTERP_KERNEL::Exception(oss.str());
8504     }
8505   if(!arr)
8506     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8507   checkThatComponentsMatch(arr->getInfoOnComponents());
8508 }
8509
8510 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8511 {
8512   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8513   if(getInfo().size()!=compos.size())
8514     {
8515       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8516       oss << " number of components of element to append (" << compos.size() << ") !";
8517       throw INTERP_KERNEL::Exception(oss.str());
8518     }
8519   if(_infos!=compos)
8520     {
8521       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8522       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8523       oss << " But compo in input fields are : ";
8524       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8525       oss << " !";
8526       throw INTERP_KERNEL::Exception(oss.str());
8527     }
8528 }
8529
8530 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8531 {
8532   std::size_t sz=_infos.size();
8533   int j=0;
8534   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8535     {
8536       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8537       if(elt)
8538         if(elt->getInfo().size()!=sz)
8539           {
8540             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8541             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8542             throw INTERP_KERNEL::Exception(oss.str());
8543           }
8544     }
8545 }
8546
8547 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8548 {
8549   if(!field)
8550     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8551   if(!_time_steps.empty())
8552     checkCoherencyOfTinyInfo(field,arr);
8553   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8554   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8555   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8556   copyTinyInfoFrom(field,arr);
8557   _time_steps.push_back(obj);
8558 }
8559
8560 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8561 {
8562   if(!field)
8563     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8564   if(!_time_steps.empty())
8565     checkCoherencyOfTinyInfo(field,arr);
8566   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8567   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8568   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8569   copyTinyInfoFrom(field,arr);
8570   _time_steps.push_back(obj);
8571 }
8572
8573 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8574 {
8575   int sz=(int)_time_steps.size();
8576   if(i<0 || i>=sz)
8577     {
8578       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8579       throw INTERP_KERNEL::Exception(oss.str());
8580     }
8581   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8582   if(tsPtr)
8583     {
8584       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8585         {
8586           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8587           throw INTERP_KERNEL::Exception(oss.str());
8588         }
8589     }
8590   _time_steps[i]=ts;
8591 }
8592
8593 //= MEDFileFieldMultiTSWithoutSDA
8594
8595 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8596 {
8597   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8598 }
8599
8600 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8601 {
8602 }
8603
8604 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8605 {
8606 }
8607
8608 /*!
8609  * \param [in] fieldId field id in C mode
8610  */
8611 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8612 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8613 {
8614 }
8615 catch(INTERP_KERNEL::Exception& e)
8616 { throw e; }
8617
8618 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8619 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8620 {
8621 }
8622 catch(INTERP_KERNEL::Exception& e)
8623 { throw e; }
8624
8625 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8626 {
8627   return new MEDFileField1TSWithoutSDA;
8628 }
8629
8630 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8631 {
8632   if(!f1ts)
8633     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8634   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8635   if(!f1tsC)
8636     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8637 }
8638
8639 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8640 {
8641   return MEDFileField1TSWithoutSDA::TYPE_STR;
8642 }
8643
8644 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8645 {
8646   return new MEDFileFieldMultiTSWithoutSDA(*this);
8647 }
8648
8649 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8650 {
8651   return new MEDFileFieldMultiTSWithoutSDA;
8652 }
8653
8654 /*!
8655  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8656  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8657  */
8658 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
8659 {
8660   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8661   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8662   if(!myF1TSC)
8663     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8664   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8665 }
8666
8667 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8668 {
8669   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8670   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8671   int i=0;
8672   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8673     {
8674       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8675       if(eltToConv)
8676         {
8677           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8678           if(!eltToConvC)
8679             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8680           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8681           ret->setIteration(i,elt);
8682         }
8683     }
8684   return ret.retn();
8685 }
8686
8687 //= MEDFileAnyTypeFieldMultiTS
8688
8689 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8690 {
8691 }
8692
8693 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8694 try:MEDFileFieldGlobsReal(fid)
8695 {
8696   _content=BuildContentFrom(fid,loadAll,ms);
8697   loadGlobals(fid);
8698 }
8699 catch(INTERP_KERNEL::Exception& e)
8700 {
8701     throw e;
8702 }
8703
8704 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8705 {
8706   med_field_type typcha;
8707   std::vector<std::string> infos;
8708   std::string dtunit;
8709   int i(-1);
8710   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8711   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8712   switch(typcha)
8713   {
8714     case MED_FLOAT64:
8715       {
8716         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8717         break;
8718       }
8719     case MED_INT32:
8720       {
8721         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8722         break;
8723       }
8724     default:
8725       {
8726         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8727         throw INTERP_KERNEL::Exception(oss.str());
8728       }
8729   }
8730   ret->setDtUnit(dtunit.c_str());
8731   return ret.retn();
8732 }
8733
8734 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8735 {
8736   med_field_type typcha;
8737   //
8738   std::vector<std::string> infos;
8739   std::string dtunit,fieldName;
8740   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8741   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8742   switch(typcha)
8743   {
8744     case MED_FLOAT64:
8745       {
8746         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8747         break;
8748       }
8749     case MED_INT32:
8750       {
8751         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8752         break;
8753       }
8754     default:
8755       {
8756         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8757         throw INTERP_KERNEL::Exception(oss.str());
8758       }
8759   }
8760   ret->setDtUnit(dtunit.c_str());
8761   return ret.retn();
8762 }
8763
8764 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8765 {
8766   if(!c)
8767     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8768   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8769     {
8770       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8771       ret->_content=c;  c->incrRef();
8772       return ret.retn();
8773     }
8774   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8775     {
8776       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8777       ret->_content=c;  c->incrRef();
8778       return ret.retn();
8779     }
8780   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8781 }
8782
8783 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8784 {
8785   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8786   std::string fileName(FileNameFromFID(fid));
8787   ret->setFileName(fileName);
8788   return ret;
8789 }
8790
8791 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8792 try:MEDFileFieldGlobsReal(fid)
8793 {
8794   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8795   loadGlobals(fid);
8796 }
8797 catch(INTERP_KERNEL::Exception& e)
8798 {
8799     throw e;
8800 }
8801
8802 //= MEDFileIntFieldMultiTSWithoutSDA
8803
8804 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8805 {
8806   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8807 }
8808
8809 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8810 {
8811 }
8812
8813 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8814 {
8815 }
8816
8817 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8818 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8819 {
8820 }
8821 catch(INTERP_KERNEL::Exception& e)
8822 { throw e; }
8823
8824 /*!
8825  * \param [in] fieldId field id in C mode
8826  */
8827 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8828 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8829 {
8830 }
8831 catch(INTERP_KERNEL::Exception& e)
8832 { throw e; }
8833
8834 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8835 {
8836   return new MEDFileIntField1TSWithoutSDA;
8837 }
8838
8839 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8840 {
8841   if(!f1ts)
8842     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8843   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8844   if(!f1tsC)
8845     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8846 }
8847
8848 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8849 {
8850   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8851 }
8852
8853 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8854 {
8855   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8856 }
8857
8858 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8859 {
8860   return new MEDFileIntFieldMultiTSWithoutSDA;
8861 }
8862
8863 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8864 {
8865   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8866   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8867   int i=0;
8868   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8869     {
8870       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8871       if(eltToConv)
8872         {
8873           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8874           if(!eltToConvC)
8875             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8876           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8877           ret->setIteration(i,elt);
8878         }
8879     }
8880   return ret.retn();
8881 }
8882
8883 //= MEDFileAnyTypeFieldMultiTS
8884
8885 /*!
8886  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8887  * that has been read from a specified MED file.
8888  *  \param [in] fileName - the name of the MED file to read.
8889  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8890  *          is to delete this field using decrRef() as it is no more needed.
8891  *  \throw If reading the file fails.
8892  */
8893 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8894 {
8895   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8896   return New(fid,loadAll);
8897 }
8898
8899 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8900 {
8901   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8902   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8903   ret->loadGlobals(fid);
8904   return ret.retn();
8905 }
8906
8907 /*!
8908  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8909  * that has been read from a specified MED file.
8910  *  \param [in] fileName - the name of the MED file to read.
8911  *  \param [in] fieldName - the name of the field to read.
8912  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8913  *          is to delete this field using decrRef() as it is no more needed.
8914  *  \throw If reading the file fails.
8915  *  \throw If there is no field named \a fieldName in the file.
8916  */
8917 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8918 {
8919   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8920   return New(fid,fieldName,loadAll);
8921 }
8922
8923 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8924 {
8925   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8926   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8927   ret->loadGlobals(fid);
8928   return ret.retn();
8929 }
8930
8931 /*!
8932  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8933  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8934  *
8935  * \warning this is a shallow copy constructor
8936  */
8937 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8938 {
8939   if(!shallowCopyOfContent)
8940     {
8941       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8942       otherPtr->incrRef();
8943       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8944     }
8945   else
8946     {
8947       _content=other.shallowCpy();
8948     }
8949 }
8950
8951 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8952 {
8953   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8954   if(!ret)
8955     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8956   return ret;
8957 }
8958
8959 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8960 {
8961   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8962   if(!ret)
8963     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8964   return ret;
8965 }
8966
8967 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8968 {
8969   return contentNotNullBase()->getPflsReallyUsed2();
8970 }
8971
8972 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8973 {
8974   return contentNotNullBase()->getLocsReallyUsed2();
8975 }
8976
8977 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8978 {
8979   return contentNotNullBase()->getPflsReallyUsedMulti2();
8980 }
8981
8982 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8983 {
8984   return contentNotNullBase()->getLocsReallyUsedMulti2();
8985 }
8986
8987 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8988 {
8989   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8990 }
8991
8992 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8993 {
8994   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8995 }
8996
8997 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8998 {
8999   return contentNotNullBase()->getNumberOfTS();
9000 }
9001
9002 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
9003 {
9004   contentNotNullBase()->eraseEmptyTS();
9005 }
9006
9007 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
9008 {
9009   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
9010 }
9011
9012 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
9013 {
9014   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
9015 }
9016
9017 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
9018 {
9019   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
9020   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9021   ret->_content=c;
9022   return ret.retn();
9023 }
9024
9025 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
9026 {
9027   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
9028   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9029   ret->_content=c;
9030   return ret.retn();
9031 }
9032
9033 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
9034 {
9035   return contentNotNullBase()->getIterations();
9036 }
9037
9038 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
9039 {
9040   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
9041     pushBackTimeStep(*it);
9042 }
9043
9044 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
9045 {
9046   if(!fmts)
9047     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
9048   int nbOfTS(fmts->getNumberOfTS());
9049   for(int i=0;i<nbOfTS;i++)
9050     {
9051       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
9052       pushBackTimeStep(elt);
9053     }
9054 }
9055
9056 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
9057 {
9058   if(!f1ts)
9059     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
9060   checkCoherencyOfType(f1ts);
9061   f1ts->incrRef();
9062   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
9063   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
9064   c->incrRef();
9065   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
9066   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
9067     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
9068   _content->pushBackTimeStep(cSafe);
9069   appendGlobs(*f1ts,1e-12);
9070 }
9071
9072 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
9073 {
9074   contentNotNullBase()->synchronizeNameScope();
9075 }
9076
9077 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
9078 {
9079   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9080 }
9081
9082 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9083 {
9084   return contentNotNullBase()->getPosGivenTime(time,eps);
9085 }
9086
9087 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9088 {
9089   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9090 }
9091
9092 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9093 {
9094   return contentNotNullBase()->getTypesOfFieldAvailable();
9095 }
9096
9097 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
9098 {
9099   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9100 }
9101
9102 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9103 {
9104   return contentNotNullBase()->getName();
9105 }
9106
9107 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9108 {
9109   contentNotNullBase()->setName(name);
9110 }
9111
9112 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9113 {
9114   return contentNotNullBase()->getDtUnit();
9115 }
9116
9117 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9118 {
9119   contentNotNullBase()->setDtUnit(dtUnit);
9120 }
9121
9122 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9123 {
9124   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9125 }
9126
9127 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9128 {
9129   return contentNotNullBase()->getTimeSteps(ret1);
9130 }
9131
9132 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9133 {
9134   return contentNotNullBase()->getMeshName();
9135 }
9136
9137 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9138 {
9139   contentNotNullBase()->setMeshName(newMeshName);
9140 }
9141
9142 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9143 {
9144   return contentNotNullBase()->changeMeshNames(modifTab);
9145 }
9146
9147 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9148 {
9149   return contentNotNullBase()->getInfo();
9150 }
9151
9152 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9153 {
9154   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9155 }
9156
9157 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9158 {
9159   return contentNotNullBase()->setInfo(info);
9160 }
9161
9162 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9163 {
9164   const std::vector<std::string> ret=getInfo();
9165   return (int)ret.size();
9166 }
9167
9168 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9169 {
9170   writeGlobals(fid,*this);
9171   contentNotNullBase()->writeLL(fid,*this);
9172 }
9173
9174 /*!
9175  * This method alloc the arrays and load potentially huge arrays contained in this field.
9176  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9177  * This method can be also called to refresh or reinit values from a file.
9178  * 
9179  * \throw If the fileName is not set or points to a non readable MED file.
9180  */
9181 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9182 {
9183   if(getFileName().empty())
9184     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9185   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9186   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9187 }
9188
9189 /*!
9190  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9191  * But once data loaded once, this method does nothing.
9192  * 
9193  * \throw If the fileName is not set or points to a non readable MED file.
9194  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9195  */
9196 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9197 {
9198   if(!getFileName().empty())
9199     {
9200       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9201       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9202     }
9203 }
9204
9205 /*!
9206  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9207  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9208  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9209  * 
9210  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9211  */
9212 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9213 {
9214   contentNotNullBase()->unloadArrays();
9215 }
9216
9217 /*!
9218  * 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.
9219  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9220  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9221  * 
9222  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9223  */
9224 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9225 {
9226   if(!getFileName().empty())
9227     contentNotNullBase()->unloadArrays();
9228 }
9229
9230 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9231 {
9232   std::ostringstream oss;
9233   contentNotNullBase()->simpleRepr(0,oss,-1);
9234   simpleReprGlobs(oss);
9235   return oss.str();
9236 }
9237
9238 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9239 {
9240   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9241 }
9242
9243 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9244 {
9245   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9246   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9247   return ret;
9248 }
9249
9250 /*!
9251  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9252  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9253  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9254  */
9255 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9256 {
9257   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9258   if(!content)
9259     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9260   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9261   std::size_t sz(contentsSplit.size());
9262   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9263   for(std::size_t i=0;i<sz;i++)
9264     {
9265       ret[i]=shallowCpy();
9266       ret[i]->_content=contentsSplit[i];
9267     }
9268   return ret;
9269 }
9270
9271 /*!
9272  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9273  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9274  */
9275 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9276 {
9277   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9278   if(!content)
9279     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9280   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9281   std::size_t sz(contentsSplit.size());
9282   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9283   for(std::size_t i=0;i<sz;i++)
9284     {
9285       ret[i]=shallowCpy();
9286       ret[i]->_content=contentsSplit[i];
9287     }
9288   return ret;
9289 }
9290
9291 /*!
9292  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9293  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9294  */
9295 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9296 {
9297   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9298   if(!content)
9299     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9300   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9301   std::size_t sz(contentsSplit.size());
9302   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9303   for(std::size_t i=0;i<sz;i++)
9304     {
9305       ret[i]=shallowCpy();
9306       ret[i]->_content=contentsSplit[i];
9307     }
9308   return ret;
9309 }
9310
9311 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9312 {
9313   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9314   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9315     ret->_content=_content->deepCopy();
9316   ret->deepCpyGlobs(*this);
9317   return ret.retn();
9318 }
9319
9320 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9321 {
9322   return _content;
9323 }
9324
9325 /*!
9326  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9327  *  \param [in] iteration - the iteration number of a required time step.
9328  *  \param [in] order - the iteration order number of required time step.
9329  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9330  *          delete this field using decrRef() as it is no more needed.
9331  *  \throw If there is no required time step in \a this field.
9332  */
9333 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9334 {
9335   int pos=getPosOfTimeStep(iteration,order);
9336   return getTimeStepAtPos(pos);
9337 }
9338
9339 /*!
9340  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9341  *  \param [in] time - the time of the time step of interest.
9342  *  \param [in] eps - a precision used to compare time values.
9343  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9344  *          delete this field using decrRef() as it is no more needed.
9345  *  \throw If there is no required time step in \a this field.
9346  */
9347 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9348 {
9349   int pos=getPosGivenTime(time,eps);
9350   return getTimeStepAtPos(pos);
9351 }
9352
9353 /*!
9354  * 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.
9355  * The float64 value of time attached to the pair of integers are not considered here.
9356  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9357  *
9358  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9359  * \throw If there is a null pointer in \a vectFMTS.
9360  */
9361 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9362 {
9363   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9364   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9365   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9366   while(!lstFMTS.empty())
9367     {
9368       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9369       MEDFileAnyTypeFieldMultiTS *curIt(*it);
9370       if(!curIt)
9371         throw INTERP_KERNEL::Exception(msg);
9372       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9373       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9374       elt.push_back(curIt); it=lstFMTS.erase(it);
9375       while(it!=lstFMTS.end())
9376         {
9377           curIt=*it;
9378           if(!curIt)
9379             throw INTERP_KERNEL::Exception(msg);
9380           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9381           if(refIts==curIts)
9382             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9383           else
9384             it++;
9385         }
9386       ret.push_back(elt);
9387     }
9388   return ret;
9389 }
9390
9391 /*!
9392  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9393  * All returned instances in a subvector can be safely loaded, rendered along time
9394  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9395  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9396  * 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).
9397  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9398  * 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.
9399  *
9400  * \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().
9401  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9402  * \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.
9403  * \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.
9404  *
9405  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9406  * \throw If an element in \a vectFMTS change of spatial discretization along time.
9407  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9408  * \thorw If some elements in \a vectFMTS do not have the same times steps.
9409  * \throw If mesh is null.
9410  * \throw If an element in \a vectFMTS is null.
9411  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9412  */
9413 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9414 {
9415   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9416   if(!mesh)
9417     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9418   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9419   if(vectFMTS.empty())
9420     return ret;
9421   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9422   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9423   if(!frstElt)
9424     throw INTERP_KERNEL::Exception(msg);
9425   std::size_t i=0;
9426   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9427   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9428   for(;it!=vectFMTS.end();it++,i++)
9429     {
9430       if(!(*it))
9431         throw INTERP_KERNEL::Exception(msg);
9432       TypeOfField tof0,tof1;
9433       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9434         {
9435           if(tof1!=ON_NODES)
9436             vectFMTSNotNodes.push_back(*it);
9437           else
9438             vectFMTSNodes.push_back(*it);
9439         }
9440       else
9441         vectFMTSNotNodes.push_back(*it);
9442     }
9443   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9444   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9445   ret=retCell;
9446   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9447     {
9448       i=0;
9449       bool isFetched(false);
9450       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9451         {
9452           if((*it0).empty())
9453             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9454           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9455             { ret[i].push_back(*it2); isFetched=true; }
9456         }
9457       if(!isFetched)
9458         {
9459           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9460           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9461           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9462         }
9463     }
9464   fsc=cmps;
9465   return ret;
9466 }
9467
9468 /*!
9469  * 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.
9470  * \param [out] cmps - same size than the returned vector.
9471  */
9472 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9473 {
9474   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9475   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9476   while(!lstFMTS.empty())
9477     {
9478       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9479       MEDFileAnyTypeFieldMultiTS *ref(*it);
9480       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9481       elt.push_back(ref); it=lstFMTS.erase(it);
9482       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9483       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9484       while(it!=lstFMTS.end())
9485         {
9486           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9487           if(cmp->isEqual(curIt))
9488             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9489           else
9490             it++;
9491         }
9492       ret.push_back(elt); cmps.push_back(cmp);
9493     }
9494   return ret;
9495 }
9496
9497 /*!
9498  * 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.
9499  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9500  *
9501  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9502  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9503  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9504  * \thorw If \a f0 and \a f1 do not have the same times steps.
9505  * \throw If mesh is null.
9506  * \throw If \a f0 or \a f1 is null.
9507  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9508  */
9509 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9510 {
9511   if(!mesh)
9512     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9513   if(!f0 || !f1)
9514     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9515   if(f0->getMeshName()!=mesh->getName())
9516     {
9517       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9518       throw INTERP_KERNEL::Exception(oss.str());
9519     }
9520   if(f1->getMeshName()!=mesh->getName())
9521     {
9522       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9523       throw INTERP_KERNEL::Exception(oss.str());
9524     }
9525   int nts=f0->getNumberOfTS();
9526   if(nts!=f1->getNumberOfTS())
9527     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9528   if(nts==0)
9529     return nts;
9530   for(int i=0;i<nts;i++)
9531     {
9532       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9533       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9534       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9535       if(tofs0.size()!=1 || tofs1.size()!=1)
9536         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9537       if(i!=0)
9538         {
9539           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9540             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9541         }
9542       else
9543         { tof0=tofs0[0]; tof1=tofs1[0]; }
9544       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9545         {
9546           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() << ") !";
9547           throw INTERP_KERNEL::Exception(oss.str());
9548         }
9549       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9550         {
9551           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() << ") !";
9552           throw INTERP_KERNEL::Exception(oss.str());
9553         }
9554       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9555         {
9556           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() << ") !";
9557           throw INTERP_KERNEL::Exception(oss.str());
9558         }
9559     }
9560   return nts;
9561 }
9562
9563 /*!
9564  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9565  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9566  *
9567  * \return A new object that the caller is responsible to deallocate.
9568  */
9569 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9570 {
9571   if(!mm)
9572     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9573   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9574   int nbTS(getNumberOfTS());
9575   for(int i=0;i<nbTS;i++)
9576     {
9577       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9578       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9579       fmtsOut->pushBackTimeStep(f1tsOut);
9580     }
9581   return fmtsOut.retn();
9582 }
9583
9584 template<class T>
9585 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9586 {
9587   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9588   if(f1tss.empty())
9589     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9590   std::size_t sz(f1tss.size()),i(0);
9591   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9592   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9593     {
9594       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9595       if(!elt)
9596         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9597       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9598     }
9599   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9600   if(!retc)
9601     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9602   retc->aggregate(f1tsw,dts);
9603   ret->setDtUnit(f1tss[0]->getDtUnit());
9604   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9605 }
9606
9607 template<class T>
9608 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9609 {
9610   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9611   if(fmtss.empty())
9612     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9613   std::size_t sz(fmtss.size());
9614   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9615     {
9616       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9617       if(!elt)
9618         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9619     }
9620   int nbTS(fmtss[0]->getNumberOfTS());
9621   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9622     if((*it)->getNumberOfTS()!=nbTS)
9623       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9624   for(int iterTS=0;iterTS<nbTS;iterTS++)
9625     {
9626       std::size_t i(0);
9627       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9628       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9629       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9630         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9631       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9632       ret->pushBackTimeStep(f1ts);
9633       ret->setDtUnit(f1ts->getDtUnit());
9634     }
9635   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9636 }
9637
9638 /*!
9639  * \a dts and \a ftmss are expected to have same size.
9640  */
9641 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9642 {
9643   if(fmtss.empty())
9644     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9645   std::size_t sz(fmtss.size());
9646   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9647   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9648   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9649     {
9650       if(!(*it))
9651         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9652       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9653       if(elt1)
9654         {
9655           fmtss1.push_back(elt1);
9656           continue;
9657         }
9658       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9659       if(elt2)
9660         {
9661           fmtss2.push_back(elt2);
9662           continue;
9663         }
9664       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9665     }
9666   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9667     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9668   if(fmtss1.size()==sz)
9669     return AggregateHelperFMTS<double>(fmtss1,dts);
9670   if(fmtss2.size()!=sz)
9671     return AggregateHelperFMTS<int>(fmtss2,dts);
9672   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9673 }
9674
9675 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9676 {
9677   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9678 }
9679
9680 //= MEDFileFieldMultiTS
9681
9682 /*!
9683  * Returns a new empty instance of MEDFileFieldMultiTS.
9684  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9685  *          is to delete this field using decrRef() as it is no more needed.
9686  */
9687 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9688 {
9689   return new MEDFileFieldMultiTS;
9690 }
9691
9692 /*!
9693  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9694  * that has been read from a specified MED file.
9695  *  \param [in] fileName - the name of the MED file to read.
9696  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9697  *          is to delete this field using decrRef() as it is no more needed.
9698  *  \throw If reading the file fails.
9699  */
9700 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9701 {
9702   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9703   return New(fid,loadAll);
9704 }
9705
9706 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9707 {
9708   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9709   ret->contentNotNull();//to check that content type matches with \a this type.
9710   return ret.retn();
9711 }
9712
9713 /*!
9714  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9715  * that has been read from a specified MED file.
9716  *  \param [in] fileName - the name of the MED file to read.
9717  *  \param [in] fieldName - the name of the field to read.
9718  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9719  *          is to delete this field using decrRef() as it is no more needed.
9720  *  \throw If reading the file fails.
9721  *  \throw If there is no field named \a fieldName in the file.
9722  */
9723 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9724 {
9725   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9726   return New(fid,fieldName,loadAll);
9727 }
9728
9729 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9730 {
9731   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9732   ret->contentNotNull();//to check that content type matches with \a this type.
9733   return ret.retn();
9734 }
9735
9736 /*!
9737  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9738  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9739  *
9740  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9741  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9742  * \warning this is a shallow copy constructor
9743  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9744  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9745  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9746  *          is to delete this field using decrRef() as it is no more needed.
9747  */
9748 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9749 {
9750   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9751 }
9752
9753 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9754 {
9755   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9756   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9757   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9758   ret->contentNotNull();//to check that content type matches with \a this type.
9759   return ret.retn();
9760 }
9761
9762 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9763 {
9764   return new MEDFileFieldMultiTS(*this);
9765 }
9766
9767 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9768 {
9769   if(!f1ts)
9770     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9771   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9772   if(!f1tsC)
9773     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9774 }
9775
9776 /*!
9777  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9778  * following the given input policy.
9779  *
9780  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9781  *                            By default (true) the globals are deeply copied.
9782  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9783  */
9784 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9785 {
9786   MCAuto<MEDFileIntFieldMultiTS> ret;
9787   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9788   if(content)
9789     {
9790       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9791       if(!contc)
9792         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9793       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9794       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9795     }
9796   else
9797     ret=MEDFileIntFieldMultiTS::New();
9798   if(isDeepCpyGlobs)
9799     ret->deepCpyGlobs(*this);
9800   else
9801     ret->shallowCpyGlobs(*this);
9802   return ret.retn();
9803 }
9804
9805 /*!
9806  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9807  *  \param [in] pos - a time step id.
9808  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9809  *          delete this field using decrRef() as it is no more needed.
9810  *  \throw If \a pos is not a valid time step id.
9811  */
9812 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9813 {
9814   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9815   if(!item)
9816     {
9817       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9818       throw INTERP_KERNEL::Exception(oss.str());
9819     }
9820   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9821   if(itemC)
9822     {
9823       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9824       ret->shallowCpyGlobs(*this);
9825       return ret.retn();
9826     }
9827   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9828   throw INTERP_KERNEL::Exception(oss.str());
9829 }
9830
9831 /*!
9832  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9833  * mesh entities of a given dimension of the first mesh in MED file.
9834  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9835  *  \param [in] type - a spatial discretization of interest.
9836  *  \param [in] iteration - the iteration number of a required time step.
9837  *  \param [in] order - the iteration order number of required time step.
9838  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9839  *  \param [in] renumPol - specifies how to permute values of the result field according to
9840  *          the optional numbers of cells and nodes, if any. The valid values are
9841  *          - 0 - do not permute.
9842  *          - 1 - permute cells.
9843  *          - 2 - permute nodes.
9844  *          - 3 - permute cells and nodes.
9845  *
9846  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9847  *          caller is to delete this field using decrRef() as it is no more needed. 
9848  *  \throw If the MED file is not readable.
9849  *  \throw If there is no mesh in the MED file.
9850  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9851  *  \throw If no field values of the required parameters are available.
9852  */
9853 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9854 {
9855   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9856   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9857   if(!myF1TSC)
9858     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9859   MCAuto<DataArray> arrOut;
9860   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9861   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9862   return ret.retn();
9863 }
9864
9865 /*!
9866  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9867  * the top level cells of the first mesh in MED file.
9868  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9869  *  \param [in] type - a spatial discretization of interest.
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] renumPol - specifies how to permute values of the result field according to
9873  *          the optional numbers of cells and nodes, if any. The valid values are
9874  *          - 0 - do not permute.
9875  *          - 1 - permute cells.
9876  *          - 2 - permute nodes.
9877  *          - 3 - permute cells and nodes.
9878  *
9879  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9880  *          caller is to delete this field using decrRef() as it is no more needed. 
9881  *  \throw If the MED file is not readable.
9882  *  \throw If there is no mesh in the MED file.
9883  *  \throw If no field values of the required parameters are available.
9884  */
9885 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9886 {
9887   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9888   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9889   if(!myF1TSC)
9890     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9891   MCAuto<DataArray> arrOut;
9892   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9893   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9894   return ret.retn();
9895 }
9896
9897 /*!
9898  * 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
9899  * method should be called (getFieldOnMeshAtLevel for example).
9900  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9901  *
9902  * \param [in] iteration - the iteration number of a required time step.
9903  * \param [in] order - the iteration order number of required time step.
9904  * \param [in] mesh - the mesh the field is lying on
9905  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9906  *          caller is to delete this field using decrRef() as it is no more needed. 
9907  */
9908 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9909 {
9910   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9911   MCAuto<DataArray> arrOut;
9912   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9913   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9914   return ret.retn();
9915 }
9916
9917 /*!
9918  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9919  * a given support.
9920  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9921  *  \param [in] type - a spatial discretization of interest.
9922  *  \param [in] iteration - the iteration number of a required time step.
9923  *  \param [in] order - the iteration order number of required time step.
9924  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9925  *  \param [in] mesh - the supporting mesh.
9926  *  \param [in] renumPol - specifies how to permute values of the result field according to
9927  *          the optional numbers of cells and nodes, if any. The valid values are
9928  *          - 0 - do not permute.
9929  *          - 1 - permute cells.
9930  *          - 2 - permute nodes.
9931  *          - 3 - permute cells and nodes.
9932  *
9933  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9934  *          caller is to delete this field using decrRef() as it is no more needed. 
9935  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9936  *  \throw If no field of \a this is lying on \a mesh.
9937  *  \throw If no field values of the required parameters are available.
9938  */
9939 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9940 {
9941   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9942   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9943   if(!myF1TSC)
9944     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9945   MCAuto<DataArray> arrOut;
9946   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9947   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9948   return ret.retn();
9949 }
9950
9951 /*!
9952  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9953  * given support. 
9954  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9955  *  \param [in] type - a spatial discretization of the new field.
9956  *  \param [in] iteration - the iteration number of a required time step.
9957  *  \param [in] order - the iteration order number of required time step.
9958  *  \param [in] mesh - the supporting mesh.
9959  *  \param [in] renumPol - specifies how to permute values of the result field according to
9960  *          the optional numbers of cells and nodes, if any. The valid values are
9961  *          - 0 - do not permute.
9962  *          - 1 - permute cells.
9963  *          - 2 - permute nodes.
9964  *          - 3 - permute cells and nodes.
9965  *
9966  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9967  *          caller is to delete this field using decrRef() as it is no more needed. 
9968  *  \throw If no field of \a this is lying on \a mesh.
9969  *  \throw If no field values of the required parameters are available.
9970  */
9971 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9972 {
9973   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9974   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9975   if(!myF1TSC)
9976     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9977   MCAuto<DataArray> arrOut;
9978   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9979   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9980   return ret.retn();
9981 }
9982
9983 /*!
9984  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9985  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9986  * This method is useful for MED2 file format when field on different mesh was autorized.
9987  */
9988 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9989 {
9990   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9991   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9992   if(!myF1TSC)
9993     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9994   MCAuto<DataArray> arrOut;
9995   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9996   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9997   return ret.retn();
9998 }
9999
10000 /*!
10001  * Returns values and a profile of the field of a given type, of a given time step,
10002  * lying on a given support.
10003  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10004  *  \param [in] type - a spatial discretization of the field.
10005  *  \param [in] iteration - the iteration number of a required time step.
10006  *  \param [in] order - the iteration order number of required time step.
10007  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10008  *  \param [in] mesh - the supporting mesh.
10009  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10010  *          field of interest lies on. If the field lies on all entities of the given
10011  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10012  *          using decrRef() as it is no more needed.  
10013  *  \param [in] glob - the global data storing profiles and localization.
10014  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
10015  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10016  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10017  *  \throw If no field of \a this is lying on \a mesh.
10018  *  \throw If no field values of the required parameters are available.
10019  */
10020 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10021 {
10022   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10023   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10024   if(!myF1TSC)
10025     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
10026   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10027   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
10028 }
10029
10030 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
10031 {
10032   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10033   if(!pt)
10034     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
10035   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
10036   if(!ret)
10037     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 !");
10038   return ret;
10039 }
10040
10041 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
10042 {
10043   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10044   if(!pt)
10045     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
10046   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
10047   if(!ret)
10048     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 !");
10049   return ret;
10050 }
10051
10052 /*!
10053  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
10054  * the given field is checked if its elements are sorted suitable for writing to MED file
10055  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10056  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10057  *  \param [in] field - the field to add to \a this.
10058  *  \throw If the name of \a field is empty.
10059  *  \throw If the data array of \a field is not set.
10060  *  \throw If existing time steps have different name or number of components than \a field.
10061  *  \throw If the underlying mesh of \a field has no name.
10062  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10063  */
10064 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
10065 {
10066   const DataArrayDouble *arr=0;
10067   if(field)
10068     arr=field->getArray();
10069   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
10070 }
10071
10072 /*!
10073  * Adds a MEDCouplingFieldDouble to \a this as another time step.
10074  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10075  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10076  * and \a profile.
10077  *
10078  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10079  * A new profile is added only if no equal profile is missing.
10080  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10081  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10082  *  \param [in] mesh - the supporting mesh of \a field.
10083  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10084  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10085  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10086  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10087  *  \throw If the data array of \a field is not set.
10088  *  \throw If the data array of \a this is already allocated but has different number of
10089  *         components than \a field.
10090  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10091  *  \sa setFieldNoProfileSBT()
10092  */
10093 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10094 {
10095   const DataArrayDouble *arr=0;
10096   if(field)
10097     arr=field->getArray();
10098   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10099 }
10100
10101 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10102 {
10103   _content=new MEDFileFieldMultiTSWithoutSDA;
10104 }
10105
10106 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10107 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10108 {
10109 }
10110 catch(INTERP_KERNEL::Exception& e)
10111 { throw e; }
10112
10113 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10114 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10115 {
10116 }
10117 catch(INTERP_KERNEL::Exception& e)
10118 { throw e; }
10119
10120 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10121 {
10122 }
10123
10124 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
10125 {
10126   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10127 }
10128
10129 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10130 {
10131   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10132 }
10133
10134 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10135 {
10136   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10137 }
10138
10139 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10140 {
10141   return MEDFileFieldMultiTS::New();
10142 }
10143
10144 //= MEDFileAnyTypeFieldMultiTSIterator
10145
10146 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10147 {
10148   if(fmts)
10149     {
10150       fmts->incrRef();
10151       _nb_iter=fmts->getNumberOfTS();
10152     }
10153 }
10154
10155 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
10156 {
10157 }
10158
10159 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10160 {
10161   if(_iter_id<_nb_iter)
10162     {
10163       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10164       if(fmts)
10165         return fmts->getTimeStepAtPos(_iter_id++);
10166       else
10167         return 0;
10168     }
10169   else
10170     return 0;
10171 }
10172
10173 //= MEDFileIntFieldMultiTS
10174
10175 /*!
10176  * Returns a new empty instance of MEDFileFieldMultiTS.
10177  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10178  *          is to delete this field using decrRef() as it is no more needed.
10179  */
10180 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10181 {
10182   return new MEDFileIntFieldMultiTS;
10183 }
10184
10185 /*!
10186  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10187  * that has been read from a specified MED file.
10188  *  \param [in] fileName - the name of the MED file to read.
10189  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10190  *          is to delete this field using decrRef() as it is no more needed.
10191  *  \throw If reading the file fails.
10192  */
10193 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10194 {
10195   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10196   return New(fid,loadAll);
10197 }
10198
10199 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10200 {
10201   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10202   ret->contentNotNull();//to check that content type matches with \a this type.
10203   return ret.retn();
10204 }
10205
10206 /*!
10207  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10208  * that has been read from a specified MED file.
10209  *  \param [in] fileName - the name of the MED file to read.
10210  *  \param [in] fieldName - the name of the field to read.
10211  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10212  *          is to delete this field using decrRef() as it is no more needed.
10213  *  \throw If reading the file fails.
10214  *  \throw If there is no field named \a fieldName in the file.
10215  */
10216 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10217 {
10218   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10219   return New(fid,fieldName,loadAll);
10220 }
10221
10222 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10223 {
10224   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10225   ret->contentNotNull();//to check that content type matches with \a this type.
10226   return ret.retn();
10227 }
10228
10229 /*!
10230  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10231  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10232  *
10233  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10234  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10235  * \warning this is a shallow copy constructor
10236  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10237  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10238  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10239  *          is to delete this field using decrRef() as it is no more needed.
10240  */
10241 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10242 {
10243   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10244 }
10245
10246 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10247 {
10248   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10249   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10250   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10251   ret->contentNotNull();//to check that content type matches with \a this type.
10252   return ret.retn();
10253 }
10254
10255 /*!
10256  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10257  * following the given input policy.
10258  *
10259  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10260  *                            By default (true) the globals are deeply copied.
10261  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10262  */
10263 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10264 {
10265   MCAuto<MEDFileFieldMultiTS> ret;
10266   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10267   if(content)
10268     {
10269       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10270       if(!contc)
10271         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10272       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10273       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10274     }
10275   else
10276     ret=MEDFileFieldMultiTS::New();
10277   if(isDeepCpyGlobs)
10278     ret->deepCpyGlobs(*this);
10279   else
10280     ret->shallowCpyGlobs(*this);
10281   return ret.retn();
10282 }
10283
10284 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10285 {
10286   return new MEDFileIntFieldMultiTS(*this);
10287 }
10288
10289 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10290 {
10291   if(!f1ts)
10292     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10293   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10294   if(!f1tsC)
10295     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10296 }
10297
10298 /*!
10299  * 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
10300  * method should be called (getFieldOnMeshAtLevel for example).
10301  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10302  *
10303  * \param [in] iteration - the iteration number of a required time step.
10304  * \param [in] order - the iteration order number of required time step.
10305  * \param [in] mesh - the mesh the field is lying on
10306  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10307  *          caller is to delete this field using decrRef() as it is no more needed. 
10308  */
10309 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10310 {
10311   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10312   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10313   if(!myF1TSC)
10314     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10315   MCAuto<DataArray> arrOut;
10316   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10317   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10318   return ret2.retn();
10319 }
10320
10321 /*!
10322  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10323  * mesh entities of a given dimension of the first mesh in MED file.
10324  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10325  *  \param [in] type - a spatial discretization of interest.
10326  *  \param [in] iteration - the iteration number of a required time step.
10327  *  \param [in] order - the iteration order number of required time step.
10328  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10329  *  \param [in] renumPol - specifies how to permute values of the result field according to
10330  *          the optional numbers of cells and nodes, if any. The valid values are
10331  *          - 0 - do not permute.
10332  *          - 1 - permute cells.
10333  *          - 2 - permute nodes.
10334  *          - 3 - permute cells and nodes.
10335  *
10336  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10337  *          caller is to delete this field using decrRef() as it is no more needed. 
10338  *  \throw If the MED file is not readable.
10339  *  \throw If there is no mesh in the MED file.
10340  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10341  *  \throw If no field values of the required parameters are available.
10342  */
10343 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10344 {
10345   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10346   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10347   if(!myF1TSC)
10348     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10349   MCAuto<DataArray> arr;
10350   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10351   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10352   return ret2.retn();
10353 }
10354
10355 /*!
10356  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10357  * the top level cells of the first mesh in MED file.
10358  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10359  *  \param [in] type - a spatial discretization of interest.
10360  *  \param [in] iteration - the iteration number of a required time step.
10361  *  \param [in] order - the iteration order number of required time step.
10362  *  \param [in] renumPol - specifies how to permute values of the result field according to
10363  *          the optional numbers of cells and nodes, if any. The valid values are
10364  *          - 0 - do not permute.
10365  *          - 1 - permute cells.
10366  *          - 2 - permute nodes.
10367  *          - 3 - permute cells and nodes.
10368  *
10369  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10370  *          caller is to delete this field using decrRef() as it is no more needed. 
10371  *  \throw If the MED file is not readable.
10372  *  \throw If there is no mesh in the MED file.
10373  *  \throw If no field values of the required parameters are available.
10374  */
10375 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10376 {
10377   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10378   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10379   if(!myF1TSC)
10380     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10381   MCAuto<DataArray> arr;
10382   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10383   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10384   return ret2.retn();
10385 }
10386
10387 /*!
10388  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10389  * a given support.
10390  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10391  *  \param [in] type - a spatial discretization of interest.
10392  *  \param [in] iteration - the iteration number of a required time step.
10393  *  \param [in] order - the iteration order number of required time step.
10394  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10395  *  \param [in] mesh - the supporting mesh.
10396  *  \param [in] renumPol - specifies how to permute values of the result field according to
10397  *          the optional numbers of cells and nodes, if any. The valid values are
10398  *          - 0 - do not permute.
10399  *          - 1 - permute cells.
10400  *          - 2 - permute nodes.
10401  *          - 3 - permute cells and nodes.
10402  *
10403  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10404  *          caller is to delete this field using decrRef() as it is no more needed. 
10405  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10406  *  \throw If no field of \a this is lying on \a mesh.
10407  *  \throw If no field values of the required parameters are available.
10408  */
10409 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10410 {
10411   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10412   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10413   if(!myF1TSC)
10414     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10415   MCAuto<DataArray> arr;
10416   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10417   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10418   return ret2.retn();
10419 }
10420
10421 /*!
10422  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10423  * given support. 
10424  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10425  *  \param [in] type - a spatial discretization of the new field.
10426  *  \param [in] iteration - the iteration number of a required time step.
10427  *  \param [in] order - the iteration order number of required time step.
10428  *  \param [in] mesh - the supporting mesh.
10429  *  \param [out] arrOut - the DataArrayInt containing values of field.
10430  *  \param [in] renumPol - specifies how to permute values of the result field according to
10431  *          the optional numbers of cells and nodes, if any. The valid values are
10432  *          - 0 - do not permute.
10433  *          - 1 - permute cells.
10434  *          - 2 - permute nodes.
10435  *          - 3 - permute cells and nodes.
10436  *
10437  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10438  *          caller is to delete this field using decrRef() as it is no more needed. 
10439  *  \throw If no field of \a this is lying on \a mesh.
10440  *  \throw If no field values of the required parameters are available.
10441  */
10442 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10443 {
10444   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10445   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10446   if(!myF1TSC)
10447     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10448   MCAuto<DataArray> arr;
10449   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10450   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10451   return ret2.retn();
10452 }
10453
10454 /*!
10455  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10456  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10457  * This method is useful for MED2 file format when field on different mesh was autorized.
10458  */
10459 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10460 {
10461   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10462   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10463   if(!myF1TSC)
10464     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10465   MCAuto<DataArray> arr;
10466   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10467   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10468   return ret2.retn();
10469 }
10470
10471 /*!
10472  * Returns values and a profile of the field of a given type, of a given time step,
10473  * lying on a given support.
10474  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10475  *  \param [in] type - a spatial discretization of the field.
10476  *  \param [in] iteration - the iteration number of a required time step.
10477  *  \param [in] order - the iteration order number of required time step.
10478  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10479  *  \param [in] mesh - the supporting mesh.
10480  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10481  *          field of interest lies on. If the field lies on all entities of the given
10482  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10483  *          using decrRef() as it is no more needed.  
10484  *  \param [in] glob - the global data storing profiles and localization.
10485  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10486  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10487  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10488  *  \throw If no field of \a this is lying on \a mesh.
10489  *  \throw If no field values of the required parameters are available.
10490  */
10491 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10492 {
10493   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10494   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10495   if(!myF1TSC)
10496     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10497   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10498   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10499 }
10500
10501 /*!
10502  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10503  *  \param [in] pos - a time step id.
10504  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10505  *          delete this field using decrRef() as it is no more needed.
10506  *  \throw If \a pos is not a valid time step id.
10507  */
10508 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10509 {
10510   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10511   if(!item)
10512     {
10513       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10514       throw INTERP_KERNEL::Exception(oss.str());
10515     }
10516   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10517   if(itemC)
10518     {
10519       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10520       ret->shallowCpyGlobs(*this);
10521       return ret.retn();
10522     }
10523   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10524   throw INTERP_KERNEL::Exception(oss.str());
10525 }
10526
10527 /*!
10528  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10529  * the given field is checked if its elements are sorted suitable for writing to MED file
10530  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10531  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10532  *  \param [in] field - the field to add to \a this.
10533  *  \throw If the name of \a field is empty.
10534  *  \throw If the data array of \a field is not set.
10535  *  \throw If existing time steps have different name or number of components than \a field.
10536  *  \throw If the underlying mesh of \a field has no name.
10537  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10538  */
10539 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10540 {
10541   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10542   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10543 }
10544
10545 /*!
10546  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10547  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10548  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10549  * and \a profile.
10550  *
10551  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10552  * A new profile is added only if no equal profile is missing.
10553  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10554  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10555  *  \param [in] arrOfVals - the values of the field \a field used.
10556  *  \param [in] mesh - the supporting mesh of \a field.
10557  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10558  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10559  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10560  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10561  *  \throw If the data array of \a field is not set.
10562  *  \throw If the data array of \a this is already allocated but has different number of
10563  *         components than \a field.
10564  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10565  *  \sa setFieldNoProfileSBT()
10566  */
10567 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10568 {
10569   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10570   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10571 }
10572
10573 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10574 {
10575   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10576   if(!pt)
10577     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10578   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10579   if(!ret)
10580     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 !");
10581   return ret;
10582 }
10583
10584 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10585 {
10586   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10587   if(!pt)
10588     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10589   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10590   if(!ret)
10591     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 !");
10592   return ret;
10593 }
10594
10595 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10596 {
10597   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10598 }
10599
10600 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10601 {
10602 }
10603
10604 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10605 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10606 {
10607 }
10608 catch(INTERP_KERNEL::Exception& e)
10609 { throw e; }
10610
10611 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10612 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10613 {
10614 }
10615 catch(INTERP_KERNEL::Exception& e)
10616 { throw e; }
10617
10618 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10619 {
10620   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10621 }
10622
10623 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10624 {
10625   return MEDFileIntFieldMultiTS::New();
10626 }
10627
10628 //= MEDFileFields
10629
10630 MEDFileFields *MEDFileFields::New()
10631 {
10632   return new MEDFileFields;
10633 }
10634
10635 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10636 {
10637   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10638   return New(fid,loadAll);
10639 }
10640
10641 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10642 {
10643   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10644   return NewWithDynGT(fid,se,loadAll);
10645 }
10646
10647 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10648 {
10649   if(!se)
10650     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10651   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10652   return new MEDFileFields(fid,loadAll,0,entities);
10653 }
10654
10655 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10656 {
10657   return new MEDFileFields(fid,loadAll,0,0);
10658 }
10659
10660 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10661 {
10662   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10663   return new MEDFileFields(fid,loadAll,ms,0);
10664 }
10665
10666 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10667 {
10668   MEDFileUtilities::CheckFileForRead(fileName);
10669   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10670   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10671   return new MEDFileFields(fid,loadAll,0,ent);
10672 }
10673
10674 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10675 {
10676   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10677   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10678   return ret;
10679 }
10680
10681 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10682 {
10683   std::vector<const BigMemoryObject *> ret;
10684   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10685     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10686   return ret;
10687 }
10688
10689 MEDFileFields *MEDFileFields::deepCopy() const
10690 {
10691   MCAuto<MEDFileFields> ret(shallowCpy());
10692   std::size_t i(0);
10693   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10694     {
10695       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10696         ret->_fields[i]=(*it)->deepCopy();
10697     }
10698   ret->deepCpyGlobs(*this);
10699   return ret.retn();
10700 }
10701
10702 MEDFileFields *MEDFileFields::shallowCpy() const
10703 {
10704   return new MEDFileFields(*this);
10705 }
10706
10707 /*!
10708  * 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
10709  * 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.
10710  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10711  *
10712  * \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.
10713  * \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.
10714  * 
10715  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10716  */
10717 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10718 {
10719   std::set< std::pair<int,int> > s;
10720   bool firstShot=true;
10721   areThereSomeForgottenTS=false;
10722   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10723     {
10724       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10725         continue;
10726       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10727       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10728       if(firstShot)
10729         { s=s1; firstShot=false; }
10730       else
10731         {
10732           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10733           if(s!=s2)
10734             areThereSomeForgottenTS=true;
10735           s=s2;
10736         }
10737     }
10738   std::vector< std::pair<int,int> > ret;
10739   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10740   return ret;
10741 }
10742
10743 int MEDFileFields::getNumberOfFields() const
10744 {
10745   return _fields.size();
10746 }
10747
10748 std::vector<std::string> MEDFileFields::getFieldsNames() const
10749 {
10750   std::vector<std::string> ret(_fields.size());
10751   int i(0);
10752   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10753     {
10754       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10755       if(f)
10756         {
10757           ret[i]=f->getName();
10758         }
10759       else
10760         {
10761           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10762           throw INTERP_KERNEL::Exception(oss.str());
10763         }
10764     }
10765   return ret;
10766 }
10767
10768 std::vector<std::string> MEDFileFields::getMeshesNames() const
10769 {
10770   std::vector<std::string> ret;
10771   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10772     {
10773       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10774       if(cur)
10775         ret.push_back(cur->getMeshName());
10776     }
10777   return ret;
10778 }
10779
10780 std::string MEDFileFields::simpleRepr() const
10781 {
10782   std::ostringstream oss;
10783   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10784   simpleRepr(0,oss);
10785   return oss.str();
10786 }
10787
10788 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10789 {
10790   int nbOfFields(getNumberOfFields());
10791   std::string startLine(bkOffset,' ');
10792   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10793   int i=0;
10794   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10795     {
10796       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10797       if(cur)
10798         {
10799           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10800         }
10801       else
10802         {
10803           oss << startLine << "  - not defined !" << std::endl;
10804         }
10805     }
10806   i=0;
10807   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10808     {
10809       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10810       std::string chapter(17,'0'+i);
10811       oss << startLine << chapter << std::endl;
10812       if(cur)
10813         {
10814           cur->simpleRepr(bkOffset+2,oss,i);
10815         }
10816       else
10817         {
10818           oss << startLine << "  - not defined !" << std::endl;
10819         }
10820       oss << startLine << chapter << std::endl;
10821     }
10822   simpleReprGlobs(oss);
10823 }
10824
10825 MEDFileFields::MEDFileFields()
10826 {
10827 }
10828
10829 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10830 try:MEDFileFieldGlobsReal(fid)
10831 {
10832   int nbFields(MEDnField(fid));
10833   _fields.resize(nbFields);
10834   med_field_type typcha;
10835   for(int i=0;i<nbFields;i++)
10836     {
10837       std::vector<std::string> infos;
10838       std::string fieldName,dtunit;
10839       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10840       switch(typcha)
10841       {
10842         case MED_FLOAT64:
10843           {
10844             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10845             break;
10846           }
10847         case MED_INT32:
10848           {
10849             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10850             break;
10851           }
10852         default:
10853           {
10854             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10855             throw INTERP_KERNEL::Exception(oss.str());
10856           }
10857       }
10858     }
10859   loadAllGlobals(fid,entities);
10860 }
10861 catch(INTERP_KERNEL::Exception& e)
10862 {
10863     throw e;
10864 }
10865
10866 void MEDFileFields::writeLL(med_idt fid) const
10867 {
10868   int i=0;
10869   writeGlobals(fid,*this);
10870   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10871     {
10872       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10873       if(!elt)
10874         {
10875           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10876           throw INTERP_KERNEL::Exception(oss.str());
10877         }
10878       elt->writeLL(fid,*this);
10879     }
10880 }
10881
10882 /*!
10883  * This method alloc the arrays and load potentially huge arrays contained in this field.
10884  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10885  * This method can be also called to refresh or reinit values from a file.
10886  * 
10887  * \throw If the fileName is not set or points to a non readable MED file.
10888  */
10889 void MEDFileFields::loadArrays()
10890 {
10891   if(getFileName().empty())
10892     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10893   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10894   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10895     {
10896       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10897       if(elt)
10898         elt->loadBigArraysRecursively(fid,*elt);
10899     }
10900 }
10901
10902 /*!
10903  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10904  * But once data loaded once, this method does nothing.
10905  * 
10906  * \throw If the fileName is not set or points to a non readable MED file.
10907  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10908  */
10909 void MEDFileFields::loadArraysIfNecessary()
10910 {
10911   if(!getFileName().empty())
10912     {
10913       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10914       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10915         {
10916           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10917           if(elt)
10918             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10919         }
10920     }
10921 }
10922
10923 /*!
10924  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10925  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10926  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10927  * 
10928  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10929  */
10930 void MEDFileFields::unloadArrays()
10931 {
10932   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10933     {
10934       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10935       if(elt)
10936         elt->unloadArrays();
10937     }
10938 }
10939
10940 /*!
10941  * 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.
10942  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10943  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10944  * 
10945  * \sa MEDFileFields::loadArraysIfNecessary
10946  */
10947 void MEDFileFields::unloadArraysWithoutDataLoss()
10948 {
10949   if(!getFileName().empty())
10950     unloadArrays();
10951 }
10952
10953 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10954 {
10955   std::vector<std::string> ret;
10956   std::set<std::string> ret2;
10957   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10958     {
10959       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10960       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10961         if(ret2.find(*it2)==ret2.end())
10962           {
10963             ret.push_back(*it2);
10964             ret2.insert(*it2);
10965           }
10966     }
10967   return ret;
10968 }
10969
10970 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10971 {
10972   std::vector<std::string> ret;
10973   std::set<std::string> ret2;
10974   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10975     {
10976       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10977       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10978         if(ret2.find(*it2)==ret2.end())
10979           {
10980             ret.push_back(*it2);
10981             ret2.insert(*it2);
10982           }
10983     }
10984   return ret;
10985 }
10986
10987 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10988 {
10989   std::vector<std::string> ret;
10990   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10991     {
10992       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10993       ret.insert(ret.end(),tmp.begin(),tmp.end());
10994     }
10995   return ret;
10996 }
10997
10998 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10999 {
11000   std::vector<std::string> ret;
11001   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11002     {
11003       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11004       ret.insert(ret.end(),tmp.begin(),tmp.end());
11005     }
11006   return ret;
11007 }
11008
11009 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11010 {
11011   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11012     (*it)->changePflsRefsNamesGen2(mapOfModif);
11013 }
11014
11015 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11016 {
11017   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11018     (*it)->changeLocsRefsNamesGen2(mapOfModif);
11019 }
11020
11021 void MEDFileFields::resize(int newSize)
11022 {
11023   _fields.resize(newSize);
11024 }
11025
11026 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
11027 {
11028   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
11029     pushField(*it);
11030 }
11031
11032 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
11033 {
11034   if(!field)
11035     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
11036   _fields.push_back(field->getContent());
11037   appendGlobs(*field,1e-12);
11038 }
11039
11040 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
11041 {
11042   if(!field)
11043     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
11044   if(i>=(int)_fields.size())
11045     _fields.resize(i+1);
11046   _fields[i]=field->getContent();
11047   appendGlobs(*field,1e-12);
11048 }
11049
11050 void MEDFileFields::destroyFieldAtPos(int i)
11051 {
11052   destroyFieldsAtPos(&i,&i+1);
11053 }
11054
11055 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
11056 {
11057   std::vector<bool> b(_fields.size(),true);
11058   for(const int *i=startIds;i!=endIds;i++)
11059     {
11060       if(*i<0 || *i>=(int)_fields.size())
11061         {
11062           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11063           throw INTERP_KERNEL::Exception(oss.str());
11064         }
11065       b[*i]=false;
11066     }
11067   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11068   std::size_t j=0;
11069   for(std::size_t i=0;i<_fields.size();i++)
11070     if(b[i])
11071       fields[j++]=_fields[i];
11072   _fields=fields;
11073 }
11074
11075 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11076 {
11077   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11078   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11079   std::vector<bool> b(_fields.size(),true);
11080   int k=bg;
11081   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11082     {
11083       if(k<0 || k>=(int)_fields.size())
11084         {
11085           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11086           throw INTERP_KERNEL::Exception(oss.str());
11087         }
11088       b[k]=false;
11089     }
11090   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11091   std::size_t j(0);
11092   for(std::size_t i=0;i<_fields.size();i++)
11093     if(b[i])
11094       fields[j++]=_fields[i];
11095   _fields=fields;
11096 }
11097
11098 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11099 {
11100   bool ret(false);
11101   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11102     {
11103       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11104       if(cur)
11105         ret=cur->changeMeshNames(modifTab) || ret;
11106     }
11107   return ret;
11108 }
11109
11110 /*!
11111  * \param [in] meshName the name of the mesh that will be renumbered.
11112  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11113  *             This code corresponds to the distribution of types in the corresponding mesh.
11114  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11115  * \param [in] renumO2N the old to new renumber array.
11116  * \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 
11117  *         field in \a this.
11118  */
11119 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11120 {
11121   bool ret(false);
11122   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11123     {
11124       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11125       if(fmts)
11126         {
11127           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11128         }
11129     }
11130   return ret;
11131 }
11132
11133 /*!
11134  * Return an extraction of \a this using \a extractDef map to specify the extraction.
11135  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11136  *
11137  * \return A new object that the caller is responsible to deallocate.
11138  */
11139 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11140 {
11141   if(!mm)
11142     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11143   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11144   int nbFields(getNumberOfFields());
11145   for(int i=0;i<nbFields;i++)
11146     {
11147       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11148       if(!fmts)
11149         {
11150           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11151           throw INTERP_KERNEL::Exception(oss.str());
11152         }
11153       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11154       fsOut->pushField(fmtsOut);
11155     }
11156   return fsOut.retn();
11157 }
11158
11159 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11160 {
11161   if(i<0 || i>=(int)_fields.size())
11162     {
11163       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11164       throw INTERP_KERNEL::Exception(oss.str());
11165     }
11166   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11167   if(!fmts)
11168     return 0;
11169   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11170   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11171   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11172   if(fmtsC)
11173     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11174   else if(fmtsC2)
11175     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11176   else
11177     {
11178       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11179       throw INTERP_KERNEL::Exception(oss.str());
11180     }
11181   ret->shallowCpyGlobs(*this);
11182   return ret.retn();
11183 }
11184
11185 /*!
11186  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11187  * This method is accessible in python using __getitem__ with a list in input.
11188  * \return a new object that the caller should deal with.
11189  */
11190 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11191 {
11192   MCAuto<MEDFileFields> ret=shallowCpy();
11193   std::size_t sz=std::distance(startIds,endIds);
11194   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11195   int j=0;
11196   for(const int *i=startIds;i!=endIds;i++,j++)
11197     {
11198       if(*i<0 || *i>=(int)_fields.size())
11199         {
11200           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11201           throw INTERP_KERNEL::Exception(oss.str());
11202         }
11203       fields[j]=_fields[*i];
11204     }
11205   ret->_fields=fields;
11206   return ret.retn();
11207 }
11208
11209 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11210 {
11211   return getFieldAtPos(getPosFromFieldName(fieldName));
11212 }
11213
11214 /*!
11215  * This method removes, if any, fields in \a this having no time steps.
11216  * 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.
11217  * 
11218  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11219  */
11220 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11221 {
11222   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11223   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11224     {
11225       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11226       if(elt)
11227         {
11228           if(elt->getNumberOfTS()>0)
11229             newFields.push_back(*it);
11230         }
11231     }
11232   if(_fields.size()==newFields.size())
11233     return false;
11234   _fields=newFields;
11235   return true;
11236 }
11237
11238 /*!
11239  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11240  * This method can be seen as a filter applied on \a this, that returns an object containing
11241  * 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
11242  * shallow copied from \a this.
11243  * 
11244  * \param [in] meshName - the name of the mesh on w
11245  * \return a new object that the caller should deal with.
11246  */
11247 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11248 {
11249   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11250   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11251     {
11252       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11253       if(!cur)
11254         continue;
11255       if(cur->getMeshName()==meshName)
11256         {
11257           cur->incrRef();
11258           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11259           ret->_fields.push_back(cur2);
11260         }
11261     }
11262   ret->shallowCpyOnlyUsedGlobs(*this);
11263   return ret.retn();
11264 }
11265
11266 /*!
11267  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11268  * Input time steps are specified using a pair of integer (iteration, order).
11269  * 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,
11270  * but for each multitimestep only the time steps in \a timeSteps are kept.
11271  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11272  * 
11273  * The returned object points to shallow copy of elements in \a this.
11274  * 
11275  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11276  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11277  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11278  */
11279 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11280 {
11281   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11282   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11283     {
11284       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11285       if(!cur)
11286         continue;
11287       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11288       ret->_fields.push_back(elt);
11289     }
11290   ret->shallowCpyOnlyUsedGlobs(*this);
11291   return ret.retn();
11292 }
11293
11294 /*!
11295  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11296  */
11297 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11298 {
11299   MCAuto<MEDFileFields> ret=MEDFileFields::New();
11300   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11301     {
11302       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11303       if(!cur)
11304         continue;
11305       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11306       if(elt->getNumberOfTS()!=0)
11307         ret->_fields.push_back(elt);
11308     }
11309   ret->shallowCpyOnlyUsedGlobs(*this);
11310   return ret.retn();
11311 }
11312
11313 bool MEDFileFields::presenceOfStructureElements() const
11314 {
11315   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11316     if((*it).isNotNull())
11317       if((*it)->presenceOfStructureElements())
11318         return true;
11319   return false;
11320 }
11321
11322 void MEDFileFields::killStructureElements()
11323 {
11324   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11325   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11326     if((*it).isNotNull())
11327       {
11328         if((*it)->presenceOfStructureElements())
11329           {
11330             if(!(*it)->onlyStructureElements())
11331               {
11332                 (*it)->killStructureElements();
11333                 ret.push_back(*it);
11334               }
11335           }
11336         else
11337           {
11338             ret.push_back(*it);
11339           }
11340       }
11341   _fields=ret;
11342 }
11343
11344 void MEDFileFields::keepOnlyStructureElements()
11345 {
11346   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11347   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11348     if((*it).isNotNull())
11349       {
11350         if((*it)->presenceOfStructureElements())
11351           {
11352             if(!(*it)->onlyStructureElements())
11353               (*it)->keepOnlyStructureElements();
11354             ret.push_back(*it);
11355           }
11356       }
11357   _fields=ret;
11358 }
11359
11360 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11361 {
11362   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11363   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11364     if((*it).isNotNull())
11365       {
11366         if((*it)->getMeshName()!=meshName)
11367           continue;
11368         std::vector< std::pair<std::string,std::string> > ps;
11369         (*it)->getMeshSENames(ps);
11370         std::pair<std::string,std::string> p(meshName,seName);
11371         if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11372           (*it)->keepOnlyOnSE(seName);
11373         ret.push_back(*it);
11374       }
11375   _fields=ret;
11376 }
11377
11378 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11379 {
11380   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11381     if((*it).isNotNull())
11382       (*it)->getMeshSENames(ps);
11383 }
11384
11385 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11386 {
11387   MCAuto<MEDFileFields> fsSEOnly(partOfThisOnStructureElements());
11388   killStructureElements();
11389   MEDFileBlowStrEltUp bu(fsSEOnly,ms,ses);
11390   bu.generate(ms,this);
11391 }
11392
11393 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11394 {
11395   MCAuto<MEDFileFields> ret(deepCopy());
11396   ret->keepOnlyStructureElements();
11397   return ret;
11398 }
11399
11400 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11401 {
11402   MCAuto<MEDFileFields> ret(deepCopy());
11403   ret->keepOnlyOnMeshSE(meshName,seName);
11404   return ret;
11405 }
11406
11407 void MEDFileFields::aggregate(const MEDFileFields& other)
11408 {
11409   int nbFieldsToAdd(other.getNumberOfFields());
11410   std::vector<std::string> fsn(getFieldsNames());
11411   for(int i=0;i<nbFieldsToAdd;i++)
11412     {
11413       MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11414       std::string name(elt->getName());
11415       if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11416         {
11417           std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11418           throw INTERP_KERNEL::Exception(oss.str());
11419         }
11420       pushField(elt);
11421     }
11422 }
11423
11424 MEDFileFieldsIterator *MEDFileFields::iterator()
11425 {
11426   return new MEDFileFieldsIterator(this);
11427 }
11428
11429 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11430 {
11431   std::string tmp(fieldName);
11432   std::vector<std::string> poss;
11433   for(std::size_t i=0;i<_fields.size();i++)
11434     {
11435       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11436       if(f)
11437         {
11438           std::string fname(f->getName());
11439           if(tmp==fname)
11440             return i;
11441           else
11442             poss.push_back(fname);
11443         }
11444     }
11445   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11446   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11447   oss << " !";
11448   throw INTERP_KERNEL::Exception(oss.str());
11449 }
11450
11451 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11452 {
11453   if(fs)
11454     {
11455       fs->incrRef();
11456       _nb_iter=fs->getNumberOfFields();
11457     }
11458 }
11459
11460 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
11461 {
11462 }
11463
11464 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11465 {
11466   if(_iter_id<_nb_iter)
11467     {
11468       MEDFileFields *fs(_fs);
11469       if(fs)
11470         return fs->getFieldAtPos(_iter_id++);
11471       else
11472         return 0;
11473     }
11474   else
11475     return 0;
11476 }