]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField.cxx
Salome HOME
Improve perf for users with more than 1000 time steps
[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 #include "MEDFileFieldVisitor.hxx"
29
30 #include "MEDCouplingFieldDouble.hxx"
31 #include "MEDCouplingFieldTemplate.hxx"
32 #include "MEDCouplingFieldDiscretization.hxx"
33
34 #include "InterpKernelAutoPtr.hxx"
35 #include "CellModel.hxx"
36
37 #include <algorithm>
38 #include <iterator>
39
40 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
41 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
42 extern med_geometry_type typmainoeud[1];
43 extern med_geometry_type typmai3[34];
44
45 using namespace MEDCoupling;
46
47 template class MEDFileField1TSTemplateWithoutSDA<int>;
48 template class MEDFileField1TSTemplateWithoutSDA<double>;
49
50 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
51 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
52
53 MEDFileGTKeeper::~MEDFileGTKeeper()
54 {
55 }
56
57 MEDFileGTKeeper *MEDFileGTKeeperSta::deepCopy() const
58 {
59   return new MEDFileGTKeeperSta(_geo_type);
60 }
61
62 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperSta::getGeoType() const
63 {
64   return _geo_type;
65 }
66
67 std::string MEDFileGTKeeperSta::getRepr() const
68 {
69   return INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr();
70 }
71
72 bool MEDFileGTKeeperSta::isEqual(const MEDFileGTKeeper *other) const
73 {
74   const MEDFileGTKeeperSta *otherC(dynamic_cast<const MEDFileGTKeeperSta *>(other));
75   if(!otherC)
76     return false;
77   return _geo_type==otherC->_geo_type;
78 }
79
80 MEDFileGTKeeperDyn::MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se):_mesh(mesh),_section(section),_se(se)
81 {
82   if(mesh)
83     mesh->incrRef();
84   if(section)
85     section->incrRef();
86   if(se)
87     se->incrRef();
88   if(_mesh.isNull() || _section.isNull() || _se.isNull())
89     throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn constructor : null pointer not allowed !");
90 }
91
92 MEDFileGTKeeper *MEDFileGTKeeperDyn::deepCopy() const
93 {
94   return new MEDFileGTKeeperDyn(_mesh,_section,_se);
95 }
96
97 INTERP_KERNEL::NormalizedCellType MEDFileGTKeeperDyn::getGeoType() const
98 {
99   throw INTERP_KERNEL::Exception("MEDFileGTKeeperDyn::getGeoType : not valid !");
100 }
101
102 std::string MEDFileGTKeeperDyn::getRepr() const
103 {
104   std::ostringstream oss;
105   oss << _se->getDynGT();
106   return oss.str();
107 }
108
109 bool MEDFileGTKeeperDyn::isEqual(const MEDFileGTKeeper *other) const
110 {
111   const MEDFileGTKeeperDyn *otherC(dynamic_cast<const MEDFileGTKeeperDyn *>(other));
112   if(!otherC)
113     return false;
114   return this==otherC;
115 }
116
117 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
118 {
119   return new MEDFileFieldLoc(fid,locName);
120 }
121
122 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id, const MEDFileEntities *entities)
123 {
124   return new MEDFileFieldLoc(fid,id,entities);
125 }
126
127 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)
128 {
129   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
130 }
131
132 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
133 {
134   med_geometry_type geotype;
135   med_geometry_type sectiongeotype;
136   int nsectionmeshcell;
137   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
138   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
139   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
140   _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
141   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
142   _nb_node_per_cell=cm.getNumberOfNodes();
143   _ref_coo.resize(_dim*_nb_node_per_cell);
144   _gs_coo.resize(_dim*_nb_gauss_pt);
145   _w.resize(_nb_gauss_pt);
146   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
147 }
148
149 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities)
150 {
151   med_geometry_type geotype;
152   med_geometry_type sectiongeotype;
153   int nsectionmeshcell;
154   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
155   INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
156   INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
157   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
158   _name=locName;
159   std::string sectionName(MEDLoaderBase::buildStringFromFortran(sectionmeshname,MED_NAME_SIZE));
160   if(sectionName.empty())
161     {
162       _gt=new MEDFileGTKeeperSta((INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype))));
163       const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
164       _nb_node_per_cell=cm.getNumberOfNodes();
165     }
166   else
167     {
168       const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
169       if(!entities2)
170         {
171           std::ostringstream oss; oss << "MEDFileFieldLoc cstr : for loc \"" << _name << "\" presence of non static type ! Expect entities !";
172           throw INTERP_KERNEL::Exception(oss.str());
173         }
174       const MEDFileStructureElement *se(entities2->getWithGT(geotype));
175       const MEDFileUMesh *um(entities2->getSupMeshWithName(se->getMeshName()));
176       const MEDFileUMesh *section(entities2->getSupMeshWithName(sectionName));
177       _gt=new MEDFileGTKeeperDyn(um,section,se);
178       {
179         int dummy;
180         MEDFILESAFECALLERWR0(MEDmeshGeotypeParameter,(fid,geotype,&dummy,&_nb_node_per_cell));
181       }
182     }
183   _ref_coo.resize(_dim*_nb_node_per_cell);
184   _gs_coo.resize(_dim*_nb_gauss_pt);
185   _w.resize(_nb_gauss_pt);
186   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
187 }
188
189 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
190                                  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)
191 {
192   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
193   _dim=cm.getDimension();
194   _nb_node_per_cell=cm.getNumberOfNodes();
195   _nb_gauss_pt=_w.size();
196 }
197
198
199 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)
200 {
201 }
202
203 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
204 {
205   return new MEDFileFieldLoc(*this);
206 }
207
208 bool MEDFileFieldLoc::isOnStructureElement() const
209 {
210   const MEDFileGTKeeper *gt(_gt);
211   if(!gt)
212     throw INTERP_KERNEL::Exception("MEDFileFieldLoc::isOnStructureElement : null pointer !");
213   const MEDFileGTKeeperDyn *gt2(dynamic_cast<const MEDFileGTKeeperDyn *>(gt));
214   return gt2!=NULL;
215 }
216
217 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
218 {
219   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
220 }
221
222 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
223 {
224   return std::vector<const BigMemoryObject *>();
225 }
226
227 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
228 {
229   static const char OFF7[]="\n    ";
230   oss << "\"" << _name << "\"" << OFF7;
231   oss << "GeoType=" << _gt->getRepr() << OFF7;
232   oss << "Dimension=" << _dim << OFF7;
233   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
234   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
235   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
236   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
237   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
238 }
239
240 void MEDFileFieldLoc::setName(const std::string& name)
241 {
242   _name=name;
243 }
244
245 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
246 {
247   if(_name!=other._name)
248     return false;
249   if(_dim!=other._dim)
250     return false;
251   if(_nb_gauss_pt!=other._nb_gauss_pt)
252     return false;
253   if(_nb_node_per_cell!=other._nb_node_per_cell)
254     return false;
255   if(!_gt->isEqual(other._gt))
256     return false;
257   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
258     return false;
259   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
260     return false;
261   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
262     return false;
263
264   return true;
265 }
266
267 void MEDFileFieldLoc::writeLL(med_idt fid) const
268 {
269   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);
270 }
271
272 std::string MEDFileFieldLoc::repr() const
273 {
274   std::ostringstream oss; oss.precision(15);
275   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
276   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
277   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
278   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
279   oss << "\n  - Ref coords are : ";
280   int sz=_ref_coo.size();
281   if(sz%_dim==0)
282     {
283       int nbOfTuples=sz/_dim;
284       for(int i=0;i<nbOfTuples;i++)
285         {
286           oss << "(";
287           for(int j=0;j<_dim;j++)
288             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
289           oss << ") ";
290         }
291     }
292   else
293     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
294   oss << "\n  - Gauss coords in reference element : ";
295   sz=_gs_coo.size();
296   if(sz%_dim==0)
297     {
298       int nbOfTuples=sz/_dim;
299       for(int i=0;i<nbOfTuples;i++)
300         {
301           oss << "(";
302           for(int j=0;j<_dim;j++)
303             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
304           oss << ") ";
305         }
306     }
307   else
308     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
309   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
310   return oss.str();
311 }
312
313 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
314 {
315   _type=field->getTypeOfField();
316   _start=start;
317   switch(_type)
318   {
319     case ON_CELLS:
320       {
321         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
322         _end=_start+nbOfCells;
323         _nval=nbOfCells;
324         break;
325       }
326     case ON_GAUSS_NE:
327       {
328         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
329         const int *arrPtr=arr->getConstPointer();
330         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
331         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
332         _nval=nbOfCells;
333         break;
334       }
335     case ON_GAUSS_PT:
336       {
337         const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
338         const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
339         const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
340         if(!disc2)
341           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
342         const DataArrayInt *dai(disc2->getArrayOfDiscIds());
343         MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
344         const int *dai2Ptr(dai2->getConstPointer());
345         int nbi(gsLoc.getWeights().size());
346         MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
347         MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
348         const int *da3Ptr(da3->getConstPointer());
349         if(da3->getNumberOfTuples()!=nbOfCells)
350           {//profile : for gauss even in NoProfile !!!
351             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
352             _profile=oss.str();
353             da3->setName(_profile.c_str());
354             glob.appendProfile(da3);
355           }
356         MCAuto<DataArrayInt> da4(DataArrayInt::New());
357         _nval=da3->getNbOfElems();
358         da4->alloc(_nval*nbi,1);
359         int *da4Ptr(da4->getPointer());
360         for(int i=0;i<_nval;i++)
361           {
362             int ref=dai2Ptr[offset+da3Ptr[i]];
363             for(int j=0;j<nbi;j++)
364               *da4Ptr++=ref+j;
365           }
366         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
367         _localization=oss2.str();
368         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
369         _end=_start+_nval*nbi;
370         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
371         break;
372       }
373     default:
374       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
375   }
376   start=_end;
377 }
378
379 /*!
380  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
381  * \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).
382  * \param [in] multiTypePfl is the end user profile specified in high level API
383  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
384  * \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.
385  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
386  * \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.
387  */
388 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)
389 {
390   _profile.clear();
391   _type=field->getTypeOfField();
392   std::string pflName(multiTypePfl->getName());
393   std::ostringstream oss; oss << pflName;
394   if(_type!=ON_NODES)
395     {
396       if(!isPflAlone)
397         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
398     }
399   else
400     { oss << "_NODE"; }
401   if(locIds)
402     {
403       if(pflName.empty())
404         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
405       if(_type!=ON_GAUSS_PT)
406         {
407           locIds->setName(oss.str());
408           glob.appendProfile(locIds);
409           _profile=oss.str();
410         }
411     }
412   _start=start;
413   switch(_type)
414   {
415     case ON_NODES:
416       {
417         _nval=idsInPfl->getNumberOfTuples();
418         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
419         _end=_start+_nval;
420         break;
421       }
422     case ON_CELLS:
423       {
424         _nval=idsInPfl->getNumberOfTuples();
425         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
426         _end=_start+_nval;
427         break;
428       }
429     case ON_GAUSS_NE:
430       {
431         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
432         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
433         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
434         arr3->computeOffsetsFull();
435         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
436         int trueNval=tmp->getNumberOfTuples();
437         _nval=idsInPfl->getNumberOfTuples();
438         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
439         _end=_start+trueNval;
440         break;
441       }
442     case ON_GAUSS_PT:
443       {
444         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
445         if(!disc2)
446           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
447         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
448         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
449         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
450         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
451         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
452         //
453         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
454         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
455         //
456         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
457         int trueNval=0;
458         for(const int *pt=da4->begin();pt!=da4->end();pt++)
459           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
460         tmp->alloc(trueNval,1);
461         int *tmpPtr=tmp->getPointer();
462         for(const int *pt=da4->begin();pt!=da4->end();pt++)
463           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
464             *tmpPtr++=j;
465         //
466         _nval=da4->getNumberOfTuples();
467         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
468         _end=_start+trueNval;
469         oss << "_loc_" << _loc_id;
470         if(locIds)
471           {
472             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
473             da5->setName(oss.str());
474             glob.appendProfile(da5);
475             _profile=oss.str();
476           }
477         else
478           {
479             if(!da3->isIota(nbOfEltsInWholeMesh))
480               {
481                 da3->setName(oss.str());
482                 glob.appendProfile(da3);
483                 _profile=oss.str();
484               }
485           }
486         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
487         _localization=oss2.str();
488         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
489         break;
490       }
491     default:
492       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
493   }
494   start=_end;
495 }
496
497 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
498 {
499   _start=start;
500   _nval=arrr->getNumberOfTuples();
501   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
502   _end=_start+_nval;
503   start=_end;
504 }
505
506 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
507 {
508   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
509 }
510
511 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
512 {
513   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
514 }
515
516 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
517 {
518   return new MEDFileFieldPerMeshPerTypePerDisc(other);
519 }
520
521 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
522 {
523   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
524 }
525
526 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
527 {
528   std::vector<const BigMemoryObject *> ret(1);
529   ret[0]=(const PartDefinition*)_pd;
530   return ret;
531 }
532
533 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
534 {
535   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
536   ret->_father=father;
537   return ret.retn();
538 }
539
540 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
541 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
542 {
543   if(pd)
544     pd->incrRef();
545 }
546 catch(INTERP_KERNEL::Exception& e)
547 {
548     throw e;
549 }
550
551 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
552 {
553 }
554
555 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)
556 {
557 }
558
559 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
560     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
561 {
562 }
563
564 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)
565 {
566   const PartDefinition *pd(_pd);
567   if(!pd)
568     {
569       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
570       int nbi,tmp1;
571       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
572       if(_end-_start!=nbValsInFile*nbi)
573         {
574           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 !";
575           throw INTERP_KERNEL::Exception(oss.str());
576         }
577       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
578     }
579   else
580     {
581       if(!_profile.empty())
582         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
583       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
584       int profilesize,nbi;
585       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
586       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
587       if(spd)
588         {
589           int start,stop,step;
590           spd->getSlice(start,stop,step);
591           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
592           med_filter filter=MED_FILTER_INIT;
593           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
594                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
595                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
596                                    /*lastblocksize=useless because count=1*/0,&filter);
597           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
598           MEDfilterClose(&filter);
599           return ;
600         }
601       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
602       if(dpd)
603         {
604           dpd->checkConsistencyLight();
605           MCAuto<DataArrayInt> myIds(dpd->toDAI());
606           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
607           myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
608           myIds->applyLin(1,-a);
609           int nbOfEltsToLoad(b-a+1);
610           med_filter filter=MED_FILTER_INIT;
611           {//TODO : manage int32 !
612             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
613             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
614             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
615                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
616                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
617                                      /*lastblocksize=useless because count=1*/0,&filter);
618             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
619             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
620             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
621             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
622           }
623           MEDfilterClose(&filter);
624         }
625       else
626         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
627     }
628 }
629
630 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
631 {
632   return _father;
633 }
634
635 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
636 {
637   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
638   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
639   std::string fieldName(nasc.getName()),meshName(getMeshName());
640   int iteration(getIteration()),order(getOrder()),profilesize,nbi;
641   TypeOfField type(getType());
642   med_geometry_type mgeoti;
643   med_entity_type menti;
644   _father->entriesForMEDfile(type,mgeoti,menti);
645   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
646   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
647   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
648   const PartDefinition *pd(_pd);
649   if(!pd)
650     {
651       _nval=zeNVal;
652     }
653   else
654     {
655       if(!_profile.empty())
656         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
657       _nval=pd->getNumberOfElems();
658     }
659   _start=start;
660   _end=start+_nval*nbi;
661   start=_end;
662   if(type==ON_CELLS && !_localization.empty())
663     {
664       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
665         setType(ON_GAUSS_PT);
666       else
667         {
668           setType(ON_GAUSS_NE);
669           _localization.clear();
670         }
671     }
672 }
673
674 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
675 {
676   std::string fieldName(nasc.getName()),meshName(getMeshName());
677   int iteration(getIteration()),order(getOrder());
678   TypeOfField type(getType());
679   med_geometry_type mgeoti;
680   med_entity_type menti;
681   _father->entriesForMEDfile(type,mgeoti,menti);
682   if(_start>_end)
683     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
684   if(_start==_end)
685     return ;
686   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
687   if(_start<0 || _start>=arr->getNumberOfTuples())
688     {
689       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
690       throw INTERP_KERNEL::Exception(oss.str());
691     }
692   if(_end<0 || _end>arr->getNumberOfTuples())
693     {
694       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
695       throw INTERP_KERNEL::Exception(oss.str());
696     }
697   int nbOfCompo(arr->getNumberOfComponents());
698   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
699   if(arrD)
700     {
701       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
702       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
703       return ;
704     }
705   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
706   if(arrI)
707     {
708       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
709       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
710       return ;
711     }
712   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
713 }
714
715 /*!
716  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
717  */
718 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
719 {
720   int delta=_end-_start;
721   _start=newValueOfStart;
722   _end=_start+delta;
723 }
724
725 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
726 {
727   return _father->getIteration();
728 }
729
730 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
731 {
732   return _father->getOrder();
733 }
734
735 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
736 {
737   return _father->getTime();
738 }
739
740 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
741 {
742   return _father->getMeshName();
743 }
744
745 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
746 {
747   const char startLine[]="    ## ";
748   std::string startLine2(bkOffset,' ');
749   startLine2+=startLine;
750   INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
751   oss << startLine2 << "Localization #" << id << "." << std::endl;
752   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
753   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
754   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
755   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
756 }
757
758 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
759 {
760   return _type;
761 }
762
763 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
764 {
765   return _father->getGeoType();
766 }
767
768 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
769 {
770   types.insert(_type);
771 }
772
773 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
774 {
775   _type=newType;
776 }
777
778 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
779 {
780   return _father->getNumberOfComponents();
781 }
782
783 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
784 {
785   return _end-_start;
786 }
787
788 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
789 {
790   return _father->getOrCreateAndGetArray();
791 }
792
793 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
794 {
795   const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
796   return fath->getOrCreateAndGetArray();
797 }
798
799 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
800 {
801   return _father->getInfo();
802 }
803
804 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
805 {
806   return _profile;
807 }
808
809 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
810 {
811   _profile=newPflName;
812 }
813
814 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
815 {
816   return _localization;
817 }
818
819 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
820 {
821   _localization=newLocName;
822 }
823
824 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
825 {
826   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
827     {
828       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
829         {
830           _profile=(*it2).second;
831           return;
832         }
833     }
834 }
835
836 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
837 {
838   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
839     {
840       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
841         {
842           _localization=(*it2).second;
843           return;
844         }
845     }
846 }
847
848 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
849 {
850   if(type!=_type)
851     return ;
852   dads.push_back(std::pair<int,int>(_start,_end));
853   geoTypes.push_back(getGeoType());
854   if(_profile.empty())
855     pfls.push_back(0);
856   else
857     {
858       pfls.push_back(glob->getProfile(_profile.c_str()));
859     }
860   if(_localization.empty())
861     locs.push_back(-1);
862   else
863     {
864       locs.push_back(glob->getLocalizationId(_localization.c_str()));
865     }
866 }
867
868 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
869 {
870   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));
871   startEntryId++;
872 }
873
874 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
875 {
876   TypeOfField type=getType();
877   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
878   med_geometry_type mgeoti;
879   med_entity_type menti;
880   _father->entriesForMEDfile(getType(),mgeoti,menti);
881   const DataArray *arr(getOrCreateAndGetArray());
882   if(!arr)
883     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
884   if(!arr->isAllocated())
885     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
886   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
887   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
888   const unsigned char *locToWrite=0;
889   if(arrD)
890     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
891   else if(arrI)
892     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
893   else
894     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
895   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
896                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
897                                                    locToWrite));
898 }
899
900 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
901 {
902   type=_type;
903   pfl=_profile;
904   loc=_localization;
905   dad.first=_start; dad.second=_end;
906 }
907
908 /*!
909  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
910  *             This code corresponds to the distribution of types in the corresponding mesh.
911  * \param [out] ptToFill memory zone where the output will be stored.
912  * \return the size of data pushed into output param \a ptToFill
913  */
914 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
915 {
916   _loc_id=offset;
917   std::ostringstream oss;
918   std::size_t nbOfType=codeOfMesh.size()/3;
919   int found=-1;
920   for(std::size_t i=0;i<nbOfType && found==-1;i++)
921     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
922       found=(int)i;
923   if(found==-1)
924     {
925       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
926       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
927       throw INTERP_KERNEL::Exception(oss.str());
928     }
929   int *work=ptToFill;
930   if(_profile.empty())
931     {
932       if(_nval!=codeOfMesh[3*found+1])
933         {
934           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
935           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
936           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
937           throw INTERP_KERNEL::Exception(oss.str());
938         }
939       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
940         *work++=ii;
941     }
942   else
943     {
944       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
945       if(pfl->getNumberOfTuples()!=_nval)
946         {
947           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
948           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
949           oss << _nval;
950           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
951           throw INTERP_KERNEL::Exception(oss.str());
952         }
953       int offset2=codeOfMesh[3*found+2];
954       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
955         {
956           if(*pflId<codeOfMesh[3*found+1])
957             *work++=offset2+*pflId;
958         }
959     }
960   return _nval;
961 }
962
963 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
964 {
965   for(int i=_start;i<_end;i++)
966     *ptToFill++=i;
967   return _end-_start;
968 }
969
970 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
971 {
972   switch(type)
973   {
974     case ON_CELLS:
975       return -2;
976     case ON_GAUSS_NE:
977       return -1;
978     case ON_GAUSS_PT:
979       return locId;
980     default:
981       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
982   }
983 }
984
985 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
986 {
987   int id=0;
988   std::map<std::pair<std::string,TypeOfField>,int> m;
989   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
990   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
991     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
992       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
993   ret.resize(id);
994   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
995     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
996   return ret;
997 }
998
999 /*!
1000  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
1001  * 
1002  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
1003  * \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.
1004  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
1005  * \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)
1006  * \param [in,out] glob if necessary by the method, new profiles can be added to it
1007  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
1008  * \param [out] result All new entries will be appended on it.
1009  * \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 !)
1010  */
1011 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1012                                                        const DataArrayInt *explicitIdsInMesh,
1013                                                        const std::vector<int>& newCode,
1014                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
1015                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
1016 {
1017   if(entriesOnSameDisc.empty())
1018     return false;
1019   TypeOfField type=entriesOnSameDisc[0]->getType();
1020   int szEntities=0,szTuples=0;
1021   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
1022     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
1023   int nbi=szTuples/szEntities;
1024   if(szTuples%szEntities!=0)
1025     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
1026   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
1027   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
1028   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
1029   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
1030   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
1031   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
1032   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
1033   int id=0;
1034   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
1035     {
1036       int startOfEltIdOfChunk=(*it)->_start;
1037       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
1038       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
1039       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
1040       //
1041       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
1042       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
1043       //
1044       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
1045       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
1046     }
1047   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
1048   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
1049   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
1050   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
1051   //
1052   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
1053   //
1054   MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
1055   arrPart->renumberInPlace(renumTupleIds->begin());
1056   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
1057   bool ret=false;
1058   const int *idIt=diffVals->begin();
1059   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
1060   int offset2=0;
1061   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
1062     {
1063       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
1064       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
1065       int nbEntityElts=subIds->getNumberOfTuples();
1066       bool ret2;
1067       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
1068           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
1069                                       offset+offset2,
1070                                       li,glob,ret2);
1071       ret=ret || ret2;
1072       result.push_back(eltToAdd);
1073       offset2+=nbEntityElts*nbi;
1074     }
1075   ret=ret || li.empty();
1076   return ret;
1077 }
1078
1079 /*!
1080  * \param [in] typeF type of field of new chunk
1081  * \param [in] geoType the geometric type of the chunk
1082  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
1083  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
1084  * \param [in] nbi number of integration points
1085  * \param [in] offset The offset in the **global array of data**.
1086  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
1087  *                 to the new chunk to create.
1088  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
1089  * \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
1090  *              and corresponding entry erased from \a entriesOnSameDisc.
1091  * \return a newly allocated chunk
1092  */
1093 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
1094                                                                                                   bool isPfl, int nbi, int offset,
1095                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
1096                                                                                                   MEDFileFieldGlobsReal& glob,
1097                                                                                                   bool &notInExisting)
1098 {
1099   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1100   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1101   for(;it!=entriesOnSameDisc.end();it++)
1102     {
1103       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1104         {
1105           if(!isPfl)
1106             {
1107               if((*it)->_profile.empty())
1108                 break;
1109               else
1110                 if(!(*it)->_profile.empty())
1111                   {
1112                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1113                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1114                       break;
1115                   }
1116             }
1117         }
1118     }
1119   if(it==entriesOnSameDisc.end())
1120     {
1121       notInExisting=true;
1122       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1123       ret->_type=typeF;
1124       ret->_loc_id=(int)geoType;
1125       ret->_nval=nbMeshEntities;
1126       ret->_start=offset;
1127       ret->_end=ret->_start+ret->_nval*nbi;
1128       if(isPfl)
1129         {
1130           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1131           glob.appendProfile(idsOfMeshElt);
1132           ret->_profile=idsOfMeshElt->getName();
1133         }
1134       //tony treatment of localization
1135       return ret;
1136     }
1137   else
1138     {
1139       notInExisting=false;
1140       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1141       ret->_loc_id=(int)geoType;
1142       ret->setNewStart(offset);
1143       entriesOnSameDisc.erase(it);
1144       return ret;
1145     }
1146
1147 }
1148
1149 ////////////////////////////////////
1150
1151 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1152 {
1153 }
1154
1155 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1156 {
1157   _father=father;
1158 }
1159
1160 void MEDFileFieldPerMeshPerTypeCommon::accept(MEDFileFieldVisitor& visitor) const
1161 {
1162   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1163     if((*it).isNotNull())
1164       {
1165         visitor.newPerMeshPerTypePerDisc(*it);
1166       }
1167 }
1168
1169 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1170 {
1171   std::size_t i=0;
1172   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1173     {
1174       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1175         _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1176     }
1177 }
1178
1179 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1180 {
1181   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1182 }
1183
1184 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1185 {
1186   std::vector<const BigMemoryObject *> ret;
1187   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1188     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1189   return ret;
1190 }
1191
1192 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1193 {
1194   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1195   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1196     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1197 }
1198
1199 /*!
1200  * This method is the most general one. No optimization is done here.
1201  * \param [in] multiTypePfl is the end user profile specified in high level API
1202  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1203  * \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.
1204  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1205  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1206  * \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.
1207  */
1208 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)
1209 {
1210   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1211   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1212     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1213 }
1214
1215 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1216 {
1217   _field_pm_pt_pd.resize(1);
1218   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1219   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1220 }
1221
1222 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1223 {
1224   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1225   if(!arr || !arr->isAllocated())
1226     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1227   _field_pm_pt_pd.resize(1);
1228   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1229   _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.
1230 }
1231
1232 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1233 {
1234   TypeOfField type=field->getTypeOfField();
1235   if(type!=ON_GAUSS_PT)
1236     {
1237       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1238       int sz=_field_pm_pt_pd.size();
1239       bool found=false;
1240       for(int j=0;j<sz && !found;j++)
1241         {
1242           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1243             {
1244               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1245               found=true;
1246             }
1247         }
1248       if(!found)
1249         {
1250           _field_pm_pt_pd.resize(sz+1);
1251           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1252         }
1253       std::vector<int> ret(1,(int)sz);
1254       return ret;
1255     }
1256   else
1257     {
1258       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1259       int sz2=ret2.size();
1260       std::vector<int> ret3(sz2);
1261       int k=0;
1262       for(int i=0;i<sz2;i++)
1263         {
1264           int sz=_field_pm_pt_pd.size();
1265           int locIdToFind=ret2[i];
1266           bool found=false;
1267           for(int j=0;j<sz && !found;j++)
1268             {
1269               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1270                 {
1271                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1272                   ret3[k++]=j;
1273                   found=true;
1274                 }
1275             }
1276           if(!found)
1277             {
1278               _field_pm_pt_pd.resize(sz+1);
1279               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1280               ret3[k++]=sz;
1281             }
1282         }
1283       return ret3;
1284     }
1285 }
1286
1287 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1288 {
1289   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1290   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1291   if(!disc2)
1292     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1293   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1294   if(!da)
1295     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1296   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1297   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1298   if(retTmp->presenceOfValue(-1))
1299     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1300   std::vector<int> ret(retTmp->begin(),retTmp->end());
1301   return ret;
1302 }
1303
1304 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1305 {
1306   TypeOfField type=field->getTypeOfField();
1307   if(type!=ON_GAUSS_PT)
1308     {
1309       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1310       int sz=_field_pm_pt_pd.size();
1311       bool found=false;
1312       for(int j=0;j<sz && !found;j++)
1313         {
1314           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1315             {
1316               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1317               found=true;
1318             }
1319         }
1320       if(!found)
1321         {
1322           _field_pm_pt_pd.resize(sz+1);
1323           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1324         }
1325       std::vector<int> ret(1,0);
1326       return ret;
1327     }
1328   else
1329     {
1330       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1331       int sz2=ret2.size();
1332       std::vector<int> ret3(sz2);
1333       int k=0;
1334       for(int i=0;i<sz2;i++)
1335         {
1336           int sz=_field_pm_pt_pd.size();
1337           int locIdToFind=ret2[i];
1338           bool found=false;
1339           for(int j=0;j<sz && !found;j++)
1340             {
1341               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1342                 {
1343                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1344                   ret3[k++]=j;
1345                   found=true;
1346                 }
1347             }
1348           if(!found)
1349             {
1350               _field_pm_pt_pd.resize(sz+1);
1351               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1352               ret3[k++]=sz;
1353             }
1354         }
1355       return ret3;
1356     }
1357 }
1358
1359 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1360 {
1361   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1362   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1363   if(!disc2)
1364     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1365   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1366   if(!da)
1367     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1368   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1369   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1370   if(retTmp->presenceOfValue(-1))
1371     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1372   std::vector<int> ret(retTmp->begin(),retTmp->end());
1373   return ret;
1374 }
1375
1376 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1377 {
1378   return _father;
1379 }
1380
1381 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1382 {
1383   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1384   int curDim((int)cm.getDimension());
1385   if(dim!=std::numeric_limits<int>::max())
1386     {
1387       if(dim!=curDim)
1388         return false;
1389     }
1390   else
1391     dim=curDim;
1392   return true;
1393 }
1394
1395 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1396 {
1397   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1398     {
1399       (*it)->fillTypesOfFieldAvailable(types);
1400     }
1401 }
1402
1403 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
1404 {
1405   int sz=_field_pm_pt_pd.size();
1406   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1407   for(int i=0;i<sz;i++)
1408     {
1409       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1410     }
1411 }
1412
1413 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1414 {
1415   return _father->getIteration();
1416 }
1417
1418 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1419 {
1420   return _father->getOrder();
1421 }
1422
1423 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1424 {
1425   return _father->getTime();
1426 }
1427
1428 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1429 {
1430   return _father->getMeshName();
1431 }
1432
1433 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1434 {
1435   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1436     {
1437       globalSz+=(*it)->getNumberOfTuples();
1438     }
1439   nbOfEntries+=(int)_field_pm_pt_pd.size();
1440 }
1441
1442 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1443 {
1444   return _father->getNumberOfComponents();
1445 }
1446
1447 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1448 {
1449   std::size_t nb(0);
1450   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1451     {
1452       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1453       if(fmtd)
1454         nb++;
1455     }
1456   return nb>1;
1457 }
1458
1459 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1460 {
1461   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1462   elt.takeRef(disc);
1463   _field_pm_pt_pd.push_back(elt);
1464 }
1465
1466 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1467 {
1468   return _father->getOrCreateAndGetArray();
1469 }
1470
1471 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1472 {
1473   const MEDFileFieldPerMesh *fath=_father;
1474   return fath->getOrCreateAndGetArray();
1475 }
1476
1477 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1478 {
1479   return _father->getInfo();
1480 }
1481
1482 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1483 {
1484   std::vector<std::string> ret;
1485   std::set<std::string> ret2;
1486   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1487     {
1488       std::string tmp=(*it1)->getProfile();
1489       if(!tmp.empty())
1490         if(ret2.find(tmp)==ret2.end())
1491           {
1492             ret.push_back(tmp);
1493             ret2.insert(tmp);
1494           }
1495     }
1496   return ret;
1497 }
1498
1499 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1500 {
1501   std::vector<std::string> ret;
1502   std::set<std::string> ret2;
1503   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1504     {
1505       std::string tmp=(*it1)->getLocalization();
1506       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1507         if(ret2.find(tmp)==ret2.end())
1508           {
1509             ret.push_back(tmp);
1510             ret2.insert(tmp);
1511           }
1512     }
1513   return ret;
1514 }
1515
1516 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1517 {
1518   std::vector<std::string> ret;
1519   std::set<std::string> ret2;
1520   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1521     {
1522       std::string tmp=(*it1)->getProfile();
1523       if(!tmp.empty())
1524         ret.push_back(tmp);
1525     }
1526   return ret;
1527 }
1528
1529 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1530 {
1531   std::vector<std::string> ret;
1532   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1533     {
1534       std::string tmp=(*it1)->getLocalization();
1535       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1536         ret.push_back(tmp);
1537     }
1538   return ret;
1539 }
1540
1541 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1542 {
1543   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1544     (*it1)->changePflsRefsNamesGen(mapOfModif);
1545 }
1546
1547 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1548 {
1549   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1550     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1551 }
1552
1553 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1554 {
1555   if(_field_pm_pt_pd.empty())
1556     {
1557       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1558       throw INTERP_KERNEL::Exception(oss.str());
1559     }
1560   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1561     return _field_pm_pt_pd[locId];
1562   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1563   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1564   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1565   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1566 }
1567
1568 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1569 {
1570   if(_field_pm_pt_pd.empty())
1571     {
1572       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1573       throw INTERP_KERNEL::Exception(oss.str());
1574     }
1575   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1576     return _field_pm_pt_pd[locId];
1577   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1578   oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1579   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1580   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1581 }
1582
1583 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1584 {
1585   int i=0;
1586   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1587     {
1588       (*it)->fillValues(i,startEntryId,entries);
1589     }
1590 }
1591
1592 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1593 {
1594   _field_pm_pt_pd=leaves;
1595   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1596     (*it)->setFather(this);
1597 }
1598
1599 /*!
1600  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1601  *  \param [out] its - list of pair (start,stop) kept
1602  *  \return bool - false if the type of field \a tof is not contained in \a this.
1603  */
1604 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1605 {
1606   bool ret(false);
1607   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1608   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609     if((*it)->getType()==tof)
1610       {
1611         newPmPtPd.push_back(*it);
1612         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1613         (*it)->setNewStart(globalNum);
1614         globalNum=(*it)->getEnd();
1615         its.push_back(bgEnd);
1616         ret=true;
1617       }
1618   if(ret)
1619     _field_pm_pt_pd=newPmPtPd;
1620   return ret;
1621 }
1622
1623 /*!
1624  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1625  *  \param [out] its - list of pair (start,stop) kept
1626  *  \return bool - false if the type of field \a tof is not contained in \a this.
1627  */
1628 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1629 {
1630   if(_field_pm_pt_pd.size()<=idOfDisc)
1631     return false;
1632   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1633   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1634   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1635   elt->setNewStart(globalNum);
1636   globalNum=elt->getEnd();
1637   its.push_back(bgEnd);
1638   _field_pm_pt_pd=newPmPtPd;
1639   return true;
1640 }
1641
1642 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1643 {
1644   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1645     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1646 }
1647
1648 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1649 {
1650   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1651     (*it)->loadBigArray(fid,nasc);
1652 }
1653
1654 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1655 {
1656   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1657     {
1658       (*it)->copyOptionsFrom(*this);
1659       (*it)->writeLL(fid,nasc);
1660     }
1661 }
1662
1663 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1664 {
1665   switch(ikType)
1666   {
1667     case ON_CELLS:
1668       medfGeoType=typmai3[(int)ikGeoType];
1669       return MED_CELL;
1670     case ON_NODES:
1671       medfGeoType=MED_NONE;
1672       return MED_NODE;
1673     case ON_GAUSS_NE:
1674       medfGeoType=typmai3[(int)ikGeoType];
1675       return MED_NODE_ELEMENT;
1676     case ON_GAUSS_PT:
1677       medfGeoType=typmai3[(int)ikGeoType];
1678       return MED_CELL;
1679     default:
1680       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1681   }
1682   return MED_UNDEF_ENTITY_TYPE;
1683 }
1684
1685 //////////////////////////////////////////////////
1686
1687 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1688 {
1689   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1690 }
1691
1692 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1693 {
1694   return new MEDFileFieldPerMeshPerType(fath,geoType);
1695 }
1696
1697 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1698 {
1699   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1700   ret->setFather(father);
1701   ret->deepCopyElements();
1702   return ret.retn();
1703 }
1704
1705 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
1706 {
1707   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1708     {
1709       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1710       if(meshDim!=(int)cm.getDimension())
1711         return ;
1712     }
1713   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1714     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1715 }
1716
1717 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1718 {
1719   return _geo_type;
1720 }
1721
1722 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1723 {
1724   ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1725 }
1726
1727 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1728 {
1729   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1730   int curDim((int)cm.getDimension());
1731   dim=std::max(dim,curDim);
1732 }
1733
1734 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1735 {
1736   const char startLine[]="  ## ";
1737   std::string startLine2(bkOffset,' ');
1738   std::string startLine3(startLine2);
1739   startLine3+=startLine;
1740   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1741     {
1742       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1743       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1744     }
1745   else
1746     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1747   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1748   int i=0;
1749   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1750     {
1751       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1752       if(cur)
1753         cur->simpleRepr(bkOffset,oss,i);
1754       else
1755         {
1756           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1757         }
1758     }
1759 }
1760
1761 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1762 {
1763   const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1764   return std::string(cm.getRepr());
1765 }
1766
1767 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1768 {
1769 }
1770
1771 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1772 {
1773   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1774   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1775   med_geometry_type mgeoti;
1776   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1777   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1778   _field_pm_pt_pd.resize(nbProfiles);
1779   for(int i=0;i<nbProfiles;i++)
1780     {
1781       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1782     }
1783   if(type==ON_CELLS)
1784     {
1785       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1786       for(int i=0;i<nbProfiles2;i++)
1787         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1788     }
1789 }
1790
1791 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)
1792 {
1793   MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1794   std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1795   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1796     {
1797       for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1798         m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1799     }
1800   for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1801     {
1802       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1803       ret->_field_pm_pt_pd.push_back(agg);
1804     }
1805   return ret;
1806 }
1807
1808 //////////////////////////////////////////////////
1809
1810 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1811 {
1812   if(!entities)
1813     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1814   const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1815   if(!entities2)
1816     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1817   const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1818   return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1819 }
1820
1821 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1822 {
1823   _se.takeRef(se);
1824   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1825   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1826   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1827   _field_pm_pt_pd.resize(nbProfiles);
1828   for(int i=0;i<nbProfiles;i++)
1829     {
1830       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1831     }
1832 }
1833
1834 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1835 {
1836   return _se->getDynGT();
1837 }
1838
1839 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1840 {
1841   return _se->getName();
1842 }
1843
1844 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1845 {
1846   throw INTERP_KERNEL::Exception("not implemented yet !");
1847 }
1848
1849 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1850 {
1851   gt=getDynGT();
1852   ent=MED_STRUCT_ELEMENT;
1853 }
1854
1855 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1856 {
1857   throw INTERP_KERNEL::Exception("not implemented yet !");
1858 }
1859
1860 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1861 {
1862   const char startLine[]="  ## ";
1863   std::string startLine2(bkOffset,' ');
1864   std::string startLine3(startLine2);
1865   startLine3+=startLine;
1866   oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1867   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1868   int i=0;
1869   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1870     {
1871       if((*it).isNotNull())
1872         (*it)->simpleRepr(bkOffset,oss,i);
1873       else
1874         {
1875           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1876         }
1877     }
1878 }
1879
1880 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1881 {
1882   throw INTERP_KERNEL::Exception("not implemented yet !");
1883 }
1884
1885 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1886 {
1887   MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1888   ret->setFather(father);
1889   ret->deepCopyElements();
1890   return ret.retn();
1891 }
1892
1893 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
1894 {
1895   throw INTERP_KERNEL::Exception("not implemented yet !");
1896 }
1897
1898 //////////////////////////////////////////////////
1899
1900 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1901 {
1902   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1903 }
1904
1905 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1906 {
1907   return new MEDFileFieldPerMesh(fath,mesh);
1908 }
1909
1910 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1911 {
1912   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1913 }
1914
1915 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1916 {
1917   std::vector<const BigMemoryObject *> ret;
1918   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1919     ret.push_back(*it);
1920   return ret;
1921 }
1922
1923 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1924 {
1925   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1926   ret->_father=father;
1927   std::size_t i=0;
1928   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1929     {
1930       if((*it).isNotNull())
1931         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1932     }
1933   return ret.retn();
1934 }
1935
1936 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1937 {
1938   std::string startLine(bkOffset,' ');
1939   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1940   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1941   int i=0;
1942   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1943     {
1944       if((*it).isNotNull())
1945         (*it)->simpleRepr(bkOffset,oss,i);
1946       else
1947         {
1948           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1949         }
1950     }
1951 }
1952
1953 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1954 {
1955   _mesh_name=mesh->getName();
1956   mesh->getTime(_mesh_iteration,_mesh_order);
1957 }
1958
1959 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1960 {
1961   int nbOfTypes=code.size()/3;
1962   int offset=0;
1963   for(int i=0;i<nbOfTypes;i++)
1964     {
1965       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1966       int nbOfCells=code[3*i+1];
1967       int pos=addNewEntryIfNecessary(type);
1968       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1969       offset+=nbOfCells;
1970     }
1971 }
1972
1973 /*!
1974  * This method is the most general one. No optimization is done here.
1975  * \param [in] multiTypePfl is the end user profile specified in high level API
1976  * \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].
1977  * \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.
1978  * \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.
1979  * \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.
1980  * \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.
1981  */
1982 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)
1983 {
1984   int nbOfTypes(code.size()/3);
1985   for(int i=0;i<nbOfTypes;i++)
1986     {
1987       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1988       int pos=addNewEntryIfNecessary(type);
1989       DataArrayInt *pfl=0;
1990       if(code[3*i+2]!=-1)
1991         pfl=idsPerType[code[3*i+2]];
1992       int nbOfTupes2=code2.size()/3;
1993       int found=0;
1994       for(;found<nbOfTupes2;found++)
1995         if(code[3*i]==code2[3*found])
1996           break;
1997       if(found==nbOfTupes2)
1998         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1999       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
2000     }
2001 }
2002
2003 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
2004 {
2005   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2006   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
2007 }
2008
2009 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
2010 {
2011   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
2012   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
2013 }
2014
2015 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
2016 {
2017   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2018     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
2019 }
2020
2021 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
2022 {
2023   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2024     (*it)->loadBigArraysRecursively(fid,nasc);
2025 }
2026
2027 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
2028 {
2029   int nbOfTypes=_field_pm_pt.size();
2030   for(int i=0;i<nbOfTypes;i++)
2031     {
2032       _field_pm_pt[i]->copyOptionsFrom(*this);
2033       _field_pm_pt[i]->writeLL(fid,nasc);
2034     }
2035 }
2036
2037 void MEDFileFieldPerMesh::getDimension(int& dim) const
2038 {
2039   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2040     (*it)->getDimension(dim);
2041 }
2042
2043 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
2044 {
2045   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2046     if(!(*it)->isUniqueLevel(dim))
2047       return false;
2048   return true;
2049 }
2050
2051 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
2052 {
2053   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2054     (*it)->fillTypesOfFieldAvailable(types);
2055 }
2056
2057 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
2058 {
2059   int sz=_field_pm_pt.size();
2060   std::vector< std::vector<std::pair<int,int> > > ret(sz);
2061   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
2062   for(int i=0;i<sz;i++)
2063     {
2064       types[i]=_field_pm_pt[i]->getGeoType();
2065       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
2066     }
2067   return ret;
2068 }
2069
2070 double MEDFileFieldPerMesh::getTime() const
2071 {
2072   int tmp1,tmp2;
2073   return _father->getTime(tmp1,tmp2);
2074 }
2075
2076 int MEDFileFieldPerMesh::getIteration() const
2077 {
2078   return _father->getIteration();
2079 }
2080
2081 int MEDFileFieldPerMesh::getOrder() const
2082 {
2083   return _father->getOrder();
2084 }
2085
2086 int MEDFileFieldPerMesh::getNumberOfComponents() const
2087 {
2088   return _father->getNumberOfComponents();
2089 }
2090
2091 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
2092 {
2093   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2094     {
2095       if((*it).isNull())
2096         continue;
2097       if((*it)->presenceOfMultiDiscPerGeoType())
2098         return true;
2099     }
2100   return false;
2101 }
2102
2103 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
2104 {
2105   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2106     if((*it).isNotNull())
2107       {
2108         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2109         if(pt)
2110           return true;
2111       }
2112   return false;
2113 }
2114
2115 bool MEDFileFieldPerMesh::onlyStructureElements() const
2116 {
2117   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2118     if((*it).isNotNull())
2119       {
2120         const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2121         if(!pt)
2122           return false;
2123       }
2124   return true;
2125 }
2126
2127 void MEDFileFieldPerMesh::killStructureElements()
2128 {
2129   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2130   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2131     {
2132       if((*it).isNotNull())
2133         {
2134           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2135           if(!pt)
2136             res.push_back(*it);
2137         }
2138     }
2139   _field_pm_pt=res;
2140 }
2141
2142 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2143 {
2144   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2145   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2146     {
2147       if((*it).isNotNull())
2148         {
2149           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2150           if(pt)
2151             res.push_back(*it);
2152         }
2153     }
2154   _field_pm_pt=res;
2155 }
2156
2157 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2158 {
2159   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2160   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2161     {
2162       if((*it).isNotNull())
2163         {
2164           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2165           if(!pt)
2166             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2167           if(pt->getModelName()==seName)
2168             res.push_back(*it);
2169         }
2170     }
2171   _field_pm_pt=res;
2172 }
2173
2174 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2175 {
2176   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2177     {
2178       if((*it).isNotNull())
2179         {
2180           const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2181           if(pt)
2182             {
2183               ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2184             }
2185           else
2186             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2187         }
2188     }
2189 }
2190
2191 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2192 {
2193   if(!_father)
2194     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2195   return _father->getOrCreateAndGetArray();
2196 }
2197
2198 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2199 {
2200   if(!_father)
2201     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2202   return _father->getOrCreateAndGetArray();
2203 }
2204
2205 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2206 {
2207   return _father->getInfo();
2208 }
2209
2210 /*!
2211  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2212  * 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.
2213  * It returns 2 output vectors :
2214  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2215  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2216  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2217  */
2218 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)
2219 {
2220   int notNullPflsSz=0;
2221   int nbOfArrs=geoTypes.size();
2222   for(int i=0;i<nbOfArrs;i++)
2223     if(pfls[i])
2224       notNullPflsSz++;
2225   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2226   int nbOfDiffGeoTypes=geoTypes3.size();
2227   code.resize(3*nbOfDiffGeoTypes);
2228   notNullPfls.resize(notNullPflsSz);
2229   notNullPflsSz=0;
2230   int j=0;
2231   for(int i=0;i<nbOfDiffGeoTypes;i++)
2232     {
2233       int startZone=j;
2234       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2235       std::vector<const DataArrayInt *> notNullTmp;
2236       if(pfls[j])
2237         notNullTmp.push_back(pfls[j]);
2238       j++;
2239       for(;j<nbOfArrs;j++)
2240         if(geoTypes[j]==refType)
2241           {
2242             if(pfls[j])
2243               notNullTmp.push_back(pfls[j]);
2244           }
2245         else
2246           break;
2247       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2248       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2249       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2250       code[3*i]=(int)refType;
2251       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2252       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2253       if(notNullTmp.empty())
2254         code[3*i+2]=-1;
2255       else
2256         {
2257           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2258           code[3*i+2]=notNullPflsSz++;
2259         }
2260     }
2261 }
2262
2263 /*!
2264  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2265  */
2266 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)
2267 {
2268   int sz=dads.size();
2269   int ret=0;
2270   for(int i=0;i<sz;i++)
2271     {
2272       if(locs[i]==-1)
2273         {
2274           if(type!=ON_GAUSS_NE)
2275             ret+=dads[i].second-dads[i].first;
2276           else
2277             {
2278               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2279               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2280             }
2281         }
2282       else
2283         {
2284           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2285           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2286         }
2287     }
2288   return ret;
2289 }
2290
2291 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2292 {
2293   std::vector<std::string> ret;
2294   std::set<std::string> ret2;
2295   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2296     {
2297       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2298       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2299         if(ret2.find(*it2)==ret2.end())
2300           {
2301             ret.push_back(*it2);
2302             ret2.insert(*it2);
2303           }
2304     }
2305   return ret;
2306 }
2307
2308 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2309 {
2310   std::vector<std::string> ret;
2311   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312     {
2313       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2314       ret.insert(ret.end(),tmp.begin(),tmp.end());
2315     }
2316   return ret;
2317 }
2318
2319 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2320 {
2321   std::vector<std::string> ret;
2322   std::set<std::string> ret2;
2323   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2324     {
2325       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2326       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2327         if(ret2.find(*it2)==ret2.end())
2328           {
2329             ret.push_back(*it2);
2330             ret2.insert(*it2);
2331           }
2332     }
2333   return ret;
2334 }
2335
2336 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2337 {
2338   std::vector<std::string> ret;
2339   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2340     {
2341       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2342       ret.insert(ret.end(),tmp.begin(),tmp.end());
2343     }
2344   return ret;
2345 }
2346
2347 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2348 {
2349   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2350     {
2351       if((*it).first==_mesh_name)
2352         {
2353           _mesh_name=(*it).second;
2354           return true;
2355         }
2356     }
2357   return false;
2358 }
2359
2360 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2361 {
2362   if(_field_pm_pt.size()!=1)
2363     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2364   if(_field_pm_pt[0].isNull())
2365     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2366   MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2367   if(!pt)
2368     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2369   if(pt->getNumberOfLoc()!=1)
2370     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2371   const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2372   if(!disc)
2373     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2374   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2375   disc2->setType(ON_NODES);
2376   MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2377   disc2->setFather(pt2);
2378   pt2->setFather(this);
2379   pt2->pushDiscretization(disc2);
2380   _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2381 }
2382
2383 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2384                                                       MEDFileFieldGlobsReal& glob)
2385 {
2386   if(_mesh_name!=meshName)
2387     return false;
2388   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2389   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2390   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2391   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2392   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2393   getUndergroundDataArrayExt(entries);
2394   DataArray *arr0(getOrCreateAndGetArray());//tony
2395   if(!arr0)
2396     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2397   DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2398   if(!arr0)
2399     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2400   int sz=0;
2401   if(!arr)
2402     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2403   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2404     {
2405       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2406         {
2407           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2408           sz+=(*it).second.second-(*it).second.first;
2409         }
2410       else
2411         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2412     }
2413   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2414   ////////////////////
2415   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2416   int *workI2=explicitIdsOldInMesh->getPointer();
2417   int sz1=0,sz2=0,sid=1;
2418   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2419   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2420   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2421     {
2422       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2423       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2424       int *workI=explicitIdsOldInArr->getPointer();
2425       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2426         {
2427           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2428           (*itL2)->setLocId(sz2);
2429           (*itL2)->_tmp_work1=(*itL2)->getStart();
2430           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2431         }
2432       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2433     }
2434   explicitIdsOldInMesh->reAlloc(sz2);
2435   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2436   ////////////////////
2437   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2438   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2439   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2440   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2441     {
2442       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2443       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2444       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2445     }
2446   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2447   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2448   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2449     {
2450       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2451       int newStart=elt->getLocId();
2452       elt->setLocId((*it)->getGeoType());
2453       elt->setNewStart(newStart);
2454       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2455       entriesKeptNew.push_back(elt);
2456       entriesKeptNew2.push_back(elt);
2457     }
2458   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2459   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2460   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2461   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2462   bool ret=false;
2463   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2464     {
2465       sid=0;
2466       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2467         {
2468           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2469           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2470           }*/
2471       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2472                                                             glob,arr2,otherEntriesNew) || ret;
2473     }
2474   if(!ret)
2475     return false;
2476   // Assign new dispatching
2477   assignNewLeaves(otherEntriesNew);
2478   arr->deepCopyFrom(*arr2);
2479   return true;
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::keepOnlySpatialDiscretization(TypeOfField tof, 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)->keepOnlySpatialDiscretization(tof,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 /*!
2502  * \param [in,out] globalNum a global numbering counter for the renumbering.
2503  * \param [out] its - list of pair (start,stop) kept
2504  */
2505 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2506 {
2507   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2508   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2509     {
2510       std::vector< std::pair<int,int> > its2;
2511       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2512         {
2513           ret.push_back(*it);
2514           its.insert(its.end(),its2.begin(),its2.end());
2515         }
2516     }
2517   _field_pm_pt=ret;
2518 }
2519
2520 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2521 {
2522   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2523   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2524     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2525   //
2526   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2527   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2528   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2529   for(;it1!=types.end();it1++,it2++)
2530     {
2531       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2532       elt->setLeaves((*it1).second);
2533       MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2534       *it2=elt2;
2535     }
2536   _field_pm_pt=fieldPmPt;
2537 }
2538
2539 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2540 {
2541   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2542     (*it)->changePflsRefsNamesGen(mapOfModif);
2543 }
2544
2545 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2546 {
2547   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2548     (*it)->changeLocsRefsNamesGen(mapOfModif);
2549 }
2550
2551 /*!
2552  * \param [in] mesh is the whole mesh
2553  */
2554 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2555 {
2556   if(_field_pm_pt.empty())
2557     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2558   //
2559   std::vector< std::pair<int,int> > dads;
2560   std::vector<const DataArrayInt *> pfls;
2561   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2562   std::vector<int> locs,code;
2563   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2564   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2565     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2566   // Sort by types
2567   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2568   if(code.empty())
2569     {
2570       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2571       throw INTERP_KERNEL::Exception(oss.str());
2572     }
2573   //
2574   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2575   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2576   if(type!=ON_NODES)
2577     {
2578       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2579       if(!arr)
2580         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2581       else
2582         {
2583           MCAuto<DataArrayInt> arr2(arr);
2584           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2585         }
2586     }
2587   else
2588     {
2589       if(code.size()!=3)
2590         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2591       int nb=code[1];
2592       if(code[2]==-1)
2593         {
2594           if(nb!=mesh->getNumberOfNodes())
2595             {
2596               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2597               oss << " nodes in mesh !";
2598               throw INTERP_KERNEL::Exception(oss.str());
2599             }
2600           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2601         }
2602       else
2603         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2604     }
2605 }
2606
2607 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2608 {
2609   if(_field_pm_pt.empty())
2610     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2611   //
2612   std::vector<std::pair<int,int> > dads;
2613   std::vector<const DataArrayInt *> pfls;
2614   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2615   std::vector<int> locs,code;
2616   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2617   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2618     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2619   // Sort by types
2620   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2621   if(code.empty())
2622     {
2623       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2624       throw INTERP_KERNEL::Exception(oss.str());
2625     }
2626   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2627   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2628   if(type!=ON_NODES)
2629     {
2630       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2631       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2632     }
2633   else
2634     {
2635       if(code.size()!=3)
2636         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2637       int nb=code[1];
2638       if(code[2]==-1)
2639         {
2640           if(nb!=mesh->getNumberOfNodes())
2641             {
2642               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2643               oss << " nodes in mesh !";
2644               throw INTERP_KERNEL::Exception(oss.str());
2645             }
2646         }
2647       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2648     }
2649   //
2650   return 0;
2651 }
2652
2653 void MEDFileFieldPerMesh::accept(MEDFileFieldVisitor& visitor) const
2654 {
2655   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2656     if((*it).isNotNull())
2657       {
2658         visitor.newPerMeshPerTypeEntry(*it);
2659         (*it)->accept(visitor);
2660         visitor.endPerMeshPerTypeEntry(*it);
2661       }
2662 }
2663
2664 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2665 {
2666   int globalSz=0;
2667   int nbOfEntries=0;
2668   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2669     {
2670       (*it)->getSizes(globalSz,nbOfEntries);
2671     }
2672   entries.resize(nbOfEntries);
2673   nbOfEntries=0;
2674   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2675     {
2676       (*it)->fillValues(nbOfEntries,entries);
2677     }
2678 }
2679
2680 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2681 {
2682   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2683     {
2684       if((*it)->getGeoType()==typ)
2685         return (*it)->getLeafGivenLocId(locId);
2686     }
2687   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2688   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2689   oss << "Possiblities are : ";
2690   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2691     {
2692       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2693       oss << "\"" << cm2.getRepr() << "\", ";
2694     }
2695   throw INTERP_KERNEL::Exception(oss.str());
2696 }
2697
2698 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2699 {
2700   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2701     {
2702       if((*it)->getGeoType()==typ)
2703         return (*it)->getLeafGivenLocId(locId);
2704     }
2705   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2706   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2707   oss << "Possiblities are : ";
2708   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2709     {
2710       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2711       oss << "\"" << cm2.getRepr() << "\", ";
2712     }
2713   throw INTERP_KERNEL::Exception(oss.str());
2714 }
2715
2716 /*!
2717  * \param [in,out] start - Integer that gives the current position in the final aggregated array
2718  * \param [in] pms - list of elements to aggregate. integer gives the mesh id 
2719  * \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.
2720  * \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.
2721  */
2722 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)
2723 {
2724   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2725   if(pms.empty())
2726     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2727   for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2728     {
2729       if(!(*it).second)
2730         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2731       if(!(*it).second->getProfile().empty())
2732         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2733       if(!(*it).second->getLocalization().empty())
2734         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2735     }
2736   INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2737   std::size_t i(0);
2738   std::vector< std::pair<int,int> > filteredDTS;
2739   for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2740     for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2741       if((*it2).first==gt)
2742         filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2743   if(pms.size()!=filteredDTS.size())
2744     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2745   std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2746   std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2747   int zeStart(start),nval(0);
2748   for(;it1!=pms.end();it1++,it2++)
2749     {
2750       if((*it1).first!=(*it2).first)
2751         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2752       int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2753       extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2754       start+=e1-s1;
2755       nval+=((*it1).second)->getNumberOfVals();
2756     }
2757   ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2758   return ret;
2759 }
2760
2761 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)
2762 {
2763   MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2764   std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2765   std::size_t i(0);
2766   for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2767     {
2768       const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2769       for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2770         {
2771           INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2772           const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2773           if(!elt)
2774             throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2775           m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2776         }
2777     }
2778   for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2779     {
2780       MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2781       MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2782       ret->_field_pm_pt.push_back(agg2);
2783     }
2784   return ret;
2785 }
2786
2787 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2788 {
2789   int i=0;
2790   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2791   std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2792   for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2793     {
2794       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2795       if(type==curType)
2796         return i;
2797       else
2798         {
2799           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2800           if(pos>pos2)
2801             it2=it+1;
2802         }
2803     }
2804   int ret=std::distance(_field_pm_pt.begin(),it2);
2805   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2806   return ret;
2807 }
2808
2809 /*!
2810  * 'dads' and 'locs' input parameters have the same number of elements
2811  * \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
2812  */
2813 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2814                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2815                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2816 {
2817   isPfl=false;
2818   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2819   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2820   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2821   const std::vector<std::string>& infos=getInfo();
2822   da->setInfoOnComponents(infos);
2823   da->setName("");
2824   if(type==ON_GAUSS_PT)
2825     {
2826       int offset=0;
2827       int nbOfArrs=dads.size();
2828       for(int i=0;i<nbOfArrs;i++)
2829         {
2830           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2831           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2832           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2833           MCAuto<DataArrayInt> di=DataArrayInt::New();
2834           di->alloc(nbOfElems,1);
2835           di->iota(offset);
2836           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2837           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2838           offset+=nbOfElems;
2839         }
2840     }
2841   arrOut=da;
2842   return ret.retn();
2843 }
2844
2845 /*!
2846  * 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.
2847  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2848  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2849  * The order of cells in the returned field is those imposed by the profile.
2850  * \param [in] mesh is the global mesh.
2851  */
2852 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2853                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2854                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2855                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2856 {
2857   if(da->isIota(mesh->getNumberOfCells()))
2858     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2859   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2860   m2->setName(mesh->getName().c_str());
2861   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2862   isPfl=true;
2863   return ret.retn();
2864 }
2865
2866 /*!
2867  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2868  */
2869 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2870                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2871                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2872 {
2873   if(da->isIota(mesh->getNumberOfNodes()))
2874     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2875   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2876   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2877   if(meshu)
2878     {
2879       if(meshu->getNodalConnectivity()==0)
2880         {
2881           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2882           int nb=da->getNbOfElems();
2883           const int *ptr=da->getConstPointer();
2884           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2885           meshuc->allocateCells(nb);
2886           for(int i=0;i<nb;i++)
2887             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2888           meshuc->finishInsertingCells();
2889           ret->setMesh(meshuc);
2890           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2891           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2892           disc->checkCoherencyBetween(meshuc,arrOut);
2893           return ret.retn();
2894         }
2895     }
2896   //
2897   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2898   isPfl=true;
2899   DataArrayInt *arr2=0;
2900   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2901   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2902   MCAuto<DataArrayInt> arr3(arr2);
2903   int nnodes=mesh2->getNumberOfNodes();
2904   if(nnodes==(int)da->getNbOfElems())
2905     {
2906       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2907       arrOut->renumberInPlace(da3->getConstPointer());
2908       mesh2->setName(mesh->getName().c_str());
2909       ret->setMesh(mesh2);
2910       return ret.retn();
2911     }
2912   else
2913     {
2914       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 !!!";
2915       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2916       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2917       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2918       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2919       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2920       throw INTERP_KERNEL::Exception(oss.str());
2921     }
2922   return 0;
2923 }
2924
2925 /*!
2926  * This method is the most light method of field retrieving.
2927  */
2928 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2929 {
2930   if(!pflIn)
2931     {
2932       pflOut=DataArrayInt::New();
2933       pflOut->alloc(nbOfElems,1);
2934       pflOut->iota(0);
2935     }
2936   else
2937     {
2938       pflOut=const_cast<DataArrayInt*>(pflIn);
2939       pflOut->incrRef();
2940     }
2941   MCAuto<DataArrayInt> safePfl(pflOut);
2942   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2943   const std::vector<std::string>& infos=getInfo();
2944   int nbOfComp=infos.size();
2945   for(int i=0;i<nbOfComp;i++)
2946     da->setInfoOnComponent(i,infos[i].c_str());
2947   safePfl->incrRef();
2948   return da.retn();
2949 }
2950
2951
2952 /// @cond INTERNAL
2953
2954 class MFFPMIter
2955 {
2956 public:
2957   static MFFPMIter *NewCell(const MEDFileEntities *entities);
2958   static bool IsPresenceOfNode(const MEDFileEntities *entities);
2959   virtual ~MFFPMIter() { }
2960   virtual void begin() = 0;
2961   virtual bool finished() const = 0;
2962   virtual void next() = 0;
2963   virtual int current() const = 0;
2964 };
2965
2966 class MFFPMIterSimple : public MFFPMIter
2967 {
2968 public:
2969   MFFPMIterSimple():_pos(0) { }
2970   void begin() { _pos=0; }
2971   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2972   void next() { _pos++; }
2973   int current() const { return _pos; }
2974 private:
2975   int _pos;
2976 };
2977
2978 class MFFPMIter2 : public MFFPMIter
2979 {
2980 public:
2981   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2982   void begin() { _it=_ids.begin(); }
2983   bool finished() const { return _it==_ids.end(); }
2984   void next() { _it++; }
2985   int current() const { return *_it; }
2986 private:
2987   std::vector<int> _ids;
2988   std::vector<int>::const_iterator _it;
2989 };
2990
2991 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2992 {
2993   if(!entities)
2994     return new MFFPMIterSimple;
2995   else
2996     {
2997       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2998       if(entities2)
2999         {
3000           std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
3001           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3002           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3003             {
3004               if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
3005                 tmp.push_back((*it).second);
3006             }
3007           return new MFFPMIter2(tmp);
3008         }
3009       return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
3010     }
3011 }
3012
3013 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
3014 {
3015   if(!entities)
3016     return true;
3017   else
3018     {
3019       const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
3020       if(entities2)
3021         {
3022           const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
3023           for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
3024             if((*it).first==ON_NODES)
3025               return true;
3026           return false;
3027         }
3028       return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
3029     }
3030 }
3031
3032 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
3033 {
3034   std::size_t sz(cts.size());
3035   _ids.resize(sz);
3036   for(std::size_t i=0;i<sz;i++)
3037     {
3038       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
3039       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
3040         _ids[i]=(int)std::distance(typmai2,loc);
3041       else
3042         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
3043     }
3044 }
3045
3046 /// @endcond
3047
3048 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),
3049     _father(fath)
3050 {
3051   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3052   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3053   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
3054   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
3055   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
3056   for(iter0->begin();!iter0->finished();iter0->next())
3057     {
3058       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3059       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3060       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
3061       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
3062       if(nbProfile>0 || nbProfile2>0)
3063         {
3064           const PartDefinition *pd(0);
3065           if(mmu)
3066             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
3067           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
3068           if(nbProfile>0)
3069             _mesh_name=name0;
3070           else
3071             _mesh_name=name1;
3072         }
3073     }
3074   if(MFFPMIter::IsPresenceOfNode(entities))
3075     {
3076       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
3077       if(nbProfile>0)
3078         {
3079           const PartDefinition *pd(0);
3080           if(mmu)
3081             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
3082           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
3083           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3084         }
3085     }
3086   if(!entities)
3087     return ;
3088   std::vector<int> dynGT(entities->getDynGTAvail());
3089   for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
3090     {
3091       int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
3092       if(nbPfl>0)
3093         {
3094           _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
3095           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
3096         }
3097     }
3098 }
3099
3100 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
3101 {
3102   copyTinyInfoFrom(mesh);
3103 }
3104
3105 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3106 {
3107   if(id>=(int)_pfls.size())
3108     _pfls.resize(id+1);
3109   _pfls[id]=DataArrayInt::New();
3110   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
3111   _pfls[id]->setName(pflName);
3112   _pfls[id]->alloc(lgth,1);
3113   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
3114   _pfls[id]->applyLin(1,-1,0);//Converting into C format
3115 }
3116
3117 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
3118 {
3119   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3120   int sz;
3121   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3122   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3123   if(i>=(int)_pfls.size())
3124     _pfls.resize(i+1);
3125   _pfls[i]=DataArrayInt::New();
3126   _pfls[i]->alloc(sz,1);
3127   _pfls[i]->setName(pflCpp.c_str());
3128   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3129   _pfls[i]->applyLin(1,-1,0);//Converting into C format
3130 }
3131
3132 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3133 {
3134   int nbOfPfls=_pfls.size();
3135   for(int i=0;i<nbOfPfls;i++)
3136     {
3137       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3138       cpy->applyLin(1,1,0);
3139       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3140       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3141       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3142     }
3143   //
3144   int nbOfLocs=_locs.size();
3145   for(int i=0;i<nbOfLocs;i++)
3146     _locs[i]->writeLL(fid);
3147 }
3148
3149 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3150 {
3151   std::vector<std::string> pfls=getPfls();
3152   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3153     {
3154       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3155       if(it2==pfls.end())
3156         {
3157           _pfls.push_back(*it);
3158         }
3159       else
3160         {
3161           int id=std::distance(pfls.begin(),it2);
3162           if(!(*it)->isEqual(*_pfls[id]))
3163             {
3164               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3165               throw INTERP_KERNEL::Exception(oss.str());
3166             }
3167         }
3168     }
3169   std::vector<std::string> locs=getLocs();
3170   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3171     {
3172       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3173       if(it2==locs.end())
3174         {
3175           _locs.push_back(*it);
3176         }
3177       else
3178         {
3179           int id=std::distance(locs.begin(),it2);
3180           if(!(*it)->isEqual(*_locs[id],eps))
3181             {
3182               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3183               throw INTERP_KERNEL::Exception(oss.str());
3184             }
3185         }
3186     }
3187 }
3188
3189 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3190 {
3191   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3192     getProfile((*it).c_str());
3193 }
3194
3195 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3196 {
3197   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3198     getLocalization((*it).c_str());
3199 }
3200
3201 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3202 {
3203   std::vector<std::string> profiles=real.getPflsReallyUsed();
3204   int sz=profiles.size();
3205   _pfls.resize(sz);
3206   for(int i=0;i<sz;i++)
3207     loadProfileInFile(fid,i,profiles[i].c_str());
3208   //
3209   std::vector<std::string> locs=real.getLocsReallyUsed();
3210   sz=locs.size();
3211   _locs.resize(sz);
3212   for(int i=0;i<sz;i++)
3213     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3214 }
3215
3216 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3217 {
3218   int nProfil=MEDnProfile(fid);
3219   for(int i=0;i<nProfil;i++)
3220     loadProfileInFile(fid,i);
3221   int sz=MEDnLocalization(fid);
3222   _locs.resize(sz);
3223   for(int i=0;i<sz;i++)
3224     {
3225       _locs[i]=MEDFileFieldLoc::New(fid,i,entities);
3226     }
3227 }
3228
3229 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3230 {
3231   return new MEDFileFieldGlobs(fid);
3232 }
3233
3234 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3235 {
3236   return new MEDFileFieldGlobs;
3237 }
3238
3239 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3240 {
3241   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3242 }
3243
3244 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3245 {
3246   std::vector<const BigMemoryObject *> ret;
3247   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3248     ret.push_back((const DataArrayInt *)*it);
3249   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3250     ret.push_back((const MEDFileFieldLoc *)*it);
3251   return ret;
3252 }
3253
3254 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3255 {
3256   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3257   std::size_t i=0;
3258   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3259     {
3260       if((const DataArrayInt *)*it)
3261         ret->_pfls[i]=(*it)->deepCopy();
3262     }
3263   i=0;
3264   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3265     {
3266       if((const MEDFileFieldLoc*)*it)
3267         ret->_locs[i]=(*it)->deepCopy();
3268     }
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::deepCpyPart
3276  */
3277 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(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::shallowCpyPart : internal error ! pfl null !");
3285       pfl->incrRef();
3286       MCAuto<DataArrayInt> pfl2(pfl);
3287       ret->_pfls.push_back(pfl2);
3288     }
3289   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3290     {
3291       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3292       if(!loc)
3293         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3294       loc->incrRef();
3295       MCAuto<MEDFileFieldLoc> loc2(loc);
3296       ret->_locs.push_back(loc2);
3297     }
3298   ret->setFileName(getFileName());
3299   return ret.retn();
3300 }
3301
3302 /*!
3303  * \throw if a profile in \a pfls in not in \a this.
3304  * \throw if a localization in \a locs in not in \a this.
3305  * \sa MEDFileFieldGlobs::shallowCpyPart
3306  */
3307 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3308 {
3309   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3310   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3311     {
3312       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3313       if(!pfl)
3314         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3315       ret->_pfls.push_back(pfl->deepCopy());
3316     }
3317   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3318     {
3319       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3320       if(!loc)
3321         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3322       ret->_locs.push_back(loc->deepCopy());
3323     }
3324   ret->setFileName(getFileName());
3325   return ret.retn();
3326 }
3327
3328 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3329 {
3330 }
3331
3332 MEDFileFieldGlobs::MEDFileFieldGlobs()
3333 {
3334 }
3335
3336 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3337 {
3338 }
3339
3340 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3341 {
3342   oss << "Profiles :\n";
3343   std::size_t n=_pfls.size();
3344   for(std::size_t i=0;i<n;i++)
3345     {
3346       oss << "  - #" << i << " ";
3347       const DataArrayInt *pfl=_pfls[i];
3348       if(pfl)
3349         oss << "\"" << pfl->getName() << "\"\n";
3350       else
3351         oss << "EMPTY !\n";
3352     }
3353   n=_locs.size();
3354   oss << "Localizations :\n";
3355   for(std::size_t i=0;i<n;i++)
3356     {
3357       oss << "  - #" << i << " ";
3358       const MEDFileFieldLoc *loc=_locs[i];
3359       if(loc)
3360         loc->simpleRepr(oss);
3361       else
3362         oss<< "EMPTY !\n";
3363     }
3364 }
3365
3366 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3367 {
3368   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3369     {
3370       DataArrayInt *elt(*it);
3371       if(elt)
3372         {
3373           std::string name(elt->getName());
3374           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3375             {
3376               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3377                 {
3378                   elt->setName((*it2).second.c_str());
3379                   return;
3380                 }
3381             }
3382         }
3383     }
3384 }
3385
3386 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3387 {
3388   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3389     {
3390       MEDFileFieldLoc *elt(*it);
3391       if(elt)
3392         {
3393           std::string name(elt->getName());
3394           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3395             {
3396               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3397                 {
3398                   elt->setName((*it2).second.c_str());
3399                   return;
3400                 }
3401             }
3402         }
3403     }
3404 }
3405
3406 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3407 {
3408   if(locId<0 || locId>=(int)_locs.size())
3409     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3410   return _locs[locId]->getNbOfGaussPtPerCell();
3411 }
3412
3413 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3414 {
3415   return getLocalizationFromId(getLocalizationId(locName));
3416 }
3417
3418 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3419 {
3420   if(locId<0 || locId>=(int)_locs.size())
3421     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3422   return *_locs[locId];
3423 }
3424
3425 /// @cond INTERNAL
3426 namespace MEDCouplingImpl
3427 {
3428   class LocFinder
3429   {
3430   public:
3431     LocFinder(const std::string& loc):_loc(loc) { }
3432     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3433   private:
3434     const std::string &_loc;
3435   };
3436
3437   class PflFinder
3438   {
3439   public:
3440     PflFinder(const std::string& pfl):_pfl(pfl) { }
3441     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3442   private:
3443     const std::string& _pfl;
3444   };
3445 }
3446 /// @endcond
3447
3448 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3449 {
3450   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3451   if(it==_locs.end())
3452     {
3453       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3454       for(it=_locs.begin();it!=_locs.end();it++)
3455         oss << "\"" << (*it)->getName() << "\", ";
3456       throw INTERP_KERNEL::Exception(oss.str());
3457     }
3458   return std::distance(_locs.begin(),it);
3459 }
3460
3461 /*!
3462  * The returned value is never null.
3463  */
3464 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3465 {
3466   std::string pflNameCpp(pflName);
3467   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3468   if(it==_pfls.end())
3469     {
3470       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3471       for(it=_pfls.begin();it!=_pfls.end();it++)
3472         oss << "\"" << (*it)->getName() << "\", ";
3473       throw INTERP_KERNEL::Exception(oss.str());
3474     }
3475   return *it;
3476 }
3477
3478 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3479 {
3480   if(pflId<0 || pflId>=(int)_pfls.size())
3481     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3482   return _pfls[pflId];
3483 }
3484
3485 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3486 {
3487   if(locId<0 || locId>=(int)_locs.size())
3488     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3489   return *_locs[locId];
3490 }
3491
3492 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3493 {
3494   return getLocalizationFromId(getLocalizationId(locName));
3495 }
3496
3497 /*!
3498  * The returned value is never null.
3499  */
3500 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3501 {
3502   std::string pflNameCpp(pflName);
3503   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3504   if(it==_pfls.end())
3505     {
3506       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3507       for(it=_pfls.begin();it!=_pfls.end();it++)
3508         oss << "\"" << (*it)->getName() << "\", ";
3509       throw INTERP_KERNEL::Exception(oss.str());
3510     }
3511   return *it;
3512 }
3513
3514 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3515 {
3516   if(pflId<0 || pflId>=(int)_pfls.size())
3517     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3518   return _pfls[pflId];
3519 }
3520
3521 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3522 {
3523   std::vector< MCAuto<DataArrayInt> > newPfls;
3524   int i=0;
3525   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3526     {
3527       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3528         newPfls.push_back(*it);
3529     }
3530   _pfls=newPfls;
3531 }
3532
3533 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3534 {
3535   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3536   int i=0;
3537   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3538     {
3539       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3540         newLocs.push_back(*it);
3541     }
3542   _locs=newLocs;
3543 }
3544
3545 void MEDFileFieldGlobs::killStructureElementsInGlobs()
3546 {
3547   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3548   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3549     {
3550       if((*it).isNull())
3551         continue;
3552       if(!(*it)->isOnStructureElement())
3553         newLocs.push_back(*it);
3554     }
3555   _locs=newLocs;
3556 }
3557
3558 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3559 {
3560   int sz=_pfls.size();
3561   std::vector<std::string> ret(sz);
3562   for(int i=0;i<sz;i++)
3563     ret[i]=_pfls[i]->getName();
3564   return ret;
3565 }
3566
3567 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3568 {
3569   int sz=_locs.size();
3570   std::vector<std::string> ret(sz);
3571   for(int i=0;i<sz;i++)
3572     ret[i]=_locs[i]->getName();
3573   return ret;
3574 }
3575
3576 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3577 {
3578   std::vector<std::string> v=getPfls();
3579   std::string s(pflName);
3580   return std::find(v.begin(),v.end(),s)!=v.end();
3581 }
3582
3583 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3584 {
3585   std::vector<std::string> v=getLocs();
3586   std::string s(locName);
3587   return std::find(v.begin(),v.end(),s)!=v.end();
3588 }
3589
3590 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3591 {
3592   std::map<int,std::vector<int> > m;
3593   int i=0;
3594   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3595     {
3596       const DataArrayInt *tmp=(*it);
3597       if(tmp)
3598         {
3599           m[tmp->getHashCode()].push_back(i);
3600         }
3601     }
3602   std::vector< std::vector<int> > ret;
3603   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3604     {
3605       if((*it2).second.size()>1)
3606         {
3607           std::vector<int> ret0;
3608           bool equalityOrNot=false;
3609           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3610             {
3611               std::vector<int>::const_iterator it4=it3; it4++;
3612               for(;it4!=(*it2).second.end();it4++)
3613                 {
3614                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3615                     {
3616                       if(!equalityOrNot)
3617                         ret0.push_back(*it3);
3618                       ret0.push_back(*it4);
3619                       equalityOrNot=true;
3620                     }
3621                 }
3622             }
3623           if(!ret0.empty())
3624             ret.push_back(ret0);
3625         }
3626     }
3627   return ret;
3628 }
3629
3630 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3631 {
3632   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3633 }
3634
3635 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3636 {
3637   std::string name(pfl->getName());
3638   if(name.empty())
3639     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3640   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3641     if(name==(*it)->getName())
3642       {
3643         if(!pfl->isEqual(*(*it)))
3644           {
3645             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3646             throw INTERP_KERNEL::Exception(oss.str());
3647           }
3648       }
3649   pfl->incrRef();
3650   _pfls.push_back(pfl);
3651 }
3652
3653 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)
3654 {
3655   std::string name(locName);
3656   if(name.empty())
3657     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3658   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3659   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3660     if((*it)->isName(locName))
3661       {
3662         if(!(*it)->isEqual(*obj,1e-12))
3663           {
3664             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3665             throw INTERP_KERNEL::Exception(oss.str());
3666           }
3667       }
3668   _locs.push_back(obj);
3669 }
3670
3671 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3672 {
3673   std::vector<std::string> names=getPfls();
3674   return CreateNewNameNotIn("NewPfl_",names);
3675 }
3676
3677 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3678 {
3679   std::vector<std::string> names=getLocs();
3680   return CreateNewNameNotIn("NewLoc_",names);
3681 }
3682
3683 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3684 {
3685   for(std::size_t sz=0;sz<100000;sz++)
3686     {
3687       std::ostringstream tryName;
3688       tryName << prefix << sz;
3689       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3690         return tryName.str();
3691     }
3692   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3693 }
3694
3695 /*!
3696  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3697  *  \param [in] fname - the file name.
3698  */
3699 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3700 {
3701 }
3702
3703 /*!
3704  * Creates an empty MEDFileFieldGlobsReal.
3705  */
3706 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3707 {
3708 }
3709
3710 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3711 {
3712   return 0;
3713 }
3714
3715 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3716 {
3717   std::vector<const BigMemoryObject *> ret;
3718   ret.push_back((const MEDFileFieldGlobs *)_globals);
3719   return ret;
3720 }
3721
3722 /*!
3723  * Returns a string describing profiles and Gauss points held in \a this.
3724  *  \return std::string - the description string.
3725  */
3726 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3727 {
3728   const MEDFileFieldGlobs *glob=_globals;
3729   std::ostringstream oss2; oss2 << glob;
3730   std::string stars(oss2.str().length(),'*');
3731   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3732   if(glob)
3733     glob->simpleRepr(oss);
3734   else
3735     oss << "NO GLOBAL INFORMATION !\n";
3736 }
3737
3738 void MEDFileFieldGlobsReal::resetContent()
3739 {
3740   _globals=MEDFileFieldGlobs::New();
3741 }
3742
3743 void MEDFileFieldGlobsReal::killStructureElementsInGlobs()
3744 {
3745   contentNotNull()->killStructureElementsInGlobs();
3746 }
3747
3748 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3749 {
3750 }
3751
3752 /*!
3753  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3754  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3755  */
3756 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3757 {
3758   _globals=other._globals;
3759 }
3760
3761 /*!
3762  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3763  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3764  */
3765 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3766 {
3767   const MEDFileFieldGlobs *otherg(other._globals);
3768   if(!otherg)
3769     return ;
3770   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3771 }
3772
3773 /*!
3774  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3775  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3776  */
3777 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3778 {
3779   const MEDFileFieldGlobs *otherg(other._globals);
3780   if(!otherg)
3781     return ;
3782   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3783 }
3784
3785 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3786 {
3787   _globals=other._globals;
3788   if((const MEDFileFieldGlobs *)_globals)
3789     _globals=other._globals->deepCopy();
3790 }
3791
3792 /*!
3793  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3794  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3795  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3796  *         \a this and \a other MEDFileFieldGlobsReal.
3797  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3798  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3799  */
3800 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3801 {
3802   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3803   if(thisGlobals==otherGlobals)
3804     return ;
3805   if(!thisGlobals)
3806     {
3807       _globals=other._globals;
3808       return ;
3809     }
3810   _globals->appendGlobs(*other._globals,eps);
3811 }
3812
3813 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3814 {
3815   checkGlobsPflsPartCoherency();
3816   checkGlobsLocsPartCoherency();
3817 }
3818
3819 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3820 {
3821   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3822 }
3823
3824 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3825 {
3826   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3827 }
3828
3829 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3830 {
3831   contentNotNull()->loadProfileInFile(fid,id,pflName);
3832 }
3833
3834 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3835 {
3836   contentNotNull()->loadProfileInFile(fid,id);
3837 }
3838
3839 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3840 {
3841   contentNotNull()->loadGlobals(fid,*this);
3842 }
3843
3844 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid, const MEDFileEntities *entities)
3845 {
3846   contentNotNull()->loadAllGlobals(fid,entities);
3847 }
3848
3849 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3850 {
3851   contentNotNull()->writeGlobals(fid,opt);
3852 }
3853
3854 /*!
3855  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3856  * or getPflsReallyUsedMulti().
3857  *  \return std::vector<std::string> - a sequence of names of all profiles.
3858  */
3859 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3860 {
3861   return contentNotNull()->getPfls();
3862 }
3863
3864 /*!
3865  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3866  * or getLocsReallyUsedMulti().
3867  *  \return std::vector<std::string> - a sequence of names of all localizations.
3868  */
3869 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3870 {
3871   return contentNotNull()->getLocs();
3872 }
3873
3874 /*!
3875  * Checks if the profile with a given name exists.
3876  *  \param [in] pflName - the profile name of interest.
3877  *  \return bool - \c true if the profile named \a pflName exists.
3878  */
3879 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3880 {
3881   return contentNotNull()->existsPfl(pflName);
3882 }
3883
3884 /*!
3885  * Checks if the localization with a given name exists.
3886  *  \param [in] locName - the localization name of interest.
3887  *  \return bool - \c true if the localization named \a locName exists.
3888  */
3889 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3890 {
3891   return contentNotNull()->existsLoc(locName);
3892 }
3893
3894 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3895 {
3896   return contentNotNull()->createNewNameOfPfl();
3897 }
3898
3899 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3900 {
3901   return contentNotNull()->createNewNameOfLoc();
3902 }
3903
3904 /*!
3905  * Sets the name of a MED file.
3906  *  \param [inout] fileName - the file name.
3907  */
3908 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3909 {
3910   contentNotNull()->setFileName(fileName);
3911 }
3912
3913 /*!
3914  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3915  * in the same order.
3916  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3917  *          Each item of this sequence is a vector containing ids of equal profiles.
3918  */
3919 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3920 {
3921   return contentNotNull()->whichAreEqualProfiles();
3922 }
3923
3924 /*!
3925  * Finds equal localizations.
3926  *  \param [in] eps - a precision used to compare real values of the localizations.
3927  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3928  *          Each item of this sequence is a vector containing ids of equal localizations.
3929  */
3930 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3931 {
3932   return contentNotNull()->whichAreEqualLocs(eps);
3933 }
3934
3935 /*!
3936  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3937  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3938  *        this sequence is a pair whose 
3939  *        - the first item is a vector of profile names to replace by the second item,
3940  *        - the second item is a profile name to replace every profile name of the first item.
3941  */
3942 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3943 {
3944   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3945 }
3946
3947 /*!
3948  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3949  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3950  *        this sequence is a pair whose 
3951  *        - the first item is a vector of localization names to replace by the second item,
3952  *        - the second item is a localization name to replace every localization name of the first item.
3953  */
3954 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3955 {
3956   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3957 }
3958
3959 /*!
3960  * Replaces references to some profiles (a reference is a profile name) by references
3961  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3962  * them-selves accordingly. <br>
3963  * This method is a generalization of changePflName().
3964  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3965  *        this sequence is a pair whose 
3966  *        - the first item is a vector of profile names to replace by the second item,
3967  *        - the second item is a profile name to replace every profile of the first item.
3968  * \sa changePflsRefsNamesGen()
3969  * \sa changePflName()
3970  */
3971 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3972 {
3973   changePflsRefsNamesGen(mapOfModif);
3974   changePflsNamesInStruct(mapOfModif);
3975 }
3976
3977 /*!
3978  * Replaces references to some localizations (a reference is a localization name) by references
3979  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3980  * them-selves accordingly. <br>
3981  * This method is a generalization of changeLocName().
3982  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3983  *        this sequence is a pair whose 
3984  *        - the first item is a vector of localization names to replace by the second item,
3985  *        - the second item is a localization name to replace every localization of the first item.
3986  * \sa changeLocsRefsNamesGen()
3987  * \sa changeLocName()
3988  */
3989 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3990 {
3991   changeLocsRefsNamesGen(mapOfModif);
3992   changeLocsNamesInStruct(mapOfModif);
3993 }
3994
3995 /*!
3996  * Renames the profile having a given name and updates references to this profile.
3997  *  \param [in] oldName - the name of the profile to rename.
3998  *  \param [in] newName - a new name of the profile.
3999  * \sa changePflsNames().
4000  */
4001 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
4002 {
4003   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4004   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4005   mapOfModif[0]=p;
4006   changePflsNames(mapOfModif);
4007 }
4008
4009 /*!
4010  * Renames the localization having a given name and updates references to this localization.
4011  *  \param [in] oldName - the name of the localization to rename.
4012  *  \param [in] newName - a new name of the localization.
4013  * \sa changeLocsNames().
4014  */
4015 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
4016 {
4017   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
4018   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
4019   mapOfModif[0]=p;
4020   changeLocsNames(mapOfModif);
4021 }
4022
4023 /*!
4024  * Removes duplicated profiles. Returns a map used to update references to removed 
4025  * profiles via changePflsRefsNamesGen().
4026  * Equal profiles are found using whichAreEqualProfiles().
4027  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
4028  *          a sequence describing the performed replacements of profiles. Each element of
4029  *          this sequence is a pair whose
4030  *          - the first item is a vector of profile names replaced by the second item,
4031  *          - the second item is a profile name replacing every profile of the first item.
4032  */
4033 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
4034 {
4035   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
4036   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4037   int i=0;
4038   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4039     {
4040       std::vector< std::string > tmp((*it).size());
4041       int j=0;
4042       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4043         tmp[j]=std::string(getProfileFromId(*it2)->getName());
4044       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4045       ret[i]=p;
4046       std::vector<int> tmp2((*it).begin()+1,(*it).end());
4047       killProfileIds(tmp2);
4048     }
4049   changePflsRefsNamesGen(ret);
4050   return ret;
4051 }
4052
4053 /*!
4054  * Removes duplicated localizations. Returns a map used to update references to removed 
4055  * localizations via changeLocsRefsNamesGen().
4056  * Equal localizations are found using whichAreEqualLocs().
4057  *  \param [in] eps - a precision used to compare real values of the localizations.
4058  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
4059  *          a sequence describing the performed replacements of localizations. Each element of
4060  *          this sequence is a pair whose
4061  *          - the first item is a vector of localization names replaced by the second item,
4062  *          - the second item is a localization name replacing every localization of the first item.
4063  */
4064 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
4065 {
4066   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
4067   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
4068   int i=0;
4069   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
4070     {
4071       std::vector< std::string > tmp((*it).size());
4072       int j=0;
4073       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
4074         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
4075       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
4076       ret[i]=p;
4077       std::vector<int> tmp2((*it).begin()+1,(*it).end());
4078       killLocalizationIds(tmp2);
4079     }
4080   changeLocsRefsNamesGen(ret);
4081   return ret;
4082 }
4083
4084 /*!
4085  * Returns number of Gauss points per cell in a given localization.
4086  *  \param [in] locId - an id of the localization of interest.
4087  *  \return int - the number of the Gauss points per cell.
4088  */
4089 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
4090 {
4091   return contentNotNull()->getNbOfGaussPtPerCell(locId);
4092 }
4093
4094 /*!
4095  * Returns an id of a localization by its name.
4096  *  \param [in] loc - the localization name of interest.
4097  *  \return int - the id of the localization.
4098  *  \throw If there is no a localization named \a loc.
4099  */
4100 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
4101 {
4102   return contentNotNull()->getLocalizationId(loc);
4103 }
4104
4105 /*!
4106  * Returns the name of the MED file.
4107  *  \return const std::string&  - the MED file name.
4108  */
4109 std::string MEDFileFieldGlobsReal::getFileName() const
4110 {
4111   return contentNotNull()->getFileName();
4112 }
4113
4114 /*!
4115  * Returns a localization object by its name.
4116  *  \param [in] locName - the name of the localization of interest.
4117  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
4118  *  \throw If there is no a localization named \a locName.
4119  */
4120 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
4121 {
4122   return contentNotNull()->getLocalization(locName);
4123 }
4124
4125 /*!
4126  * Returns a localization object by its id.
4127  *  \param [in] locId - the id of the localization of interest.
4128  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
4129  *  \throw If there is no a localization with id \a locId.
4130  */
4131 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
4132 {
4133   return contentNotNull()->getLocalizationFromId(locId);
4134 }
4135
4136 /*!
4137  * Returns a profile array by its name.
4138  *  \param [in] pflName - the name of the profile of interest.
4139  *  \return const DataArrayInt * - the profile array having the name \a pflName.
4140  *  \throw If there is no a profile named \a pflName.
4141  */
4142 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4143 {
4144   return contentNotNull()->getProfile(pflName);
4145 }
4146
4147 /*!
4148  * Returns a profile array by its id.
4149  *  \param [in] pflId - the id of the profile of interest.
4150  *  \return const DataArrayInt * - the profile array having the id \a pflId.
4151  *  \throw If there is no a profile with id \a pflId.
4152  */
4153 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4154 {
4155   return contentNotNull()->getProfileFromId(pflId);
4156 }
4157
4158 /*!
4159  * Returns a localization object, apt for modification, by its id.
4160  *  \param [in] locId - the id of the localization of interest.
4161  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4162  *          having the id \a locId.
4163  *  \throw If there is no a localization with id \a locId.
4164  */
4165 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4166 {
4167   return contentNotNull()->getLocalizationFromId(locId);
4168 }
4169
4170 /*!
4171  * Returns a localization object, apt for modification, by its name.
4172  *  \param [in] locName - the name of the localization of interest.
4173  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
4174  *          having the name \a locName.
4175  *  \throw If there is no a localization named \a locName.
4176  */
4177 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4178 {
4179   return contentNotNull()->getLocalization(locName);
4180 }
4181
4182 /*!
4183  * Returns a profile array, apt for modification, by its name.
4184  *  \param [in] pflName - the name of the profile of interest.
4185  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4186  *  \throw If there is no a profile named \a pflName.
4187  */
4188 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4189 {
4190   return contentNotNull()->getProfile(pflName);
4191 }
4192
4193 /*!
4194  * Returns a profile array, apt for modification, by its id.
4195  *  \param [in] pflId - the id of the profile of interest.
4196  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4197  *  \throw If there is no a profile with id \a pflId.
4198  */
4199 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4200 {
4201   return contentNotNull()->getProfileFromId(pflId);
4202 }
4203
4204 /*!
4205  * Removes profiles given by their ids. No data is updated to track this removal.
4206  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
4207  */
4208 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4209 {
4210   contentNotNull()->killProfileIds(pflIds);
4211 }
4212
4213 /*!
4214  * Removes localizations given by their ids. No data is updated to track this removal.
4215  *  \param [in] locIds - a sequence of ids of the localizations to remove.
4216  */
4217 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4218 {
4219   contentNotNull()->killLocalizationIds(locIds);
4220 }
4221
4222 /*!
4223  * Stores a profile array.
4224  *  \param [in] pfl - the profile array to store.
4225  *  \throw If the name of \a pfl is empty.
4226  *  \throw If a profile with the same name as that of \a pfl already exists but contains
4227  *         different ids.
4228  */
4229 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4230 {
4231   contentNotNull()->appendProfile(pfl);
4232 }
4233
4234 /*!
4235  * Adds a new localization of Gauss points.
4236  *  \param [in] locName - the name of the new localization.
4237  *  \param [in] geoType - a geometrical type of the reference cell.
4238  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4239  *         must be \c nbOfNodesPerCell * \c dimOfType.
4240  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4241  *         must be  _wg_.size() * \c dimOfType.
4242  *  \param [in] w - the weights of Gauss points.
4243  *  \throw If \a locName is empty.
4244  *  \throw If a localization with the name \a locName already exists but is
4245  *         different form the new one.
4246  */
4247 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)
4248 {
4249   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4250 }
4251
4252 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4253 {
4254   MEDFileFieldGlobs *g(_globals);
4255   if(!g)
4256     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4257   return g;
4258 }
4259
4260 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4261 {
4262   const MEDFileFieldGlobs *g(_globals);
4263   if(!g)
4264     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4265   return g;
4266 }
4267
4268 //= MEDFileFieldNameScope
4269
4270 MEDFileFieldNameScope::MEDFileFieldNameScope()
4271 {
4272 }
4273
4274 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4275 {
4276 }
4277
4278 /*!
4279  * Returns the name of \a this field.
4280  *  \return std::string - a string containing the field name.
4281  */
4282 std::string MEDFileFieldNameScope::getName() const
4283 {
4284   return _name;
4285 }
4286
4287 /*!
4288  * Sets name of \a this field
4289  *  \param [in] name - the new field name.
4290  */
4291 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4292 {
4293   _name=fieldName;
4294 }
4295
4296 std::string MEDFileFieldNameScope::getDtUnit() const
4297 {
4298   return _dt_unit;
4299 }
4300
4301 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4302 {
4303   _dt_unit=dtUnit;
4304 }
4305
4306 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4307 {
4308   _name=other._name;
4309   _dt_unit=other._dt_unit;
4310 }
4311
4312 //= MEDFileAnyTypeField1TSWithoutSDA
4313
4314 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4315 {
4316   _field_per_mesh.resize(other._field_per_mesh.size());
4317   std::size_t i=0;
4318   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4319     {
4320       if((const MEDFileFieldPerMesh *)*it)
4321         _field_per_mesh[i]=(*it)->deepCopy(this);
4322     }
4323 }
4324
4325 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
4326 {
4327   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4328     if((*it).isNotNull())
4329       {
4330         visitor.newMeshEntry(*it);
4331         (*it)->accept(visitor);
4332         visitor.endMeshEntry(*it);
4333       }
4334 }
4335
4336 /*!
4337  * Prints a string describing \a this field into a stream. This string is outputted 
4338  * by \c print Python command.
4339  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4340  *  \param [in,out] oss - the out stream.
4341  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4342  *          info id printed, else, not.
4343  */
4344 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4345 {
4346   std::string startOfLine(bkOffset,' ');
4347   oss << startOfLine << "Field ";
4348   if(bkOffset==0)
4349     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4350   oss << "on one time Step ";
4351   if(f1tsId>=0)
4352     oss << "(" << f1tsId << ") ";
4353   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4354   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4355   const DataArray *arr=getUndergroundDataArray();
4356   if(arr)
4357     {
4358       const std::vector<std::string> &comps=arr->getInfoOnComponents();
4359       if(f1tsId<0)
4360         {
4361           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4362           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4363             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
4364         }
4365       if(arr->isAllocated())
4366         {
4367           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4368         }
4369       else
4370         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4371     }
4372   else
4373     {
4374       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4375     }
4376   oss << startOfLine << "----------------------" << std::endl;
4377   if(!_field_per_mesh.empty())
4378     {
4379       int i=0;
4380       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4381         {
4382           const MEDFileFieldPerMesh *cur=(*it2);
4383           if(cur)
4384             cur->simpleRepr(bkOffset,oss,i);
4385           else
4386             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4387         }
4388     }
4389   else
4390     {
4391       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4392     }
4393   oss << startOfLine << "----------------------" << std::endl;
4394 }
4395
4396 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4397 {
4398   const DataArray *arr(getUndergroundDataArray());
4399   if(!arr)
4400     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4401   int nbOfCompo=arr->getNumberOfComponents();
4402   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4403   for(int i=0;i<nbOfCompo;i++)
4404     {
4405       ret[i]=deepCopy();
4406       std::vector<int> v(1,i);
4407       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4408       ret[i]->setArray(arr2);
4409     }
4410   return ret;
4411 }
4412
4413 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)
4414 {
4415 }
4416
4417 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4418 {
4419 }
4420
4421 /*!
4422  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4423  * empty. Returns -1 if this in on nodes.
4424  *  \return int - the dimension of \a this.
4425  */
4426 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4427 {
4428   int ret=-2;
4429   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4430     (*it)->getDimension(ret);
4431   return ret;
4432 }
4433
4434 /*!
4435  * Returns the mesh name.
4436  *  \return std::string - a string holding the mesh name.
4437  *  \throw If \c _field_per_mesh.empty()
4438  */
4439 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4440 {
4441   if(_field_per_mesh.empty())
4442     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4443   return _field_per_mesh[0]->getMeshName();
4444 }
4445
4446 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4447 {
4448   std::string oldName(getMeshName());
4449   std::vector< std::pair<std::string,std::string> > v(1);
4450   v[0].first=oldName; v[0].second=newMeshName;
4451   changeMeshNames(v);
4452 }
4453
4454 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4455 {
4456   bool ret=false;
4457   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4458     {
4459       MEDFileFieldPerMesh *cur(*it);
4460       if(cur)
4461         ret=cur->changeMeshNames(modifTab) || ret;
4462     }
4463   return ret;
4464 }
4465
4466 /*!
4467  * Returns the number of iteration of the state of underlying mesh.
4468  *  \return int - the iteration number.
4469  *  \throw If \c _field_per_mesh.empty()
4470  */
4471 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4472 {
4473   if(_field_per_mesh.empty())
4474     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4475   return _field_per_mesh[0]->getMeshIteration();
4476 }
4477
4478 /*!
4479  * Returns the order number of iteration of the state of underlying mesh.
4480  *  \return int - the order number.
4481  *  \throw If \c _field_per_mesh.empty()
4482  */
4483 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4484 {
4485   if(_field_per_mesh.empty())
4486     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4487   return _field_per_mesh[0]->getMeshOrder();
4488 }
4489
4490 /*!
4491  * Checks if \a this field is tagged by a given iteration number and a given
4492  * iteration order number.
4493  *  \param [in] iteration - the iteration number of interest.
4494  *  \param [in] order - the iteration order number of interest.
4495  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
4496  *          \a this->getOrder() == \a order.
4497  */
4498 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4499 {
4500   return iteration==_iteration && order==_order;
4501 }
4502
4503 /*!
4504  * Returns number of iteration and order number of iteration when
4505  * \a this field has been calculated.
4506  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
4507  *          order number.
4508  */
4509 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4510 {
4511   std::pair<int,int> p;
4512   fillIteration(p);
4513   return p;
4514 }
4515
4516 /*!
4517  * Returns number of iteration and order number of iteration when
4518  * \a this field has been calculated.
4519  *  \param [in,out] p - a pair returning the iteration number and the iteration
4520  *          order number.
4521  */
4522 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4523 {
4524   p.first=_iteration;
4525   p.second=_order;
4526 }
4527
4528 /*!
4529  * Returns all types of spatial discretization of \a this field.
4530  *  \param [in,out] types - a sequence of types of \a this field.
4531  */
4532 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4533 {
4534   std::set<TypeOfField> types2;
4535   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4536     {
4537       (*it)->fillTypesOfFieldAvailable(types2);
4538     }
4539   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4540   std::copy(types2.begin(),types2.end(),bi);
4541 }
4542
4543 /*!
4544  * Returns all types of spatial discretization of \a this field.
4545  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4546  *          of \a this field.
4547  */
4548 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4549 {
4550   std::vector<TypeOfField> ret;
4551   fillTypesOfFieldAvailable(ret);
4552   return ret;
4553 }
4554
4555 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4556 {
4557   std::vector<std::string> ret;
4558   std::set<std::string> ret2;
4559   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4560     {
4561       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4562       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4563         if(ret2.find(*it2)==ret2.end())
4564           {
4565             ret.push_back(*it2);
4566             ret2.insert(*it2);
4567           }
4568     }
4569   return ret;
4570 }
4571
4572 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4573 {
4574   std::vector<std::string> ret;
4575   std::set<std::string> ret2;
4576   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4577     {
4578       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4579       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4580         if(ret2.find(*it2)==ret2.end())
4581           {
4582             ret.push_back(*it2);
4583             ret2.insert(*it2);
4584           }
4585     }
4586   return ret;
4587 }
4588
4589 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4590 {
4591   std::vector<std::string> ret;
4592   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4593     {
4594       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4595       ret.insert(ret.end(),tmp.begin(),tmp.end());
4596     }
4597   return ret;
4598 }
4599
4600 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4601 {
4602   std::vector<std::string> ret;
4603   std::set<std::string> ret2;
4604   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4605     {
4606       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4607       ret.insert(ret.end(),tmp.begin(),tmp.end());
4608     }
4609   return ret;
4610 }
4611
4612 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4613 {
4614   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4615     (*it)->changePflsRefsNamesGen(mapOfModif);
4616 }
4617
4618 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4619 {
4620   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4621     (*it)->changeLocsRefsNamesGen(mapOfModif);
4622 }
4623
4624 /*!
4625  * Returns all attributes of parts of \a this field lying on a given mesh.
4626  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4627  * item of every of returned sequences refers to the _i_-th part of \a this field.
4628  * Thus all sequences returned by this method are of the same length equal to number
4629  * of different types of supporting entities.<br>
4630  * A field part can include sub-parts with several different spatial discretizations,
4631  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4632  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4633  * of a nested sequence corresponds to a type of spatial discretization.<br>
4634  * This method allows for iteration over MEDFile DataStructure without any overhead.
4635  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4636  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4637  *          not checked if \a mname == \c NULL).
4638  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4639  *          a field part is returned. 
4640  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4641  *          This sequence is of the same length as \a types. 
4642  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4643  *          discretization. A profile name can be empty.
4644  *          Length of this and of nested sequences is the same as that of \a typesF.
4645  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4646  *          discretization. A localization name can be empty.
4647  *          Length of this and of nested sequences is the same as that of \a typesF.
4648  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4649  *          of ids of tuples within the data array, per each type of spatial
4650  *          discretization within one mesh entity type. 
4651  *          Length of this and of nested sequences is the same as that of \a typesF.
4652  *  \throw If no field is lying on \a mname.
4653  */
4654 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
4655 {
4656   int meshId=0;
4657   if(!mname.empty())
4658     meshId=getMeshIdFromMeshName(mname);
4659   else
4660     if(_field_per_mesh.empty())
4661       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4662   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4663 }
4664
4665 /*!
4666  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4667  * maximal absolute dimension and values returned via the out parameter \a levs are 
4668  * dimensions relative to the maximal absolute dimension. <br>
4669  * This method is designed for MEDFileField1TS instances that have a discretization
4670  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4671  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4672  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4673  * Only these 3 discretizations will be taken into account here. If \a this is
4674  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4675  * This method is useful to make the link between the dimension of the underlying mesh
4676  * and the levels of \a this, because it is possible that the highest dimension of \a this
4677  * field is not equal to the dimension of the underlying mesh.
4678  * 
4679  * Let's consider the following case:
4680  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4681  * TETRA4, HEXA8, TRI3 and SEG2.
4682  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4683  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4684  *
4685  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4686  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4687  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4688  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4689  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4690  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4691  * For example<br>
4692  * to retrieve the highest level of
4693  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4694  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4695  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4696  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4697  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4698  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4699  *          not checked if \a mname == \c NULL).
4700  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4701  *          absolute one. They are in decreasing order. This sequence is cleared before
4702  *          filling it in.
4703  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4704  *  \throw If no field is lying on \a mname.
4705  */
4706 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4707 {
4708   levs.clear();
4709   int meshId=getMeshIdFromMeshName(mname);
4710   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4711   std::vector< std::vector<TypeOfField> > typesF;
4712   std::vector< std::vector<std::string> > pfls, locs;
4713   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4714   if(types.empty())
4715     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4716   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4717   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4718     return -1;
4719   st.erase(INTERP_KERNEL::NORM_ERROR);
4720   std::set<int> ret1;
4721   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4722     {
4723       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4724       ret1.insert((int)cm.getDimension());
4725     }
4726   int ret=*std::max_element(ret1.begin(),ret1.end());
4727   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4728   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4729   return ret;
4730 }
4731
4732 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4733 {
4734   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4735     if((*it).isNotNull())
4736       (*it)->convertMedBallIntoClassic();
4737 }
4738
4739 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
4740 {
4741   if(!pfl)
4742     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
4743   std::string name(pfl->getName());
4744   pfl->checkAllocated();
4745   if(pfl->getNumberOfComponents()!=1)
4746     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
4747   if(name.empty())
4748     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
4749   if(_field_per_mesh.size()!=1)
4750     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
4751   MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
4752   if(fpm.isNull())
4753     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
4754   MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
4755   if(disc->getType()!=tof)
4756     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
4757   int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
4758   DataArray *arr(getUndergroundDataArray());
4759   int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
4760   if(delta<0)
4761     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
4762   MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
4763   MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
4764   MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
4765   arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
4766   arrOut->copyStringInfoFrom(*arr);
4767   arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
4768   arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
4769   arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
4770   setArray(arrOut);
4771   disc->setEnd(e-delta);
4772   disc->setProfile(name);
4773 }
4774
4775 /*!
4776  * \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.
4777  * \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.
4778  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4779  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4780  */
4781 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4782 {
4783   int mid=getMeshIdFromMeshName(mName);
4784   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4785 }
4786
4787 /*!
4788  * \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.
4789  * \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.
4790  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4791  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4792  */
4793 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4794 {
4795   int mid=getMeshIdFromMeshName(mName);
4796   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4797 }
4798
4799 /*!
4800  * \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.
4801  */
4802 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4803 {
4804   if(_field_per_mesh.empty())
4805     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4806   if(mName.empty())
4807     return 0;
4808   std::string mName2(mName);
4809   int ret=0;
4810   std::vector<std::string> msg;
4811   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4812     if(mName2==(*it)->getMeshName())
4813       return ret;
4814     else
4815       msg.push_back((*it)->getMeshName());
4816   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4817   oss << "Possible meshes are : ";
4818   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4819     oss << "\"" << (*it2) << "\" ";
4820   throw INTERP_KERNEL::Exception(oss.str());
4821 }
4822
4823 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4824 {
4825   if(!mesh)
4826     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4827   std::string tmp(mesh->getName());
4828   if(tmp.empty())
4829     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4830   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4831   int i=0;
4832   for(;it!=_field_per_mesh.end();it++,i++)
4833     {
4834       if((*it)->getMeshName()==tmp)
4835         return i;
4836     }
4837   int sz=_field_per_mesh.size();
4838   _field_per_mesh.resize(sz+1);
4839   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4840   return sz;
4841 }
4842
4843 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4844                                                                    MEDFileFieldGlobsReal& glob)
4845 {
4846   bool ret=false;
4847   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4848     {
4849       MEDFileFieldPerMesh *fpm(*it);
4850       if(fpm)
4851         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4852     }
4853   return ret;
4854 }
4855
4856 /*!
4857  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4858  * splitting that leads to single spatial discretization of this.
4859  *
4860  * \sa splitMultiDiscrPerGeoTypes
4861  */
4862 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4863 {
4864   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4865   std::vector< std::vector<TypeOfField> > typesF;
4866   std::vector< std::vector<std::string> > pfls,locs;
4867   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4868   std::set<TypeOfField> allEnt;
4869   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4870     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4871       allEnt.insert(*it2);
4872   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4873   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4874   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4875     {
4876       std::vector< std::pair<int,int> > its;
4877       ret[i]=shallowCpy();
4878       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4879       ret[i]->updateData(newLgth,its);
4880     }
4881   return ret;
4882 }
4883
4884 /*!
4885  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4886  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4887  *
4888  * \sa splitDiscretizations
4889  */
4890 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4891 {
4892   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4893   std::vector< std::vector<TypeOfField> > typesF;
4894   std::vector< std::vector<std::string> > pfls,locs;
4895   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4896   std::set<TypeOfField> allEnt;
4897   std::size_t nbOfMDPGT(0),ii(0);
4898   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4899     {
4900       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4901       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4902         allEnt.insert(*it2);
4903     }
4904   if(allEnt.size()!=1)
4905     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4906   if(nbOfMDPGT==0)
4907     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4908   if(nbOfMDPGT==1)
4909     {
4910       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4911       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4912       return ret0;
4913     }
4914   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4915   for(std::size_t i=0;i<nbOfMDPGT;i++)
4916     {
4917       std::vector< std::pair<int,int> > its;
4918       ret[i]=shallowCpy();
4919       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4920       ret[i]->updateData(newLgth,its);
4921     }
4922   return ret;
4923 }
4924
4925 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4926 {
4927   int globalCounter(0);
4928   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4929     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4930   return globalCounter;
4931 }
4932
4933 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4934 {
4935   int globalCounter(0);
4936   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4937     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4938   return globalCounter;
4939 }
4940
4941 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4942 {
4943   if(_nb_of_tuples_to_be_allocated>=0)
4944     {
4945       _nb_of_tuples_to_be_allocated=newLgth;
4946       const DataArray *oldArr(getUndergroundDataArray());
4947       if(oldArr)
4948         {
4949           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4950           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4951           setArray(newArr);
4952           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4953         }
4954       return ;
4955     }
4956   if(_nb_of_tuples_to_be_allocated==-1)
4957     return ;
4958   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4959     {
4960       const DataArray *oldArr(getUndergroundDataArray());
4961       if(!oldArr || !oldArr->isAllocated())
4962         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4963       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4964       newArr->alloc(newLgth,getNumberOfComponents());
4965       if(oldArr)
4966         newArr->copyStringInfoFrom(*oldArr);
4967       int pos=0;
4968       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4969         {
4970           if((*it).second<(*it).first)
4971             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4972           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4973           pos+=(*it).second-(*it).first;
4974         }
4975       setArray(newArr);
4976       return ;
4977     }
4978   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4979 }
4980
4981 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4982 {
4983   if(_field_per_mesh.empty())
4984     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4985   if(_field_per_mesh.size()>1)
4986     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4987   _field_per_mesh[0]->copyOptionsFrom(opts);
4988   _field_per_mesh[0]->writeLL(fid,nasc);
4989 }
4990
4991 /*!
4992  * 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.
4993  * If false is returned the memory allocation is not required.
4994  */
4995 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4996 {
4997   if(_nb_of_tuples_to_be_allocated>=0)
4998     {
4999       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
5000       _nb_of_tuples_to_be_allocated=-2;
5001       return true;
5002     }
5003   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
5004     return false;
5005   if(_nb_of_tuples_to_be_allocated==-1)
5006     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
5007   if(_nb_of_tuples_to_be_allocated<-3)
5008     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5009   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
5010 }
5011
5012 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5013 {
5014   med_int numdt,numit;
5015   med_float dt;
5016   med_int nmesh;
5017   med_bool localMesh;
5018   med_int meshnumdt,meshnumit;
5019   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5020   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
5021   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
5022   if(_iteration!=numdt || _order!=numit)
5023     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
5024   _field_per_mesh.resize(nmesh);
5025   //
5026   MEDFileMesh *mm(0);
5027   if(ms)
5028     {
5029       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
5030       mm=ms->getMeshWithName(meshNameCpp);
5031     }
5032   //
5033   for(int i=0;i<nmesh;i++)
5034     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
5035   _nb_of_tuples_to_be_allocated=0;
5036   for(int i=0;i<nmesh;i++)
5037     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
5038 }
5039
5040 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
5041 {
5042   allocIfNecessaryTheArrayToReceiveDataFromFile();
5043   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5044     (*it)->loadBigArraysRecursively(fid,nasc);
5045 }
5046
5047 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
5048 {
5049   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
5050     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5051       (*it)->loadBigArraysRecursively(fid,nasc);
5052 }
5053
5054 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5055 {
5056   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
5057   loadBigArraysRecursively(fid,nasc);
5058 }
5059
5060 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
5061 {
5062   DataArray *thisArr(getUndergroundDataArray());
5063   if(thisArr && thisArr->isAllocated())
5064     {
5065       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
5066       thisArr->desallocate();
5067     }
5068 }
5069
5070 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
5071 {
5072   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
5073 }
5074
5075 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
5076 {
5077   std::vector<const BigMemoryObject *> ret;
5078   if(getUndergroundDataArray())
5079     ret.push_back(getUndergroundDataArray());
5080   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5081     ret.push_back((const MEDFileFieldPerMesh *)*it);
5082   return ret;
5083 }
5084
5085 /*!
5086  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
5087  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
5088  * "Sort By Type"), if not, an exception is thrown. 
5089  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
5090  *  \param [in] arr - the array of values.
5091  *  \param [in,out] glob - the global data where profiles and localization present in
5092  *          \a field, if any, are added.
5093  *  \throw If the name of \a field is empty.
5094  *  \throw If the data array of \a field is not set.
5095  *  \throw If \a this->_arr is already allocated but has different number of components
5096  *         than \a field.
5097  *  \throw If the underlying mesh of \a field has no name.
5098  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
5099  */
5100 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5101 {
5102   const MEDCouplingMesh *mesh=field->getMesh();
5103   //
5104   TypeOfField type=field->getTypeOfField();
5105   std::vector<DataArrayInt *> dummy;
5106   int start=copyTinyInfoFrom(field,arr);
5107   int pos=addNewEntryIfNecessary(mesh);
5108   if(type!=ON_NODES)
5109     {
5110       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
5111       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
5112     }
5113   else
5114     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
5115 }
5116
5117 /*!
5118  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
5119  * of a given mesh are used as the support of the given field (a real support is not used). 
5120  * Elements of the given mesh must be sorted suitable for writing to MED file. 
5121  * Order of underlying mesh entities of the given field specified by \a profile parameter
5122  * is not prescribed; this method permutes field values to have them sorted by element
5123  * type as required for writing to MED file. A new profile is added only if no equal
5124  * profile is missing. 
5125  *  \param [in] field - the field to add to \a this. The field double values are ignored.
5126  *  \param [in] arrOfVals - the values of the field \a field used.
5127  *  \param [in] mesh - the supporting mesh of \a field.
5128  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
5129  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
5130  *  \param [in,out] glob - the global data where profiles and localization present in
5131  *          \a field, if any, are added.
5132  *  \throw If either \a field or \a mesh or \a profile has an empty name.
5133  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5134  *  \throw If the data array of \a field is not set.
5135  *  \throw If \a this->_arr is already allocated but has different number of components
5136  *         than \a field.
5137  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5138  *  \sa setFieldNoProfileSBT()
5139  */
5140 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
5141 {
5142   if(!field)
5143     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
5144   if(!arrOfVals || !arrOfVals->isAllocated())
5145     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
5146   TypeOfField type=field->getTypeOfField();
5147   std::vector<DataArrayInt *> idsInPflPerType;
5148   std::vector<DataArrayInt *> idsPerType;
5149   std::vector<int> code,code2;
5150   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5151   if(type!=ON_NODES)
5152     {
5153       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
5154       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
5155       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
5156       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
5157       // start of check
5158       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
5159       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
5160       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5161         {
5162           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5163           throw INTERP_KERNEL::Exception(oss.str());
5164         }
5165       // end of check
5166       int start=copyTinyInfoFrom(field,arrOfVals);
5167       code2=m->getDistributionOfTypes();
5168       //
5169       int pos=addNewEntryIfNecessary(m);
5170       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
5171     }
5172   else
5173     {
5174       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
5175         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
5176       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
5177       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
5178       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
5179       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
5180         {
5181           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
5182           throw INTERP_KERNEL::Exception(oss.str());
5183         }
5184       int start=copyTinyInfoFrom(field,arrOfVals);
5185       int pos=addNewEntryIfNecessary(m);
5186       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5187     }
5188 }
5189
5190 /*!
5191  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5192  */
5193 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5194 {
5195   if(_nb_of_tuples_to_be_allocated>=0)
5196     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 !");
5197   DataArray *arr(getOrCreateAndGetArray());
5198   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5199   _nb_of_tuples_to_be_allocated=-3;
5200 }
5201
5202 /*!
5203  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5204  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5205  * larger by the size of \a field. Returns an id of the first not filled
5206  * tuple of \a this->_arr.
5207  *  \param [in] field - the field to copy the info on components and the name from.
5208  *  \return int - the id of first not initialized tuple of \a this->_arr.
5209  *  \throw If the name of \a field is empty.
5210  *  \throw If the data array of \a field is not set.
5211  *  \throw If \a this->_arr is already allocated but has different number of components
5212  *         than \a field.
5213  */
5214 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5215 {
5216   if(!field)
5217     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5218   std::string name(field->getName());
5219   setName(name.c_str());
5220   setDtUnit(field->getTimeUnit());
5221   if(name.empty())
5222     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5223   if(!arr)
5224     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5225   if(!arr->isAllocated())
5226     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5227   _dt=field->getTime(_iteration,_order);
5228   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5229   if(!getOrCreateAndGetArray()->isAllocated())
5230     {
5231       allocNotFromFile(arr->getNumberOfTuples());
5232       return 0;
5233     }
5234   else
5235     {
5236       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5237       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5238       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5239       _nb_of_tuples_to_be_allocated=-3;
5240       return oldNbOfTuples;
5241     }
5242 }
5243
5244 /*!
5245  * Returns number of components in \a this field
5246  *  \return int - the number of components.
5247  */
5248 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5249 {
5250   return getOrCreateAndGetArray()->getNumberOfComponents();
5251 }
5252
5253 /*!
5254  * Change info on components in \a this.
5255  * \throw If size of \a infos is not equal to the number of components already in \a this.
5256  */
5257 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5258 {
5259   DataArray *arr=getOrCreateAndGetArray();
5260   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5261 }
5262
5263 /*!
5264  * Returns info on components of \a this field.
5265  *  \return const std::vector<std::string>& - a sequence of strings each being an
5266  *          information on _i_-th component.
5267  */
5268 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5269 {
5270   const DataArray *arr=getOrCreateAndGetArray();
5271   return arr->getInfoOnComponents();
5272 }
5273
5274 /*!
5275  * Returns a mutable info on components of \a this field.
5276  *  \return std::vector<std::string>& - a sequence of strings each being an
5277  *          information on _i_-th component.
5278  */
5279 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5280 {
5281   DataArray *arr=getOrCreateAndGetArray();
5282   return arr->getInfoOnComponents();
5283 }
5284
5285 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5286 {
5287   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5288     {
5289       const MEDFileFieldPerMesh *fpm(*it);
5290       if(!fpm)
5291         continue;
5292       if(fpm->presenceOfMultiDiscPerGeoType())
5293         return true;
5294     }
5295   return false;
5296 }
5297
5298 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5299 {
5300   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5301     if((*it).isNotNull())
5302       if((*it)->presenceOfStructureElements())
5303         return true;
5304   return false;
5305 }
5306
5307 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5308 {
5309   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5310     if((*it).isNotNull())
5311       if(!(*it)->onlyStructureElements())
5312         return false;
5313   return true;
5314 }
5315
5316 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5317 {
5318   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5319     if((*it).isNotNull())
5320       (*it)->killStructureElements();
5321 }
5322
5323 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5324 {
5325   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5326     if((*it).isNotNull())
5327       (*it)->keepOnlyStructureElements();
5328 }
5329
5330 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5331 {
5332   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5333     if((*it).isNotNull())
5334       (*it)->keepOnlyOnSE(seName);
5335 }
5336
5337 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5338 {
5339   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5340     if((*it).isNotNull())
5341       (*it)->getMeshSENames(ps);
5342 }
5343
5344 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5345 {
5346   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 !";
5347   if(_field_per_mesh.empty())
5348     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5349   if(_field_per_mesh.size()>1)
5350     throw INTERP_KERNEL::Exception(MSG0);
5351   if(_field_per_mesh[0].isNull())
5352     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5353   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5354   std::set<TypeOfField> types;
5355   pm->fillTypesOfFieldAvailable(types);
5356   if(types.size()!=1)
5357     throw INTERP_KERNEL::Exception(MSG0);
5358   TypeOfField type(*types.begin());
5359   int meshDimRelToMax(0);
5360   if(type==ON_NODES)
5361     meshDimRelToMax=0;
5362   else
5363     {
5364       int myDim(std::numeric_limits<int>::max());
5365       bool isUnique(pm->isUniqueLevel(myDim));
5366       if(!isUnique)
5367         throw INTERP_KERNEL::Exception(MSG0);
5368       meshDimRelToMax=myDim-mesh->getMeshDimension();
5369       if(meshDimRelToMax>0)
5370         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5371     }
5372   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5373 }
5374
5375 /*!
5376  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5377  *  \param [in] type - a spatial discretization of the new field.
5378  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5379  *  \param [in] mName - a name of the supporting mesh.
5380  *  \param [in] renumPol - specifies how to permute values of the result field according to
5381  *          the optional numbers of cells and nodes, if any. The valid values are
5382  *          - 0 - do not permute.
5383  *          - 1 - permute cells.
5384  *          - 2 - permute nodes.
5385  *          - 3 - permute cells and nodes.
5386  *
5387  *  \param [in] glob - the global data storing profiles and localization.
5388  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5389  *          caller is to delete this field using decrRef() as it is no more needed. 
5390  *  \throw If the MED file is not readable.
5391  *  \throw If there is no mesh named \a mName in the MED file.
5392  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5393  *  \throw If no field of \a this is lying on the mesh \a mName.
5394  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5395  */
5396 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, 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   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5404 }
5405
5406 /*!
5407  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5408  *  \param [in] type - a spatial discretization of the new field.
5409  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5410  *  \param [in] renumPol - specifies how to permute values of the result field according to
5411  *          the optional numbers of cells and nodes, if any. The valid values are
5412  *          - 0 - do not permute.
5413  *          - 1 - permute cells.
5414  *          - 2 - permute nodes.
5415  *          - 3 - permute cells and nodes.
5416  *
5417  *  \param [in] glob - the global data storing profiles and localization.
5418  *  \param [in] mesh - the supporting mesh.
5419  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5420  *          caller is to delete this field using decrRef() as it is no more needed. 
5421  *  \throw If the MED file is not readable.
5422  *  \throw If no field of \a this is lying on \a mesh.
5423  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5424  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5425  */
5426 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5427 {
5428   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5429   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5430   if(meshDimRelToMax==1)
5431     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5432   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5433 }
5434
5435 /*!
5436  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5437  * given mesh. 
5438  *  \param [in] type - a spatial discretization of the new field.
5439  *  \param [in] mName - a name of the supporting mesh.
5440  *  \param [in] renumPol - specifies how to permute values of the result field according to
5441  *          the optional numbers of cells and nodes, if any. The valid values are
5442  *          - 0 - do not permute.
5443  *          - 1 - permute cells.
5444  *          - 2 - permute nodes.
5445  *          - 3 - permute cells and nodes.
5446  *
5447  *  \param [in] glob - the global data storing profiles and localization.
5448  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5449  *          caller is to delete this field using decrRef() as it is no more needed. 
5450  *  \throw If the MED file is not readable.
5451  *  \throw If there is no mesh named \a mName in the MED file.
5452  *  \throw If there are no mesh entities in the mesh.
5453  *  \throw If no field values of the given \a type are available.
5454  */
5455 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5456 {
5457   MCAuto<MEDFileMesh> mm;
5458   if(mName.empty())
5459     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5460   else
5461     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5462   int absDim=getDimension();
5463   int meshDimRelToMax=absDim-mm->getMeshDimension();
5464   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5465 }
5466
5467 /*!
5468  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5469  *  \param [in] type - a spatial discretization of the new field.
5470  *  \param [in] renumPol - specifies how to permute values of the result field according to
5471  *          the optional numbers of cells and nodes, if any. The valid values are
5472  *          - 0 - do not permute.
5473  *          - 1 - permute cells.
5474  *          - 2 - permute nodes.
5475  *          - 3 - permute cells and nodes.
5476  *
5477  *  \param [in] glob - the global data storing profiles and localization.
5478  *  \param [in] mesh - the supporting mesh.
5479  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
5480  *         field according to \a renumPol.
5481  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
5482  *         field according to \a renumPol.
5483  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5484  *          caller is to delete this field using decrRef() as it is no more needed. 
5485  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5486  *  \throw If no field of \a this is lying on \a mesh.
5487  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5488  */
5489 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
5490 {
5491   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5492   int meshId=getMeshIdFromMeshName(mesh->getName());
5493   bool isPfl=false;
5494   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5495   switch(renumPol)
5496   {
5497     case 0:
5498       {
5499         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5500         return ret.retn();
5501       }
5502     case 3:
5503     case 1:
5504       {
5505         if(isPfl)
5506           throw INTERP_KERNEL::Exception(msg1);
5507         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5508         if(cellRenum)
5509           {
5510             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5511               {
5512                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5513                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5514                 throw INTERP_KERNEL::Exception(oss.str());
5515               }
5516             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5517             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5518             std::vector<DataArray *> arrOut2(1,arrOut);
5519             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5520             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5521             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5522           }
5523         if(renumPol==1)
5524           return ret.retn();
5525       }
5526     case 2:
5527       {
5528         //no need to test _field_per_mesh.empty() because geMeshName has already done it
5529         if(isPfl)
5530           throw INTERP_KERNEL::Exception(msg1);
5531         if(nodeRenum)
5532           {
5533             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5534               {
5535                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5536                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5537                 throw INTERP_KERNEL::Exception(oss.str());
5538               }
5539             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5540             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5541               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5542             ret->renumberNodes(nodeRenumSafe->getConstPointer());
5543           }
5544         return ret.retn();
5545       }
5546     default:
5547       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5548   }
5549 }
5550
5551 /*!
5552  * Returns values and a profile of the field of a given type lying on a given support.
5553  *  \param [in] type - a spatial discretization of the field.
5554  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5555  *  \param [in] mesh - the supporting mesh.
5556  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5557  *          field of interest lies on. If the field lies on all entities of the given
5558  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
5559  *          using decrRef() as it is no more needed.  
5560  *  \param [in] glob - the global data storing profiles and localization.
5561  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5562  *          field. The caller is to delete this array using decrRef() as it is no more needed.
5563  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5564  *  \throw If no field of \a this is lying on \a mesh.
5565  *  \throw If no field values of the given \a type are available.
5566  */
5567 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5568 {
5569   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5570   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5571   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5572   ret->setName(nasc.getName().c_str());
5573   return ret.retn();
5574 }
5575
5576 //= MEDFileField1TSWithoutSDA
5577
5578 /*!
5579  * Throws if a given value is not a valid (non-extended) relative dimension.
5580  *  \param [in] meshDimRelToMax - the relative dimension value.
5581  *  \throw If \a meshDimRelToMax > 0.
5582  */
5583 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5584 {
5585   if(meshDimRelToMax>0)
5586     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5587 }
5588
5589 /*!
5590  * Checks if elements of a given mesh are in the order suitable for writing 
5591  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5592  * vector describing types of elements and their number.
5593  *  \param [in] mesh - the mesh to check.
5594  *  \return std::vector<int> - a vector holding for each element type (1) item of
5595  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
5596  *          These values are in full-interlace mode.
5597  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5598  */
5599 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5600 {
5601   if(!mesh)
5602     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5603   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5604   int nbOfTypes=geoTypes.size();
5605   std::vector<int> code(3*nbOfTypes);
5606   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5607   arr1->alloc(nbOfTypes,1);
5608   int *arrPtr=arr1->getPointer();
5609   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5610   for(int i=0;i<nbOfTypes;i++,it++)
5611     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5612   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5613   const int *arrPtr2=arr2->getConstPointer();
5614   int i=0;
5615   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5616     {
5617       int pos=arrPtr2[i];
5618       int nbCells=mesh->getNumberOfCellsWithType(*it);
5619       code[3*pos]=(int)(*it);
5620       code[3*pos+1]=nbCells;
5621       code[3*pos+2]=-1;//no profiles
5622     }
5623   std::vector<const DataArrayInt *> idsPerType;//no profiles
5624   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5625   if(da)
5626     {
5627       da->decrRef();
5628       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5629     }
5630   return code;
5631 }
5632
5633 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5634 {
5635   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5636 }
5637
5638 /*!
5639  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5640  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5641  * item of every of returned sequences refers to the _i_-th part of \a this field.
5642  * Thus all sequences returned by this method are of the same length equal to number
5643  * of different types of supporting entities.<br>
5644  * A field part can include sub-parts with several different spatial discretizations,
5645  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5646  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5647  * of a nested sequence corresponds to a type of spatial discretization.<br>
5648  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5649  * The overhead is due to selecting values into new instances of DataArrayDouble.
5650  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5651  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5652  *          not checked if \a mname == \c NULL).
5653  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5654  *          a field part is returned. 
5655  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5656  *          A field part can include sub-parts with several different spatial discretizations,
5657  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5658  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5659  *          This sequence is of the same length as \a types. 
5660  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5661  *          discretization. A profile name can be empty.
5662  *          Length of this and of nested sequences is the same as that of \a typesF.
5663  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5664  *          discretization. A localization name can be empty.
5665  *          Length of this and of nested sequences is the same as that of \a typesF.
5666  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5667  *          per each type of spatial discretization within one mesh entity type.
5668  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5669  *          Length of this and of nested sequences is the same as that of \a typesF.
5670  *  \throw If no field is lying on \a mname.
5671  */
5672 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
5673 {
5674   int meshId=0;
5675   if(!mname.empty())
5676     meshId=getMeshIdFromMeshName(mname);
5677   else
5678     if(_field_per_mesh.empty())
5679       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5680   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5681   int nbOfRet=ret0.size();
5682   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5683   for(int i=0;i<nbOfRet;i++)
5684     {
5685       const std::vector< std::pair<int,int> >& p=ret0[i];
5686       int nbOfRet1=p.size();
5687       ret[i].resize(nbOfRet1);
5688       for(int j=0;j<nbOfRet1;j++)
5689         {
5690           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5691           ret[i][j]=tmp;
5692         }
5693     }
5694   return ret;
5695 }
5696
5697 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5698 {
5699   return TYPE_STR;
5700 }
5701
5702 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5703 {
5704   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5705   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5706   ret->deepCpyLeavesFrom(*this);
5707   const DataArrayDouble *arr(_arr);
5708   if(arr)
5709     {
5710       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5711       ret->setArray(arr2);
5712     }
5713   return ret.retn();
5714 }
5715
5716 /*!
5717  * Returns a pointer to the underground DataArrayDouble instance and a
5718  * sequence describing parameters of a support of each part of \a this field. The
5719  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5720  * direct access to the field values. This method is intended for the field lying on one
5721  * mesh only.
5722  *  \param [in,out] entries - the sequence describing parameters of a support of each
5723  *         part of \a this field. Each item of this sequence consists of two parts. The
5724  *         first part describes a type of mesh entity and an id of discretization of a
5725  *         current field part. The second part describes a range of values [begin,end)
5726  *         within the returned array relating to the current field part.
5727  *  \return DataArrayDouble * - the pointer to the field values array.
5728  *  \throw If the number of underlying meshes is not equal to 1.
5729  *  \throw If no field values are available.
5730  *  \sa getUndergroundDataArray()
5731  */
5732 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5733 {
5734   if(_field_per_mesh.size()!=1)
5735     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5736   if(_field_per_mesh[0]==0)
5737     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5738   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5739   return getUndergroundDataArrayTemplate();
5740 }
5741
5742 /*!
5743  * Returns a pointer to the underground DataArrayDouble instance and a
5744  * sequence describing parameters of a support of each part of \a this field. The
5745  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5746  * direct access to the field values. This method is intended for the field lying on one
5747  * mesh only.
5748  *  \param [in,out] entries - the sequence describing parameters of a support of each
5749  *         part of \a this field. Each item of this sequence consists of two parts. The
5750  *         first part describes a type of mesh entity and an id of discretization of a
5751  *         current field part. The second part describes a range of values [begin,end)
5752  *         within the returned array relating to the current field part.
5753  *  \return DataArrayDouble * - the pointer to the field values array.
5754  *  \throw If the number of underlying meshes is not equal to 1.
5755  *  \throw If no field values are available.
5756  *  \sa getUndergroundDataArray()
5757  */
5758 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5759 {
5760   return getUndergroundDataArrayDoubleExt(entries);
5761 }
5762
5763 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5764 {
5765   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5766   arr->setInfoAndChangeNbOfCompo(infos);
5767 }
5768
5769 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5770 {
5771 }
5772
5773 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5774 {
5775   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5776   ret->deepCpyLeavesFrom(*this);
5777   return ret.retn();
5778 }
5779
5780 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5781 {
5782   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5783   if(_arr.isNotNull())
5784     ret->_arr=_arr->deepCopy();
5785   return ret.retn();
5786 }
5787
5788 //= MEDFileIntField1TSWithoutSDA
5789
5790 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5791 {
5792   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5793 }
5794
5795 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5796 {
5797 }
5798
5799 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5800                                                            const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5801 {
5802   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5803   arr->setInfoAndChangeNbOfCompo(infos);
5804 }
5805
5806 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5807 {
5808   return TYPE_STR;
5809 }
5810
5811 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5812 {
5813   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5814   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5815   ret->deepCpyLeavesFrom(*this);
5816   const DataArrayInt *arr(_arr);
5817   if(arr)
5818     {
5819       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5820       ret->setArray(arr2);
5821     }
5822   return ret.retn();
5823 }
5824
5825 /*!
5826  * Returns a pointer to the underground DataArrayInt instance and a
5827  * sequence describing parameters of a support of each part of \a this field. The
5828  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5829  * direct access to the field values. This method is intended for the field lying on one
5830  * mesh only.
5831  *  \param [in,out] entries - the sequence describing parameters of a support of each
5832  *         part of \a this field. Each item of this sequence consists of two parts. The
5833  *         first part describes a type of mesh entity and an id of discretization of a
5834  *         current field part. The second part describes a range of values [begin,end)
5835  *         within the returned array relating to the current field part.
5836  *  \return DataArrayInt * - the pointer to the field values array.
5837  *  \throw If the number of underlying meshes is not equal to 1.
5838  *  \throw If no field values are available.
5839  *  \sa getUndergroundDataArray()
5840  */
5841 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5842 {
5843   return getUndergroundDataArrayIntExt(entries);
5844 }
5845
5846 /*!
5847  * Returns a pointer to the underground DataArrayInt instance and a
5848  * sequence describing parameters of a support of each part of \a this field. The
5849  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5850  * direct access to the field values. This method is intended for the field lying on one
5851  * mesh only.
5852  *  \param [in,out] entries - the sequence describing parameters of a support of each
5853  *         part of \a this field. Each item of this sequence consists of two parts. The
5854  *         first part describes a type of mesh entity and an id of discretization of a
5855  *         current field part. The second part describes a range of values [begin,end)
5856  *         within the returned array relating to the current field part.
5857  *  \return DataArrayInt * - the pointer to the field values array.
5858  *  \throw If the number of underlying meshes is not equal to 1.
5859  *  \throw If no field values are available.
5860  *  \sa getUndergroundDataArray()
5861  */
5862 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5863 {
5864   if(_field_per_mesh.size()!=1)
5865     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5866   if(_field_per_mesh[0]==0)
5867     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5868   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5869   return getUndergroundDataArrayTemplate();
5870 }
5871
5872 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5873 {
5874   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5875   ret->deepCpyLeavesFrom(*this);
5876   return ret.retn();
5877 }
5878
5879 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5880 {
5881   MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5882   if(_arr.isNotNull())
5883     ret->_arr=_arr->deepCopy();
5884   return ret.retn();
5885 }
5886
5887 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5888 {
5889 }
5890
5891 //= MEDFileAnyTypeField1TS
5892
5893 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5894 {
5895   med_field_type typcha;
5896   //
5897   std::vector<std::string> infos;
5898   std::string dtunit,fieldName;
5899   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5900   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5901   switch(typcha)
5902   {
5903     case MED_FLOAT64:
5904       {
5905         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5906         break;
5907       }
5908     case MED_INT32:
5909       {
5910         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5911         break;
5912       }
5913     default:
5914       {
5915         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] !";
5916         throw INTERP_KERNEL::Exception(oss.str());
5917       }
5918   }
5919   ret->setDtUnit(dtunit.c_str());
5920   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5921   //
5922   med_int numdt,numit;
5923   med_float dt;
5924   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5925   ret->setTime(numdt,numit,dt);
5926   ret->_csit=1;
5927   if(loadAll)
5928     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5929   else
5930     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5931   return ret.retn();
5932 }
5933
5934 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5935 try:MEDFileFieldGlobsReal(fid)
5936 {
5937   _content=BuildContentFrom(fid,loadAll,ms,entities);
5938   loadGlobals(fid);
5939 }
5940 catch(INTERP_KERNEL::Exception& e)
5941 {
5942     throw e;
5943 }
5944
5945 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5946 {
5947   med_field_type typcha;
5948   std::vector<std::string> infos;
5949   std::string dtunit;
5950   int iii=-1;
5951   int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5952   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5953   switch(typcha)
5954   {
5955     case MED_FLOAT64:
5956       {
5957         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5958         break;
5959       }
5960     case MED_INT32:
5961       {
5962         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5963         break;
5964       }
5965     default:
5966       {
5967         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] !";
5968         throw INTERP_KERNEL::Exception(oss.str());
5969       }
5970   }
5971   ret->setDtUnit(dtunit.c_str());
5972   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5973   //
5974   if(nbSteps<1)
5975     {
5976       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5977       throw INTERP_KERNEL::Exception(oss.str());
5978     }
5979   //
5980   med_int numdt,numit;
5981   med_float dt;
5982   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5983   ret->setTime(numdt,numit,dt);
5984   ret->_csit=1;
5985   if(loadAll)
5986     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5987   else
5988     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
5989   return ret.retn();
5990 }
5991
5992 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
5993 try:MEDFileFieldGlobsReal(fid)
5994 {
5995   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
5996   loadGlobals(fid);
5997 }
5998 catch(INTERP_KERNEL::Exception& e)
5999 {
6000     throw e;
6001 }
6002
6003 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
6004 {
6005   if(!c)
6006     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
6007   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
6008     {
6009       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6010       ret->_content=c; c->incrRef();
6011       return ret.retn();
6012     }
6013   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
6014     {
6015       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
6016       ret->_content=c; c->incrRef();
6017       return ret.retn();
6018     }
6019   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
6020 }
6021
6022 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
6023 {
6024   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
6025   ret->setFileName(FileNameFromFID(fid));
6026   return ret;
6027 }
6028
6029 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
6030 {
6031   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6032   return New(fid,loadAll);
6033 }
6034
6035 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
6036 {
6037   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
6038   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6039   ret->loadGlobals(fid);
6040   return ret.retn();
6041 }
6042
6043 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6044 {
6045   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6046   return New(fid,fieldName,loadAll);
6047 }
6048
6049 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6050 {
6051   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
6052   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6053   ret->loadGlobals(fid);
6054   return ret.retn();
6055 }
6056
6057 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6058 {
6059   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6060   return New(fid,fieldName,iteration,order,loadAll);
6061 }
6062
6063 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6064 {
6065   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
6066   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6067   ret->loadGlobals(fid);
6068   return ret.retn();
6069 }
6070
6071 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6072 {
6073   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6074   return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
6075 }
6076
6077 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
6078 {
6079   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
6080   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
6081   ret->loadGlobals(fid);
6082   return ret.retn();
6083 }
6084
6085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6086 {
6087   med_field_type typcha;
6088   std::vector<std::string> infos;
6089   std::string dtunit;
6090   int iii(-1);
6091   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
6092   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
6093   switch(typcha)
6094   {
6095     case MED_FLOAT64:
6096       {
6097         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6098         break;
6099       }
6100     case MED_INT32:
6101       {
6102         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
6103         break;
6104       }
6105     default:
6106       {
6107         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] !";
6108         throw INTERP_KERNEL::Exception(oss.str());
6109       }
6110   }
6111   ret->setDtUnit(dtunit.c_str());
6112   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
6113   //
6114   bool found=false;
6115   std::vector< std::pair<int,int> > dtits(nbOfStep2);
6116   for(int i=0;i<nbOfStep2 && !found;i++)
6117     {
6118       med_int numdt,numit;
6119       med_float dt;
6120       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
6121       if(numdt==iteration && numit==order)
6122         {
6123           found=true;
6124           ret->_csit=i+1;
6125         }
6126       else
6127         dtits[i]=std::pair<int,int>(numdt,numit);
6128     }
6129   if(!found)
6130     {
6131       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
6132       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
6133         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
6134       throw INTERP_KERNEL::Exception(oss.str());
6135     }
6136   if(loadAll)
6137     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6138   else
6139     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
6140   return ret.retn();
6141 }
6142
6143 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
6144 try:MEDFileFieldGlobsReal(fid)
6145 {
6146   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
6147   loadGlobals(fid);
6148 }
6149 catch(INTERP_KERNEL::Exception& e)
6150 {
6151     throw e;
6152 }
6153
6154 /*!
6155  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6156  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6157  *
6158  * \warning this is a shallow copy constructor
6159  */
6160 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
6161 {
6162   if(!shallowCopyOfContent)
6163     {
6164       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
6165       otherPtr->incrRef();
6166       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
6167     }
6168   else
6169     {
6170       _content=other.shallowCpy();
6171     }
6172 }
6173
6174 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)
6175 {
6176   if(checkFieldId)
6177     {
6178       int nbFields=MEDnField(fid);
6179       if(fieldIdCFormat>=nbFields)
6180         {
6181           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
6182           throw INTERP_KERNEL::Exception(oss.str());
6183         }
6184     }
6185   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
6186   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6187   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
6188   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
6189   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6190   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
6191   med_bool localMesh;
6192   int nbOfStep;
6193   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
6194   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
6195   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
6196   infos.clear(); infos.resize(ncomp);
6197   for(int j=0;j<ncomp;j++)
6198     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6199   return nbOfStep;
6200 }
6201
6202 /*!
6203  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6204  * 
6205  * \param [out]
6206  * \return in case of success the number of time steps available for the field with name \a fieldName.
6207  */
6208 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6209 {
6210   int nbFields=MEDnField(fid);
6211   bool found=false;
6212   std::vector<std::string> fns(nbFields);
6213   int nbOfStep2(-1);
6214   for(int i=0;i<nbFields && !found;i++)
6215     {
6216       std::string tmp;
6217       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6218       fns[i]=tmp;
6219       found=(tmp==fieldName);
6220       if(found)
6221         posCFormat=i;
6222     }
6223   if(!found)
6224     {
6225       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6226       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6227         oss << "\"" << *it << "\" ";
6228       throw INTERP_KERNEL::Exception(oss.str());
6229     }
6230   return nbOfStep2;
6231 }
6232
6233 /*!
6234  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6235  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6236  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6237  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6238  * to keep a valid instance.
6239  * 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.
6240  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6241  * 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.
6242  *
6243  * \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.
6244  * \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.
6245  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6246  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6247  * \param [in] newLocName is the new localization name.
6248  * \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.
6249  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6250  */
6251 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6252 {
6253   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6254   std::string oldPflName=disc->getProfile();
6255   std::vector<std::string> vv=getPflsReallyUsedMulti();
6256   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6257   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6258     {
6259       disc->setProfile(newPflName);
6260       DataArrayInt *pfl=getProfile(oldPflName.c_str());
6261       pfl->setName(newPflName);
6262     }
6263   else
6264     {
6265       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6266       throw INTERP_KERNEL::Exception(oss.str());
6267     }
6268 }
6269
6270 /*!
6271  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6272  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6273  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6274  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6275  * to keep a valid instance.
6276  * 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.
6277  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6278  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6279  * 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.
6280  *
6281  * \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.
6282  * \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.
6283  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
6284  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6285  * \param [in] newLocName is the new localization name.
6286  * \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.
6287  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6288  */
6289 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6290 {
6291   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6292   std::string oldLocName=disc->getLocalization();
6293   std::vector<std::string> vv=getLocsReallyUsedMulti();
6294   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6295   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6296     {
6297       disc->setLocalization(newLocName);
6298       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6299       loc.setName(newLocName);
6300     }
6301   else
6302     {
6303       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6304       throw INTERP_KERNEL::Exception(oss.str());
6305     }
6306 }
6307
6308 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6309 {
6310   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6311   if(!ret)
6312     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6313   return ret;
6314 }
6315
6316 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6317 {
6318   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6319   if(!ret)
6320     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6321   return ret;
6322 }
6323
6324 /*!
6325  * This method alloc the arrays and load potentially huge arrays contained in this field.
6326  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6327  * This method can be also called to refresh or reinit values from a file.
6328  * 
6329  * \throw If the fileName is not set or points to a non readable MED file.
6330  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6331  */
6332 void MEDFileAnyTypeField1TS::loadArrays()
6333 {
6334   if(getFileName().empty())
6335     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6336   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6337   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6338 }
6339
6340 /*!
6341  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6342  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6343  * this method does not throw if \a this does not come from file read.
6344  * 
6345  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6346  */
6347 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6348 {
6349   if(!getFileName().empty())
6350     {
6351       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6352       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6353     }
6354 }
6355
6356 /*!
6357  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6358  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6359  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6360  * 
6361  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6362  */
6363 void MEDFileAnyTypeField1TS::unloadArrays()
6364 {
6365   contentNotNullBase()->unloadArrays();
6366 }
6367
6368 /*!
6369  * 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.
6370  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6371  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6372  * 
6373  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6374  */
6375 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6376 {
6377   if(!getFileName().empty())
6378     contentNotNullBase()->unloadArrays();
6379 }
6380
6381 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6382 {
6383   int nbComp(getNumberOfComponents());
6384   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6385   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6386   for(int i=0;i<nbComp;i++)
6387     {
6388       std::string info=getInfo()[i];
6389       std::string c,u;
6390       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6391       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6392       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6393     }
6394   if(getName().empty())
6395     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6396   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6397   writeGlobals(fid,*this);
6398   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6399 }
6400
6401 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6402 {
6403   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6404 }
6405
6406 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6407 {
6408   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6409   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6410   return ret;
6411 }
6412
6413 /*!
6414  * Returns a string describing \a this field. This string is outputted 
6415  * by \c print Python command.
6416  */
6417 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6418 {
6419   std::ostringstream oss;
6420   contentNotNullBase()->simpleRepr(0,oss,-1);
6421   simpleReprGlobs(oss);
6422   return oss.str();
6423 }
6424
6425 /*!
6426  * This method returns all profiles whose name is non empty used.
6427  * \b WARNING If profile is used several times it will be reported \b only \b once.
6428  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6429  */
6430 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6431 {
6432   return contentNotNullBase()->getPflsReallyUsed2();
6433 }
6434
6435 /*!
6436  * This method returns all localizations whose name is non empty used.
6437  * \b WARNING If localization is used several times it will be reported \b only \b once.
6438  */
6439 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6440 {
6441   return contentNotNullBase()->getLocsReallyUsed2();
6442 }
6443
6444 /*!
6445  * This method returns all profiles whose name is non empty used.
6446  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6447  */
6448 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6449 {
6450   return contentNotNullBase()->getPflsReallyUsedMulti2();
6451 }
6452
6453 /*!
6454  * This method returns all localizations whose name is non empty used.
6455  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6456  */
6457 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6458 {
6459   return contentNotNullBase()->getLocsReallyUsedMulti2();
6460 }
6461
6462 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6463 {
6464   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6465 }
6466
6467 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6468 {
6469   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6470 }
6471
6472 int MEDFileAnyTypeField1TS::getDimension() const
6473 {
6474   return contentNotNullBase()->getDimension();
6475 }
6476
6477 int MEDFileAnyTypeField1TS::getIteration() const
6478 {
6479   return contentNotNullBase()->getIteration();
6480 }
6481
6482 int MEDFileAnyTypeField1TS::getOrder() const
6483 {
6484   return contentNotNullBase()->getOrder();
6485 }
6486
6487 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6488 {
6489   return contentNotNullBase()->getTime(iteration,order);
6490 }
6491
6492 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6493 {
6494   contentNotNullBase()->setTime(iteration,order,val);
6495 }
6496
6497 std::string MEDFileAnyTypeField1TS::getName() const
6498 {
6499   return contentNotNullBase()->getName();
6500 }
6501
6502 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6503 {
6504   contentNotNullBase()->setName(name);
6505 }
6506
6507 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6508 {
6509   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6510 }
6511
6512 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6513 {
6514   return contentNotNullBase()->getDtUnit();
6515 }
6516
6517 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6518 {
6519   contentNotNullBase()->setDtUnit(dtUnit);
6520 }
6521
6522 std::string MEDFileAnyTypeField1TS::getMeshName() const
6523 {
6524   return contentNotNullBase()->getMeshName();
6525 }
6526
6527 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6528 {
6529   contentNotNullBase()->setMeshName(newMeshName);
6530 }
6531
6532 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6533 {
6534   return contentNotNullBase()->changeMeshNames(modifTab);
6535 }
6536
6537 int MEDFileAnyTypeField1TS::getMeshIteration() const
6538 {
6539   return contentNotNullBase()->getMeshIteration();
6540 }
6541
6542 int MEDFileAnyTypeField1TS::getMeshOrder() const
6543 {
6544   return contentNotNullBase()->getMeshOrder();
6545 }
6546
6547 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6548 {
6549   return contentNotNullBase()->getNumberOfComponents();
6550 }
6551
6552 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6553 {
6554   return contentNotNullBase()->isDealingTS(iteration,order);
6555 }
6556
6557 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6558 {
6559   return contentNotNullBase()->getDtIt();
6560 }
6561
6562 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6563 {
6564   contentNotNullBase()->fillIteration(p);
6565 }
6566
6567 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6568 {
6569   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6570 }
6571
6572 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6573 {
6574   contentNotNullBase()->setInfo(infos);
6575 }
6576
6577 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6578 {
6579   return contentNotNullBase()->getInfo();
6580 }
6581 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6582 {
6583   return contentNotNullBase()->getInfo();
6584 }
6585
6586 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6587 {
6588   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6589 }
6590
6591 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6592 {
6593   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6594 }
6595
6596 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6597 {
6598   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6599 }
6600
6601 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6602 {
6603   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6604 }
6605
6606 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6607 {
6608   return contentNotNullBase()->convertMedBallIntoClassic();
6609 }
6610
6611 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
6612 {
6613   return contentNotNullBase()->makeReduction(ct,tof,pfl);
6614 }
6615
6616 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6617 {
6618   return contentNotNullBase()->getTypesOfFieldAvailable();
6619 }
6620
6621 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,
6622                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6623 {
6624   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6625 }
6626
6627 /*!
6628  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6629  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6630  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6631  */
6632 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6633 {
6634   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6635   if(!content)
6636     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6637   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6638   std::size_t sz(contentsSplit.size());
6639   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6640   for(std::size_t i=0;i<sz;i++)
6641     {
6642       ret[i]=shallowCpy();
6643       ret[i]->_content=contentsSplit[i];
6644     }
6645   return ret;
6646 }
6647
6648 /*!
6649  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6650  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6651  */
6652 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6653 {
6654   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6655   if(!content)
6656     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6657   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6658   std::size_t sz(contentsSplit.size());
6659   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6660   for(std::size_t i=0;i<sz;i++)
6661     {
6662       ret[i]=shallowCpy();
6663       ret[i]->_content=contentsSplit[i];
6664     }
6665   return ret;
6666 }
6667
6668 /*!
6669  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6670  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6671  */
6672 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6673 {
6674   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6675   if(!content)
6676     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6677   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6678   std::size_t sz(contentsSplit.size());
6679   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6680   for(std::size_t i=0;i<sz;i++)
6681     {
6682       ret[i]=shallowCpy();
6683       ret[i]->_content=contentsSplit[i];
6684     }
6685   return ret;
6686 }
6687
6688 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6689 {
6690   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6691   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6692     ret->_content=_content->deepCopy();
6693   ret->deepCpyGlobs(*this);
6694   return ret.retn();
6695 }
6696
6697 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6698 {
6699   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6700 }
6701
6702 //= MEDFileField1TS
6703
6704 /*!
6705  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6706  * the first field that has been read from a specified MED file.
6707  *  \param [in] fileName - the name of the MED file to read.
6708  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6709  *          is to delete this field using decrRef() as it is no more needed.
6710  *  \throw If reading the file fails.
6711  */
6712 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6713 {
6714   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6715   return New(fid,loadAll);
6716 }
6717
6718 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6719 {
6720   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6721   ret->contentNotNull();
6722   return ret.retn();
6723 }
6724
6725 /*!
6726  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6727  * a given field that has been read from a specified MED file.
6728  *  \param [in] fileName - the name of the MED file to read.
6729  *  \param [in] fieldName - the name of the field to read.
6730  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6731  *          is to delete this field using decrRef() as it is no more needed.
6732  *  \throw If reading the file fails.
6733  *  \throw If there is no field named \a fieldName in the file.
6734  */
6735 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6736 {
6737   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6738   return New(fid,fieldName,loadAll);
6739 }
6740
6741 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6742 {
6743   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6744   ret->contentNotNull();
6745   return ret.retn();
6746 }
6747
6748 /*!
6749  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6750  * a given field that has been read from a specified MED file.
6751  *  \param [in] fileName - the name of the MED file to read.
6752  *  \param [in] fieldName - the name of the field to read.
6753  *  \param [in] iteration - the iteration number of a required time step.
6754  *  \param [in] order - the iteration order number of required time step.
6755  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6756  *          is to delete this field using decrRef() as it is no more needed.
6757  *  \throw If reading the file fails.
6758  *  \throw If there is no field named \a fieldName in the file.
6759  *  \throw If the required time step is missing from the file.
6760  */
6761 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6762 {
6763   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6764   return New(fid,fieldName,iteration,order,loadAll);
6765 }
6766
6767 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6768 {
6769   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6770   ret->contentNotNull();
6771   return ret.retn();
6772 }
6773
6774 /*!
6775  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6776  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6777  *
6778  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6779  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6780  * \warning this is a shallow copy constructor
6781  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6782  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6783  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6784  *          is to delete this field using decrRef() as it is no more needed.
6785  */
6786 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6787 {
6788   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6789   ret->contentNotNull();
6790   return ret.retn();
6791 }
6792
6793 /*!
6794  * Returns a new empty instance of MEDFileField1TS.
6795  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6796  *          is to delete this field using decrRef() as it is no more needed.
6797  */
6798 MEDFileField1TS *MEDFileField1TS::New()
6799 {
6800   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6801   ret->contentNotNull();
6802   return ret.retn();
6803 }
6804
6805 /*!
6806  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6807  * following the given input policy.
6808  *
6809  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6810  *                            By default (true) the globals are deeply copied.
6811  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6812  */
6813 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6814 {
6815   MCAuto<MEDFileIntField1TS> ret;
6816   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6817   if(content)
6818     {
6819       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6820       if(!contc)
6821         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6822       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6823       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6824     }
6825   else
6826     ret=MEDFileIntField1TS::New();
6827   if(isDeepCpyGlobs)
6828     ret->deepCpyGlobs(*this);
6829   else
6830     ret->shallowCpyGlobs(*this);
6831   return ret.retn();
6832 }
6833
6834 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6835 {
6836   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6837   if(!pt)
6838     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6839   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6840   if(!ret)
6841     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 !");
6842   return ret;
6843 }
6844
6845 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6846 {
6847   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6848   if(!pt)
6849     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6850   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6851   if(!ret)
6852     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 !");
6853   return ret;
6854 }
6855
6856 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6857 {
6858   if(!f)
6859     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6860   if(arr.isNull())
6861     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6862   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6863   if(!arrOutC)
6864     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6865   f->setArray(arrOutC);
6866 }
6867
6868 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6869 {
6870   if(arr.isNull())
6871     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6872   DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6873   if(!arrOutC)
6874     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6875   arrOutC->incrRef();
6876   return arrOutC;
6877 }
6878
6879 /*!
6880  * Return an extraction of \a this using \a extractDef map to specify the extraction.
6881  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6882  *
6883  * \return A new object that the caller is responsible to deallocate.
6884  * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6885  */
6886 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6887 {
6888   if(!mm)
6889     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6890   MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6891   std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6892   for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6893     {
6894       if((*it0)!=ON_NODES)
6895         {
6896           std::vector<int> levs;
6897           getNonEmptyLevels(mm->getName(),levs);
6898           for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6899             {
6900               std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6901               if(it2!=extractDef.end())
6902                 {
6903                   MCAuto<DataArrayInt> t((*it2).second);
6904                   if(t.isNull())
6905                     throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6906                   MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6907                   MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6908                   ret->setFieldNoProfileSBT(fOut);
6909                 }
6910             }
6911         }
6912       else
6913         {
6914           std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6915           if(it2==extractDef.end())
6916             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6917           MCAuto<DataArrayInt> t((*it2).second);
6918           if(t.isNull())
6919             throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6920           MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6921           MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6922           DataArrayDouble *arr(f->getArray());
6923           MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6924           fOut->setArray(newArr);
6925           ret->setFieldNoProfileSBT(fOut);
6926         }
6927     }
6928   return ret.retn();
6929 }
6930
6931 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6932 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6933 {
6934 }
6935 catch(INTERP_KERNEL::Exception& e)
6936 { throw e; }
6937
6938 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6939 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6940 {
6941 }
6942 catch(INTERP_KERNEL::Exception& e)
6943 { throw e; }
6944
6945 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6946 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6947 {
6948 }
6949 catch(INTERP_KERNEL::Exception& e)
6950 { throw e; }
6951
6952 /*!
6953  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6954  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6955  *
6956  * \warning this is a shallow copy constructor
6957  */
6958 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6959 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6960 {
6961 }
6962 catch(INTERP_KERNEL::Exception& e)
6963 { throw e; }
6964
6965 MEDFileField1TS::MEDFileField1TS()
6966 {
6967   _content=new MEDFileField1TSWithoutSDA;
6968 }
6969
6970 /*!
6971  * 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
6972  * method should be called (getFieldOnMeshAtLevel for example).
6973  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6974  *
6975  * \param [in] mesh - the mesh the field is lying on
6976  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6977  *          caller is to delete this field using decrRef() as it is no more needed. 
6978  */
6979 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6980 {
6981   MCAuto<DataArray> arrOut;
6982   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6983   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6984   return ret.retn();
6985 }
6986
6987 /*!
6988  * Returns a new MEDCouplingFieldDouble of a given type lying on
6989  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6990  * has not been constructed via file reading, an exception is thrown.
6991  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6992  *  \param [in] type - a spatial discretization of interest.
6993  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6994  *  \param [in] renumPol - specifies how to permute values of the result field according to
6995  *          the optional numbers of cells and nodes, if any. The valid values are
6996  *          - 0 - do not permute.
6997  *          - 1 - permute cells.
6998  *          - 2 - permute nodes.
6999  *          - 3 - permute cells and nodes.
7000  *
7001  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7002  *          caller is to delete this field using decrRef() as it is no more needed. 
7003  *  \throw If \a this field has not been constructed via file reading.
7004  *  \throw If the MED file is not readable.
7005  *  \throw If there is no mesh in the MED file.
7006  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7007  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7008  *  \sa getFieldOnMeshAtLevel()
7009  */
7010 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7011 {
7012   if(getFileName().empty())
7013     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7014   MCAuto<DataArray> arrOut;
7015   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7016   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7017   return ret.retn();
7018 }
7019
7020 /*!
7021  * Returns a new MEDCouplingFieldDouble of a given type lying on
7022  * the top level cells of the first mesh in MED file. If \a this field 
7023  * has not been constructed via file reading, an exception is thrown.
7024  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7025  *  \param [in] type - a spatial discretization of interest.
7026  *  \param [in] renumPol - specifies how to permute values of the result field according to
7027  *          the optional numbers of cells and nodes, if any. The valid values are
7028  *          - 0 - do not permute.
7029  *          - 1 - permute cells.
7030  *          - 2 - permute nodes.
7031  *          - 3 - permute cells and nodes.
7032  *
7033  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7034  *          caller is to delete this field using decrRef() as it is no more needed. 
7035  *  \throw If \a this field has not been constructed via file reading.
7036  *  \throw If the MED file is not readable.
7037  *  \throw If there is no mesh in the MED file.
7038  *  \throw If no field values of the given \a type.
7039  *  \throw If no field values lying on the top level support.
7040  *  \sa getFieldAtLevel()
7041  */
7042 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7043 {
7044   if(getFileName().empty())
7045     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7046   MCAuto<DataArray> arrOut;
7047   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7048   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7049   return ret.retn();
7050 }
7051
7052 /*!
7053  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
7054  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7055  *  \param [in] type - a spatial discretization of the new field.
7056  *  \param [in] mesh - the supporting mesh.
7057  *  \param [in] renumPol - specifies how to permute values of the result field according to
7058  *          the optional numbers of cells and nodes, if any. The valid values are
7059  *          - 0 - do not permute.
7060  *          - 1 - permute cells.
7061  *          - 2 - permute nodes.
7062  *          - 3 - permute cells and nodes.
7063  *
7064  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7065  *          caller is to delete this field using decrRef() as it is no more needed. 
7066  *  \throw If no field of \a this is lying on \a mesh.
7067  *  \throw If the mesh is empty.
7068  *  \throw If no field values of the given \a type are available.
7069  *  \sa getFieldAtLevel()
7070  *  \sa getFieldOnMeshAtLevel() 
7071  */
7072 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7073 {
7074   MCAuto<DataArray> arrOut;
7075   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7076   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7077   return ret.retn();
7078 }
7079
7080 /*!
7081  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7082  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7083  *  \param [in] type - a spatial discretization of interest.
7084  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7085  *  \param [in] mesh - the supporting mesh.
7086  *  \param [in] renumPol - specifies how to permute values of the result field according to
7087  *          the optional numbers of cells and nodes, if any. The valid values are
7088  *          - 0 - do not permute.
7089  *          - 1 - permute cells.
7090  *          - 2 - permute nodes.
7091  *          - 3 - permute cells and nodes.
7092  *
7093  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7094  *          caller is to delete this field using decrRef() as it is no more needed. 
7095  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7096  *  \throw If no field of \a this is lying on \a mesh.
7097  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7098  *  \sa getFieldAtLevel()
7099  *  \sa getFieldOnMeshAtLevel() 
7100  */
7101 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7102 {
7103   MCAuto<DataArray> arrOut;
7104   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7105   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7106   return ret.retn();
7107 }
7108
7109 /*!
7110  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7111  * This method is called "Old" because in MED3 norm a field has only one meshName
7112  * attached, so this method is for readers of MED2 files. If \a this field 
7113  * has not been constructed via file reading, an exception is thrown.
7114  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7115  *  \param [in] type - a spatial discretization of interest.
7116  *  \param [in] mName - a name of the supporting mesh.
7117  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7118  *  \param [in] renumPol - specifies how to permute values of the result field according to
7119  *          the optional numbers of cells and nodes, if any. The valid values are
7120  *          - 0 - do not permute.
7121  *          - 1 - permute cells.
7122  *          - 2 - permute nodes.
7123  *          - 3 - permute cells and nodes.
7124  *
7125  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7126  *          caller is to delete this field using decrRef() as it is no more needed. 
7127  *  \throw If the MED file is not readable.
7128  *  \throw If there is no mesh named \a mName in the MED file.
7129  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7130  *  \throw If \a this field has not been constructed via file reading.
7131  *  \throw If no field of \a this is lying on the mesh named \a mName.
7132  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7133  *  \sa getFieldAtLevel()
7134  */
7135 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7136 {
7137   if(getFileName().empty())
7138     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7139   MCAuto<DataArray> arrOut;
7140   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
7141   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
7142   return ret.retn();
7143 }
7144
7145 /*!
7146  * Returns values and a profile of the field of a given type lying on a given support.
7147  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7148  *  \param [in] type - a spatial discretization of the field.
7149  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7150  *  \param [in] mesh - the supporting mesh.
7151  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7152  *          field of interest lies on. If the field lies on all entities of the given
7153  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7154  *          using decrRef() as it is no more needed.  
7155  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
7156  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7157  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7158  *  \throw If no field of \a this is lying on \a mesh.
7159  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7160  */
7161 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7162 {
7163   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7164   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
7165 }
7166
7167 /*!
7168  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
7169  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7170  * "Sort By Type"), if not, an exception is thrown. 
7171  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7172  *  \param [in] field - the field to add to \a this.
7173  *  \throw If the name of \a field is empty.
7174  *  \throw If the data array of \a field is not set.
7175  *  \throw If the data array is already allocated but has different number of components
7176  *         than \a field.
7177  *  \throw If the underlying mesh of \a field has no name.
7178  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7179  */
7180 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
7181 {
7182   setFileName("");
7183   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
7184 }
7185
7186 /*!
7187  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7188  * can be an aggregation of several MEDCouplingFieldDouble instances.
7189  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7190  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7191  * and \a profile.
7192  *
7193  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7194  * A new profile is added only if no equal profile is missing.
7195  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7196  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
7197  *  \param [in] mesh - the supporting mesh of \a field.
7198  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7199  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7200  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7201  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7202  *  \throw If the data array of \a field is not set.
7203  *  \throw If the data array of \a this is already allocated but has different number of
7204  *         components than \a field.
7205  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7206  *  \sa setFieldNoProfileSBT()
7207  */
7208 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7209 {
7210   setFileName("");
7211   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7212 }
7213
7214 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7215 {
7216   return new MEDFileField1TS(*this);
7217 }
7218
7219 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7220 {
7221   return contentNotNull()->getUndergroundDataArrayTemplate();
7222 }
7223
7224 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7225 {
7226   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7227 }
7228
7229 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7230                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7231 {
7232   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7233 }
7234
7235 //= MEDFileIntField1TS
7236
7237 MEDFileIntField1TS *MEDFileIntField1TS::New()
7238 {
7239   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7240   ret->contentNotNull();
7241   return ret.retn();
7242 }
7243
7244 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7245 {
7246   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7247   return MEDFileIntField1TS::New(fid,loadAll);
7248 }
7249
7250 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7251 {
7252   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7253   ret->contentNotNull();
7254   return ret.retn();
7255 }
7256
7257 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7258 {
7259   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7260   return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7261 }
7262
7263 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7264 {
7265   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7266   ret->contentNotNull();
7267   return ret.retn();
7268 }
7269
7270 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7271 {
7272   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7273   return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7274 }
7275
7276 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7277 {
7278   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7279   ret->contentNotNull();
7280   return ret.retn();
7281 }
7282
7283 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7284 {
7285   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7286   ret->contentNotNull();
7287   return ret.retn();
7288 }
7289
7290 MEDFileIntField1TS::MEDFileIntField1TS()
7291 {
7292   _content=new MEDFileIntField1TSWithoutSDA;
7293 }
7294
7295 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7296 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7297 {
7298 }
7299 catch(INTERP_KERNEL::Exception& e)
7300 { throw e; }
7301
7302 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7303 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7304 {
7305 }
7306 catch(INTERP_KERNEL::Exception& e)
7307 { throw e; }
7308
7309 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7310 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7311 {
7312 }
7313 catch(INTERP_KERNEL::Exception& e)
7314 { throw e; }
7315
7316 /*!
7317  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7318  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7319  *
7320  * \warning this is a shallow copy constructor
7321  */
7322 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7323 {
7324 }
7325
7326 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7327 {
7328   return new MEDFileIntField1TS(*this);
7329 }
7330
7331 /*!
7332  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7333  * following the given input policy.
7334  *
7335  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7336  *                            By default (true) the globals are deeply copied.
7337  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7338  */
7339 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7340 {
7341   MCAuto<MEDFileField1TS> ret;
7342   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7343   if(content)
7344     {
7345       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7346       if(!contc)
7347         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7348       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7349       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7350     }
7351   else
7352     ret=MEDFileField1TS::New();
7353   if(isDeepCpyGlobs)
7354     ret->deepCpyGlobs(*this);
7355   else
7356     ret->shallowCpyGlobs(*this);
7357   return ret.retn();
7358 }
7359
7360 /*!
7361  * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7362  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7363  * "Sort By Type"), if not, an exception is thrown. 
7364  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7365  *  \param [in] field - the field to add to \a this.
7366  *  \throw If the name of \a field is empty.
7367  *  \throw If the data array of \a field is not set.
7368  *  \throw If the data array is already allocated but has different number of components
7369  *         than \a field.
7370  *  \throw If the underlying mesh of \a field has no name.
7371  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7372  */
7373 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7374 {
7375   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7376   setFileName("");
7377   contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7378 }
7379
7380 /*!
7381  * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7382  * can be an aggregation of several MEDCouplingFieldDouble instances.
7383  * The mesh support of input parameter \a field is ignored here, it can be NULL.
7384  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7385  * and \a profile.
7386  *
7387  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7388  * A new profile is added only if no equal profile is missing.
7389  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7390  *  \param [in] field - the field to add to \a this.
7391  *  \param [in] mesh - the supporting mesh of \a field.
7392  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7393  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
7394  *  \throw If either \a field or \a mesh or \a profile has an empty name.
7395  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7396  *  \throw If the data array of \a field is not set.
7397  *  \throw If the data array of \a this is already allocated but has different number of
7398  *         components than \a field.
7399  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7400  *  \sa setFieldNoProfileSBT()
7401  */
7402 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7403 {
7404   MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7405   setFileName("");
7406   contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7407 }
7408
7409 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7410 {
7411   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7412   if(!pt)
7413     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7414   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7415   if(!ret)
7416     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 !");
7417   return ret;
7418 }
7419
7420 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7421 {
7422   if(getFileName().empty())
7423     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7424   MCAuto<DataArray> arrOut;
7425   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7426   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7427   return ret2.retn();
7428 }
7429
7430 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7431 {
7432   if(arr.isNull())
7433     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7434   DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7435   if(!arrC)
7436     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7437   arrC->incrRef();
7438   return arrC;
7439 }
7440
7441 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7442 {
7443   int t1,t2;
7444   double t0(f->getTime(t1,t2));
7445   MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7446   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7447   MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7448   ret->setTime(t0,t1,t2); ret->setArray(arr2);
7449   return ret.retn();
7450 }
7451
7452 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7453 {
7454   if(!f)
7455     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7456   int t1,t2;
7457   double t0(f->getTime(t1,t2));
7458   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7459   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7460   ret->setTime(t0,t1,t2);
7461   return ret;
7462 }
7463
7464 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7465 {
7466   throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7467 }
7468
7469 /*!
7470  * 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
7471  * method should be called (getFieldOnMeshAtLevel for example).
7472  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7473  *
7474  * \param [in] mesh - the mesh the field is lying on
7475  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7476  *          caller is to delete this field using decrRef() as it is no more needed. 
7477  */
7478 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7479 {
7480   MCAuto<DataArray> arrOut;
7481   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7482   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7483   return ret2.retn();
7484 }
7485
7486 /*!
7487  * Returns a new MEDCouplingFieldInt of a given type lying on
7488  * the top level cells of the first mesh in MED file. If \a this field 
7489  * has not been constructed via file reading, an exception is thrown.
7490  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7491  *  \param [in] type - a spatial discretization of interest.
7492  *  \param [in] renumPol - specifies how to permute values of the result field according to
7493  *          the optional numbers of cells and nodes, if any. The valid values are
7494  *          - 0 - do not permute.
7495  *          - 1 - permute cells.
7496  *          - 2 - permute nodes.
7497  *          - 3 - permute cells and nodes.
7498  *
7499  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7500  *          caller is to delete this field using decrRef() as it is no more needed. 
7501  *  \throw If \a this field has not been constructed via file reading.
7502  *  \throw If the MED file is not readable.
7503  *  \throw If there is no mesh in the MED file.
7504  *  \throw If no field values of the given \a type.
7505  *  \throw If no field values lying on the top level support.
7506  *  \sa getFieldAtLevel()
7507  */
7508 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7509 {
7510   if(getFileName().empty())
7511     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7512   MCAuto<DataArray> arrOut;
7513   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7514   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7515   return ret2.retn();
7516 }
7517
7518 /*!
7519  * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7520  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7521  *  \param [in] type - a spatial discretization of the new field.
7522  *  \param [in] mesh - the supporting mesh.
7523  *  \param [in] renumPol - specifies how to permute values of the result field according to
7524  *          the optional numbers of cells and nodes, if any. The valid values are
7525  *          - 0 - do not permute.
7526  *          - 1 - permute cells.
7527  *          - 2 - permute nodes.
7528  *          - 3 - permute cells and nodes.
7529  *
7530  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7531  *          caller is to delete this field using decrRef() as it is no more needed. 
7532  *  \throw If no field of \a this is lying on \a mesh.
7533  *  \throw If the mesh is empty.
7534  *  \throw If no field values of the given \a type are available.
7535  *  \sa getFieldAtLevel()
7536  *  \sa getFieldOnMeshAtLevel() 
7537  */
7538 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7539 {
7540   MCAuto<DataArray> arrOut;
7541   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7542   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7543   return ret2.retn();
7544 }
7545
7546 /*!
7547  * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7548  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7549  *  \param [in] type - a spatial discretization of interest.
7550  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7551  *  \param [in] mesh - the supporting mesh.
7552  *  \param [in] renumPol - specifies how to permute values of the result field according to
7553  *          the optional numbers of cells and nodes, if any. The valid values are
7554  *          - 0 - do not permute.
7555  *          - 1 - permute cells.
7556  *          - 2 - permute nodes.
7557  *          - 3 - permute cells and nodes.
7558  *
7559  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7560  *          caller is to delete this field using decrRef() as it is no more needed. 
7561  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7562  *  \throw If no field of \a this is lying on \a mesh.
7563  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7564  *  \sa getFieldAtLevel()
7565  *  \sa getFieldOnMeshAtLevel() 
7566  */
7567 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7568 {
7569   MCAuto<DataArray> arrOut;
7570   MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7571   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7572   return ret2.retn();
7573 }
7574
7575 /*!
7576  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7577  * This method is called "Old" because in MED3 norm a field has only one meshName
7578  * attached, so this method is for readers of MED2 files. If \a this field 
7579  * has not been constructed via file reading, an exception is thrown.
7580  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7581  *  \param [in] type - a spatial discretization of interest.
7582  *  \param [in] mName - a name of the supporting mesh.
7583  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7584  *  \param [in] renumPol - specifies how to permute values of the result field according to
7585  *          the optional numbers of cells and nodes, if any. The valid values are
7586  *          - 0 - do not permute.
7587  *          - 1 - permute cells.
7588  *          - 2 - permute nodes.
7589  *          - 3 - permute cells and nodes.
7590  *
7591  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7592  *          caller is to delete this field using decrRef() as it is no more needed. 
7593  *  \throw If the MED file is not readable.
7594  *  \throw If there is no mesh named \a mName in the MED file.
7595  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7596  *  \throw If \a this field has not been constructed via file reading.
7597  *  \throw If no field of \a this is lying on the mesh named \a mName.
7598  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7599  *  \sa getFieldAtLevel()
7600  */
7601 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7602 {
7603   if(getFileName().empty())
7604     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7605   MCAuto<DataArray> arrOut;
7606   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7607   MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7608   return ret2.retn();
7609 }
7610
7611 /*!
7612  * Returns values and a profile of the field of a given type lying on a given support.
7613  * For more info, see \ref AdvMEDLoaderAPIFieldRW
7614  *  \param [in] type - a spatial discretization of the field.
7615  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7616  *  \param [in] mesh - the supporting mesh.
7617  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7618  *          field of interest lies on. If the field lies on all entities of the given
7619  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
7620  *          using decrRef() as it is no more needed.  
7621  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7622  *          field. The caller is to delete this array using decrRef() as it is no more needed.
7623  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7624  *  \throw If no field of \a this is lying on \a mesh.
7625  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7626  */
7627 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7628 {
7629   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7630   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7631 }
7632
7633 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7634 {
7635   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7636   if(!pt)
7637     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7638   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7639   if(!ret)
7640     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 !");
7641   return ret;
7642 }
7643
7644 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7645 {
7646   return contentNotNull()->getUndergroundDataArrayTemplate();
7647 }
7648
7649 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7650
7651 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7652 {
7653 }
7654
7655 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7656 {
7657 }
7658
7659 /*!
7660  * \param [in] fieldId field id in C mode
7661  */
7662 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7663 {
7664   med_field_type typcha;
7665   std::string dtunitOut;
7666   int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7667   setDtUnit(dtunitOut.c_str());
7668   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7669 }
7670
7671 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)
7672 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7673 {
7674   setDtUnit(dtunit.c_str());
7675   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7676 }
7677 catch(INTERP_KERNEL::Exception& e)
7678 {
7679     throw e;
7680 }
7681
7682 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7683 {
7684   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7685   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7686     ret+=(*it).capacity();
7687   return ret;
7688 }
7689
7690 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7691 {
7692   std::vector<const BigMemoryObject *> ret;
7693   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7694     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7695   return ret;
7696 }
7697
7698 /*!
7699  * 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
7700  * NULL.
7701  */
7702 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7703 {
7704   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7705   ret->setInfo(_infos);
7706   int sz=(int)_time_steps.size();
7707   for(const int *id=startIds;id!=endIds;id++)
7708     {
7709       if(*id>=0 && *id<sz)
7710         {
7711           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7712           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7713           if(tse)
7714             {
7715               tse->incrRef();
7716               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7717             }
7718           ret->pushBackTimeStep(tse2);
7719         }
7720       else
7721         {
7722           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7723           oss << " ! Should be in [0," << sz << ") !";
7724           throw INTERP_KERNEL::Exception(oss.str());
7725         }
7726     }
7727   if(ret->getNumberOfTS()>0)
7728     ret->synchronizeNameScope();
7729   ret->copyNameScope(*this);
7730   return ret.retn();
7731 }
7732
7733 /*!
7734  * 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
7735  * NULL.
7736  */
7737 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7738 {
7739   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7740   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7741   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7742   ret->setInfo(_infos);
7743   int sz=(int)_time_steps.size();
7744   int j=bg;
7745   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7746     {
7747       if(j>=0 && j<sz)
7748         {
7749           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7750           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7751           if(tse)
7752             {
7753               tse->incrRef();
7754               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7755             }
7756           ret->pushBackTimeStep(tse2);
7757         }
7758       else
7759         {
7760           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7761           oss << " ! Should be in [0," << sz << ") !";
7762           throw INTERP_KERNEL::Exception(oss.str());
7763         }
7764     }
7765   if(ret->getNumberOfTS()>0)
7766     ret->synchronizeNameScope();
7767   ret->copyNameScope(*this);
7768   return ret.retn();
7769 }
7770
7771 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7772 {
7773   int id=0;
7774   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7775   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7776     {
7777       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7778       if(!cur)
7779         continue;
7780       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7781       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7782         ids->pushBackSilent(id);
7783     }
7784   return buildFromTimeStepIds(ids->begin(),ids->end());
7785 }
7786
7787 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7788 {
7789   int id=0;
7790   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7791   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7792     {
7793       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7794       if(!cur)
7795         continue;
7796       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7797       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7798         ids->pushBackSilent(id);
7799     }
7800   return buildFromTimeStepIds(ids->begin(),ids->end());
7801 }
7802
7803 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7804 {
7805   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7806     if((*it).isNotNull())
7807       if((*it)->presenceOfStructureElements())
7808         return true;
7809   return false;
7810 }
7811
7812 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7813 {
7814   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7815     if((*it).isNotNull())
7816       if(!(*it)->onlyStructureElements())
7817         return false;
7818   return true;
7819 }
7820
7821 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7822 {
7823   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7824   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7825     if((*it).isNotNull())
7826       {
7827         if((*it)->presenceOfStructureElements())
7828           {
7829             if(!(*it)->onlyStructureElements())
7830               {
7831                 (*it)->killStructureElements();
7832                 ret.push_back(*it);
7833               }
7834           }
7835         else
7836           {
7837             ret.push_back(*it);
7838           }
7839       }
7840   _time_steps=ret;
7841 }
7842
7843 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7844 {
7845   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7846   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7847     if((*it).isNotNull())
7848       {
7849         if((*it)->presenceOfStructureElements())
7850           {
7851             if(!(*it)->onlyStructureElements())
7852               (*it)->keepOnlyStructureElements();
7853             ret.push_back(*it);
7854           }
7855       }
7856   _time_steps=ret;
7857 }
7858
7859 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7860 {
7861   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7862   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7863     if((*it).isNotNull())
7864       (*it)->keepOnlyOnSE(seName);
7865 }
7866
7867 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7868 {
7869   std::vector< std::pair<std::string,std::string> > ps2;
7870   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7871     if((*it).isNotNull())
7872       {
7873         (*it)->getMeshSENames(ps2);
7874         break;
7875       }
7876   if(ps2.empty())
7877     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7878   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7879     if((*it).isNotNull())
7880       {
7881         std::vector< std::pair<std::string,std::string> > ps3;
7882         (*it)->getMeshSENames(ps3);
7883         if(ps2!=ps3)
7884           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7885       }
7886   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7887     {
7888       std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7889       if(it2==ps.end())
7890         ps.push_back(*it);
7891     }
7892 }
7893
7894 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7895 {
7896   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7897     {
7898       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7899       if(!cur)
7900         continue;
7901       if(cur->presenceOfMultiDiscPerGeoType())
7902         return true;
7903     }
7904   return false;
7905 }
7906
7907 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7908 {
7909   return _infos;
7910 }
7911
7912 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7913 {
7914   _infos=info;
7915 }
7916
7917 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7918 {
7919   int ret=0;
7920   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7921     {
7922       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7923       if(pt->isDealingTS(iteration,order))
7924         return ret;
7925     }
7926   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7927   std::vector< std::pair<int,int> > vp=getIterations();
7928   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7929     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7930   throw INTERP_KERNEL::Exception(oss.str());
7931 }
7932
7933 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7934 {
7935   return *_time_steps[getTimeStepPos(iteration,order)];
7936 }
7937
7938 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7939 {
7940   return *_time_steps[getTimeStepPos(iteration,order)];
7941 }
7942
7943 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7944 {
7945   if(_time_steps.empty())
7946     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7947   return _time_steps[0]->getMeshName();
7948 }
7949
7950 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7951 {
7952   std::string oldName(getMeshName());
7953   std::vector< std::pair<std::string,std::string> > v(1);
7954   v[0].first=oldName; v[0].second=newMeshName;
7955   changeMeshNames(v);
7956 }
7957
7958 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7959 {
7960   bool ret=false;
7961   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7962     {
7963       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7964       if(cur)
7965         ret=cur->changeMeshNames(modifTab) || ret;
7966     }
7967   return ret;
7968 }
7969
7970 /*!
7971  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7972  */
7973 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7974 {
7975   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7976 }
7977
7978 /*!
7979  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7980  */
7981 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7982 {
7983   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7984 }
7985
7986 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7987                                                                        MEDFileFieldGlobsReal& glob)
7988 {
7989   bool ret=false;
7990   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7991     {
7992       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7993       if(f1ts)
7994         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7995     }
7996   return ret;
7997 }
7998
7999 void MEDFileAnyTypeFieldMultiTSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
8000 {
8001   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8002     if((*it).isNotNull())
8003       {
8004         visitor.newTimeStepEntry(*it);
8005         (*it)->accept(visitor);
8006         visitor.endTimeStepEntry(*it);
8007       }
8008 }
8009
8010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8011 {
8012   std::string startLine(bkOffset,' ');
8013   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
8014   if(fmtsId>=0)
8015     oss << " (" << fmtsId << ")";
8016   oss << " has the following name: \"" << _name << "\"." << std::endl;
8017   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
8018   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
8019     {
8020       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
8021     }
8022   int i=0;
8023   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8024     {
8025       std::string chapter(17,'0'+i);
8026       oss << startLine << chapter << std::endl;
8027       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8028       if(cur)
8029         cur->simpleRepr(bkOffset+2,oss,i);
8030       else
8031         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
8032       oss << startLine << chapter << std::endl;
8033     }
8034 }
8035
8036 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
8037 {
8038   std::size_t sz=_time_steps.size();
8039   std::vector< std::pair<int,int> > ret(sz);
8040   ret1.resize(sz);
8041   for(std::size_t i=0;i<sz;i++)
8042     {
8043       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
8044       if(f1ts)
8045         {
8046           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
8047         }
8048       else
8049         {
8050           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
8051           throw INTERP_KERNEL::Exception(oss.str());
8052         }
8053     }
8054   return ret;
8055 }
8056
8057 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
8058 {
8059   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
8060   if(!tse2)
8061     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
8062   checkCoherencyOfType(tse2);
8063   if(_time_steps.empty())
8064     {
8065       setName(tse2->getName().c_str());
8066       setInfo(tse2->getInfo());
8067     }
8068   checkThatComponentsMatch(tse2->getInfo());
8069   if(getDtUnit().empty() && !tse->getDtUnit().empty())
8070     setDtUnit(tse->getDtUnit());
8071   _time_steps.push_back(tse);
8072 }
8073
8074 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
8075 {
8076   std::size_t nbOfCompo=_infos.size();
8077   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8078     {
8079       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
8080       if(cur)
8081         {
8082           if((cur->getInfo()).size()!=nbOfCompo)
8083             {
8084               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
8085               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
8086               throw INTERP_KERNEL::Exception(oss.str());
8087             }
8088           cur->copyNameScope(*this);
8089         }
8090     }
8091 }
8092
8093 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8094 {
8095   _time_steps.resize(nbPdt);
8096   for(int i=0;i<nbPdt;i++)
8097     {
8098       std::vector< std::pair<int,int> > ts;
8099       med_int numdt=0,numo=0;
8100       med_float dt=0.0;
8101       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
8102       switch(fieldTyp)
8103       {
8104         case MED_FLOAT64:
8105           {
8106             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8107             break;
8108           }
8109         case MED_INT32:
8110           {
8111             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
8112             break;
8113           }
8114         default:
8115           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
8116       }
8117       if(loadAll)
8118         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
8119       else
8120         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
8121       synchronizeNameScope();
8122     }
8123 }
8124
8125 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
8126 {
8127   if(_time_steps.empty())
8128     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
8129   checkThatNbOfCompoOfTSMatchThis();
8130   std::vector<std::string> infos(getInfo());
8131   int nbComp=infos.size();
8132   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8133   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
8134   for(int i=0;i<nbComp;i++)
8135     {
8136       std::string info=infos[i];
8137       std::string c,u;
8138       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
8139       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8140       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
8141     }
8142   if(_name.empty())
8143     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
8144   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
8145   int nbOfTS=_time_steps.size();
8146   for(int i=0;i<nbOfTS;i++)
8147     _time_steps[i]->writeLL(fid,opts,*this);
8148 }
8149
8150 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
8151 {
8152   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8153     {
8154       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8155       if(elt)
8156         elt->loadBigArraysRecursively(fid,nasc);
8157     }
8158 }
8159
8160 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
8161 {
8162   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8163     {
8164       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8165       if(elt)
8166         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
8167     }
8168 }
8169
8170 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
8171 {
8172   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8173     {
8174       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8175       if(elt)
8176         elt->unloadArrays();
8177     }
8178 }
8179
8180 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
8181 {
8182   return _time_steps.size();
8183 }
8184
8185 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
8186 {
8187   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
8188   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8189     {
8190       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
8191       if(tmp)
8192         newTS.push_back(*it);
8193     }
8194   _time_steps=newTS;
8195 }
8196
8197 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
8198 {
8199   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8200   int maxId=(int)_time_steps.size();
8201   int ii=0;
8202   std::set<int> idsToDel;
8203   for(const int *id=startIds;id!=endIds;id++,ii++)
8204     {
8205       if(*id>=0 && *id<maxId)
8206         {
8207           idsToDel.insert(*id);
8208         }
8209       else
8210         {
8211           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
8212           throw INTERP_KERNEL::Exception(oss.str());
8213         }
8214     }
8215   for(int iii=0;iii<maxId;iii++)
8216     if(idsToDel.find(iii)==idsToDel.end())
8217       newTS.push_back(_time_steps[iii]);
8218   _time_steps=newTS;
8219 }
8220
8221 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8222 {
8223   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8224   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8225   if(nbOfEntriesToKill==0)
8226     return ;
8227   std::size_t sz=_time_steps.size();
8228   std::vector<bool> b(sz,true);
8229   int j=bg;
8230   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8231     b[j]=false;
8232   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8233   for(std::size_t i=0;i<sz;i++)
8234     if(b[i])
8235       newTS.push_back(_time_steps[i]);
8236   _time_steps=newTS;
8237 }
8238
8239 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8240 {
8241   int ret=0;
8242   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
8243   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8244     {
8245       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8246       if(tmp)
8247         {
8248           int it2,ord;
8249           tmp->getTime(it2,ord);
8250           if(it2==iteration && order==ord)
8251             return ret;
8252           else
8253             oss << "(" << it2 << ","  << ord << "), ";
8254         }
8255     }
8256   throw INTERP_KERNEL::Exception(oss.str());
8257 }
8258
8259 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8260 {
8261   int ret=0;
8262   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8263   oss.precision(15);
8264   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8265     {
8266       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8267       if(tmp)
8268         {
8269           int it2,ord;
8270           double ti=tmp->getTime(it2,ord);
8271           if(fabs(time-ti)<eps)
8272             return ret;
8273           else
8274             oss << ti << ", ";
8275         }
8276     }
8277   throw INTERP_KERNEL::Exception(oss.str());
8278 }
8279
8280 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8281 {
8282   int lgth=_time_steps.size();
8283   std::vector< std::pair<int,int> > ret(lgth);
8284   for(int i=0;i<lgth;i++)
8285     _time_steps[i]->fillIteration(ret[i]);
8286   return ret;
8287 }
8288
8289 /*!
8290  * 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'
8291  * This method returns two things.
8292  * - The absolute dimension of 'this' in first parameter. 
8293  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8294  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
8295  *
8296  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8297  * Only these 3 discretizations will be taken into account here.
8298  *
8299  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8300  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8301  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8302  *
8303  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8304  * 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'.
8305  * 
8306  * Let's consider the typical following case :
8307  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8308  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8309  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8310  *   TETRA4 and SEG2
8311  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8312  *
8313  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8314  * 
8315  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8316  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8317  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8318  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8319  */
8320 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8321 {
8322   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8323 }
8324
8325 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8326 {
8327   if(pos<0 || pos>=(int)_time_steps.size())
8328     {
8329       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8330       throw INTERP_KERNEL::Exception(oss.str());
8331     }
8332   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8333   if(item==0)
8334     {
8335       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8336       oss << "\nTry to use following method eraseEmptyTS !";
8337       throw INTERP_KERNEL::Exception(oss.str());
8338     }
8339   return item;
8340 }
8341
8342 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8343 {
8344   if(pos<0 || pos>=(int)_time_steps.size())
8345     {
8346       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8347       throw INTERP_KERNEL::Exception(oss.str());
8348     }
8349   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8350   if(item==0)
8351     {
8352       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8353       oss << "\nTry to use following method eraseEmptyTS !";
8354       throw INTERP_KERNEL::Exception(oss.str());
8355     }
8356   return item;
8357 }
8358
8359 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8360 {
8361   std::vector<std::string> ret;
8362   std::set<std::string> ret2;
8363   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8364     {
8365       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8366       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8367         if(ret2.find(*it2)==ret2.end())
8368           {
8369             ret.push_back(*it2);
8370             ret2.insert(*it2);
8371           }
8372     }
8373   return ret;
8374 }
8375
8376 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8377 {
8378   std::vector<std::string> ret;
8379   std::set<std::string> ret2;
8380   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8381     {
8382       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8383       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8384         if(ret2.find(*it2)==ret2.end())
8385           {
8386             ret.push_back(*it2);
8387             ret2.insert(*it2);
8388           }
8389     }
8390   return ret;
8391 }
8392
8393 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8394 {
8395   std::vector<std::string> ret;
8396   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8397     {
8398       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8399       ret.insert(ret.end(),tmp.begin(),tmp.end());
8400     }
8401   return ret;
8402 }
8403
8404 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8405 {
8406   std::vector<std::string> ret;
8407   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8408     {
8409       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8410       ret.insert(ret.end(),tmp.begin(),tmp.end());
8411     }
8412   return ret;
8413 }
8414
8415 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8416 {
8417   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8418     (*it)->changePflsRefsNamesGen2(mapOfModif);
8419 }
8420
8421 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8422 {
8423   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8424     (*it)->changeLocsRefsNamesGen2(mapOfModif);
8425 }
8426
8427 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8428 {
8429   int lgth=_time_steps.size();
8430   std::vector< std::vector<TypeOfField> > ret(lgth);
8431   for(int i=0;i<lgth;i++)
8432     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8433   return ret;
8434 }
8435
8436 /*!
8437  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8438  */
8439 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
8440 {
8441   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8442 }
8443
8444 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8445 {
8446   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8447   std::size_t i=0;
8448   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8449     {
8450       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8451         ret->_time_steps[i]=(*it)->deepCopy();
8452     }
8453   return ret.retn();
8454 }
8455
8456 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8457 {
8458   std::size_t sz(_infos.size()),sz2(_time_steps.size());
8459   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8460   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8461   for(std::size_t i=0;i<sz;i++)
8462     {
8463       ret[i]=shallowCpy();
8464       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8465     }
8466   for(std::size_t i=0;i<sz2;i++)
8467     {
8468       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8469       if(ret1.size()!=sz)
8470         {
8471           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8472           throw INTERP_KERNEL::Exception(oss.str());
8473         }
8474       ts[i]=ret1;
8475     }
8476   for(std::size_t i=0;i<sz;i++)
8477     for(std::size_t j=0;j<sz2;j++)
8478       ret[i]->_time_steps[j]=ts[j][i];
8479   return ret;
8480 }
8481
8482 /*!
8483  * This method splits into discretization each time steps in \a this.
8484  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8485  */
8486 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8487 {
8488   std::size_t sz(_time_steps.size());
8489   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8490   for(std::size_t i=0;i<sz;i++)
8491     {
8492       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8493       if(!timeStep)
8494         {
8495           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
8496           throw INTERP_KERNEL::Exception(oss.str());
8497         }
8498       items[i]=timeStep->splitDiscretizations();  
8499     }
8500   //
8501   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8502   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8503   std::vector< TypeOfField > types;
8504   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8505     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8506       {
8507         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8508         if(ts.size()!=1)
8509           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8510         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8511         if(it2==types.end())
8512           types.push_back(ts[0]);
8513       }
8514   ret.resize(types.size()); ret2.resize(types.size());
8515   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8516     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8517       {
8518         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8519         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8520         ret2[pos].push_back(*it1);
8521       }
8522   for(std::size_t i=0;i<types.size();i++)
8523     {
8524       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8525       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8526         elt->pushBackTimeStep(*it1);//also updates infos in elt
8527       ret[i]=elt;
8528       elt->MEDFileFieldNameScope::operator=(*this);
8529     }
8530   return ret;
8531 }
8532
8533 /*!
8534  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8535  */
8536 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8537 {
8538   std::size_t sz(_time_steps.size());
8539   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8540   std::size_t szOut(std::numeric_limits<std::size_t>::max());
8541   for(std::size_t i=0;i<sz;i++)
8542     {
8543       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8544       if(!timeStep)
8545         {
8546           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8547           throw INTERP_KERNEL::Exception(oss.str());
8548         }
8549       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8550       if(szOut==std::numeric_limits<std::size_t>::max())
8551         szOut=items[i].size();
8552       else
8553         if(items[i].size()!=szOut)
8554           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8555     }
8556   if(szOut==std::numeric_limits<std::size_t>::max())
8557     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8558   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8559   for(std::size_t i=0;i<szOut;i++)
8560     {
8561       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8562       for(std::size_t j=0;j<sz;j++)
8563         elt->pushBackTimeStep(items[j][i]);
8564       ret[i]=elt;
8565       elt->MEDFileFieldNameScope::operator=(*this);
8566     }
8567   return ret;
8568 }
8569
8570 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8571 {
8572   _name=field->getName();
8573   if(_name.empty())
8574     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8575   if(!arr)
8576     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8577   _infos=arr->getInfoOnComponents();
8578 }
8579
8580 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8581 {
8582   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8583   if(_name!=field->getName())
8584     {
8585       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8586       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8587       throw INTERP_KERNEL::Exception(oss.str());
8588     }
8589   if(!arr)
8590     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8591   checkThatComponentsMatch(arr->getInfoOnComponents());
8592 }
8593
8594 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8595 {
8596   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8597   if(getInfo().size()!=compos.size())
8598     {
8599       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8600       oss << " number of components of element to append (" << compos.size() << ") !";
8601       throw INTERP_KERNEL::Exception(oss.str());
8602     }
8603   if(_infos!=compos)
8604     {
8605       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8606       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8607       oss << " But compo in input fields are : ";
8608       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8609       oss << " !";
8610       throw INTERP_KERNEL::Exception(oss.str());
8611     }
8612 }
8613
8614 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8615 {
8616   std::size_t sz=_infos.size();
8617   int j=0;
8618   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8619     {
8620       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8621       if(elt)
8622         if(elt->getInfo().size()!=sz)
8623           {
8624             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8625             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8626             throw INTERP_KERNEL::Exception(oss.str());
8627           }
8628     }
8629 }
8630
8631 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8632 {
8633   if(!field)
8634     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8635   if(!_time_steps.empty())
8636     checkCoherencyOfTinyInfo(field,arr);
8637   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8638   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8639   objC->setFieldNoProfileSBT(field,arr,glob,*this);
8640   copyTinyInfoFrom(field,arr);
8641   _time_steps.push_back(obj);
8642 }
8643
8644 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8645 {
8646   if(!field)
8647     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8648   if(!_time_steps.empty())
8649     checkCoherencyOfTinyInfo(field,arr);
8650   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8651   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8652   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8653   copyTinyInfoFrom(field,arr);
8654   _time_steps.push_back(obj);
8655 }
8656
8657 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8658 {
8659   int sz=(int)_time_steps.size();
8660   if(i<0 || i>=sz)
8661     {
8662       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8663       throw INTERP_KERNEL::Exception(oss.str());
8664     }
8665   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8666   if(tsPtr)
8667     {
8668       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8669         {
8670           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
8671           throw INTERP_KERNEL::Exception(oss.str());
8672         }
8673     }
8674   _time_steps[i]=ts;
8675 }
8676
8677 //= MEDFileFieldMultiTSWithoutSDA
8678
8679 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)
8680 {
8681   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8682 }
8683
8684 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8685 {
8686 }
8687
8688 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8689 {
8690 }
8691
8692 /*!
8693  * \param [in] fieldId field id in C mode
8694  */
8695 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8696 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8697 {
8698 }
8699 catch(INTERP_KERNEL::Exception& e)
8700 { throw e; }
8701
8702 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)
8703 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8704 {
8705 }
8706 catch(INTERP_KERNEL::Exception& e)
8707 { throw e; }
8708
8709 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8710 {
8711   return new MEDFileField1TSWithoutSDA;
8712 }
8713
8714 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8715 {
8716   if(!f1ts)
8717     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8718   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8719   if(!f1tsC)
8720     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8721 }
8722
8723 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8724 {
8725   return MEDFileField1TSWithoutSDA::TYPE_STR;
8726 }
8727
8728 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8729 {
8730   return new MEDFileFieldMultiTSWithoutSDA(*this);
8731 }
8732
8733 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8734 {
8735   return new MEDFileFieldMultiTSWithoutSDA;
8736 }
8737
8738 /*!
8739  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8740  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8741  */
8742 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
8743 {
8744   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8745   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8746   if(!myF1TSC)
8747     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8748   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8749 }
8750
8751 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8752 {
8753   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8754   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8755   int i=0;
8756   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8757     {
8758       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8759       if(eltToConv)
8760         {
8761           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8762           if(!eltToConvC)
8763             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8764           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8765           ret->setIteration(i,elt);
8766         }
8767     }
8768   return ret.retn();
8769 }
8770
8771 //= MEDFileAnyTypeFieldMultiTS
8772
8773 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8774 {
8775 }
8776
8777 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8778 try:MEDFileFieldGlobsReal(fid)
8779 {
8780   _content=BuildContentFrom(fid,loadAll,ms);
8781   loadGlobals(fid);
8782 }
8783 catch(INTERP_KERNEL::Exception& e)
8784 {
8785     throw e;
8786 }
8787
8788 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8789 {
8790   med_field_type typcha;
8791   std::vector<std::string> infos;
8792   std::string dtunit;
8793   int i(-1);
8794   MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8795   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8796   switch(typcha)
8797   {
8798     case MED_FLOAT64:
8799       {
8800         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8801         break;
8802       }
8803     case MED_INT32:
8804       {
8805         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8806         break;
8807       }
8808     default:
8809       {
8810         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] !";
8811         throw INTERP_KERNEL::Exception(oss.str());
8812       }
8813   }
8814   ret->setDtUnit(dtunit.c_str());
8815   return ret.retn();
8816 }
8817
8818 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8819 {
8820   med_field_type typcha;
8821   //
8822   std::vector<std::string> infos;
8823   std::string dtunit,fieldName;
8824   MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8825   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8826   switch(typcha)
8827   {
8828     case MED_FLOAT64:
8829       {
8830         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8831         break;
8832       }
8833     case MED_INT32:
8834       {
8835         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8836         break;
8837       }
8838     default:
8839       {
8840         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] !";
8841         throw INTERP_KERNEL::Exception(oss.str());
8842       }
8843   }
8844   ret->setDtUnit(dtunit.c_str());
8845   return ret.retn();
8846 }
8847
8848 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8849 {
8850   if(!c)
8851     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8852   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8853     {
8854       MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8855       ret->_content=c;  c->incrRef();
8856       return ret.retn();
8857     }
8858   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8859     {
8860       MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8861       ret->_content=c;  c->incrRef();
8862       return ret.retn();
8863     }
8864   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8865 }
8866
8867 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8868 {
8869   MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8870   std::string fileName(FileNameFromFID(fid));
8871   ret->setFileName(fileName);
8872   return ret;
8873 }
8874
8875 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8876 try:MEDFileFieldGlobsReal(fid)
8877 {
8878   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8879   loadGlobals(fid);
8880 }
8881 catch(INTERP_KERNEL::Exception& e)
8882 {
8883     throw e;
8884 }
8885
8886 //= MEDFileIntFieldMultiTSWithoutSDA
8887
8888 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)
8889 {
8890   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8891 }
8892
8893 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8894 {
8895 }
8896
8897 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8898 {
8899 }
8900
8901 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)
8902 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8903 {
8904 }
8905 catch(INTERP_KERNEL::Exception& e)
8906 { throw e; }
8907
8908 /*!
8909  * \param [in] fieldId field id in C mode
8910  */
8911 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8912 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8913 {
8914 }
8915 catch(INTERP_KERNEL::Exception& e)
8916 { throw e; }
8917
8918 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8919 {
8920   return new MEDFileIntField1TSWithoutSDA;
8921 }
8922
8923 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8924 {
8925   if(!f1ts)
8926     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8927   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8928   if(!f1tsC)
8929     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8930 }
8931
8932 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8933 {
8934   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8935 }
8936
8937 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8938 {
8939   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8940 }
8941
8942 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8943 {
8944   return new MEDFileIntFieldMultiTSWithoutSDA;
8945 }
8946
8947 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8948 {
8949   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8950   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8951   int i=0;
8952   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8953     {
8954       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8955       if(eltToConv)
8956         {
8957           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8958           if(!eltToConvC)
8959             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8960           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8961           ret->setIteration(i,elt);
8962         }
8963     }
8964   return ret.retn();
8965 }
8966
8967 //= MEDFileAnyTypeFieldMultiTS
8968
8969 /*!
8970  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8971  * that has been read from a specified MED file.
8972  *  \param [in] fileName - the name of the MED file to read.
8973  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8974  *          is to delete this field using decrRef() as it is no more needed.
8975  *  \throw If reading the file fails.
8976  */
8977 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8978 {
8979   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8980   return New(fid,loadAll);
8981 }
8982
8983 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8984 {
8985   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8986   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8987   ret->loadGlobals(fid);
8988   return ret.retn();
8989 }
8990
8991 /*!
8992  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8993  * that has been read from a specified MED file.
8994  *  \param [in] fileName - the name of the MED file to read.
8995  *  \param [in] fieldName - the name of the field to read.
8996  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8997  *          is to delete this field using decrRef() as it is no more needed.
8998  *  \throw If reading the file fails.
8999  *  \throw If there is no field named \a fieldName in the file.
9000  */
9001 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9002 {
9003   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9004   return New(fid,fieldName,loadAll);
9005 }
9006
9007 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9008 {
9009   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
9010   MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
9011   ret->loadGlobals(fid);
9012   return ret.retn();
9013 }
9014
9015 /*!
9016  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9017  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9018  *
9019  * \warning this is a shallow copy constructor
9020  */
9021 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9022 {
9023   if(!shallowCopyOfContent)
9024     {
9025       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
9026       otherPtr->incrRef();
9027       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
9028     }
9029   else
9030     {
9031       _content=other.shallowCpy();
9032     }
9033 }
9034
9035 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
9036 {
9037   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9038   if(!ret)
9039     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
9040   return ret;
9041 }
9042
9043 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
9044 {
9045   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
9046   if(!ret)
9047     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
9048   return ret;
9049 }
9050
9051 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
9052 {
9053   return contentNotNullBase()->getPflsReallyUsed2();
9054 }
9055
9056 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
9057 {
9058   return contentNotNullBase()->getLocsReallyUsed2();
9059 }
9060
9061 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
9062 {
9063   return contentNotNullBase()->getPflsReallyUsedMulti2();
9064 }
9065
9066 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
9067 {
9068   return contentNotNullBase()->getLocsReallyUsedMulti2();
9069 }
9070
9071 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9072 {
9073   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
9074 }
9075
9076 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9077 {
9078   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
9079 }
9080
9081 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
9082 {
9083   return contentNotNullBase()->getNumberOfTS();
9084 }
9085
9086 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
9087 {
9088   contentNotNullBase()->eraseEmptyTS();
9089 }
9090
9091 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
9092 {
9093   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
9094 }
9095
9096 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
9097 {
9098   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
9099 }
9100
9101 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
9102 {
9103   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
9104   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9105   ret->_content=c;
9106   return ret.retn();
9107 }
9108
9109 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
9110 {
9111   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
9112   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9113   ret->_content=c;
9114   return ret.retn();
9115 }
9116
9117 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
9118 {
9119   return contentNotNullBase()->getIterations();
9120 }
9121
9122 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
9123 {
9124   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
9125     pushBackTimeStep(*it);
9126 }
9127
9128 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
9129 {
9130   if(!fmts)
9131     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
9132   int nbOfTS(fmts->getNumberOfTS());
9133   for(int i=0;i<nbOfTS;i++)
9134     {
9135       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
9136       pushBackTimeStep(elt);
9137     }
9138 }
9139
9140 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
9141 {
9142   if(!f1ts)
9143     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
9144   checkCoherencyOfType(f1ts);
9145   f1ts->incrRef();
9146   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
9147   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
9148   c->incrRef();
9149   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
9150   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
9151     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
9152   _content->pushBackTimeStep(cSafe);
9153   appendGlobs(*f1ts,1e-12);
9154 }
9155
9156 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
9157 {
9158   contentNotNullBase()->synchronizeNameScope();
9159 }
9160
9161 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
9162 {
9163   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
9164 }
9165
9166 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
9167 {
9168   return contentNotNullBase()->getPosGivenTime(time,eps);
9169 }
9170
9171 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
9172 {
9173   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
9174 }
9175
9176 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
9177 {
9178   return contentNotNullBase()->getTypesOfFieldAvailable();
9179 }
9180
9181 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
9182 {
9183   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
9184 }
9185
9186 std::string MEDFileAnyTypeFieldMultiTS::getName() const
9187 {
9188   return contentNotNullBase()->getName();
9189 }
9190
9191 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
9192 {
9193   contentNotNullBase()->setName(name);
9194 }
9195
9196 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
9197 {
9198   return contentNotNullBase()->getDtUnit();
9199 }
9200
9201 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
9202 {
9203   contentNotNullBase()->setDtUnit(dtUnit);
9204 }
9205
9206 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
9207 {
9208   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
9209 }
9210
9211 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
9212 {
9213   return contentNotNullBase()->getTimeSteps(ret1);
9214 }
9215
9216 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9217 {
9218   return contentNotNullBase()->getMeshName();
9219 }
9220
9221 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9222 {
9223   contentNotNullBase()->setMeshName(newMeshName);
9224 }
9225
9226 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9227 {
9228   return contentNotNullBase()->changeMeshNames(modifTab);
9229 }
9230
9231 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9232 {
9233   return contentNotNullBase()->getInfo();
9234 }
9235
9236 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9237 {
9238   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9239 }
9240
9241 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9242 {
9243   return contentNotNullBase()->setInfo(info);
9244 }
9245
9246 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9247 {
9248   const std::vector<std::string> ret=getInfo();
9249   return (int)ret.size();
9250 }
9251
9252 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9253 {
9254   writeGlobals(fid,*this);
9255   contentNotNullBase()->writeLL(fid,*this);
9256 }
9257
9258 /*!
9259  * This method alloc the arrays and load potentially huge arrays contained in this field.
9260  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9261  * This method can be also called to refresh or reinit values from a file.
9262  * 
9263  * \throw If the fileName is not set or points to a non readable MED file.
9264  */
9265 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9266 {
9267   if(getFileName().empty())
9268     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9269   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9270   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9271 }
9272
9273 /*!
9274  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9275  * But once data loaded once, this method does nothing.
9276  * 
9277  * \throw If the fileName is not set or points to a non readable MED file.
9278  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9279  */
9280 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9281 {
9282   if(!getFileName().empty())
9283     {
9284       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9285       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9286     }
9287 }
9288
9289 /*!
9290  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9291  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9292  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9293  * 
9294  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9295  */
9296 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9297 {
9298   contentNotNullBase()->unloadArrays();
9299 }
9300
9301 /*!
9302  * 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.
9303  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9304  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9305  * 
9306  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9307  */
9308 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9309 {
9310   if(!getFileName().empty())
9311     contentNotNullBase()->unloadArrays();
9312 }
9313
9314 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9315 {
9316   std::ostringstream oss;
9317   contentNotNullBase()->simpleRepr(0,oss,-1);
9318   simpleReprGlobs(oss);
9319   return oss.str();
9320 }
9321
9322 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9323 {
9324   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9325 }
9326
9327 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9328 {
9329   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9330   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9331   return ret;
9332 }
9333
9334 /*!
9335  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9336  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9337  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9338  */
9339 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9340 {
9341   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9342   if(!content)
9343     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9344   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9345   std::size_t sz(contentsSplit.size());
9346   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9347   for(std::size_t i=0;i<sz;i++)
9348     {
9349       ret[i]=shallowCpy();
9350       ret[i]->_content=contentsSplit[i];
9351     }
9352   return ret;
9353 }
9354
9355 /*!
9356  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9357  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9358  */
9359 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9360 {
9361   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9362   if(!content)
9363     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9364   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9365   std::size_t sz(contentsSplit.size());
9366   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9367   for(std::size_t i=0;i<sz;i++)
9368     {
9369       ret[i]=shallowCpy();
9370       ret[i]->_content=contentsSplit[i];
9371     }
9372   return ret;
9373 }
9374
9375 /*!
9376  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9377  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9378  */
9379 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9380 {
9381   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9382   if(!content)
9383     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9384   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9385   std::size_t sz(contentsSplit.size());
9386   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9387   for(std::size_t i=0;i<sz;i++)
9388     {
9389       ret[i]=shallowCpy();
9390       ret[i]->_content=contentsSplit[i];
9391     }
9392   return ret;
9393 }
9394
9395 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9396 {
9397   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9398   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9399     ret->_content=_content->deepCopy();
9400   ret->deepCpyGlobs(*this);
9401   return ret.retn();
9402 }
9403
9404 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9405 {
9406   return _content;
9407 }
9408
9409 /*!
9410  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9411  *  \param [in] iteration - the iteration number of a required time step.
9412  *  \param [in] order - the iteration order number of required time step.
9413  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9414  *          delete this field using decrRef() as it is no more needed.
9415  *  \throw If there is no required time step in \a this field.
9416  */
9417 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9418 {
9419   int pos=getPosOfTimeStep(iteration,order);
9420   return getTimeStepAtPos(pos);
9421 }
9422
9423 /*!
9424  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9425  *  \param [in] time - the time of the time step of interest.
9426  *  \param [in] eps - a precision used to compare time values.
9427  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9428  *          delete this field using decrRef() as it is no more needed.
9429  *  \throw If there is no required time step in \a this field.
9430  */
9431 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9432 {
9433   int pos=getPosGivenTime(time,eps);
9434   return getTimeStepAtPos(pos);
9435 }
9436
9437 /*!
9438  * 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.
9439  * The float64 value of time attached to the pair of integers are not considered here.
9440  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9441  *
9442  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9443  * \throw If there is a null pointer in \a vectFMTS.
9444  */
9445 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9446 {
9447   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9448   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9449   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9450   while(!lstFMTS.empty())
9451     {
9452       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9453       MEDFileAnyTypeFieldMultiTS *curIt(*it);
9454       if(!curIt)
9455         throw INTERP_KERNEL::Exception(msg);
9456       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9457       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9458       elt.push_back(curIt); it=lstFMTS.erase(it);
9459       while(it!=lstFMTS.end())
9460         {
9461           curIt=*it;
9462           if(!curIt)
9463             throw INTERP_KERNEL::Exception(msg);
9464           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9465           if(refIts==curIts)
9466             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9467           else
9468             it++;
9469         }
9470       ret.push_back(elt);
9471     }
9472   return ret;
9473 }
9474
9475 /*!
9476  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9477  * All returned instances in a subvector can be safely loaded, rendered along time
9478  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9479  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9480  * 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).
9481  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9482  * 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.
9483  *
9484  * \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().
9485  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9486  * \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.
9487  * \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.
9488  *
9489  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9490  * \throw If an element in \a vectFMTS change of spatial discretization along time.
9491  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9492  * \thorw If some elements in \a vectFMTS do not have the same times steps.
9493  * \throw If mesh is null.
9494  * \throw If an element in \a vectFMTS is null.
9495  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9496  */
9497 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9498 {
9499   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9500   if(!mesh)
9501     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9502   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9503   if(vectFMTS.empty())
9504     return ret;
9505   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9506   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9507   if(!frstElt)
9508     throw INTERP_KERNEL::Exception(msg);
9509   std::size_t i=0;
9510   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9511   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9512   for(;it!=vectFMTS.end();it++,i++)
9513     {
9514       if(!(*it))
9515         throw INTERP_KERNEL::Exception(msg);
9516       TypeOfField tof0,tof1;
9517       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9518         {
9519           if(tof1!=ON_NODES)
9520             vectFMTSNotNodes.push_back(*it);
9521           else
9522             vectFMTSNodes.push_back(*it);
9523         }
9524       else
9525         vectFMTSNotNodes.push_back(*it);
9526     }
9527   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9528   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9529   ret=retCell;
9530   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9531     {
9532       i=0;
9533       bool isFetched(false);
9534       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9535         {
9536           if((*it0).empty())
9537             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9538           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9539             { ret[i].push_back(*it2); isFetched=true; }
9540         }
9541       if(!isFetched)
9542         {
9543           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9544           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9545           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9546         }
9547     }
9548   fsc=cmps;
9549   return ret;
9550 }
9551
9552 /*!
9553  * 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.
9554  * \param [out] cmps - same size than the returned vector.
9555  */
9556 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9557 {
9558   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9559   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9560   while(!lstFMTS.empty())
9561     {
9562       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9563       MEDFileAnyTypeFieldMultiTS *ref(*it);
9564       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9565       elt.push_back(ref); it=lstFMTS.erase(it);
9566       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9567       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9568       while(it!=lstFMTS.end())
9569         {
9570           MEDFileAnyTypeFieldMultiTS *curIt(*it);
9571           if(cmp->isEqual(curIt))
9572             { elt.push_back(curIt); it=lstFMTS.erase(it); }
9573           else
9574             it++;
9575         }
9576       ret.push_back(elt); cmps.push_back(cmp);
9577     }
9578   return ret;
9579 }
9580
9581 /*!
9582  * 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.
9583  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9584  *
9585  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9586  * \throw If \a f0 or \a f1 change of spatial discretization along time.
9587  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9588  * \thorw If \a f0 and \a f1 do not have the same times steps.
9589  * \throw If mesh is null.
9590  * \throw If \a f0 or \a f1 is null.
9591  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9592  */
9593 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9594 {
9595   if(!mesh)
9596     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9597   if(!f0 || !f1)
9598     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9599   if(f0->getMeshName()!=mesh->getName())
9600     {
9601       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9602       throw INTERP_KERNEL::Exception(oss.str());
9603     }
9604   if(f1->getMeshName()!=mesh->getName())
9605     {
9606       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9607       throw INTERP_KERNEL::Exception(oss.str());
9608     }
9609   int nts=f0->getNumberOfTS();
9610   if(nts!=f1->getNumberOfTS())
9611     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9612   if(nts==0)
9613     return nts;
9614   for(int i=0;i<nts;i++)
9615     {
9616       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9617       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9618       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9619       if(tofs0.size()!=1 || tofs1.size()!=1)
9620         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9621       if(i!=0)
9622         {
9623           if(tof0!=tofs0[0] || tof1!=tofs1[0])
9624             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9625         }
9626       else
9627         { tof0=tofs0[0]; tof1=tofs1[0]; }
9628       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9629         {
9630           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() << ") !";
9631           throw INTERP_KERNEL::Exception(oss.str());
9632         }
9633       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9634         {
9635           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() << ") !";
9636           throw INTERP_KERNEL::Exception(oss.str());
9637         }
9638       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9639         {
9640           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() << ") !";
9641           throw INTERP_KERNEL::Exception(oss.str());
9642         }
9643     }
9644   return nts;
9645 }
9646
9647 /*!
9648  * Return an extraction of \a this using \a extractDef map to specify the extraction.
9649  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9650  *
9651  * \return A new object that the caller is responsible to deallocate.
9652  */
9653 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9654 {
9655   if(!mm)
9656     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9657   MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9658   int nbTS(getNumberOfTS());
9659   for(int i=0;i<nbTS;i++)
9660     {
9661       MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9662       MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9663       fmtsOut->pushBackTimeStep(f1tsOut);
9664     }
9665   return fmtsOut.retn();
9666 }
9667
9668 template<class T>
9669 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9670 {
9671   MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9672   if(f1tss.empty())
9673     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9674   std::size_t sz(f1tss.size()),i(0);
9675   std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9676   for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9677     {
9678       typename MLFieldTraits<T>::F1TSType const *elt(*it);
9679       if(!elt)
9680         throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9681       f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9682     }
9683   typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9684   if(!retc)
9685     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9686   retc->aggregate(f1tsw,dts);
9687   ret->setDtUnit(f1tss[0]->getDtUnit());
9688   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9689 }
9690
9691 template<class T>
9692 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9693 {
9694   MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9695   if(fmtss.empty())
9696     throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9697   std::size_t sz(fmtss.size());
9698   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9699     {
9700       typename MLFieldTraits<T>::FMTSType const *elt(*it);
9701       if(!elt)
9702         throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9703     }
9704   int nbTS(fmtss[0]->getNumberOfTS());
9705   for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9706     if((*it)->getNumberOfTS()!=nbTS)
9707       throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9708   for(int iterTS=0;iterTS<nbTS;iterTS++)
9709     {
9710       std::size_t i(0);
9711       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9712       std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9713       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9714         { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9715       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9716       ret->pushBackTimeStep(f1ts);
9717       ret->setDtUnit(f1ts->getDtUnit());
9718     }
9719   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9720 }
9721
9722 /*!
9723  * \a dts and \a ftmss are expected to have same size.
9724  */
9725 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9726 {
9727   if(fmtss.empty())
9728     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9729   std::size_t sz(fmtss.size());
9730   std::vector<const MEDFileFieldMultiTS *> fmtss1;
9731   std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9732   for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9733     {
9734       if(!(*it))
9735         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9736       const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9737       if(elt1)
9738         {
9739           fmtss1.push_back(elt1);
9740           continue;
9741         }
9742       const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9743       if(elt2)
9744         {
9745           fmtss2.push_back(elt2);
9746           continue;
9747         }
9748       throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9749     }
9750   if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9751     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9752   if(fmtss1.size()==sz)
9753     return AggregateHelperFMTS<double>(fmtss1,dts);
9754   if(fmtss2.size()!=sz)
9755     return AggregateHelperFMTS<int>(fmtss2,dts);
9756   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9757 }
9758
9759 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9760 {
9761   return new MEDFileAnyTypeFieldMultiTSIterator(this);
9762 }
9763
9764 //= MEDFileFieldMultiTS
9765
9766 /*!
9767  * Returns a new empty instance of MEDFileFieldMultiTS.
9768  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9769  *          is to delete this field using decrRef() as it is no more needed.
9770  */
9771 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9772 {
9773   return new MEDFileFieldMultiTS;
9774 }
9775
9776 /*!
9777  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9778  * that has been read from a specified MED file.
9779  *  \param [in] fileName - the name of the MED file to read.
9780  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9781  *          is to delete this field using decrRef() as it is no more needed.
9782  *  \throw If reading the file fails.
9783  */
9784 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9785 {
9786   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9787   return New(fid,loadAll);
9788 }
9789
9790 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9791 {
9792   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9793   ret->contentNotNull();//to check that content type matches with \a this type.
9794   return ret.retn();
9795 }
9796
9797 /*!
9798  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9799  * that has been read from a specified MED file.
9800  *  \param [in] fileName - the name of the MED file to read.
9801  *  \param [in] fieldName - the name of the field to read.
9802  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9803  *          is to delete this field using decrRef() as it is no more needed.
9804  *  \throw If reading the file fails.
9805  *  \throw If there is no field named \a fieldName in the file.
9806  */
9807 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9808 {
9809   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9810   return New(fid,fieldName,loadAll);
9811 }
9812
9813 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9814 {
9815   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9816   ret->contentNotNull();//to check that content type matches with \a this type.
9817   return ret.retn();
9818 }
9819
9820 /*!
9821  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9822  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9823  *
9824  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9825  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9826  * \warning this is a shallow copy constructor
9827  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9828  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9829  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9830  *          is to delete this field using decrRef() as it is no more needed.
9831  */
9832 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9833 {
9834   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9835 }
9836
9837 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9838 {
9839   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9840   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9841   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9842   ret->contentNotNull();//to check that content type matches with \a this type.
9843   return ret.retn();
9844 }
9845
9846 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9847 {
9848   return new MEDFileFieldMultiTS(*this);
9849 }
9850
9851 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9852 {
9853   if(!f1ts)
9854     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9855   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9856   if(!f1tsC)
9857     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9858 }
9859
9860 /*!
9861  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9862  * following the given input policy.
9863  *
9864  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9865  *                            By default (true) the globals are deeply copied.
9866  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9867  */
9868 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9869 {
9870   MCAuto<MEDFileIntFieldMultiTS> ret;
9871   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9872   if(content)
9873     {
9874       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9875       if(!contc)
9876         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9877       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9878       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9879     }
9880   else
9881     ret=MEDFileIntFieldMultiTS::New();
9882   if(isDeepCpyGlobs)
9883     ret->deepCpyGlobs(*this);
9884   else
9885     ret->shallowCpyGlobs(*this);
9886   return ret.retn();
9887 }
9888
9889 /*!
9890  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9891  *  \param [in] pos - a time step id.
9892  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9893  *          delete this field using decrRef() as it is no more needed.
9894  *  \throw If \a pos is not a valid time step id.
9895  */
9896 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9897 {
9898   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9899   if(!item)
9900     {
9901       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9902       throw INTERP_KERNEL::Exception(oss.str());
9903     }
9904   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9905   if(itemC)
9906     {
9907       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9908       ret->shallowCpyGlobs(*this);
9909       return ret.retn();
9910     }
9911   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9912   throw INTERP_KERNEL::Exception(oss.str());
9913 }
9914
9915 /*!
9916  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9917  * mesh entities of a given dimension of the first mesh in MED file.
9918  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9919  *  \param [in] type - a spatial discretization of interest.
9920  *  \param [in] iteration - the iteration number of a required time step.
9921  *  \param [in] order - the iteration order number of required time step.
9922  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9923  *  \param [in] renumPol - specifies how to permute values of the result field according to
9924  *          the optional numbers of cells and nodes, if any. The valid values are
9925  *          - 0 - do not permute.
9926  *          - 1 - permute cells.
9927  *          - 2 - permute nodes.
9928  *          - 3 - permute cells and nodes.
9929  *
9930  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9931  *          caller is to delete this field using decrRef() as it is no more needed. 
9932  *  \throw If the MED file is not readable.
9933  *  \throw If there is no mesh in the MED file.
9934  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9935  *  \throw If no field values of the required parameters are available.
9936  */
9937 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9938 {
9939   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9940   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9941   if(!myF1TSC)
9942     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9943   MCAuto<DataArray> arrOut;
9944   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9945   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9946   return ret.retn();
9947 }
9948
9949 /*!
9950  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9951  * the top level cells of the first mesh in MED file.
9952  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9953  *  \param [in] type - a spatial discretization of interest.
9954  *  \param [in] iteration - the iteration number of a required time step.
9955  *  \param [in] order - the iteration order number of required time step.
9956  *  \param [in] renumPol - specifies how to permute values of the result field according to
9957  *          the optional numbers of cells and nodes, if any. The valid values are
9958  *          - 0 - do not permute.
9959  *          - 1 - permute cells.
9960  *          - 2 - permute nodes.
9961  *          - 3 - permute cells and nodes.
9962  *
9963  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9964  *          caller is to delete this field using decrRef() as it is no more needed. 
9965  *  \throw If the MED file is not readable.
9966  *  \throw If there is no mesh in the MED file.
9967  *  \throw If no field values of the required parameters are available.
9968  */
9969 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9970 {
9971   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9972   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9973   if(!myF1TSC)
9974     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9975   MCAuto<DataArray> arrOut;
9976   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9977   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9978   return ret.retn();
9979 }
9980
9981 /*!
9982  * 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
9983  * method should be called (getFieldOnMeshAtLevel for example).
9984  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9985  *
9986  * \param [in] iteration - the iteration number of a required time step.
9987  * \param [in] order - the iteration order number of required time step.
9988  * \param [in] mesh - the mesh the field is lying on
9989  * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9990  *          caller is to delete this field using decrRef() as it is no more needed. 
9991  */
9992 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9993 {
9994   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9995   MCAuto<DataArray> arrOut;
9996   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9997   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9998   return ret.retn();
9999 }
10000
10001 /*!
10002  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
10003  * a given support.
10004  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10005  *  \param [in] type - a spatial discretization of interest.
10006  *  \param [in] iteration - the iteration number of a required time step.
10007  *  \param [in] order - the iteration order number of required time step.
10008  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10009  *  \param [in] mesh - the supporting mesh.
10010  *  \param [in] renumPol - specifies how to permute values of the result field according to
10011  *          the optional numbers of cells and nodes, if any. The valid values are
10012  *          - 0 - do not permute.
10013  *          - 1 - permute cells.
10014  *          - 2 - permute nodes.
10015  *          - 3 - permute cells and nodes.
10016  *
10017  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10018  *          caller is to delete this field using decrRef() as it is no more needed. 
10019  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10020  *  \throw If no field of \a this is lying on \a mesh.
10021  *  \throw If no field values of the required parameters are available.
10022  */
10023 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10024 {
10025   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10026   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10027   if(!myF1TSC)
10028     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10029   MCAuto<DataArray> arrOut;
10030   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
10031   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10032   return ret.retn();
10033 }
10034
10035 /*!
10036  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
10037  * given support. 
10038  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10039  *  \param [in] type - a spatial discretization of the new field.
10040  *  \param [in] iteration - the iteration number of a required time step.
10041  *  \param [in] order - the iteration order number of required time step.
10042  *  \param [in] mesh - the supporting mesh.
10043  *  \param [in] renumPol - specifies how to permute values of the result field according to
10044  *          the optional numbers of cells and nodes, if any. The valid values are
10045  *          - 0 - do not permute.
10046  *          - 1 - permute cells.
10047  *          - 2 - permute nodes.
10048  *          - 3 - permute cells and nodes.
10049  *
10050  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
10051  *          caller is to delete this field using decrRef() as it is no more needed. 
10052  *  \throw If no field of \a this is lying on \a mesh.
10053  *  \throw If no field values of the required parameters are available.
10054  */
10055 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10056 {
10057   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10058   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10059   if(!myF1TSC)
10060     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
10061   MCAuto<DataArray> arrOut;
10062   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
10063   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10064   return ret.retn();
10065 }
10066
10067 /*!
10068  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
10069  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10070  * This method is useful for MED2 file format when field on different mesh was autorized.
10071  */
10072 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
10073 {
10074   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10075   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10076   if(!myF1TSC)
10077     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
10078   MCAuto<DataArray> arrOut;
10079   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
10080   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
10081   return ret.retn();
10082 }
10083
10084 /*!
10085  * Returns values and a profile of the field of a given type, of a given time step,
10086  * lying on a given support.
10087  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10088  *  \param [in] type - a spatial discretization of the field.
10089  *  \param [in] iteration - the iteration number of a required time step.
10090  *  \param [in] order - the iteration order number of required time step.
10091  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10092  *  \param [in] mesh - the supporting mesh.
10093  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10094  *          field of interest lies on. If the field lies on all entities of the given
10095  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10096  *          using decrRef() as it is no more needed.  
10097  *  \param [in] glob - the global data storing profiles and localization.
10098  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
10099  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10100  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10101  *  \throw If no field of \a this is lying on \a mesh.
10102  *  \throw If no field values of the required parameters are available.
10103  */
10104 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10105 {
10106   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10107   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
10108   if(!myF1TSC)
10109     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
10110   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10111   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
10112 }
10113
10114 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
10115 {
10116   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10117   if(!pt)
10118     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
10119   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
10120   if(!ret)
10121     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 !");
10122   return ret;
10123 }
10124
10125 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
10126 {
10127   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10128   if(!pt)
10129     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
10130   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
10131   if(!ret)
10132     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 !");
10133   return ret;
10134 }
10135
10136 /*!
10137  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
10138  * the given field is checked if its elements are sorted suitable for writing to MED file
10139  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10140  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10141  *  \param [in] field - the field to add to \a this.
10142  *  \throw If the name of \a field is empty.
10143  *  \throw If the data array of \a field is not set.
10144  *  \throw If existing time steps have different name or number of components than \a field.
10145  *  \throw If the underlying mesh of \a field has no name.
10146  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10147  */
10148 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
10149 {
10150   const DataArrayDouble *arr=0;
10151   if(field)
10152     arr=field->getArray();
10153   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
10154 }
10155
10156 /*!
10157  * Adds a MEDCouplingFieldDouble to \a this as another time step.
10158  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10159  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10160  * and \a profile.
10161  *
10162  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10163  * A new profile is added only if no equal profile is missing.
10164  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10165  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
10166  *  \param [in] mesh - the supporting mesh of \a field.
10167  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10168  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10169  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10170  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10171  *  \throw If the data array of \a field is not set.
10172  *  \throw If the data array of \a this is already allocated but has different number of
10173  *         components than \a field.
10174  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10175  *  \sa setFieldNoProfileSBT()
10176  */
10177 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10178 {
10179   const DataArrayDouble *arr=0;
10180   if(field)
10181     arr=field->getArray();
10182   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
10183 }
10184
10185 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
10186 {
10187   _content=new MEDFileFieldMultiTSWithoutSDA;
10188 }
10189
10190 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10191 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10192 {
10193 }
10194 catch(INTERP_KERNEL::Exception& e)
10195 { throw e; }
10196
10197 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10198 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10199 {
10200 }
10201 catch(INTERP_KERNEL::Exception& e)
10202 { throw e; }
10203
10204 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10205 {
10206 }
10207
10208 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
10209 {
10210   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
10211 }
10212
10213 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10214 {
10215   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10216 }
10217
10218 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10219 {
10220   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10221 }
10222
10223 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10224 {
10225   return MEDFileFieldMultiTS::New();
10226 }
10227
10228 //= MEDFileAnyTypeFieldMultiTSIterator
10229
10230 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10231 {
10232   if(fmts)
10233     {
10234       fmts->incrRef();
10235       _nb_iter=fmts->getNumberOfTS();
10236     }
10237 }
10238
10239 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
10240 {
10241 }
10242
10243 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10244 {
10245   if(_iter_id<_nb_iter)
10246     {
10247       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10248       if(fmts)
10249         return fmts->getTimeStepAtPos(_iter_id++);
10250       else
10251         return 0;
10252     }
10253   else
10254     return 0;
10255 }
10256
10257 //= MEDFileIntFieldMultiTS
10258
10259 /*!
10260  * Returns a new empty instance of MEDFileFieldMultiTS.
10261  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10262  *          is to delete this field using decrRef() as it is no more needed.
10263  */
10264 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10265 {
10266   return new MEDFileIntFieldMultiTS;
10267 }
10268
10269 /*!
10270  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10271  * that has been read from a specified MED file.
10272  *  \param [in] fileName - the name of the MED file to read.
10273  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10274  *          is to delete this field using decrRef() as it is no more needed.
10275  *  \throw If reading the file fails.
10276  */
10277 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10278 {
10279   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10280   return New(fid,loadAll);
10281 }
10282
10283 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10284 {
10285   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10286   ret->contentNotNull();//to check that content type matches with \a this type.
10287   return ret.retn();
10288 }
10289
10290 /*!
10291  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10292  * that has been read from a specified MED file.
10293  *  \param [in] fileName - the name of the MED file to read.
10294  *  \param [in] fieldName - the name of the field to read.
10295  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10296  *          is to delete this field using decrRef() as it is no more needed.
10297  *  \throw If reading the file fails.
10298  *  \throw If there is no field named \a fieldName in the file.
10299  */
10300 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10301 {
10302   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10303   return New(fid,fieldName,loadAll);
10304 }
10305
10306 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10307 {
10308   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10309   ret->contentNotNull();//to check that content type matches with \a this type.
10310   return ret.retn();
10311 }
10312
10313 /*!
10314  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10315  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10316  *
10317  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10318  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10319  * \warning this is a shallow copy constructor
10320  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10321  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10322  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10323  *          is to delete this field using decrRef() as it is no more needed.
10324  */
10325 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10326 {
10327   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10328 }
10329
10330 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10331 {
10332   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10333   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10334   MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10335   ret->contentNotNull();//to check that content type matches with \a this type.
10336   return ret.retn();
10337 }
10338
10339 /*!
10340  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10341  * following the given input policy.
10342  *
10343  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10344  *                            By default (true) the globals are deeply copied.
10345  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10346  */
10347 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10348 {
10349   MCAuto<MEDFileFieldMultiTS> ret;
10350   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10351   if(content)
10352     {
10353       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10354       if(!contc)
10355         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10356       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10357       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10358     }
10359   else
10360     ret=MEDFileFieldMultiTS::New();
10361   if(isDeepCpyGlobs)
10362     ret->deepCpyGlobs(*this);
10363   else
10364     ret->shallowCpyGlobs(*this);
10365   return ret.retn();
10366 }
10367
10368 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10369 {
10370   return new MEDFileIntFieldMultiTS(*this);
10371 }
10372
10373 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10374 {
10375   if(!f1ts)
10376     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10377   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10378   if(!f1tsC)
10379     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10380 }
10381
10382 /*!
10383  * 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
10384  * method should be called (getFieldOnMeshAtLevel for example).
10385  * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10386  *
10387  * \param [in] iteration - the iteration number of a required time step.
10388  * \param [in] order - the iteration order number of required time step.
10389  * \param [in] mesh - the mesh the field is lying on
10390  * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10391  *          caller is to delete this field using decrRef() as it is no more needed. 
10392  */
10393 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10394 {
10395   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10396   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10397   if(!myF1TSC)
10398     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10399   MCAuto<DataArray> arrOut;
10400   MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10401   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10402   return ret2.retn();
10403 }
10404
10405 /*!
10406  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10407  * mesh entities of a given dimension of the first mesh in MED file.
10408  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10409  *  \param [in] type - a spatial discretization of interest.
10410  *  \param [in] iteration - the iteration number of a required time step.
10411  *  \param [in] order - the iteration order number of required time step.
10412  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10413  *  \param [in] renumPol - specifies how to permute values of the result field according to
10414  *          the optional numbers of cells and nodes, if any. The valid values are
10415  *          - 0 - do not permute.
10416  *          - 1 - permute cells.
10417  *          - 2 - permute nodes.
10418  *          - 3 - permute cells and nodes.
10419  *
10420  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10421  *          caller is to delete this field using decrRef() as it is no more needed. 
10422  *  \throw If the MED file is not readable.
10423  *  \throw If there is no mesh in the MED file.
10424  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10425  *  \throw If no field values of the required parameters are available.
10426  */
10427 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10428 {
10429   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10430   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10431   if(!myF1TSC)
10432     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10433   MCAuto<DataArray> arr;
10434   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10435   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10436   return ret2.retn();
10437 }
10438
10439 /*!
10440  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10441  * the top level cells of the first mesh in MED file.
10442  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10443  *  \param [in] type - a spatial discretization of interest.
10444  *  \param [in] iteration - the iteration number of a required time step.
10445  *  \param [in] order - the iteration order number of required time step.
10446  *  \param [in] renumPol - specifies how to permute values of the result field according to
10447  *          the optional numbers of cells and nodes, if any. The valid values are
10448  *          - 0 - do not permute.
10449  *          - 1 - permute cells.
10450  *          - 2 - permute nodes.
10451  *          - 3 - permute cells and nodes.
10452  *
10453  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10454  *          caller is to delete this field using decrRef() as it is no more needed. 
10455  *  \throw If the MED file is not readable.
10456  *  \throw If there is no mesh in the MED file.
10457  *  \throw If no field values of the required parameters are available.
10458  */
10459 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, 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("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10465   MCAuto<DataArray> arr;
10466   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10467   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10468   return ret2.retn();
10469 }
10470
10471 /*!
10472  * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10473  * a given support.
10474  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10475  *  \param [in] type - a spatial discretization of interest.
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 [in] renumPol - specifies how to permute values of the result field according to
10481  *          the optional numbers of cells and nodes, if any. The valid values are
10482  *          - 0 - do not permute.
10483  *          - 1 - permute cells.
10484  *          - 2 - permute nodes.
10485  *          - 3 - permute cells and nodes.
10486  *
10487  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10488  *          caller is to delete this field using decrRef() as it is no more needed. 
10489  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10490  *  \throw If no field of \a this is lying on \a mesh.
10491  *  \throw If no field values of the required parameters are available.
10492  */
10493 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10494 {
10495   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10496   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10497   if(!myF1TSC)
10498     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10499   MCAuto<DataArray> arr;
10500   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10501   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10502   return ret2.retn();
10503 }
10504
10505 /*!
10506  * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10507  * given support. 
10508  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10509  *  \param [in] type - a spatial discretization of the new field.
10510  *  \param [in] iteration - the iteration number of a required time step.
10511  *  \param [in] order - the iteration order number of required time step.
10512  *  \param [in] mesh - the supporting mesh.
10513  *  \param [out] arrOut - the DataArrayInt containing values of field.
10514  *  \param [in] renumPol - specifies how to permute values of the result field according to
10515  *          the optional numbers of cells and nodes, if any. The valid values are
10516  *          - 0 - do not permute.
10517  *          - 1 - permute cells.
10518  *          - 2 - permute nodes.
10519  *          - 3 - permute cells and nodes.
10520  *
10521  *  \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10522  *          caller is to delete this field using decrRef() as it is no more needed. 
10523  *  \throw If no field of \a this is lying on \a mesh.
10524  *  \throw If no field values of the required parameters are available.
10525  */
10526 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10527 {
10528   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10529   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10530   if(!myF1TSC)
10531     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10532   MCAuto<DataArray> arr;
10533   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10534   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10535   return ret2.retn();
10536 }
10537
10538 /*!
10539  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10540  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10541  * This method is useful for MED2 file format when field on different mesh was autorized.
10542  */
10543 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10544 {
10545   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10546   const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10547   if(!myF1TSC)
10548     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10549   MCAuto<DataArray> arr;
10550   MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10551   MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10552   return ret2.retn();
10553 }
10554
10555 /*!
10556  * Returns values and a profile of the field of a given type, of a given time step,
10557  * lying on a given support.
10558  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10559  *  \param [in] type - a spatial discretization of the field.
10560  *  \param [in] iteration - the iteration number of a required time step.
10561  *  \param [in] order - the iteration order number of required time step.
10562  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10563  *  \param [in] mesh - the supporting mesh.
10564  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10565  *          field of interest lies on. If the field lies on all entities of the given
10566  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
10567  *          using decrRef() as it is no more needed.  
10568  *  \param [in] glob - the global data storing profiles and localization.
10569  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10570  *          field. The caller is to delete this array using decrRef() as it is no more needed.
10571  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10572  *  \throw If no field of \a this is lying on \a mesh.
10573  *  \throw If no field values of the required parameters are available.
10574  */
10575 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10576 {
10577   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10578   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10579   if(!myF1TSC)
10580     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10581   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10582   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10583 }
10584
10585 /*!
10586  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10587  *  \param [in] pos - a time step id.
10588  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10589  *          delete this field using decrRef() as it is no more needed.
10590  *  \throw If \a pos is not a valid time step id.
10591  */
10592 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10593 {
10594   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10595   if(!item)
10596     {
10597       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10598       throw INTERP_KERNEL::Exception(oss.str());
10599     }
10600   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10601   if(itemC)
10602     {
10603       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10604       ret->shallowCpyGlobs(*this);
10605       return ret.retn();
10606     }
10607   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10608   throw INTERP_KERNEL::Exception(oss.str());
10609 }
10610
10611 /*!
10612  * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10613  * the given field is checked if its elements are sorted suitable for writing to MED file
10614  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
10615  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10616  *  \param [in] field - the field to add to \a this.
10617  *  \throw If the name of \a field is empty.
10618  *  \throw If the data array of \a field is not set.
10619  *  \throw If existing time steps have different name or number of components than \a field.
10620  *  \throw If the underlying mesh of \a field has no name.
10621  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10622  */
10623 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10624 {
10625   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10626   contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10627 }
10628
10629 /*!
10630  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
10631  * The mesh support of input parameter \a field is ignored here, it can be NULL.
10632  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10633  * and \a profile.
10634  *
10635  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10636  * A new profile is added only if no equal profile is missing.
10637  * For more info, see \ref AdvMEDLoaderAPIFieldRW
10638  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10639  *  \param [in] arrOfVals - the values of the field \a field used.
10640  *  \param [in] mesh - the supporting mesh of \a field.
10641  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10642  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
10643  *  \throw If either \a field or \a mesh or \a profile has an empty name.
10644  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10645  *  \throw If the data array of \a field is not set.
10646  *  \throw If the data array of \a this is already allocated but has different number of
10647  *         components than \a field.
10648  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10649  *  \sa setFieldNoProfileSBT()
10650  */
10651 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10652 {
10653   MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10654   contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10655 }
10656
10657 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10658 {
10659   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10660   if(!pt)
10661     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10662   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10663   if(!ret)
10664     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 !");
10665   return ret;
10666 }
10667
10668 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10669 {
10670   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10671   if(!pt)
10672     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10673   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10674   if(!ret)
10675     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 !");
10676   return ret;
10677 }
10678
10679 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10680 {
10681   _content=new MEDFileIntFieldMultiTSWithoutSDA;
10682 }
10683
10684 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10685 {
10686 }
10687
10688 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10689 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10690 {
10691 }
10692 catch(INTERP_KERNEL::Exception& e)
10693 { throw e; }
10694
10695 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10696 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10697 {
10698 }
10699 catch(INTERP_KERNEL::Exception& e)
10700 { throw e; }
10701
10702 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10703 {
10704   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10705 }
10706
10707 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10708 {
10709   return MEDFileIntFieldMultiTS::New();
10710 }
10711
10712 //= MEDFileFields
10713
10714 MEDFileFields *MEDFileFields::New()
10715 {
10716   return new MEDFileFields;
10717 }
10718
10719 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10720 {
10721   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10722   return New(fid,loadAll);
10723 }
10724
10725 MEDFileFields *MEDFileFields::NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities)
10726 {
10727   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10728   return NewAdv(fid,loadAll,entities);
10729 }
10730
10731 MEDFileFields *MEDFileFields::NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities)
10732 {
10733   return new MEDFileFields(fid,loadAll,0,entities);
10734 }
10735
10736 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10737 {
10738   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10739   return NewWithDynGT(fid,se,loadAll);
10740 }
10741
10742 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10743 {
10744   if(!se)
10745     throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10746   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10747   return new MEDFileFields(fid,loadAll,0,entities);
10748 }
10749
10750 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10751 {
10752   return new MEDFileFields(fid,loadAll,0,0);
10753 }
10754
10755 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10756 {
10757   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10758   return new MEDFileFields(fid,loadAll,ms,0);
10759 }
10760
10761 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10762 {
10763   MEDFileUtilities::CheckFileForRead(fileName);
10764   INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10765   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10766   return new MEDFileFields(fid,loadAll,0,ent);
10767 }
10768
10769 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10770 {
10771   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10772   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10773   return ret;
10774 }
10775
10776 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10777 {
10778   std::vector<const BigMemoryObject *> ret;
10779   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10780     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10781   return ret;
10782 }
10783
10784 MEDFileFields *MEDFileFields::deepCopy() const
10785 {
10786   MCAuto<MEDFileFields> ret(shallowCpy());
10787   std::size_t i(0);
10788   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10789     {
10790       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10791         ret->_fields[i]=(*it)->deepCopy();
10792     }
10793   ret->deepCpyGlobs(*this);
10794   return ret.retn();
10795 }
10796
10797 MEDFileFields *MEDFileFields::shallowCpy() const
10798 {
10799   return new MEDFileFields(*this);
10800 }
10801
10802 /*!
10803  * 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
10804  * 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.
10805  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10806  *
10807  * \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.
10808  * \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.
10809  * 
10810  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10811  */
10812 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10813 {
10814   std::set< std::pair<int,int> > s;
10815   bool firstShot=true;
10816   areThereSomeForgottenTS=false;
10817   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10818     {
10819       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10820         continue;
10821       std::vector< std::pair<int,int> > v=(*it)->getIterations();
10822       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10823       if(firstShot)
10824         { s=s1; firstShot=false; }
10825       else
10826         {
10827           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10828           if(s!=s2)
10829             areThereSomeForgottenTS=true;
10830           s=s2;
10831         }
10832     }
10833   std::vector< std::pair<int,int> > ret;
10834   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10835   return ret;
10836 }
10837
10838 int MEDFileFields::getNumberOfFields() const
10839 {
10840   return _fields.size();
10841 }
10842
10843 std::vector<std::string> MEDFileFields::getFieldsNames() const
10844 {
10845   std::vector<std::string> ret(_fields.size());
10846   int i(0);
10847   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10848     {
10849       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10850       if(f)
10851         {
10852           ret[i]=f->getName();
10853         }
10854       else
10855         {
10856           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10857           throw INTERP_KERNEL::Exception(oss.str());
10858         }
10859     }
10860   return ret;
10861 }
10862
10863 std::vector<std::string> MEDFileFields::getMeshesNames() const
10864 {
10865   std::vector<std::string> ret;
10866   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10867     {
10868       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10869       if(cur)
10870         ret.push_back(cur->getMeshName());
10871     }
10872   return ret;
10873 }
10874
10875 std::string MEDFileFields::simpleRepr() const
10876 {
10877   std::ostringstream oss;
10878   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10879   simpleRepr(0,oss);
10880   return oss.str();
10881 }
10882
10883 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10884 {
10885   int nbOfFields(getNumberOfFields());
10886   std::string startLine(bkOffset,' ');
10887   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10888   int i=0;
10889   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10890     {
10891       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10892       if(cur)
10893         {
10894           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10895         }
10896       else
10897         {
10898           oss << startLine << "  - not defined !" << std::endl;
10899         }
10900     }
10901   i=0;
10902   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10903     {
10904       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10905       std::string chapter(17,'0'+i);
10906       oss << startLine << chapter << std::endl;
10907       if(cur)
10908         {
10909           cur->simpleRepr(bkOffset+2,oss,i);
10910         }
10911       else
10912         {
10913           oss << startLine << "  - not defined !" << std::endl;
10914         }
10915       oss << startLine << chapter << std::endl;
10916     }
10917   simpleReprGlobs(oss);
10918 }
10919
10920 MEDFileFields::MEDFileFields()
10921 {
10922 }
10923
10924 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10925 try:MEDFileFieldGlobsReal(fid)
10926 {
10927   int nbFields(MEDnField(fid));
10928   _fields.resize(nbFields);
10929   med_field_type typcha;
10930   for(int i=0;i<nbFields;i++)
10931     {
10932       std::vector<std::string> infos;
10933       std::string fieldName,dtunit;
10934       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10935       switch(typcha)
10936       {
10937         case MED_FLOAT64:
10938           {
10939             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10940             break;
10941           }
10942         case MED_INT32:
10943           {
10944             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10945             break;
10946           }
10947         default:
10948           {
10949             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] !";
10950             throw INTERP_KERNEL::Exception(oss.str());
10951           }
10952       }
10953     }
10954   loadAllGlobals(fid,entities);
10955 }
10956 catch(INTERP_KERNEL::Exception& e)
10957 {
10958     throw e;
10959 }
10960
10961 void MEDFileFields::writeLL(med_idt fid) const
10962 {
10963   int i=0;
10964   writeGlobals(fid,*this);
10965   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10966     {
10967       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10968       if(!elt)
10969         {
10970           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10971           throw INTERP_KERNEL::Exception(oss.str());
10972         }
10973       elt->writeLL(fid,*this);
10974     }
10975 }
10976
10977 /*!
10978  * This method alloc the arrays and load potentially huge arrays contained in this field.
10979  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10980  * This method can be also called to refresh or reinit values from a file.
10981  * 
10982  * \throw If the fileName is not set or points to a non readable MED file.
10983  */
10984 void MEDFileFields::loadArrays()
10985 {
10986   if(getFileName().empty())
10987     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10988   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10989   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10990     {
10991       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10992       if(elt)
10993         elt->loadBigArraysRecursively(fid,*elt);
10994     }
10995 }
10996
10997 /*!
10998  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10999  * But once data loaded once, this method does nothing.
11000  * 
11001  * \throw If the fileName is not set or points to a non readable MED file.
11002  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
11003  */
11004 void MEDFileFields::loadArraysIfNecessary()
11005 {
11006   if(!getFileName().empty())
11007     {
11008       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
11009       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11010         {
11011           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11012           if(elt)
11013             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
11014         }
11015     }
11016 }
11017
11018 /*!
11019  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
11020  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
11021  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
11022  * 
11023  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
11024  */
11025 void MEDFileFields::unloadArrays()
11026 {
11027   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11028     {
11029       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11030       if(elt)
11031         elt->unloadArrays();
11032     }
11033 }
11034
11035 /*!
11036  * 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.
11037  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
11038  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
11039  * 
11040  * \sa MEDFileFields::loadArraysIfNecessary
11041  */
11042 void MEDFileFields::unloadArraysWithoutDataLoss()
11043 {
11044   if(!getFileName().empty())
11045     unloadArrays();
11046 }
11047
11048 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
11049 {
11050   std::vector<std::string> ret;
11051   std::set<std::string> ret2;
11052   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11053     {
11054       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
11055       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11056         if(ret2.find(*it2)==ret2.end())
11057           {
11058             ret.push_back(*it2);
11059             ret2.insert(*it2);
11060           }
11061     }
11062   return ret;
11063 }
11064
11065 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
11066 {
11067   std::vector<std::string> ret;
11068   std::set<std::string> ret2;
11069   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11070     {
11071       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11072       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
11073         if(ret2.find(*it2)==ret2.end())
11074           {
11075             ret.push_back(*it2);
11076             ret2.insert(*it2);
11077           }
11078     }
11079   return ret;
11080 }
11081
11082 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
11083 {
11084   std::vector<std::string> ret;
11085   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11086     {
11087       std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
11088       ret.insert(ret.end(),tmp.begin(),tmp.end());
11089     }
11090   return ret;
11091 }
11092
11093 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
11094 {
11095   std::vector<std::string> ret;
11096   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11097     {
11098       std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
11099       ret.insert(ret.end(),tmp.begin(),tmp.end());
11100     }
11101   return ret;
11102 }
11103
11104 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11105 {
11106   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11107     (*it)->changePflsRefsNamesGen2(mapOfModif);
11108 }
11109
11110 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
11111 {
11112   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
11113     (*it)->changeLocsRefsNamesGen2(mapOfModif);
11114 }
11115
11116 void MEDFileFields::resize(int newSize)
11117 {
11118   _fields.resize(newSize);
11119 }
11120
11121 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
11122 {
11123   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
11124     pushField(*it);
11125 }
11126
11127 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
11128 {
11129   if(!field)
11130     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
11131   _fields.push_back(field->getContent());
11132   appendGlobs(*field,1e-12);
11133 }
11134
11135 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
11136 {
11137   if(!field)
11138     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
11139   if(i>=(int)_fields.size())
11140     _fields.resize(i+1);
11141   _fields[i]=field->getContent();
11142   appendGlobs(*field,1e-12);
11143 }
11144
11145 void MEDFileFields::destroyFieldAtPos(int i)
11146 {
11147   destroyFieldsAtPos(&i,&i+1);
11148 }
11149
11150 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
11151 {
11152   std::vector<bool> b(_fields.size(),true);
11153   for(const int *i=startIds;i!=endIds;i++)
11154     {
11155       if(*i<0 || *i>=(int)_fields.size())
11156         {
11157           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11158           throw INTERP_KERNEL::Exception(oss.str());
11159         }
11160       b[*i]=false;
11161     }
11162   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11163   std::size_t j=0;
11164   for(std::size_t i=0;i<_fields.size();i++)
11165     if(b[i])
11166       fields[j++]=_fields[i];
11167   _fields=fields;
11168 }
11169
11170 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
11171 {
11172   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
11173   int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
11174   std::vector<bool> b(_fields.size(),true);
11175   int k=bg;
11176   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
11177     {
11178       if(k<0 || k>=(int)_fields.size())
11179         {
11180           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
11181           throw INTERP_KERNEL::Exception(oss.str());
11182         }
11183       b[k]=false;
11184     }
11185   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
11186   std::size_t j(0);
11187   for(std::size_t i=0;i<_fields.size();i++)
11188     if(b[i])
11189       fields[j++]=_fields[i];
11190   _fields=fields;
11191 }
11192
11193 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
11194 {
11195   bool ret(false);
11196   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11197     {
11198       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11199       if(cur)
11200         ret=cur->changeMeshNames(modifTab) || ret;
11201     }
11202   return ret;
11203 }
11204
11205 /*!
11206  * \param [in] meshName the name of the mesh that will be renumbered.
11207  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
11208  *             This code corresponds to the distribution of types in the corresponding mesh.
11209  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
11210  * \param [in] renumO2N the old to new renumber array.
11211  * \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 
11212  *         field in \a this.
11213  */
11214 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
11215 {
11216   bool ret(false);
11217   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11218     {
11219       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
11220       if(fmts)
11221         {
11222           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11223         }
11224     }
11225   return ret;
11226 }
11227
11228 /*!
11229  * Return an extraction of \a this using \a extractDef map to specify the extraction.
11230  * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11231  *
11232  * \return A new object that the caller is responsible to deallocate.
11233  */
11234 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11235 {
11236   if(!mm)
11237     throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11238   MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11239   int nbFields(getNumberOfFields());
11240   for(int i=0;i<nbFields;i++)
11241     {
11242       MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11243       if(!fmts)
11244         {
11245           std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11246           throw INTERP_KERNEL::Exception(oss.str());
11247         }
11248       MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11249       fsOut->pushField(fmtsOut);
11250     }
11251   return fsOut.retn();
11252 }
11253
11254 void MEDFileFields::accept(MEDFileFieldVisitor& visitor) const
11255 {
11256   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11257     if((*it).isNotNull())
11258       {
11259         visitor.newFieldEntry(*it);
11260         (*it)->accept(visitor);
11261         visitor.endFieldEntry(*it);
11262       }
11263 }
11264
11265 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11266 {
11267   if(i<0 || i>=(int)_fields.size())
11268     {
11269       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11270       throw INTERP_KERNEL::Exception(oss.str());
11271     }
11272   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11273   if(!fmts)
11274     return 0;
11275   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11276   const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11277   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11278   if(fmtsC)
11279     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11280   else if(fmtsC2)
11281     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11282   else
11283     {
11284       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11285       throw INTERP_KERNEL::Exception(oss.str());
11286     }
11287   ret->shallowCpyGlobs(*this);
11288   return ret.retn();
11289 }
11290
11291 /*!
11292  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11293  * This method is accessible in python using __getitem__ with a list in input.
11294  * \return a new object that the caller should deal with.
11295  */
11296 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11297 {
11298   MCAuto<MEDFileFields> ret=shallowCpy();
11299   std::size_t sz=std::distance(startIds,endIds);
11300   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11301   int j=0;
11302   for(const int *i=startIds;i!=endIds;i++,j++)
11303     {
11304       if(*i<0 || *i>=(int)_fields.size())
11305         {
11306           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11307           throw INTERP_KERNEL::Exception(oss.str());
11308         }
11309       fields[j]=_fields[*i];
11310     }
11311   ret->_fields=fields;
11312   return ret.retn();
11313 }
11314
11315 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11316 {
11317   return getFieldAtPos(getPosFromFieldName(fieldName));
11318 }
11319
11320 /*!
11321  * This method removes, if any, fields in \a this having no time steps.
11322  * 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.
11323  * 
11324  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11325  */
11326 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11327 {
11328   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11329   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11330     {
11331       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11332       if(elt)
11333         {
11334           if(elt->getNumberOfTS()>0)
11335             newFields.push_back(*it);
11336         }
11337     }
11338   if(_fields.size()==newFields.size())
11339     return false;
11340   _fields=newFields;
11341   return true;
11342 }
11343
11344 /*!
11345  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11346  * This method can be seen as a filter applied on \a this, that returns an object containing
11347  * 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
11348  * shallow copied from \a this.
11349  * 
11350  * \param [in] meshName - the name of the mesh on w
11351  * \return a new object that the caller should deal with.
11352  */
11353 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11354 {
11355   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11356   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11357     {
11358       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11359       if(!cur)
11360         continue;
11361       if(cur->getMeshName()==meshName)
11362         {
11363           cur->incrRef();
11364           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11365           ret->_fields.push_back(cur2);
11366         }
11367     }
11368   ret->shallowCpyOnlyUsedGlobs(*this);
11369   return ret.retn();
11370 }
11371
11372 /*!
11373  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11374  * Input time steps are specified using a pair of integer (iteration, order).
11375  * 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,
11376  * but for each multitimestep only the time steps in \a timeSteps are kept.
11377  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11378  * 
11379  * The returned object points to shallow copy of elements in \a this.
11380  * 
11381  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11382  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11383  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11384  */
11385 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11386 {
11387   MCAuto<MEDFileFields> ret(MEDFileFields::New());
11388   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11389     {
11390       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11391       if(!cur)
11392         continue;
11393       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11394       ret->_fields.push_back(elt);
11395     }
11396   ret->shallowCpyOnlyUsedGlobs(*this);
11397   return ret.retn();
11398 }
11399
11400 /*!
11401  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11402  */
11403 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11404 {
11405   MCAuto<MEDFileFields> ret=MEDFileFields::New();
11406   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11407     {
11408       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11409       if(!cur)
11410         continue;
11411       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11412       if(elt->getNumberOfTS()!=0)
11413         ret->_fields.push_back(elt);
11414     }
11415   ret->shallowCpyOnlyUsedGlobs(*this);
11416   return ret.retn();
11417 }
11418
11419 bool MEDFileFields::presenceOfStructureElements() const
11420 {
11421   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11422     if((*it).isNotNull())
11423       if((*it)->presenceOfStructureElements())
11424         return true;
11425   return false;
11426 }
11427
11428 void MEDFileFields::killStructureElements()
11429 {
11430   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11431   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11432     if((*it).isNotNull())
11433       {
11434         if((*it)->presenceOfStructureElements())
11435           {
11436             if(!(*it)->onlyStructureElements())
11437               {
11438                 (*it)->killStructureElements();
11439                 ret.push_back(*it);
11440               }
11441           }
11442         else
11443           {
11444             ret.push_back(*it);
11445           }
11446       }
11447   _fields=ret;
11448 }
11449
11450 void MEDFileFields::keepOnlyStructureElements()
11451 {
11452   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11453   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11454     if((*it).isNotNull())
11455       {
11456         if((*it)->presenceOfStructureElements())
11457           {
11458             if(!(*it)->onlyStructureElements())
11459               (*it)->keepOnlyStructureElements();
11460             ret.push_back(*it);
11461           }
11462       }
11463   _fields=ret;
11464 }
11465
11466 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11467 {
11468   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11469   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11470     if((*it).isNotNull())
11471       {
11472         if((*it)->getMeshName()!=meshName)
11473           continue;
11474         std::vector< std::pair<std::string,std::string> > ps;
11475         (*it)->getMeshSENames(ps);
11476         std::pair<std::string,std::string> p(meshName,seName);
11477         if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11478           (*it)->keepOnlyOnSE(seName);
11479         ret.push_back(*it);
11480       }
11481   _fields=ret;
11482 }
11483
11484 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11485 {
11486   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11487     if((*it).isNotNull())
11488       (*it)->getMeshSENames(ps);
11489 }
11490
11491 void MEDFileFields::blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses)
11492 {
11493   MEDFileBlowStrEltUp::DealWithSE(this,ms,ses);
11494 }
11495
11496 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11497 {
11498   MCAuto<MEDFileFields> ret(deepCopy());
11499   ret->keepOnlyStructureElements();
11500   return ret;
11501 }
11502
11503 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11504 {
11505   MCAuto<MEDFileFields> ret(deepCopy());
11506   ret->keepOnlyOnMeshSE(meshName,seName);
11507   return ret;
11508 }
11509
11510 void MEDFileFields::aggregate(const MEDFileFields& other)
11511 {
11512   int nbFieldsToAdd(other.getNumberOfFields());
11513   std::vector<std::string> fsn(getFieldsNames());
11514   for(int i=0;i<nbFieldsToAdd;i++)
11515     {
11516       MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11517       std::string name(elt->getName());
11518       if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11519         {
11520           std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11521           throw INTERP_KERNEL::Exception(oss.str());
11522         }
11523       pushField(elt);
11524     }
11525 }
11526
11527 MEDFileFieldsIterator *MEDFileFields::iterator()
11528 {
11529   return new MEDFileFieldsIterator(this);
11530 }
11531
11532 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11533 {
11534   std::string tmp(fieldName);
11535   std::vector<std::string> poss;
11536   for(std::size_t i=0;i<_fields.size();i++)
11537     {
11538       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11539       if(f)
11540         {
11541           std::string fname(f->getName());
11542           if(tmp==fname)
11543             return i;
11544           else
11545             poss.push_back(fname);
11546         }
11547     }
11548   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11549   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11550   oss << " !";
11551   throw INTERP_KERNEL::Exception(oss.str());
11552 }
11553
11554 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11555 {
11556   if(fs)
11557     {
11558       fs->incrRef();
11559       _nb_iter=fs->getNumberOfFields();
11560     }
11561 }
11562
11563 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
11564 {
11565 }
11566
11567 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11568 {
11569   if(_iter_id<_nb_iter)
11570     {
11571       MEDFileFields *fs(_fs);
11572       if(fs)
11573         return fs->getFieldAtPos(_iter_id++);
11574       else
11575         return 0;
11576     }
11577   else
11578     return 0;
11579 }