Salome HOME
MEDCoupling API change - stage #1
[tools/medcoupling.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
27
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldDiscretization.hxx"
30
31 #include "InterpKernelAutoPtr.hxx"
32 #include "CellModel.hxx"
33
34 #include <algorithm>
35 #include <iterator>
36
37 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
38 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
39 extern med_geometry_type typmainoeud[1];
40 extern med_geometry_type typmai3[34];
41
42 using namespace MEDCoupling;
43
44 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
45 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
48 {
49   return new MEDFileFieldLoc(fid,locName);
50 }
51
52 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 {
54   return new MEDFileFieldLoc(fid,id);
55 }
56
57 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)
58 {
59   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
60 }
61
62 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
63 {
64   med_geometry_type geotype;
65   med_geometry_type sectiongeotype;
66   int nsectionmeshcell;
67   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69   MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
70   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
71   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
72   _nb_node_per_cell=cm.getNumberOfNodes();
73   _ref_coo.resize(_dim*_nb_node_per_cell);
74   _gs_coo.resize(_dim*_nb_gauss_pt);
75   _w.resize(_nb_gauss_pt);
76   MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
77 }
78
79 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 {
81   med_geometry_type geotype;
82   med_geometry_type sectiongeotype;
83   int nsectionmeshcell;
84   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
88   _name=locName;
89   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
90   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
91   _nb_node_per_cell=cm.getNumberOfNodes();
92   _ref_coo.resize(_dim*_nb_node_per_cell);
93   _gs_coo.resize(_dim*_nb_gauss_pt);
94   _w.resize(_nb_gauss_pt);
95   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
96 }
97
98 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
99                                  const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
100                                      _w(w)
101 {
102   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
103   _dim=cm.getDimension();
104   _nb_node_per_cell=cm.getNumberOfNodes();
105   _nb_gauss_pt=_w.size();
106 }
107
108 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
109 {
110   return new MEDFileFieldLoc(*this);
111 }
112
113 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 {
115   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
116 }
117
118 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
119 {
120   return std::vector<const BigMemoryObject *>();
121 }
122
123 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 {
125   static const char OFF7[]="\n    ";
126   oss << "\"" << _name << "\"" << OFF7;
127   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
128   oss << "Dimension=" << _dim << OFF7;
129   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
130   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
131   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
134 }
135
136 void MEDFileFieldLoc::setName(const std::string& name)
137 {
138   _name=name;
139 }
140
141 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
142 {
143   if(_name!=other._name)
144     return false;
145   if(_dim!=other._dim)
146     return false;
147   if(_nb_gauss_pt!=other._nb_gauss_pt)
148     return false;
149   if(_nb_node_per_cell!=other._nb_node_per_cell)
150     return false;
151   if(_geo_type!=other._geo_type)
152     return false;
153   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
154     return false;
155   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
156     return false;
157   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
158     return false;
159
160   return true;
161 }
162
163 void MEDFileFieldLoc::writeLL(med_idt fid) const
164 {
165   MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
166 }
167
168 std::string MEDFileFieldLoc::repr() const
169 {
170   std::ostringstream oss; oss.precision(15);
171   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
172   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
173   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
174   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
175   oss << "\n  - Ref coords are : ";
176   int sz=_ref_coo.size();
177   if(sz%_dim==0)
178     {
179       int nbOfTuples=sz/_dim;
180       for(int i=0;i<nbOfTuples;i++)
181         {
182           oss << "(";
183           for(int j=0;j<_dim;j++)
184             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
185           oss << ") ";
186         }
187     }
188   else
189     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
190   oss << "\n  - Gauss coords in reference element : ";
191   sz=_gs_coo.size();
192   if(sz%_dim==0)
193     {
194       int nbOfTuples=sz/_dim;
195       for(int i=0;i<nbOfTuples;i++)
196         {
197           oss << "(";
198           for(int j=0;j<_dim;j++)
199             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
200           oss << ") ";
201         }
202     }
203   else
204     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
205   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
206   return oss.str();
207 }
208
209 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
210 {
211   _type=field->getTypeOfField();
212   _start=start;
213   switch(_type)
214   {
215     case ON_CELLS:
216       {
217         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
218         _end=_start+nbOfCells;
219         _nval=nbOfCells;
220         break;
221       }
222     case ON_GAUSS_NE:
223       {
224         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
225         const int *arrPtr=arr->getConstPointer();
226         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
227         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
228         _nval=nbOfCells;
229         break;
230       }
231     case ON_GAUSS_PT:
232       {
233         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
234         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
235         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
236         if(!disc2)
237           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
238         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
239         MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
240         const int *dai2Ptr=dai2->getConstPointer();
241         int nbi=gsLoc.getWeights().size();
242         MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
243         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
244         const int *da3Ptr=da3->getConstPointer();
245         if(da3->getNumberOfTuples()!=nbOfCells)
246           {//profile : for gauss even in NoProfile !!!
247             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
248             _profile=oss.str();
249             da3->setName(_profile.c_str());
250             glob.appendProfile(da3);
251           }
252         MCAuto<DataArrayInt> da4=DataArrayInt::New();
253         _nval=da3->getNbOfElems();
254         da4->alloc(_nval*nbi,1);
255         int *da4Ptr=da4->getPointer();
256         for(int i=0;i<_nval;i++)
257           {
258             int ref=dai2Ptr[offset+da3Ptr[i]];
259             for(int j=0;j<nbi;j++)
260               *da4Ptr++=ref+j;
261           }
262         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
263         _localization=oss2.str();
264         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
265         _end=_start+_nval*nbi;
266         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
267         break;
268       }
269     default:
270       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
271   }
272   start=_end;
273 }
274
275 /*!
276  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
277  * \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).
278  * \param [in] multiTypePfl is the end user profile specified in high level API
279  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
280  * \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.
281  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
282  * \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.
283  */
284 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)
285 {
286   _profile.clear();
287   _type=field->getTypeOfField();
288   std::string pflName(multiTypePfl->getName());
289   std::ostringstream oss; oss << pflName;
290   if(_type!=ON_NODES)
291     {
292       if(!isPflAlone)
293         { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); }
294     }
295   else
296     { oss << "_NODE"; }
297   if(locIds)
298     {
299       if(pflName.empty())
300         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
301       if(_type!=ON_GAUSS_PT)
302         {
303           locIds->setName(oss.str().c_str());
304           glob.appendProfile(locIds);
305           _profile=oss.str();
306         }
307     }
308   _start=start;
309   switch(_type)
310   {
311     case ON_NODES:
312       {
313         _nval=idsInPfl->getNumberOfTuples();
314         getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
315         _end=_start+_nval;
316         break;
317       }
318     case ON_CELLS:
319       {
320         _nval=idsInPfl->getNumberOfTuples();
321         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
322         _end=_start+_nval;
323         break;
324       }
325     case ON_GAUSS_NE:
326       {
327         MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
328         MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
329         MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
330         arr3->computeOffsetsFull();
331         MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
332         int trueNval=tmp->getNumberOfTuples();
333         _nval=idsInPfl->getNumberOfTuples();
334         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
335         _end=_start+trueNval;
336         break;
337       }
338     case ON_GAUSS_PT:
339       {
340         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
341         if(!disc2)
342           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
343         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
344         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
345         MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
346         MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
347         MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
348         //
349         MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
350         MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
351         //
352         MCAuto<DataArrayInt> tmp=DataArrayInt::New();
353         int trueNval=0;
354         for(const int *pt=da4->begin();pt!=da4->end();pt++)
355           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
356         tmp->alloc(trueNval,1);
357         int *tmpPtr=tmp->getPointer();
358         for(const int *pt=da4->begin();pt!=da4->end();pt++)
359           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
360             *tmpPtr++=j;
361         //
362         _nval=da4->getNumberOfTuples();
363         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
364         _end=_start+trueNval;
365         oss << "_loc_" << _loc_id;
366         if(locIds)
367           {
368             MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
369             da5->setName(oss.str().c_str());
370             glob.appendProfile(da5);
371             _profile=oss.str();
372           }
373         else
374           {
375             if(!da3->isIota(nbOfEltsInWholeMesh))
376               {
377                 da3->setName(oss.str().c_str());
378                 glob.appendProfile(da3);
379                 _profile=oss.str();
380               }
381           }
382         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
383         _localization=oss2.str();
384         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
385         break;
386       }
387     default:
388       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
389   }
390   start=_end;
391 }
392
393 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
394 {
395   _start=start;
396   _nval=arrr->getNumberOfTuples();
397   getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
398   _end=_start+_nval;
399   start=_end;
400 }
401
402 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
403 {
404   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
405 }
406
407 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
408 {
409   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
410 }
411
412 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
413 {
414   return new MEDFileFieldPerMeshPerTypePerDisc(other);
415 }
416
417 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
418 {
419   return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
420 }
421
422 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
423 {
424   std::vector<const BigMemoryObject *> ret(1);
425   ret[0]=(const PartDefinition*)_pd;
426   return ret;
427 }
428
429 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
430 {
431   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
432   ret->_father=father;
433   return ret.retn();
434 }
435
436 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
437 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
438 {
439   if(pd)
440     pd->incrRef();
441 }
442 catch(INTERP_KERNEL::Exception& e)
443 {
444     throw e;
445 }
446
447 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
448 {
449 }
450
451 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)
452 {
453 }
454
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
456     _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
457 {
458 }
459
460 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)
461 {
462   const PartDefinition *pd(_pd);
463   if(!pd)
464     {
465       INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
466       int nbi,tmp1;
467       med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
468       if(_end-_start!=nbValsInFile*nbi)
469         {
470           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 !";
471           throw INTERP_KERNEL::Exception(oss.str().c_str());
472         }
473       MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
474     }
475   else
476     {
477       if(!_profile.empty())
478         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
479       INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
480       int profilesize,nbi;
481       int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
482       const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
483       if(spd)
484         {
485           int start,stop,step;
486           spd->getSlice(start,stop,step);
487           int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
488           med_filter filter=MED_FILTER_INIT;
489           MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
490                                    MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
491                                    /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
492                                    /*lastblocksize=useless because count=1*/0,&filter);
493           MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
494           MEDfilterClose(&filter);
495           return ;
496         }
497       const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
498       if(dpd)
499         {
500           dpd->checkConsistencyLight();
501           MCAuto<DataArrayInt> myIds(dpd->toDAI());
502           int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
503           myIds->applyLin(1,-a);
504           int nbOfEltsToLoad(b-a+1);
505           med_filter filter=MED_FILTER_INIT;
506           {//TODO : manage int32 !
507             MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
508             tmp->alloc(nbOfEltsToLoad,nbOfCompo);
509             MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
510                                      MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
511                                      /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
512                                      /*lastblocksize=useless because count=1*/0,&filter);
513             MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
514             MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
515             feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
516             feeder->setContigPartOfSelectedValues(0,tmp,myIds);
517           }
518           MEDfilterClose(&filter);
519         }
520       else
521         throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
522     }
523 }
524
525 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
526 {
527   return _father;
528 }
529
530 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
531 {
532   INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533   INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
534   std::string fieldName(nasc.getName()),meshName(getMeshName());
535   int iteration(getIteration()),order(getOrder());
536   TypeOfField type(getType());
537   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
538   int profilesize,nbi;
539   med_geometry_type mgeoti;
540   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
541   int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
542   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
543   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
544   const PartDefinition *pd(_pd);
545   if(!pd)
546     {
547       _nval=zeNVal;
548     }
549   else
550     {
551       if(!_profile.empty())
552         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
553       _nval=pd->getNumberOfElems();
554     }
555   _start=start;
556   _end=start+_nval*nbi;
557   start=_end;
558   if(type==ON_CELLS && !_localization.empty())
559     {
560       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
561         setType(ON_GAUSS_PT);
562       else
563         {
564           setType(ON_GAUSS_NE);
565           _localization.clear();
566         }
567     }
568 }
569
570 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
571 {
572   std::string fieldName(nasc.getName()),meshName(getMeshName());
573   int iteration(getIteration()),order(getOrder());
574   TypeOfField type(getType());
575   INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
576   med_geometry_type mgeoti;
577   med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
578   if(_start>_end)
579     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
580   if(_start==_end)
581     return ;
582   DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
583   if(_start<0 || _start>=arr->getNumberOfTuples())
584     {
585       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
586       throw INTERP_KERNEL::Exception(oss.str().c_str());
587     }
588   if(_end<0 || _end>arr->getNumberOfTuples())
589     {
590       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
591       throw INTERP_KERNEL::Exception(oss.str().c_str());
592     }
593   int nbOfCompo(arr->getNumberOfComponents());
594   DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
595   if(arrD)
596     {
597       double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
598       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
599       return ;
600     }
601   DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
602   if(arrI)
603     {
604       int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
605       goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
606       return ;
607     }
608   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
609 }
610
611 /*!
612  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
613  */
614 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
615 {
616   int delta=_end-_start;
617   _start=newValueOfStart;
618   _end=_start+delta;
619 }
620
621 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
622 {
623   return _father->getIteration();
624 }
625
626 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
627 {
628   return _father->getOrder();
629 }
630
631 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
632 {
633   return _father->getTime();
634 }
635
636 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
637 {
638   return _father->getMeshName();
639 }
640
641 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
642 {
643   const char startLine[]="    ## ";
644   std::string startLine2(bkOffset,' ');
645   startLine2+=startLine;
646   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
647   oss << startLine2 << "Localization #" << id << "." << std::endl;
648   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
649   delete tmp;
650   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
651   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
652   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
653 }
654
655 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
656 {
657   return _type;
658 }
659
660 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
661 {
662   types.insert(_type);
663 }
664
665 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
666 {
667   _type=newType;
668 }
669
670 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
671 {
672   return _father->getGeoType();
673 }
674
675 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
676 {
677   return _father->getNumberOfComponents();
678 }
679
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
681 {
682   return _end-_start;
683 }
684
685 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
686 {
687   return _father->getOrCreateAndGetArray();
688 }
689
690 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
691 {
692   const MEDFileFieldPerMeshPerType *fath=_father;
693   return fath->getOrCreateAndGetArray();
694 }
695
696 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
697 {
698   return _father->getInfo();
699 }
700
701 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
702 {
703   return _profile;
704 }
705
706 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
707 {
708   _profile=newPflName;
709 }
710
711 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
712 {
713   return _localization;
714 }
715
716 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
717 {
718   _localization=newLocName;
719 }
720
721 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
722 {
723   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
724     {
725       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
726         {
727           _profile=(*it2).second;
728           return;
729         }
730     }
731 }
732
733 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
734 {
735   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
736     {
737       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
738         {
739           _localization=(*it2).second;
740           return;
741         }
742     }
743 }
744
745 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
746 {
747   if(type!=_type)
748     return ;
749   dads.push_back(std::pair<int,int>(_start,_end));
750   geoTypes.push_back(getGeoType());
751   if(_profile.empty())
752     pfls.push_back(0);
753   else
754     {
755       pfls.push_back(glob->getProfile(_profile.c_str()));
756     }
757   if(_localization.empty())
758     locs.push_back(-1);
759   else
760     {
761       locs.push_back(glob->getLocalizationId(_localization.c_str()));
762     }
763 }
764
765 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
766 {
767   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));
768   startEntryId++;
769 }
770
771 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
772 {
773   TypeOfField type=getType();
774   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
775   med_geometry_type mgeoti;
776   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
777   const DataArray *arr=getOrCreateAndGetArray();
778   if(!arr)
779     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
780   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
781   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
782   const unsigned char *locToWrite=0;
783   if(arrD)
784     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
785   else if(arrI)
786     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
787   else
788     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
789   MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
790                                                    MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
791                                                    locToWrite));
792 }
793
794 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
795 {
796   type=_type;
797   pfl=_profile;
798   loc=_localization;
799   dad.first=_start; dad.second=_end;
800 }
801
802 /*!
803  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
804  *             This code corresponds to the distribution of types in the corresponding mesh.
805  * \param [out] ptToFill memory zone where the output will be stored.
806  * \return the size of data pushed into output param \a ptToFill
807  */
808 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
809 {
810   _loc_id=offset;
811   std::ostringstream oss;
812   std::size_t nbOfType=codeOfMesh.size()/3;
813   int found=-1;
814   for(std::size_t i=0;i<nbOfType && found==-1;i++)
815     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
816       found=(int)i;
817   if(found==-1)
818     {
819       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
820       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
821       throw INTERP_KERNEL::Exception(oss.str().c_str());
822     }
823   int *work=ptToFill;
824   if(_profile.empty())
825     {
826       if(_nval!=codeOfMesh[3*found+1])
827         {
828           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
829           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
830           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
831           throw INTERP_KERNEL::Exception(oss.str().c_str());
832         }
833       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
834         *work++=ii;
835     }
836   else
837     {
838       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
839       if(pfl->getNumberOfTuples()!=_nval)
840         {
841           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
842           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
843           oss << _nval;
844           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
845           throw INTERP_KERNEL::Exception(oss.str().c_str());
846         }
847       int offset2=codeOfMesh[3*found+2];
848       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
849         {
850           if(*pflId<codeOfMesh[3*found+1])
851             *work++=offset2+*pflId;
852         }
853     }
854   return _nval;
855 }
856
857 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
858 {
859   for(int i=_start;i<_end;i++)
860     *ptToFill++=i;
861   return _end-_start;
862 }
863
864 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
865 {
866   switch(type)
867   {
868     case ON_CELLS:
869       return -2;
870     case ON_GAUSS_NE:
871       return -1;
872     case ON_GAUSS_PT:
873       return locId;
874     default:
875       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
876   }
877 }
878
879 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
880 {
881   int id=0;
882   std::map<std::pair<std::string,TypeOfField>,int> m;
883   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
884   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
885     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
886       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
887   ret.resize(id);
888   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
890   return ret;
891 }
892
893 /*!
894  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
895  * 
896  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
897  * \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.
898  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
899  * \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)
900  * \param [in,out] glob if necessary by the method, new profiles can be added to it
901  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
902  * \param [out] result All new entries will be appended on it.
903  * \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 !)
904  */
905 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
906                                                        const DataArrayInt *explicitIdsInMesh,
907                                                        const std::vector<int>& newCode,
908                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
909                                                        std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
910 {
911   if(entriesOnSameDisc.empty())
912     return false;
913   TypeOfField type=entriesOnSameDisc[0]->getType();
914   int szEntities=0,szTuples=0;
915   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
916     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
917   int nbi=szTuples/szEntities;
918   if(szTuples%szEntities!=0)
919     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
920   MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
921   MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
922   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
923   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
924   std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
925   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
926   MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
927   int id=0;
928   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
929     {
930       int startOfEltIdOfChunk=(*it)->_start;
931       MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
932       MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
933       MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
934       //
935       MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
936       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
937       //
938       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
939       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
940     }
941   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
942   MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
943   MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
944   MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
945   //
946   MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
947   //
948   MCAuto<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
949   arrPart->renumberInPlace(renumTupleIds->begin());
950   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
951   bool ret=false;
952   const int *idIt=diffVals->begin();
953   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
954   int offset2=0;
955   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
956     {
957       MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
958       MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
959       int nbEntityElts=subIds->getNumberOfTuples();
960       bool ret2;
961       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
962           NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
963                                       offset+offset2,
964                                       li,glob,ret2);
965       ret=ret || ret2;
966       result.push_back(eltToAdd);
967       offset2+=nbEntityElts*nbi;
968     }
969   ret=ret || li.empty();
970   return ret;
971 }
972
973 /*!
974  * \param [in] typeF type of field of new chunk
975  * \param [in] geoType the geometric type of the chunk
976  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
977  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
978  * \param [in] nbi number of integration points
979  * \param [in] offset The offset in the **global array of data**.
980  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
981  *                 to the new chunk to create.
982  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
983  * \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
984  *              and corresponding entry erased from \a entriesOnSameDisc.
985  * \return a newly allocated chunk
986  */
987 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
988                                                                                                   bool isPfl, int nbi, int offset,
989                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
990                                                                                                   MEDFileFieldGlobsReal& glob,
991                                                                                                   bool &notInExisting)
992 {
993   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
994   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
995   for(;it!=entriesOnSameDisc.end();it++)
996     {
997       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
998         {
999           if(!isPfl)
1000             {
1001               if((*it)->_profile.empty())
1002                 break;
1003               else
1004                 if(!(*it)->_profile.empty())
1005                   {
1006                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1007                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1008                       break;
1009                   }
1010             }
1011         }
1012     }
1013   if(it==entriesOnSameDisc.end())
1014     {
1015       notInExisting=true;
1016       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1017       ret->_type=typeF;
1018       ret->_loc_id=(int)geoType;
1019       ret->_nval=nbMeshEntities;
1020       ret->_start=offset;
1021       ret->_end=ret->_start+ret->_nval*nbi;
1022       if(isPfl)
1023         {
1024           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1025           glob.appendProfile(idsOfMeshElt);
1026           ret->_profile=idsOfMeshElt->getName();
1027         }
1028       //tony treatment of localization
1029       return ret;
1030     }
1031   else
1032     {
1033       notInExisting=false;
1034       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1035       ret->_loc_id=(int)geoType;
1036       ret->setNewStart(offset);
1037       entriesOnSameDisc.erase(it);
1038       return ret;
1039     }
1040
1041 }
1042
1043 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1044 {
1045   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1046 }
1047
1048 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1049 {
1050   return new MEDFileFieldPerMeshPerType(fath,geoType);
1051 }
1052
1053 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1054 {
1055   return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1056 }
1057
1058 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1059 {
1060   std::vector<const BigMemoryObject *> ret;
1061   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1062     ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1063   return ret;
1064 }
1065
1066 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1067 {
1068   MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1069   ret->_father=father;
1070   std::size_t i=0;
1071   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1072     {
1073       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1074         ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1075     }
1076   return ret.retn();
1077 }
1078
1079 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1080 {
1081   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1082   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1083     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1084 }
1085
1086 /*!
1087  * This method is the most general one. No optimization is done here.
1088  * \param [in] multiTypePfl is the end user profile specified in high level API
1089  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1090  * \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.
1091  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1092  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1093  * \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.
1094  */
1095 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1096 {
1097   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1098   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1099     _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1100 }
1101
1102 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1103 {
1104   _field_pm_pt_pd.resize(1);
1105   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1106   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1107 }
1108
1109 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1110 {
1111   MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1112   if(!arr || !arr->isAllocated())
1113     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1114   _field_pm_pt_pd.resize(1);
1115   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1116   _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.
1117 }
1118
1119 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1120 {
1121   TypeOfField type=field->getTypeOfField();
1122   if(type!=ON_GAUSS_PT)
1123     {
1124       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1125       int sz=_field_pm_pt_pd.size();
1126       bool found=false;
1127       for(int j=0;j<sz && !found;j++)
1128         {
1129           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1130             {
1131               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1132               found=true;
1133             }
1134         }
1135       if(!found)
1136         {
1137           _field_pm_pt_pd.resize(sz+1);
1138           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1139         }
1140       std::vector<int> ret(1,(int)sz);
1141       return ret;
1142     }
1143   else
1144     {
1145       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1146       int sz2=ret2.size();
1147       std::vector<int> ret3(sz2);
1148       int k=0;
1149       for(int i=0;i<sz2;i++)
1150         {
1151           int sz=_field_pm_pt_pd.size();
1152           int locIdToFind=ret2[i];
1153           bool found=false;
1154           for(int j=0;j<sz && !found;j++)
1155             {
1156               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1157                 {
1158                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1159                   ret3[k++]=j;
1160                   found=true;
1161                 }
1162             }
1163           if(!found)
1164             {
1165               _field_pm_pt_pd.resize(sz+1);
1166               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1167               ret3[k++]=sz;
1168             }
1169         }
1170       return ret3;
1171     }
1172 }
1173
1174 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1175 {
1176   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1177   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1178   if(!disc2)
1179     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1180   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1181   if(!da)
1182     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1183   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1184   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1185   if(retTmp->presenceOfValue(-1))
1186     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1187   std::vector<int> ret(retTmp->begin(),retTmp->end());
1188   return ret;
1189 }
1190
1191 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1192 {
1193   TypeOfField type=field->getTypeOfField();
1194   if(type!=ON_GAUSS_PT)
1195     {
1196       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1197       int sz=_field_pm_pt_pd.size();
1198       bool found=false;
1199       for(int j=0;j<sz && !found;j++)
1200         {
1201           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1202             {
1203               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1204               found=true;
1205             }
1206         }
1207       if(!found)
1208         {
1209           _field_pm_pt_pd.resize(sz+1);
1210           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1211         }
1212       std::vector<int> ret(1,0);
1213       return ret;
1214     }
1215   else
1216     {
1217       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1218       int sz2=ret2.size();
1219       std::vector<int> ret3(sz2);
1220       int k=0;
1221       for(int i=0;i<sz2;i++)
1222         {
1223           int sz=_field_pm_pt_pd.size();
1224           int locIdToFind=ret2[i];
1225           bool found=false;
1226           for(int j=0;j<sz && !found;j++)
1227             {
1228               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1229                 {
1230                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1231                   ret3[k++]=j;
1232                   found=true;
1233                 }
1234             }
1235           if(!found)
1236             {
1237               _field_pm_pt_pd.resize(sz+1);
1238               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1239               ret3[k++]=sz;
1240             }
1241         }
1242       return ret3;
1243     }
1244 }
1245
1246 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1247 {
1248   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1249   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1250   if(!disc2)
1251     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1252   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1253   if(!da)
1254     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1255   MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1256   MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1257   if(retTmp->presenceOfValue(-1))
1258     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1259   std::vector<int> ret(retTmp->begin(),retTmp->end());
1260   return ret;
1261 }
1262
1263 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1264 {
1265   return _father;
1266 }
1267
1268 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1269 {
1270   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1271   int curDim=(int)cm.getDimension();
1272   dim=std::max(dim,curDim);
1273 }
1274
1275 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1276 {
1277   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1278     {
1279       (*it)->fillTypesOfFieldAvailable(types);
1280     }
1281 }
1282
1283 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1284 {
1285   int sz=_field_pm_pt_pd.size();
1286   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1287   for(int i=0;i<sz;i++)
1288     {
1289       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1290     }
1291 }
1292
1293 int MEDFileFieldPerMeshPerType::getIteration() const
1294 {
1295   return _father->getIteration();
1296 }
1297
1298 int MEDFileFieldPerMeshPerType::getOrder() const
1299 {
1300   return _father->getOrder();
1301 }
1302
1303 double MEDFileFieldPerMeshPerType::getTime() const
1304 {
1305   return _father->getTime();
1306 }
1307
1308 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1309 {
1310   return _father->getMeshName();
1311 }
1312
1313 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1314 {
1315   const char startLine[]="  ## ";
1316   std::string startLine2(bkOffset,' ');
1317   std::string startLine3(startLine2);
1318   startLine3+=startLine;
1319   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1320     {
1321       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1322       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1323     }
1324   else
1325     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1326   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1327   int i=0;
1328   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1329     {
1330       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1331       if(cur)
1332         cur->simpleRepr(bkOffset,oss,i);
1333       else
1334         {
1335           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1336         }
1337     }
1338 }
1339
1340 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1341 {
1342   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343     {
1344       globalSz+=(*it)->getNumberOfTuples();
1345     }
1346   nbOfEntries+=(int)_field_pm_pt_pd.size();
1347 }
1348
1349 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1350 {
1351   return _geo_type;
1352 }
1353
1354
1355 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1356 {
1357   return _father->getNumberOfComponents();
1358 }
1359
1360 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1361 {
1362   std::size_t nb(0);
1363   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1364     {
1365       const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1366       if(fmtd)
1367         nb++;
1368     }
1369   return nb>1;
1370 }
1371
1372 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1373 {
1374   return _father->getOrCreateAndGetArray();
1375 }
1376
1377 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1378 {
1379   const MEDFileFieldPerMesh *fath=_father;
1380   return fath->getOrCreateAndGetArray();
1381 }
1382
1383 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1384 {
1385   return _father->getInfo();
1386 }
1387
1388 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1389 {
1390   std::vector<std::string> ret;
1391   std::set<std::string> ret2;
1392   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1393     {
1394       std::string tmp=(*it1)->getProfile();
1395       if(!tmp.empty())
1396         if(ret2.find(tmp)==ret2.end())
1397           {
1398             ret.push_back(tmp);
1399             ret2.insert(tmp);
1400           }
1401     }
1402   return ret;
1403 }
1404
1405 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1406 {
1407   std::vector<std::string> ret;
1408   std::set<std::string> ret2;
1409   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1410     {
1411       std::string tmp=(*it1)->getLocalization();
1412       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1413         if(ret2.find(tmp)==ret2.end())
1414           {
1415             ret.push_back(tmp);
1416             ret2.insert(tmp);
1417           }
1418     }
1419   return ret;
1420 }
1421
1422 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1423 {
1424   std::vector<std::string> ret;
1425   std::set<std::string> ret2;
1426   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1427     {
1428       std::string tmp=(*it1)->getProfile();
1429       if(!tmp.empty())
1430         ret.push_back(tmp);
1431     }
1432   return ret;
1433 }
1434
1435 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1436 {
1437   std::vector<std::string> ret;
1438   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1439     {
1440       std::string tmp=(*it1)->getLocalization();
1441       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1442         ret.push_back(tmp);
1443     }
1444   return ret;
1445 }
1446
1447 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1448 {
1449   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1450     (*it1)->changePflsRefsNamesGen(mapOfModif);
1451 }
1452
1453 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1454 {
1455   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1456     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1457 }
1458
1459 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1460 {
1461   if(_field_pm_pt_pd.empty())
1462     {
1463       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1464       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1465       throw INTERP_KERNEL::Exception(oss.str().c_str());
1466     }
1467   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1468     return _field_pm_pt_pd[locId];
1469   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1470   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1471   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1472   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1473   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1474 }
1475
1476 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1477 {
1478   if(_field_pm_pt_pd.empty())
1479     {
1480       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1481       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1482       throw INTERP_KERNEL::Exception(oss.str().c_str());
1483     }
1484   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1485     return _field_pm_pt_pd[locId];
1486   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1487   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1488   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1489   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1490   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1491 }
1492
1493 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
1494 {
1495   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1496     {
1497       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1498       if(meshDim!=(int)cm.getDimension())
1499         return ;
1500     }
1501   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1502     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1503 }
1504
1505 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1506 {
1507   int i=0;
1508   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1509     {
1510       (*it)->fillValues(i,startEntryId,entries);
1511     }
1512 }
1513
1514 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1515 {
1516   _field_pm_pt_pd=leaves;
1517   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1518     (*it)->setFather(this);
1519 }
1520
1521 /*!
1522  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1523  *  \param [out] its - list of pair (start,stop) kept
1524  *  \return bool - false if the type of field \a tof is not contained in \a this.
1525  */
1526 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1527 {
1528   bool ret(false);
1529   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1530   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1531     if((*it)->getType()==tof)
1532       {
1533         newPmPtPd.push_back(*it);
1534         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1535         (*it)->setNewStart(globalNum);
1536         globalNum=(*it)->getEnd();
1537         its.push_back(bgEnd);
1538         ret=true;
1539       }
1540   if(ret)
1541     _field_pm_pt_pd=newPmPtPd;
1542   return ret;
1543 }
1544
1545 /*!
1546  *  \param [in,out] globalNum a global numbering counter for the renumbering.
1547  *  \param [out] its - list of pair (start,stop) kept
1548  *  \return bool - false if the type of field \a tof is not contained in \a this.
1549  */
1550 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1551 {
1552   if(_field_pm_pt_pd.size()<=idOfDisc)
1553     return false;
1554   MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1555   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1556   std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1557   elt->setNewStart(globalNum);
1558   globalNum=elt->getEnd();
1559   its.push_back(bgEnd);
1560   _field_pm_pt_pd=newPmPtPd;
1561   return true;
1562 }
1563
1564 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1565 {
1566 }
1567
1568 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1569 {
1570   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1572   med_geometry_type mgeoti;
1573   med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1574   int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1575   _field_pm_pt_pd.resize(nbProfiles);
1576   for(int i=0;i<nbProfiles;i++)
1577     {
1578       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1579     }
1580   if(type==ON_CELLS)
1581     {
1582       int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1583       for(int i=0;i<nbProfiles2;i++)
1584         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1585     }
1586 }
1587
1588 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1589 {
1590   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1591     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1592 }
1593
1594 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1595 {
1596   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1597     (*it)->loadBigArray(fid,nasc);
1598 }
1599
1600 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1601 {
1602   for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1603     {
1604       (*it)->copyOptionsFrom(*this);
1605       (*it)->writeLL(fid,nasc);
1606     }
1607 }
1608
1609 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1610 {
1611   switch(ikType)
1612   {
1613     case ON_CELLS:
1614       medfGeoType=typmai3[(int)ikGeoType];
1615       return MED_CELL;
1616     case ON_NODES:
1617       medfGeoType=MED_NONE;
1618       return MED_NODE;
1619     case ON_GAUSS_NE:
1620       medfGeoType=typmai3[(int)ikGeoType];
1621       return MED_NODE_ELEMENT;
1622     case ON_GAUSS_PT:
1623       medfGeoType=typmai3[(int)ikGeoType];
1624       return MED_CELL;
1625     default:
1626       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1627   }
1628   return MED_UNDEF_ENTITY_TYPE;
1629 }
1630
1631 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1632 {
1633   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1634 }
1635
1636 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1637 {
1638   return new MEDFileFieldPerMesh(fath,mesh);
1639 }
1640
1641 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1642 {
1643   return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1644 }
1645
1646 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1647 {
1648   std::vector<const BigMemoryObject *> ret;
1649   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1650     ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1651   return ret;
1652 }
1653
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1655 {
1656   MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1657   ret->_father=father;
1658   std::size_t i=0;
1659   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1660     {
1661       if((const MEDFileFieldPerMeshPerType *)*it)
1662         ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1663     }
1664   return ret.retn();
1665 }
1666
1667 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1668 {
1669   std::string startLine(bkOffset,' ');
1670   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1671   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1672   int i=0;
1673   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1674     {
1675       const MEDFileFieldPerMeshPerType *cur=*it;
1676       if(cur)
1677         cur->simpleRepr(bkOffset,oss,i);
1678       else
1679         {
1680           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1681         }
1682     }
1683 }
1684
1685 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1686 {
1687   _mesh_name=mesh->getName();
1688   mesh->getTime(_mesh_iteration,_mesh_order);
1689 }
1690
1691 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1692 {
1693   int nbOfTypes=code.size()/3;
1694   int offset=0;
1695   for(int i=0;i<nbOfTypes;i++)
1696     {
1697       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1698       int nbOfCells=code[3*i+1];
1699       int pos=addNewEntryIfNecessary(type);
1700       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1701       offset+=nbOfCells;
1702     }
1703 }
1704
1705 /*!
1706  * This method is the most general one. No optimization is done here.
1707  * \param [in] multiTypePfl is the end user profile specified in high level API
1708  * \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].
1709  * \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.
1710  * \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.
1711  * \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.
1712  * \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.
1713  */
1714 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)
1715 {
1716   int nbOfTypes(code.size()/3);
1717   for(int i=0;i<nbOfTypes;i++)
1718     {
1719       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1720       int pos=addNewEntryIfNecessary(type);
1721       DataArrayInt *pfl=0;
1722       if(code[3*i+2]!=-1)
1723         pfl=idsPerType[code[3*i+2]];
1724       int nbOfTupes2=code2.size()/3;
1725       int found=0;
1726       for(;found<nbOfTupes2;found++)
1727         if(code[3*i]==code2[3*found])
1728           break;
1729       if(found==nbOfTupes2)
1730         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1731       _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1732     }
1733 }
1734
1735 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1736 {
1737   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1738   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1739 }
1740
1741 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1742 {
1743   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1744   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1745 }
1746
1747 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1748 {
1749   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1750     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1751 }
1752
1753 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1754 {
1755   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1756     (*it)->loadBigArraysRecursively(fid,nasc);
1757 }
1758
1759 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1760 {
1761   int nbOfTypes=_field_pm_pt.size();
1762   for(int i=0;i<nbOfTypes;i++)
1763     {
1764       _field_pm_pt[i]->copyOptionsFrom(*this);
1765       _field_pm_pt[i]->writeLL(fid,nasc);
1766     }
1767 }
1768
1769 void MEDFileFieldPerMesh::getDimension(int& dim) const
1770 {
1771   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1772     (*it)->getDimension(dim);
1773 }
1774
1775 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1776 {
1777   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778     (*it)->fillTypesOfFieldAvailable(types);
1779 }
1780
1781 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
1782 {
1783   int sz=_field_pm_pt.size();
1784   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1785   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1786   for(int i=0;i<sz;i++)
1787     {
1788       types[i]=_field_pm_pt[i]->getGeoType();
1789       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1790     }
1791   return ret;
1792 }
1793
1794 double MEDFileFieldPerMesh::getTime() const
1795 {
1796   int tmp1,tmp2;
1797   return _father->getTime(tmp1,tmp2);
1798 }
1799
1800 int MEDFileFieldPerMesh::getIteration() const
1801 {
1802   return _father->getIteration();
1803 }
1804
1805 int MEDFileFieldPerMesh::getOrder() const
1806 {
1807   return _father->getOrder();
1808 }
1809
1810 int MEDFileFieldPerMesh::getNumberOfComponents() const
1811 {
1812   return _father->getNumberOfComponents();
1813 }
1814
1815 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1816 {
1817   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1818     {
1819       const MEDFileFieldPerMeshPerType *fpmt(*it);
1820       if(!fpmt)
1821         continue;
1822       if(fpmt->presenceOfMultiDiscPerGeoType())
1823         return true;
1824     }
1825   return false;
1826 }
1827
1828 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1829 {
1830   if(!_father)
1831     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1832   return _father->getOrCreateAndGetArray();
1833 }
1834
1835 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1836 {
1837   if(!_father)
1838     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1839   return _father->getOrCreateAndGetArray();
1840 }
1841
1842 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1843 {
1844   return _father->getInfo();
1845 }
1846
1847 /*!
1848  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1849  * 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.
1850  * It returns 2 output vectors :
1851  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1852  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1853  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1854  */
1855 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)
1856 {
1857   int notNullPflsSz=0;
1858   int nbOfArrs=geoTypes.size();
1859   for(int i=0;i<nbOfArrs;i++)
1860     if(pfls[i])
1861       notNullPflsSz++;
1862   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1863   int nbOfDiffGeoTypes=geoTypes3.size();
1864   code.resize(3*nbOfDiffGeoTypes);
1865   notNullPfls.resize(notNullPflsSz);
1866   notNullPflsSz=0;
1867   int j=0;
1868   for(int i=0;i<nbOfDiffGeoTypes;i++)
1869     {
1870       int startZone=j;
1871       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1872       std::vector<const DataArrayInt *> notNullTmp;
1873       if(pfls[j])
1874         notNullTmp.push_back(pfls[j]);
1875       j++;
1876       for(;j<nbOfArrs;j++)
1877         if(geoTypes[j]==refType)
1878           {
1879             if(pfls[j])
1880               notNullTmp.push_back(pfls[j]);
1881           }
1882         else
1883           break;
1884       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1885       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1886       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1887       code[3*i]=(int)refType;
1888       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1889       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1890       if(notNullTmp.empty())
1891         code[3*i+2]=-1;
1892       else
1893         {
1894           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1895           code[3*i+2]=notNullPflsSz++;
1896         }
1897     }
1898 }
1899
1900 /*!
1901  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1902  */
1903 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)
1904 {
1905   int sz=dads.size();
1906   int ret=0;
1907   for(int i=0;i<sz;i++)
1908     {
1909       if(locs[i]==-1)
1910         {
1911           if(type!=ON_GAUSS_NE)
1912             ret+=dads[i].second-dads[i].first;
1913           else
1914             {
1915               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1916               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1917             }
1918         }
1919       else
1920         {
1921           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1922           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1923         }
1924     }
1925   return ret;
1926 }
1927
1928 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1929 {
1930   std::vector<std::string> ret;
1931   std::set<std::string> ret2;
1932   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1933     {
1934       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1935       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1936         if(ret2.find(*it2)==ret2.end())
1937           {
1938             ret.push_back(*it2);
1939             ret2.insert(*it2);
1940           }
1941     }
1942   return ret;
1943 }
1944
1945 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1946 {
1947   std::vector<std::string> ret;
1948   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1949     {
1950       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1951       ret.insert(ret.end(),tmp.begin(),tmp.end());
1952     }
1953   return ret;
1954 }
1955
1956 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1957 {
1958   std::vector<std::string> ret;
1959   std::set<std::string> ret2;
1960   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1961     {
1962       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1963       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1964         if(ret2.find(*it2)==ret2.end())
1965           {
1966             ret.push_back(*it2);
1967             ret2.insert(*it2);
1968           }
1969     }
1970   return ret;
1971 }
1972
1973 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1974 {
1975   std::vector<std::string> ret;
1976   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1977     {
1978       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1979       ret.insert(ret.end(),tmp.begin(),tmp.end());
1980     }
1981   return ret;
1982 }
1983
1984 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1985 {
1986   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1987     {
1988       if((*it).first==_mesh_name)
1989         {
1990           _mesh_name=(*it).second;
1991           return true;
1992         }
1993     }
1994   return false;
1995 }
1996
1997 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1998                                                       MEDFileFieldGlobsReal& glob)
1999 {
2000   if(_mesh_name!=meshName)
2001     return false;
2002   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2003   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2004   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2005   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2006   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2007   getUndergroundDataArrayExt(entries);
2008   DataArray *arr0=getOrCreateAndGetArray();//tony
2009   if(!arr0)
2010     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2011   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2012   if(!arr0)
2013     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2014   int sz=0;
2015   if(!arr)
2016     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2017   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2018     {
2019       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2020         {
2021           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2022           sz+=(*it).second.second-(*it).second.first;
2023         }
2024       else
2025         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2026     }
2027   MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2028   ////////////////////
2029   MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2030   int *workI2=explicitIdsOldInMesh->getPointer();
2031   int sz1=0,sz2=0,sid=1;
2032   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2033   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2034   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2035     {
2036       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2037       MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2038       int *workI=explicitIdsOldInArr->getPointer();
2039       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2040         {
2041           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2042           (*itL2)->setLocId(sz2);
2043           (*itL2)->_tmp_work1=(*itL2)->getStart();
2044           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2045         }
2046       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2047     }
2048   explicitIdsOldInMesh->reAlloc(sz2);
2049   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2050   ////////////////////
2051   MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2052   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2053   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2054   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2055     {
2056       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2057       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2058       otherEntriesNew.back()->setLocId((*it)->getGeoType());
2059     }
2060   std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2061   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2062   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2063     {
2064       MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2065       int newStart=elt->getLocId();
2066       elt->setLocId((*it)->getGeoType());
2067       elt->setNewStart(newStart);
2068       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2069       entriesKeptNew.push_back(elt);
2070       entriesKeptNew2.push_back(elt);
2071     }
2072   MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2073   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2074   MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2075   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2076   bool ret=false;
2077   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2078     {
2079       sid=0;
2080       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2081         {
2082           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2083           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2084           }*/
2085       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2086                                                             glob,arr2,otherEntriesNew) || ret;
2087     }
2088   if(!ret)
2089     return false;
2090   // Assign new dispatching
2091   assignNewLeaves(otherEntriesNew);
2092   arr->deepCopyFrom(*arr2);
2093   return true;
2094 }
2095
2096 /*!
2097  * \param [in,out] globalNum a global numbering counter for the renumbering.
2098  * \param [out] its - list of pair (start,stop) kept
2099  */
2100 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2101 {
2102   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2103   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2104     {
2105       std::vector< std::pair<int,int> > its2;
2106       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2107         {
2108           ret.push_back(*it);
2109           its.insert(its.end(),its2.begin(),its2.end());
2110         }
2111     }
2112   _field_pm_pt=ret;
2113 }
2114
2115 /*!
2116  * \param [in,out] globalNum a global numbering counter for the renumbering.
2117  * \param [out] its - list of pair (start,stop) kept
2118  */
2119 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2120 {
2121   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2122   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2123     {
2124       std::vector< std::pair<int,int> > its2;
2125       if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2126         {
2127           ret.push_back(*it);
2128           its.insert(its.end(),its2.begin(),its2.end());
2129         }
2130     }
2131   _field_pm_pt=ret;
2132 }
2133
2134 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2135 {
2136   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2137   for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2138     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2139   //
2140   std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2141   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2142   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2143   for(;it1!=types.end();it1++,it2++)
2144     {
2145       MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2146       elt->setLeaves((*it1).second);
2147       *it2=elt;
2148     }
2149   _field_pm_pt=fieldPmPt;
2150 }
2151
2152 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2153 {
2154   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155     (*it)->changePflsRefsNamesGen(mapOfModif);
2156 }
2157
2158 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2159 {
2160   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2161     (*it)->changeLocsRefsNamesGen(mapOfModif);
2162 }
2163
2164 /*!
2165  * \param [in] mesh is the whole mesh
2166  */
2167 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2168 {
2169   if(_field_pm_pt.empty())
2170     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2171   //
2172   std::vector< std::pair<int,int> > dads;
2173   std::vector<const DataArrayInt *> pfls;
2174   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2175   std::vector<int> locs,code;
2176   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2177   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2179   // Sort by types
2180   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2181   if(code.empty())
2182     {
2183       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2184       throw INTERP_KERNEL::Exception(oss.str().c_str());
2185     }
2186   //
2187   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2188   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2189   if(type!=ON_NODES)
2190     {
2191       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2192       if(!arr)
2193         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2194       else
2195         {
2196           MCAuto<DataArrayInt> arr2(arr);
2197           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2198         }
2199     }
2200   else
2201     {
2202       if(code.size()!=3)
2203         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2204       int nb=code[1];
2205       if(code[2]==-1)
2206         {
2207           if(nb!=mesh->getNumberOfNodes())
2208             {
2209               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2210               oss << " nodes in mesh !";
2211               throw INTERP_KERNEL::Exception(oss.str().c_str());
2212             }
2213           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2214         }
2215       else
2216         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2217     }
2218 }
2219
2220 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2221 {
2222   if(_field_pm_pt.empty())
2223     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2224   //
2225   std::vector<std::pair<int,int> > dads;
2226   std::vector<const DataArrayInt *> pfls;
2227   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2228   std::vector<int> locs,code;
2229   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2230   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2231     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2232   // Sort by types
2233   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2234   if(code.empty())
2235     {
2236       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2237       throw INTERP_KERNEL::Exception(oss.str().c_str());
2238     }
2239   std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2240   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2241   if(type!=ON_NODES)
2242     {
2243       MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2244       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2245     }
2246   else
2247     {
2248       if(code.size()!=3)
2249         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2250       int nb=code[1];
2251       if(code[2]==-1)
2252         {
2253           if(nb!=mesh->getNumberOfNodes())
2254             {
2255               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2256               oss << " nodes in mesh !";
2257               throw INTERP_KERNEL::Exception(oss.str().c_str());
2258             }
2259         }
2260       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2261     }
2262   //
2263   return 0;
2264 }
2265
2266 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2267 {
2268   int globalSz=0;
2269   int nbOfEntries=0;
2270   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2271     {
2272       (*it)->getSizes(globalSz,nbOfEntries);
2273     }
2274   entries.resize(nbOfEntries);
2275   nbOfEntries=0;
2276   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2277     {
2278       (*it)->fillValues(nbOfEntries,entries);
2279     }
2280 }
2281
2282 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2283 {
2284   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2285     {
2286       if((*it)->getGeoType()==typ)
2287         return (*it)->getLeafGivenLocId(locId);
2288     }
2289   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2290   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2291   oss << "Possiblities are : ";
2292   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2293     {
2294       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2295       oss << "\"" << cm2.getRepr() << "\", ";
2296     }
2297   throw INTERP_KERNEL::Exception(oss.str().c_str());
2298 }
2299
2300 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2301 {
2302   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2303     {
2304       if((*it)->getGeoType()==typ)
2305         return (*it)->getLeafGivenLocId(locId);
2306     }
2307   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2308   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2309   oss << "Possiblities are : ";
2310   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2311     {
2312       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2313       oss << "\"" << cm2.getRepr() << "\", ";
2314     }
2315   throw INTERP_KERNEL::Exception(oss.str().c_str());
2316 }
2317
2318 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2319 {
2320   int i=0;
2321   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2322   std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2323   for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2324     {
2325       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2326       if(type==curType)
2327         return i;
2328       else
2329         {
2330           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2331           if(pos>pos2)
2332             it2=it+1;
2333         }
2334     }
2335   int ret=std::distance(_field_pm_pt.begin(),it2);
2336   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2337   return ret;
2338 }
2339
2340 /*!
2341  * 'dads' and 'locs' input parameters have the same number of elements
2342  * \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
2343  */
2344 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2345                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2346                                                          const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2347 {
2348   isPfl=false;
2349   MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2350   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2351   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2352   const std::vector<std::string>& infos=getInfo();
2353   da->setInfoOnComponents(infos);
2354   da->setName("");
2355   if(type==ON_GAUSS_PT)
2356     {
2357       int offset=0;
2358       int nbOfArrs=dads.size();
2359       for(int i=0;i<nbOfArrs;i++)
2360         {
2361           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2362           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2363           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2364           MCAuto<DataArrayInt> di=DataArrayInt::New();
2365           di->alloc(nbOfElems,1);
2366           di->iota(offset);
2367           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2368           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2369           offset+=nbOfElems;
2370         }
2371     }
2372   arrOut=da;
2373   return ret.retn();
2374 }
2375
2376 /*!
2377  * 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.
2378  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2379  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2380  * The order of cells in the returned field is those imposed by the profile.
2381  * \param [in] mesh is the global mesh.
2382  */
2383 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2384                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2385                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2386                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2387 {
2388   if(da->isIota(mesh->getNumberOfCells()))
2389     return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2390   MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2391   m2->setName(mesh->getName().c_str());
2392   MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2393   isPfl=true;
2394   return ret.retn();
2395 }
2396
2397 /*!
2398  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2399  */
2400 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2401                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2402                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2403 {
2404   if(da->isIota(mesh->getNumberOfNodes()))
2405     return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2406   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2407   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2408   if(meshu)
2409     {
2410       if(meshu->getNodalConnectivity()==0)
2411         {
2412           MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2413           int nb=da->getNbOfElems();
2414           const int *ptr=da->getConstPointer();
2415           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2416           meshuc->allocateCells(nb);
2417           for(int i=0;i<nb;i++)
2418             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2419           meshuc->finishInsertingCells();
2420           ret->setMesh(meshuc);
2421           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2422           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2423           disc->checkCoherencyBetween(meshuc,arrOut);
2424           return ret.retn();
2425         }
2426     }
2427   //
2428   MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2429   isPfl=true;
2430   DataArrayInt *arr2=0;
2431   MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2432   MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2433   MCAuto<DataArrayInt> arr3(arr2);
2434   int nnodes=mesh2->getNumberOfNodes();
2435   if(nnodes==(int)da->getNbOfElems())
2436     {
2437       MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2438       arrOut->renumberInPlace(da3->getConstPointer());
2439       mesh2->setName(mesh->getName().c_str());
2440       ret->setMesh(mesh2);
2441       return ret.retn();
2442     }
2443   else
2444     {
2445       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 !!!";
2446       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2447       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2448       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2449       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2450       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2451       throw INTERP_KERNEL::Exception(oss.str().c_str());
2452     }
2453   return 0;
2454 }
2455
2456 /*!
2457  * This method is the most light method of field retrieving.
2458  */
2459 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2460 {
2461   if(!pflIn)
2462     {
2463       pflOut=DataArrayInt::New();
2464       pflOut->alloc(nbOfElems,1);
2465       pflOut->iota(0);
2466     }
2467   else
2468     {
2469       pflOut=const_cast<DataArrayInt*>(pflIn);
2470       pflOut->incrRef();
2471     }
2472   MCAuto<DataArrayInt> safePfl(pflOut);
2473   MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2474   const std::vector<std::string>& infos=getInfo();
2475   int nbOfComp=infos.size();
2476   for(int i=0;i<nbOfComp;i++)
2477     da->setInfoOnComponent(i,infos[i].c_str());
2478   safePfl->incrRef();
2479   return da.retn();
2480 }
2481
2482
2483 /// @cond INTERNAL
2484
2485 class MFFPMIter
2486 {
2487 public:
2488   static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2489   static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2490   virtual ~MFFPMIter() { }
2491   virtual void begin() = 0;
2492   virtual bool finished() const = 0;
2493   virtual void next() = 0;
2494   virtual int current() const = 0;
2495 };
2496
2497 class MFFPMIterSimple : public MFFPMIter
2498 {
2499 public:
2500   MFFPMIterSimple():_pos(0) { }
2501   void begin() { _pos=0; }
2502   bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2503   void next() { _pos++; }
2504   int current() const { return _pos; }
2505 private:
2506   int _pos;
2507 };
2508
2509 class MFFPMIter2 : public MFFPMIter
2510 {
2511 public:
2512   MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2513   void begin() { _it=_ids.begin(); }
2514   bool finished() const { return _it==_ids.end(); }
2515   void next() { _it++; }
2516   int current() const { return *_it; }
2517 private:
2518   std::vector<int> _ids;
2519   std::vector<int>::const_iterator _it;
2520 };
2521
2522 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2523 {
2524   if(!entities)
2525     return new MFFPMIterSimple;
2526   else
2527     {
2528       std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2529       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2530         {
2531           if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2532             tmp.push_back((*it).second);
2533         }
2534       return new MFFPMIter2(tmp);
2535     }
2536 }
2537
2538 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2539 {
2540   if(!entities)
2541     return true;
2542   else
2543     {
2544       for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2545         if((*it).first==ON_NODES)
2546           return true;
2547       return false;
2548     }
2549 }
2550
2551 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2552 {
2553   std::size_t sz(cts.size());
2554   _ids.resize(sz);
2555   for(std::size_t i=0;i<sz;i++)
2556     {
2557       INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2558       if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2559         _ids[i]=(int)std::distance(typmai2,loc);
2560       else
2561         throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2562     }
2563 }
2564
2565 /// @endcond
2566
2567 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2568     _father(fath)
2569 {
2570   INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2571   INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2572   INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2573   const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2574   INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2575   for(iter0->begin();!iter0->finished();iter0->next())
2576     {
2577       int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2578       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2579       int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2580       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2581       if(nbProfile>0 || nbProfile2>0)
2582         {
2583           const PartDefinition *pd(0);
2584           if(mmu)
2585             pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2586           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2587           if(nbProfile>0)
2588             _mesh_name=name0;
2589           else
2590             _mesh_name=name1;
2591         }
2592     }
2593   if(MFFPMIter::IsPresenceOfNode(entities))
2594     {
2595       int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2596       if(nbProfile>0)
2597         {
2598           const PartDefinition *pd(0);
2599           if(mmu)
2600             pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2601           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2602           _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2603         }
2604     }
2605 }
2606
2607 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2608 {
2609   copyTinyInfoFrom(mesh);
2610 }
2611
2612 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2613 {
2614   if(id>=(int)_pfls.size())
2615     _pfls.resize(id+1);
2616   _pfls[id]=DataArrayInt::New();
2617   int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2618   _pfls[id]->setName(pflName);
2619   _pfls[id]->alloc(lgth,1);
2620   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2621   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2622 }
2623
2624 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2625 {
2626   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2627   int sz;
2628   MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2629   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2630   if(i>=(int)_pfls.size())
2631     _pfls.resize(i+1);
2632   _pfls[i]=DataArrayInt::New();
2633   _pfls[i]->alloc(sz,1);
2634   _pfls[i]->setName(pflCpp.c_str());
2635   MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2636   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2637 }
2638
2639 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2640 {
2641   int nbOfPfls=_pfls.size();
2642   for(int i=0;i<nbOfPfls;i++)
2643     {
2644       MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2645       cpy->applyLin(1,1,0);
2646       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2647       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2648       MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2649     }
2650   //
2651   int nbOfLocs=_locs.size();
2652   for(int i=0;i<nbOfLocs;i++)
2653     _locs[i]->writeLL(fid);
2654 }
2655
2656 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2657 {
2658   std::vector<std::string> pfls=getPfls();
2659   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2660     {
2661       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2662       if(it2==pfls.end())
2663         {
2664           _pfls.push_back(*it);
2665         }
2666       else
2667         {
2668           int id=std::distance(pfls.begin(),it2);
2669           if(!(*it)->isEqual(*_pfls[id]))
2670             {
2671               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2672               throw INTERP_KERNEL::Exception(oss.str().c_str());
2673             }
2674         }
2675     }
2676   std::vector<std::string> locs=getLocs();
2677   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2678     {
2679       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2680       if(it2==locs.end())
2681         {
2682           _locs.push_back(*it);
2683         }
2684       else
2685         {
2686           int id=std::distance(locs.begin(),it2);
2687           if(!(*it)->isEqual(*_locs[id],eps))
2688             {
2689               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2690               throw INTERP_KERNEL::Exception(oss.str().c_str());
2691             }
2692         }
2693     }
2694 }
2695
2696 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2697 {
2698   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2699     getProfile((*it).c_str());
2700 }
2701
2702 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2703 {
2704   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2705     getLocalization((*it).c_str());
2706 }
2707
2708 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2709 {
2710   std::vector<std::string> profiles=real.getPflsReallyUsed();
2711   int sz=profiles.size();
2712   _pfls.resize(sz);
2713   for(int i=0;i<sz;i++)
2714     loadProfileInFile(fid,i,profiles[i].c_str());
2715   //
2716   std::vector<std::string> locs=real.getLocsReallyUsed();
2717   sz=locs.size();
2718   _locs.resize(sz);
2719   for(int i=0;i<sz;i++)
2720     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2721 }
2722
2723 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2724 {
2725   int nProfil=MEDnProfile(fid);
2726   for(int i=0;i<nProfil;i++)
2727     loadProfileInFile(fid,i);
2728   int sz=MEDnLocalization(fid);
2729   _locs.resize(sz);
2730   for(int i=0;i<sz;i++)
2731     {
2732       _locs[i]=MEDFileFieldLoc::New(fid,i);
2733     }
2734 }
2735
2736 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2737 {
2738   return new MEDFileFieldGlobs(fname);
2739 }
2740
2741 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2742 {
2743   return new MEDFileFieldGlobs;
2744 }
2745
2746 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2747 {
2748   return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2749 }
2750
2751 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2752 {
2753   std::vector<const BigMemoryObject *> ret;
2754   for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2755     ret.push_back((const DataArrayInt *)*it);
2756   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2757     ret.push_back((const MEDFileFieldLoc *)*it);
2758   return ret;
2759 }
2760
2761 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2762 {
2763   MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2764   std::size_t i=0;
2765   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2766     {
2767       if((const DataArrayInt *)*it)
2768         ret->_pfls[i]=(*it)->deepCopy();
2769     }
2770   i=0;
2771   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2772     {
2773       if((const MEDFileFieldLoc*)*it)
2774         ret->_locs[i]=(*it)->deepCopy();
2775     }
2776   return ret.retn();
2777 }
2778
2779 /*!
2780  * \throw if a profile in \a pfls in not in \a this.
2781  * \throw if a localization in \a locs in not in \a this.
2782  * \sa MEDFileFieldGlobs::deepCpyPart
2783  */
2784 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2785 {
2786   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2787   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2788     {
2789       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2790       if(!pfl)
2791         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2792       pfl->incrRef();
2793       MCAuto<DataArrayInt> pfl2(pfl);
2794       ret->_pfls.push_back(pfl2);
2795     }
2796   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2797     {
2798       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2799       if(!loc)
2800         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2801       loc->incrRef();
2802       MCAuto<MEDFileFieldLoc> loc2(loc);
2803       ret->_locs.push_back(loc2);
2804     }
2805   ret->setFileName(getFileName());
2806   return ret.retn();
2807 }
2808
2809 /*!
2810  * \throw if a profile in \a pfls in not in \a this.
2811  * \throw if a localization in \a locs in not in \a this.
2812  * \sa MEDFileFieldGlobs::shallowCpyPart
2813  */
2814 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2815 {
2816   MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2817   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2818     {
2819       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2820       if(!pfl)
2821         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2822       ret->_pfls.push_back(pfl->deepCopy());
2823     }
2824   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2825     {
2826       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2827       if(!loc)
2828         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2829       ret->_locs.push_back(loc->deepCopy());
2830     }
2831   ret->setFileName(getFileName());
2832   return ret.retn();
2833 }
2834
2835 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2836 {
2837 }
2838
2839 MEDFileFieldGlobs::MEDFileFieldGlobs()
2840 {
2841 }
2842
2843 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2844 {
2845 }
2846
2847 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2848 {
2849   oss << "Profiles :\n";
2850   std::size_t n=_pfls.size();
2851   for(std::size_t i=0;i<n;i++)
2852     {
2853       oss << "  - #" << i << " ";
2854       const DataArrayInt *pfl=_pfls[i];
2855       if(pfl)
2856         oss << "\"" << pfl->getName() << "\"\n";
2857       else
2858         oss << "EMPTY !\n";
2859     }
2860   n=_locs.size();
2861   oss << "Localizations :\n";
2862   for(std::size_t i=0;i<n;i++)
2863     {
2864       oss << "  - #" << i << " ";
2865       const MEDFileFieldLoc *loc=_locs[i];
2866       if(loc)
2867         loc->simpleRepr(oss);
2868       else
2869         oss<< "EMPTY !\n";
2870     }
2871 }
2872
2873 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2874 {
2875   _file_name=fileName;
2876 }
2877
2878 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2879 {
2880   for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2881     {
2882       DataArrayInt *elt(*it);
2883       if(elt)
2884         {
2885           std::string name(elt->getName());
2886           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2887             {
2888               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2889                 {
2890                   elt->setName((*it2).second.c_str());
2891                   return;
2892                 }
2893             }
2894         }
2895     }
2896 }
2897
2898 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2899 {
2900   for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2901     {
2902       MEDFileFieldLoc *elt(*it);
2903       if(elt)
2904         {
2905           std::string name(elt->getName());
2906           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2907             {
2908               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2909                 {
2910                   elt->setName((*it2).second.c_str());
2911                   return;
2912                 }
2913             }
2914         }
2915     }
2916 }
2917
2918 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2919 {
2920   if(locId<0 || locId>=(int)_locs.size())
2921     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2922   return _locs[locId]->getNbOfGaussPtPerCell();
2923 }
2924
2925 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2926 {
2927   return getLocalizationFromId(getLocalizationId(locName));
2928 }
2929
2930 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2931 {
2932   if(locId<0 || locId>=(int)_locs.size())
2933     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2934   return *_locs[locId];
2935 }
2936
2937 /// @cond INTERNAL
2938 namespace MEDCouplingImpl
2939 {
2940   class LocFinder
2941   {
2942   public:
2943     LocFinder(const std::string& loc):_loc(loc) { }
2944     bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2945   private:
2946     const std::string &_loc;
2947   };
2948
2949   class PflFinder
2950   {
2951   public:
2952     PflFinder(const std::string& pfl):_pfl(pfl) { }
2953     bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2954   private:
2955     const std::string& _pfl;
2956   };
2957 }
2958 /// @endcond
2959
2960 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2961 {
2962   std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2963   if(it==_locs.end())
2964     {
2965       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2966       for(it=_locs.begin();it!=_locs.end();it++)
2967         oss << "\"" << (*it)->getName() << "\", ";
2968       throw INTERP_KERNEL::Exception(oss.str().c_str());
2969     }
2970   return std::distance(_locs.begin(),it);
2971 }
2972
2973 /*!
2974  * The returned value is never null.
2975  */
2976 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2977 {
2978   std::string pflNameCpp(pflName);
2979   std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
2980   if(it==_pfls.end())
2981     {
2982       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2983       for(it=_pfls.begin();it!=_pfls.end();it++)
2984         oss << "\"" << (*it)->getName() << "\", ";
2985       throw INTERP_KERNEL::Exception(oss.str().c_str());
2986     }
2987   return *it;
2988 }
2989
2990 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2991 {
2992   if(pflId<0 || pflId>=(int)_pfls.size())
2993     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2994   return _pfls[pflId];
2995 }
2996
2997 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2998 {
2999   if(locId<0 || locId>=(int)_locs.size())
3000     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3001   return *_locs[locId];
3002 }
3003
3004 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3005 {
3006   return getLocalizationFromId(getLocalizationId(locName));
3007 }
3008
3009 /*!
3010  * The returned value is never null.
3011  */
3012 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3013 {
3014   std::string pflNameCpp(pflName);
3015   std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3016   if(it==_pfls.end())
3017     {
3018       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3019       for(it=_pfls.begin();it!=_pfls.end();it++)
3020         oss << "\"" << (*it)->getName() << "\", ";
3021       throw INTERP_KERNEL::Exception(oss.str().c_str());
3022     }
3023   return *it;
3024 }
3025
3026 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3027 {
3028   if(pflId<0 || pflId>=(int)_pfls.size())
3029     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3030   return _pfls[pflId];
3031 }
3032
3033 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3034 {
3035   std::vector< MCAuto<DataArrayInt> > newPfls;
3036   int i=0;
3037   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3038     {
3039       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3040         newPfls.push_back(*it);
3041     }
3042   _pfls=newPfls;
3043 }
3044
3045 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3046 {
3047   std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3048   int i=0;
3049   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3050     {
3051       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3052         newLocs.push_back(*it);
3053     }
3054   _locs=newLocs;
3055 }
3056
3057 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3058 {
3059   int sz=_pfls.size();
3060   std::vector<std::string> ret(sz);
3061   for(int i=0;i<sz;i++)
3062     ret[i]=_pfls[i]->getName();
3063   return ret;
3064 }
3065
3066 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3067 {
3068   int sz=_locs.size();
3069   std::vector<std::string> ret(sz);
3070   for(int i=0;i<sz;i++)
3071     ret[i]=_locs[i]->getName();
3072   return ret;
3073 }
3074
3075 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3076 {
3077   std::vector<std::string> v=getPfls();
3078   std::string s(pflName);
3079   return std::find(v.begin(),v.end(),s)!=v.end();
3080 }
3081
3082 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3083 {
3084   std::vector<std::string> v=getLocs();
3085   std::string s(locName);
3086   return std::find(v.begin(),v.end(),s)!=v.end();
3087 }
3088
3089 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3090 {
3091   std::map<int,std::vector<int> > m;
3092   int i=0;
3093   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3094     {
3095       const DataArrayInt *tmp=(*it);
3096       if(tmp)
3097         {
3098           m[tmp->getHashCode()].push_back(i);
3099         }
3100     }
3101   std::vector< std::vector<int> > ret;
3102   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3103     {
3104       if((*it2).second.size()>1)
3105         {
3106           std::vector<int> ret0;
3107           bool equalityOrNot=false;
3108           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3109             {
3110               std::vector<int>::const_iterator it4=it3; it4++;
3111               for(;it4!=(*it2).second.end();it4++)
3112                 {
3113                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3114                     {
3115                       if(!equalityOrNot)
3116                         ret0.push_back(*it3);
3117                       ret0.push_back(*it4);
3118                       equalityOrNot=true;
3119                     }
3120                 }
3121             }
3122           if(!ret0.empty())
3123             ret.push_back(ret0);
3124         }
3125     }
3126   return ret;
3127 }
3128
3129 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3130 {
3131   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3132 }
3133
3134 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3135 {
3136   std::string name(pfl->getName());
3137   if(name.empty())
3138     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3139   for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3140     if(name==(*it)->getName())
3141       {
3142         if(!pfl->isEqual(*(*it)))
3143           {
3144             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3145             throw INTERP_KERNEL::Exception(oss.str().c_str());
3146           }
3147       }
3148   pfl->incrRef();
3149   _pfls.push_back(pfl);
3150 }
3151
3152 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)
3153 {
3154   std::string name(locName);
3155   if(name.empty())
3156     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3157   MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3158   for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3159     if((*it)->isName(locName))
3160       {
3161         if(!(*it)->isEqual(*obj,1e-12))
3162           {
3163             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3164             throw INTERP_KERNEL::Exception(oss.str().c_str());
3165           }
3166       }
3167   _locs.push_back(obj);
3168 }
3169
3170 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3171 {
3172   std::vector<std::string> names=getPfls();
3173   return CreateNewNameNotIn("NewPfl_",names);
3174 }
3175
3176 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3177 {
3178   std::vector<std::string> names=getLocs();
3179   return CreateNewNameNotIn("NewLoc_",names);
3180 }
3181
3182 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3183 {
3184   for(std::size_t sz=0;sz<100000;sz++)
3185     {
3186       std::ostringstream tryName;
3187       tryName << prefix << sz;
3188       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3189         return tryName.str();
3190     }
3191   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3192 }
3193
3194 /*!
3195  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3196  *  \param [in] fname - the file name.
3197  */
3198 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3199 {
3200 }
3201
3202 /*!
3203  * Creates an empty MEDFileFieldGlobsReal.
3204  */
3205 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3206 {
3207 }
3208
3209 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3210 {
3211   return 0;
3212 }
3213
3214 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3215 {
3216   std::vector<const BigMemoryObject *> ret;
3217   ret.push_back((const MEDFileFieldGlobs *)_globals);
3218   return ret;
3219 }
3220
3221 /*!
3222  * Returns a string describing profiles and Gauss points held in \a this.
3223  *  \return std::string - the description string.
3224  */
3225 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3226 {
3227   const MEDFileFieldGlobs *glob=_globals;
3228   std::ostringstream oss2; oss2 << glob;
3229   std::string stars(oss2.str().length(),'*');
3230   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
3231   if(glob)
3232     glob->simpleRepr(oss);
3233   else
3234     oss << "NO GLOBAL INFORMATION !\n";
3235 }
3236
3237 void MEDFileFieldGlobsReal::resetContent()
3238 {
3239   _globals=MEDFileFieldGlobs::New();
3240 }
3241
3242 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3243 {
3244 }
3245
3246 /*!
3247  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3248  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3249  */
3250 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3251 {
3252   _globals=other._globals;
3253 }
3254
3255 /*!
3256  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3257  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3258  */
3259 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3260 {
3261   const MEDFileFieldGlobs *otherg(other._globals);
3262   if(!otherg)
3263     return ;
3264   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3265 }
3266
3267 /*!
3268  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3269  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3270  */
3271 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3272 {
3273   const MEDFileFieldGlobs *otherg(other._globals);
3274   if(!otherg)
3275     return ;
3276   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3277 }
3278
3279 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3280 {
3281   _globals=other._globals;
3282   if((const MEDFileFieldGlobs *)_globals)
3283     _globals=other._globals->deepCopy();
3284 }
3285
3286 /*!
3287  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3288  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3289  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3290  *         \a this and \a other MEDFileFieldGlobsReal.
3291  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3292  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3293  */
3294 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3295 {
3296   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3297   if(thisGlobals==otherGlobals)
3298     return ;
3299   if(!thisGlobals)
3300     {
3301       _globals=other._globals;
3302       return ;
3303     }
3304   _globals->appendGlobs(*other._globals,eps);
3305 }
3306
3307 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3308 {
3309   checkGlobsPflsPartCoherency();
3310   checkGlobsLocsPartCoherency();
3311 }
3312
3313 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3314 {
3315   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3316 }
3317
3318 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3319 {
3320   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3321 }
3322
3323 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3324 {
3325   contentNotNull()->loadProfileInFile(fid,id,pflName);
3326 }
3327
3328 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3329 {
3330   contentNotNull()->loadProfileInFile(fid,id);
3331 }
3332
3333 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3334 {
3335   contentNotNull()->loadGlobals(fid,*this);
3336 }
3337
3338 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3339 {
3340   contentNotNull()->loadAllGlobals(fid);
3341 }
3342
3343 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3344 {
3345   contentNotNull()->writeGlobals(fid,opt);
3346 }
3347
3348 /*!
3349  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3350  * or getPflsReallyUsedMulti().
3351  *  \return std::vector<std::string> - a sequence of names of all profiles.
3352  */
3353 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3354 {
3355   return contentNotNull()->getPfls();
3356 }
3357
3358 /*!
3359  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3360  * or getLocsReallyUsedMulti().
3361  *  \return std::vector<std::string> - a sequence of names of all localizations.
3362  */
3363 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3364 {
3365   return contentNotNull()->getLocs();
3366 }
3367
3368 /*!
3369  * Checks if the profile with a given name exists.
3370  *  \param [in] pflName - the profile name of interest.
3371  *  \return bool - \c true if the profile named \a pflName exists.
3372  */
3373 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3374 {
3375   return contentNotNull()->existsPfl(pflName);
3376 }
3377
3378 /*!
3379  * Checks if the localization with a given name exists.
3380  *  \param [in] locName - the localization name of interest.
3381  *  \return bool - \c true if the localization named \a locName exists.
3382  */
3383 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3384 {
3385   return contentNotNull()->existsLoc(locName);
3386 }
3387
3388 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3389 {
3390   return contentNotNull()->createNewNameOfPfl();
3391 }
3392
3393 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3394 {
3395   return contentNotNull()->createNewNameOfLoc();
3396 }
3397
3398 /*!
3399  * Sets the name of a MED file.
3400  *  \param [inout] fileName - the file name.
3401  */
3402 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3403 {
3404   contentNotNull()->setFileName(fileName);
3405 }
3406
3407 /*!
3408  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3409  * in the same order.
3410  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3411  *          Each item of this sequence is a vector containing ids of equal profiles.
3412  */
3413 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3414 {
3415   return contentNotNull()->whichAreEqualProfiles();
3416 }
3417
3418 /*!
3419  * Finds equal localizations.
3420  *  \param [in] eps - a precision used to compare real values of the localizations.
3421  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3422  *          Each item of this sequence is a vector containing ids of equal localizations.
3423  */
3424 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3425 {
3426   return contentNotNull()->whichAreEqualLocs(eps);
3427 }
3428
3429 /*!
3430  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3431  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3432  *        this sequence is a pair whose 
3433  *        - the first item is a vector of profile names to replace by the second item,
3434  *        - the second item is a profile name to replace every profile name of the first item.
3435  */
3436 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3437 {
3438   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3439 }
3440
3441 /*!
3442  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3443  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3444  *        this sequence is a pair whose 
3445  *        - the first item is a vector of localization names to replace by the second item,
3446  *        - the second item is a localization name to replace every localization name of the first item.
3447  */
3448 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3449 {
3450   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3451 }
3452
3453 /*!
3454  * Replaces references to some profiles (a reference is a profile name) by references
3455  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3456  * them-selves accordingly. <br>
3457  * This method is a generalization of changePflName().
3458  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3459  *        this sequence is a pair whose 
3460  *        - the first item is a vector of profile names to replace by the second item,
3461  *        - the second item is a profile name to replace every profile of the first item.
3462  * \sa changePflsRefsNamesGen()
3463  * \sa changePflName()
3464  */
3465 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3466 {
3467   changePflsRefsNamesGen(mapOfModif);
3468   changePflsNamesInStruct(mapOfModif);
3469 }
3470
3471 /*!
3472  * Replaces references to some localizations (a reference is a localization name) by references
3473  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3474  * them-selves accordingly. <br>
3475  * This method is a generalization of changeLocName().
3476  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3477  *        this sequence is a pair whose 
3478  *        - the first item is a vector of localization names to replace by the second item,
3479  *        - the second item is a localization name to replace every localization of the first item.
3480  * \sa changeLocsRefsNamesGen()
3481  * \sa changeLocName()
3482  */
3483 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3484 {
3485   changeLocsRefsNamesGen(mapOfModif);
3486   changeLocsNamesInStruct(mapOfModif);
3487 }
3488
3489 /*!
3490  * Renames the profile having a given name and updates references to this profile.
3491  *  \param [in] oldName - the name of the profile to rename.
3492  *  \param [in] newName - a new name of the profile.
3493  * \sa changePflsNames().
3494  */
3495 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3496 {
3497   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3498   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3499   mapOfModif[0]=p;
3500   changePflsNames(mapOfModif);
3501 }
3502
3503 /*!
3504  * Renames the localization having a given name and updates references to this localization.
3505  *  \param [in] oldName - the name of the localization to rename.
3506  *  \param [in] newName - a new name of the localization.
3507  * \sa changeLocsNames().
3508  */
3509 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3510 {
3511   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3512   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3513   mapOfModif[0]=p;
3514   changeLocsNames(mapOfModif);
3515 }
3516
3517 /*!
3518  * Removes duplicated profiles. Returns a map used to update references to removed 
3519  * profiles via changePflsRefsNamesGen().
3520  * Equal profiles are found using whichAreEqualProfiles().
3521  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3522  *          a sequence describing the performed replacements of profiles. Each element of
3523  *          this sequence is a pair whose
3524  *          - the first item is a vector of profile names replaced by the second item,
3525  *          - the second item is a profile name replacing every profile of the first item.
3526  */
3527 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3528 {
3529   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3530   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3531   int i=0;
3532   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3533     {
3534       std::vector< std::string > tmp((*it).size());
3535       int j=0;
3536       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3537         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3538       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3539       ret[i]=p;
3540       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3541       killProfileIds(tmp2);
3542     }
3543   changePflsRefsNamesGen(ret);
3544   return ret;
3545 }
3546
3547 /*!
3548  * Removes duplicated localizations. Returns a map used to update references to removed 
3549  * localizations via changeLocsRefsNamesGen().
3550  * Equal localizations are found using whichAreEqualLocs().
3551  *  \param [in] eps - a precision used to compare real values of the localizations.
3552  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3553  *          a sequence describing the performed replacements of localizations. Each element of
3554  *          this sequence is a pair whose
3555  *          - the first item is a vector of localization names replaced by the second item,
3556  *          - the second item is a localization name replacing every localization of the first item.
3557  */
3558 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3559 {
3560   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3561   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3562   int i=0;
3563   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3564     {
3565       std::vector< std::string > tmp((*it).size());
3566       int j=0;
3567       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3568         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3569       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3570       ret[i]=p;
3571       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3572       killLocalizationIds(tmp2);
3573     }
3574   changeLocsRefsNamesGen(ret);
3575   return ret;
3576 }
3577
3578 /*!
3579  * Returns number of Gauss points per cell in a given localization.
3580  *  \param [in] locId - an id of the localization of interest.
3581  *  \return int - the number of the Gauss points per cell.
3582  */
3583 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3584 {
3585   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3586 }
3587
3588 /*!
3589  * Returns an id of a localization by its name.
3590  *  \param [in] loc - the localization name of interest.
3591  *  \return int - the id of the localization.
3592  *  \throw If there is no a localization named \a loc.
3593  */
3594 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3595 {
3596   return contentNotNull()->getLocalizationId(loc);
3597 }
3598
3599 /*!
3600  * Returns the name of the MED file.
3601  *  \return const std::string&  - the MED file name.
3602  */
3603 std::string MEDFileFieldGlobsReal::getFileName() const
3604 {
3605   return contentNotNull()->getFileName();
3606 }
3607
3608 /*!
3609  * Returns a localization object by its name.
3610  *  \param [in] locName - the name of the localization of interest.
3611  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3612  *  \throw If there is no a localization named \a locName.
3613  */
3614 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3615 {
3616   return contentNotNull()->getLocalization(locName);
3617 }
3618
3619 /*!
3620  * Returns a localization object by its id.
3621  *  \param [in] locId - the id of the localization of interest.
3622  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3623  *  \throw If there is no a localization with id \a locId.
3624  */
3625 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3626 {
3627   return contentNotNull()->getLocalizationFromId(locId);
3628 }
3629
3630 /*!
3631  * Returns a profile array by its name.
3632  *  \param [in] pflName - the name of the profile of interest.
3633  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3634  *  \throw If there is no a profile named \a pflName.
3635  */
3636 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3637 {
3638   return contentNotNull()->getProfile(pflName);
3639 }
3640
3641 /*!
3642  * Returns a profile array by its id.
3643  *  \param [in] pflId - the id of the profile of interest.
3644  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3645  *  \throw If there is no a profile with id \a pflId.
3646  */
3647 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3648 {
3649   return contentNotNull()->getProfileFromId(pflId);
3650 }
3651
3652 /*!
3653  * Returns a localization object, apt for modification, by its id.
3654  *  \param [in] locId - the id of the localization of interest.
3655  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3656  *          having the id \a locId.
3657  *  \throw If there is no a localization with id \a locId.
3658  */
3659 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3660 {
3661   return contentNotNull()->getLocalizationFromId(locId);
3662 }
3663
3664 /*!
3665  * Returns a localization object, apt for modification, by its name.
3666  *  \param [in] locName - the name of the localization of interest.
3667  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3668  *          having the name \a locName.
3669  *  \throw If there is no a localization named \a locName.
3670  */
3671 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3672 {
3673   return contentNotNull()->getLocalization(locName);
3674 }
3675
3676 /*!
3677  * Returns a profile array, apt for modification, by its name.
3678  *  \param [in] pflName - the name of the profile of interest.
3679  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3680  *  \throw If there is no a profile named \a pflName.
3681  */
3682 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3683 {
3684   return contentNotNull()->getProfile(pflName);
3685 }
3686
3687 /*!
3688  * Returns a profile array, apt for modification, by its id.
3689  *  \param [in] pflId - the id of the profile of interest.
3690  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3691  *  \throw If there is no a profile with id \a pflId.
3692  */
3693 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3694 {
3695   return contentNotNull()->getProfileFromId(pflId);
3696 }
3697
3698 /*!
3699  * Removes profiles given by their ids. No data is updated to track this removal.
3700  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3701  */
3702 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3703 {
3704   contentNotNull()->killProfileIds(pflIds);
3705 }
3706
3707 /*!
3708  * Removes localizations given by their ids. No data is updated to track this removal.
3709  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3710  */
3711 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3712 {
3713   contentNotNull()->killLocalizationIds(locIds);
3714 }
3715
3716 /*!
3717  * Stores a profile array.
3718  *  \param [in] pfl - the profile array to store.
3719  *  \throw If the name of \a pfl is empty.
3720  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3721  *         different ids.
3722  */
3723 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3724 {
3725   contentNotNull()->appendProfile(pfl);
3726 }
3727
3728 /*!
3729  * Adds a new localization of Gauss points.
3730  *  \param [in] locName - the name of the new localization.
3731  *  \param [in] geoType - a geometrical type of the reference cell.
3732  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3733  *         must be \c nbOfNodesPerCell * \c dimOfType.
3734  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3735  *         must be  _wg_.size() * \c dimOfType.
3736  *  \param [in] w - the weights of Gauss points.
3737  *  \throw If \a locName is empty.
3738  *  \throw If a localization with the name \a locName already exists but is
3739  *         different form the new one.
3740  */
3741 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)
3742 {
3743   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3744 }
3745
3746 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3747 {
3748   MEDFileFieldGlobs *g(_globals);
3749   if(!g)
3750     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3751   return g;
3752 }
3753
3754 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3755 {
3756   const MEDFileFieldGlobs *g(_globals);
3757   if(!g)
3758     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3759   return g;
3760 }
3761
3762 //= MEDFileFieldNameScope
3763
3764 MEDFileFieldNameScope::MEDFileFieldNameScope()
3765 {
3766 }
3767
3768 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3769 {
3770 }
3771
3772 /*!
3773  * Returns the name of \a this field.
3774  *  \return std::string - a string containing the field name.
3775  */
3776 std::string MEDFileFieldNameScope::getName() const
3777 {
3778   return _name;
3779 }
3780
3781 /*!
3782  * Sets name of \a this field
3783  *  \param [in] name - the new field name.
3784  */
3785 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3786 {
3787   _name=fieldName;
3788 }
3789
3790 std::string MEDFileFieldNameScope::getDtUnit() const
3791 {
3792   return _dt_unit;
3793 }
3794
3795 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3796 {
3797   _dt_unit=dtUnit;
3798 }
3799
3800 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3801 {
3802   _name=other._name;
3803   _dt_unit=other._dt_unit;
3804 }
3805
3806 //= MEDFileAnyTypeField1TSWithoutSDA
3807
3808 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3809 {
3810   _field_per_mesh.resize(other._field_per_mesh.size());
3811   std::size_t i=0;
3812   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3813     {
3814       if((const MEDFileFieldPerMesh *)*it)
3815         _field_per_mesh[i]=(*it)->deepCopy(this);
3816     }
3817 }
3818
3819 /*!
3820  * Prints a string describing \a this field into a stream. This string is outputted 
3821  * by \c print Python command.
3822  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3823  *  \param [in,out] oss - the out stream.
3824  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3825  *          info id printed, else, not.
3826  */
3827 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3828 {
3829   std::string startOfLine(bkOffset,' ');
3830   oss << startOfLine << "Field ";
3831   if(bkOffset==0)
3832     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3833   oss << "on one time Step ";
3834   if(f1tsId>=0)
3835     oss << "(" << f1tsId << ") ";
3836   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3837   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3838   const DataArray *arr=getUndergroundDataArray();
3839   if(arr)
3840     {
3841       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3842       if(f1tsId<0)
3843         {
3844           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3845           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3846             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3847         }
3848       if(arr->isAllocated())
3849         {
3850           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3851         }
3852       else
3853         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3854     }
3855   else
3856     {
3857       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3858     }
3859   oss << startOfLine << "----------------------" << std::endl;
3860   if(!_field_per_mesh.empty())
3861     {
3862       int i=0;
3863       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3864         {
3865           const MEDFileFieldPerMesh *cur=(*it2);
3866           if(cur)
3867             cur->simpleRepr(bkOffset,oss,i);
3868           else
3869             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3870         }
3871     }
3872   else
3873     {
3874       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3875     }
3876   oss << startOfLine << "----------------------" << std::endl;
3877 }
3878
3879 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3880 {
3881   const DataArray *arr(getUndergroundDataArray());
3882   if(!arr)
3883     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3884   int nbOfCompo=arr->getNumberOfComponents();
3885   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3886   for(int i=0;i<nbOfCompo;i++)
3887     {
3888       ret[i]=deepCopy();
3889       std::vector<int> v(1,i);
3890       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3891       ret[i]->setArray(arr2);
3892     }
3893   return ret;
3894 }
3895
3896 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)
3897 {
3898 }
3899
3900 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3901 {
3902 }
3903
3904 /*!
3905  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3906  * empty. Returns -1 if this in on nodes.
3907  *  \return int - the dimension of \a this.
3908  */
3909 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3910 {
3911   int ret=-2;
3912   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3913     (*it)->getDimension(ret);
3914   return ret;
3915 }
3916
3917 /*!
3918  * Returns the mesh name.
3919  *  \return std::string - a string holding the mesh name.
3920  *  \throw If \c _field_per_mesh.empty()
3921  */
3922 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3923 {
3924   if(_field_per_mesh.empty())
3925     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3926   return _field_per_mesh[0]->getMeshName();
3927 }
3928
3929 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3930 {
3931   std::string oldName(getMeshName());
3932   std::vector< std::pair<std::string,std::string> > v(1);
3933   v[0].first=oldName; v[0].second=newMeshName;
3934   changeMeshNames(v);
3935 }
3936
3937 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3938 {
3939   bool ret=false;
3940   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3941     {
3942       MEDFileFieldPerMesh *cur(*it);
3943       if(cur)
3944         ret=cur->changeMeshNames(modifTab) || ret;
3945     }
3946   return ret;
3947 }
3948
3949 /*!
3950  * Returns the number of iteration of the state of underlying mesh.
3951  *  \return int - the iteration number.
3952  *  \throw If \c _field_per_mesh.empty()
3953  */
3954 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3955 {
3956   if(_field_per_mesh.empty())
3957     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3958   return _field_per_mesh[0]->getMeshIteration();
3959 }
3960
3961 /*!
3962  * Returns the order number of iteration of the state of underlying mesh.
3963  *  \return int - the order number.
3964  *  \throw If \c _field_per_mesh.empty()
3965  */
3966 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3967 {
3968   if(_field_per_mesh.empty())
3969     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3970   return _field_per_mesh[0]->getMeshOrder();
3971 }
3972
3973 /*!
3974  * Checks if \a this field is tagged by a given iteration number and a given
3975  * iteration order number.
3976  *  \param [in] iteration - the iteration number of interest.
3977  *  \param [in] order - the iteration order number of interest.
3978  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
3979  *          \a this->getOrder() == \a order.
3980  */
3981 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3982 {
3983   return iteration==_iteration && order==_order;
3984 }
3985
3986 /*!
3987  * Returns number of iteration and order number of iteration when
3988  * \a this field has been calculated.
3989  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
3990  *          order number.
3991  */
3992 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3993 {
3994   std::pair<int,int> p;
3995   fillIteration(p);
3996   return p;
3997 }
3998
3999 /*!
4000  * Returns number of iteration and order number of iteration when
4001  * \a this field has been calculated.
4002  *  \param [in,out] p - a pair returning the iteration number and the iteration
4003  *          order number.
4004  */
4005 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4006 {
4007   p.first=_iteration;
4008   p.second=_order;
4009 }
4010
4011 /*!
4012  * Returns all types of spatial discretization of \a this field.
4013  *  \param [in,out] types - a sequence of types of \a this field.
4014  */
4015 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4016 {
4017   std::set<TypeOfField> types2;
4018   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4019     {
4020       (*it)->fillTypesOfFieldAvailable(types2);
4021     }
4022   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4023   std::copy(types2.begin(),types2.end(),bi);
4024 }
4025
4026 /*!
4027  * Returns all types of spatial discretization of \a this field.
4028  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4029  *          of \a this field.
4030  */
4031 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4032 {
4033   std::vector<TypeOfField> ret;
4034   fillTypesOfFieldAvailable(ret);
4035   return ret;
4036 }
4037
4038 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4039 {
4040   std::vector<std::string> ret;
4041   std::set<std::string> ret2;
4042   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4043     {
4044       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4045       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4046         if(ret2.find(*it2)==ret2.end())
4047           {
4048             ret.push_back(*it2);
4049             ret2.insert(*it2);
4050           }
4051     }
4052   return ret;
4053 }
4054
4055 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4056 {
4057   std::vector<std::string> ret;
4058   std::set<std::string> ret2;
4059   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4060     {
4061       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4062       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4063         if(ret2.find(*it2)==ret2.end())
4064           {
4065             ret.push_back(*it2);
4066             ret2.insert(*it2);
4067           }
4068     }
4069   return ret;
4070 }
4071
4072 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4073 {
4074   std::vector<std::string> ret;
4075   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4076     {
4077       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4078       ret.insert(ret.end(),tmp.begin(),tmp.end());
4079     }
4080   return ret;
4081 }
4082
4083 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4084 {
4085   std::vector<std::string> ret;
4086   std::set<std::string> ret2;
4087   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4088     {
4089       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4090       ret.insert(ret.end(),tmp.begin(),tmp.end());
4091     }
4092   return ret;
4093 }
4094
4095 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4096 {
4097   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4098     (*it)->changePflsRefsNamesGen(mapOfModif);
4099 }
4100
4101 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4102 {
4103   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4104     (*it)->changeLocsRefsNamesGen(mapOfModif);
4105 }
4106
4107 /*!
4108  * Returns all attributes of parts of \a this field lying on a given mesh.
4109  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4110  * item of every of returned sequences refers to the _i_-th part of \a this field.
4111  * Thus all sequences returned by this method are of the same length equal to number
4112  * of different types of supporting entities.<br>
4113  * A field part can include sub-parts with several different spatial discretizations,
4114  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4115  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4116  * of a nested sequence corresponds to a type of spatial discretization.<br>
4117  * This method allows for iteration over MEDFile DataStructure without any overhead.
4118  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4119  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4120  *          not checked if \a mname == \c NULL).
4121  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4122  *          a field part is returned. 
4123  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4124  *          This sequence is of the same length as \a types. 
4125  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4126  *          discretization. A profile name can be empty.
4127  *          Length of this and of nested sequences is the same as that of \a typesF.
4128  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4129  *          discretization. A localization name can be empty.
4130  *          Length of this and of nested sequences is the same as that of \a typesF.
4131  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4132  *          of ids of tuples within the data array, per each type of spatial
4133  *          discretization within one mesh entity type. 
4134  *          Length of this and of nested sequences is the same as that of \a typesF.
4135  *  \throw If no field is lying on \a mname.
4136  */
4137 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
4138 {
4139   int meshId=0;
4140   if(!mname.empty())
4141     meshId=getMeshIdFromMeshName(mname);
4142   else
4143     if(_field_per_mesh.empty())
4144       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4145   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4146 }
4147
4148 /*!
4149  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4150  * maximal absolute dimension and values returned via the out parameter \a levs are 
4151  * dimensions relative to the maximal absolute dimension. <br>
4152  * This method is designed for MEDFileField1TS instances that have a discretization
4153  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
4154  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
4155  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4156  * Only these 3 discretizations will be taken into account here. If \a this is
4157  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4158  * This method is useful to make the link between the dimension of the underlying mesh
4159  * and the levels of \a this, because it is possible that the highest dimension of \a this
4160  * field is not equal to the dimension of the underlying mesh.
4161  * 
4162  * Let's consider the following case:
4163  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4164  * TETRA4, HEXA8, TRI3 and SEG2.
4165  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4166  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4167  *
4168  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4169  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4170  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4171  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4172  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4173  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4174  * For example<br>
4175  * to retrieve the highest level of
4176  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
4177  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4178  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4179  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4180  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4181  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4182  *          not checked if \a mname == \c NULL).
4183  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4184  *          absolute one. They are in decreasing order. This sequence is cleared before
4185  *          filling it in.
4186  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
4187  *  \throw If no field is lying on \a mname.
4188  */
4189 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4190 {
4191   levs.clear();
4192   int meshId=getMeshIdFromMeshName(mname);
4193   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4194   std::vector< std::vector<TypeOfField> > typesF;
4195   std::vector< std::vector<std::string> > pfls, locs;
4196   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4197   if(types.empty())
4198     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4199   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4200   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4201     return -1;
4202   st.erase(INTERP_KERNEL::NORM_ERROR);
4203   std::set<int> ret1;
4204   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4205     {
4206       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4207       ret1.insert((int)cm.getDimension());
4208     }
4209   int ret=*std::max_element(ret1.begin(),ret1.end());
4210   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4211   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4212   return ret;
4213 }
4214
4215 /*!
4216  * \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.
4217  * \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.
4218  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4219  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4220  */
4221 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4222 {
4223   int mid=getMeshIdFromMeshName(mName);
4224   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4225 }
4226
4227 /*!
4228  * \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.
4229  * \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.
4230  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
4231  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4232  */
4233 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4234 {
4235   int mid=getMeshIdFromMeshName(mName);
4236   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4237 }
4238
4239 /*!
4240  * \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.
4241  */
4242 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4243 {
4244   if(_field_per_mesh.empty())
4245     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4246   if(mName.empty())
4247     return 0;
4248   std::string mName2(mName);
4249   int ret=0;
4250   std::vector<std::string> msg;
4251   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4252     if(mName2==(*it)->getMeshName())
4253       return ret;
4254     else
4255       msg.push_back((*it)->getMeshName());
4256   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4257   oss << "Possible meshes are : ";
4258   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4259     oss << "\"" << (*it2) << "\" ";
4260   throw INTERP_KERNEL::Exception(oss.str().c_str());
4261 }
4262
4263 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4264 {
4265   if(!mesh)
4266     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4267   std::string tmp(mesh->getName());
4268   if(tmp.empty())
4269     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4270   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4271   int i=0;
4272   for(;it!=_field_per_mesh.end();it++,i++)
4273     {
4274       if((*it)->getMeshName()==tmp)
4275         return i;
4276     }
4277   int sz=_field_per_mesh.size();
4278   _field_per_mesh.resize(sz+1);
4279   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4280   return sz;
4281 }
4282
4283 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4284                                                                    MEDFileFieldGlobsReal& glob)
4285 {
4286   bool ret=false;
4287   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4288     {
4289       MEDFileFieldPerMesh *fpm(*it);
4290       if(fpm)
4291         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4292     }
4293   return ret;
4294 }
4295
4296 /*!
4297  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4298  * splitting that leads to single spatial discretization of this.
4299  *
4300  * \sa splitMultiDiscrPerGeoTypes
4301  */
4302 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4303 {
4304   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4305   std::vector< std::vector<TypeOfField> > typesF;
4306   std::vector< std::vector<std::string> > pfls,locs;
4307   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4308   std::set<TypeOfField> allEnt;
4309   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4310     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4311       allEnt.insert(*it2);
4312   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4313   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4314   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4315     {
4316       std::vector< std::pair<int,int> > its;
4317       ret[i]=shallowCpy();
4318       int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4319       ret[i]->updateData(newLgth,its);
4320     }
4321   return ret;
4322 }
4323
4324 /*!
4325  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4326  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4327  *
4328  * \sa splitDiscretizations
4329  */
4330 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4331 {
4332   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4333   std::vector< std::vector<TypeOfField> > typesF;
4334   std::vector< std::vector<std::string> > pfls,locs;
4335   std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4336   std::set<TypeOfField> allEnt;
4337   std::size_t nbOfMDPGT(0),ii(0);
4338   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4339     {
4340       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4341       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4342         allEnt.insert(*it2);
4343     }
4344   if(allEnt.size()!=1)
4345     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4346   if(nbOfMDPGT==0)
4347     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4348   if(nbOfMDPGT==1)
4349     {
4350       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4351       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4352       return ret0;
4353     }
4354   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4355   for(std::size_t i=0;i<nbOfMDPGT;i++)
4356     {
4357       std::vector< std::pair<int,int> > its;
4358       ret[i]=shallowCpy();
4359       int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4360       ret[i]->updateData(newLgth,its);
4361     }
4362   return ret;
4363 }
4364
4365 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4366 {
4367   int globalCounter(0);
4368   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4369     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4370   return globalCounter;
4371 }
4372
4373 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4374 {
4375   int globalCounter(0);
4376   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4377     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4378   return globalCounter;
4379 }
4380
4381 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4382 {
4383   if(_nb_of_tuples_to_be_allocated>=0)
4384     {
4385       _nb_of_tuples_to_be_allocated=newLgth;
4386       const DataArray *oldArr(getUndergroundDataArray());
4387       if(oldArr)
4388         {
4389           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4390           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4391           setArray(newArr);
4392           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4393         }
4394       return ;
4395     }
4396   if(_nb_of_tuples_to_be_allocated==-1)
4397     return ;
4398   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4399     {
4400       const DataArray *oldArr(getUndergroundDataArray());
4401       if(!oldArr || !oldArr->isAllocated())
4402         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4403       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4404       newArr->alloc(newLgth,getNumberOfComponents());
4405       if(oldArr)
4406         newArr->copyStringInfoFrom(*oldArr);
4407       int pos=0;
4408       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4409         {
4410           if((*it).second<(*it).first)
4411             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4412           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4413           pos+=(*it).second-(*it).first;
4414         }
4415       setArray(newArr);
4416       return ;
4417     }
4418   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4419 }
4420
4421 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4422 {
4423   if(_field_per_mesh.empty())
4424     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4425   if(_field_per_mesh.size()>1)
4426     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4427   _field_per_mesh[0]->copyOptionsFrom(opts);
4428   _field_per_mesh[0]->writeLL(fid,nasc);
4429 }
4430
4431 /*!
4432  * 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.
4433  * If false is returned the memory allocation is not required.
4434  */
4435 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4436 {
4437   if(_nb_of_tuples_to_be_allocated>=0)
4438     {
4439       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4440       _nb_of_tuples_to_be_allocated=-2;
4441       return true;
4442     }
4443   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4444     return false;
4445   if(_nb_of_tuples_to_be_allocated==-1)
4446     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4447   if(_nb_of_tuples_to_be_allocated<-3)
4448     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4449   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4450 }
4451
4452 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4453 {
4454   med_int numdt,numit;
4455   med_float dt;
4456   med_int nmesh;
4457   med_bool localMesh;
4458   med_int meshnumdt,meshnumit;
4459   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4460   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4461   MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4462   if(_iteration!=numdt || _order!=numit)
4463     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4464   _field_per_mesh.resize(nmesh);
4465   //
4466   MEDFileMesh *mm(0);
4467   if(ms)
4468     {
4469       std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4470       mm=ms->getMeshWithName(meshNameCpp);
4471     }
4472   //
4473   for(int i=0;i<nmesh;i++)
4474     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4475   _nb_of_tuples_to_be_allocated=0;
4476   for(int i=0;i<nmesh;i++)
4477     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4478 }
4479
4480 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4481 {
4482   allocIfNecessaryTheArrayToReceiveDataFromFile();
4483   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4484     (*it)->loadBigArraysRecursively(fid,nasc);
4485 }
4486
4487 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4488 {
4489   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4490     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4491       (*it)->loadBigArraysRecursively(fid,nasc);
4492 }
4493
4494 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4495 {
4496   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4497   loadBigArraysRecursively(fid,nasc);
4498 }
4499
4500 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4501 {
4502   DataArray *thisArr(getUndergroundDataArray());
4503   if(thisArr && thisArr->isAllocated())
4504     {
4505       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4506       thisArr->desallocate();
4507     }
4508 }
4509
4510 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4511 {
4512   return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4513 }
4514
4515 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4516 {
4517   std::vector<const BigMemoryObject *> ret;
4518   if(getUndergroundDataArray())
4519     ret.push_back(getUndergroundDataArray());
4520   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4521     ret.push_back((const MEDFileFieldPerMesh *)*it);
4522   return ret;
4523 }
4524
4525 /*!
4526  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4527  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4528  * "Sort By Type"), if not, an exception is thrown. 
4529  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4530  *  \param [in] arr - the array of values.
4531  *  \param [in,out] glob - the global data where profiles and localization present in
4532  *          \a field, if any, are added.
4533  *  \throw If the name of \a field is empty.
4534  *  \throw If the data array of \a field is not set.
4535  *  \throw If \a this->_arr is already allocated but has different number of components
4536  *         than \a field.
4537  *  \throw If the underlying mesh of \a field has no name.
4538  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4539  */
4540 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4541 {
4542   const MEDCouplingMesh *mesh=field->getMesh();
4543   //
4544   TypeOfField type=field->getTypeOfField();
4545   std::vector<DataArrayInt *> dummy;
4546   int start=copyTinyInfoFrom(field,arr);
4547   int pos=addNewEntryIfNecessary(mesh);
4548   if(type!=ON_NODES)
4549     {
4550       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4551       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4552     }
4553   else
4554     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4555 }
4556
4557 /*!
4558  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4559  * of a given mesh are used as the support of the given field (a real support is not used). 
4560  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4561  * Order of underlying mesh entities of the given field specified by \a profile parameter
4562  * is not prescribed; this method permutes field values to have them sorted by element
4563  * type as required for writing to MED file. A new profile is added only if no equal
4564  * profile is missing. 
4565  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4566  *  \param [in] arrOfVals - the values of the field \a field used.
4567  *  \param [in] mesh - the supporting mesh of \a field.
4568  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4569  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4570  *  \param [in,out] glob - the global data where profiles and localization present in
4571  *          \a field, if any, are added.
4572  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4573  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4574  *  \throw If the data array of \a field is not set.
4575  *  \throw If \a this->_arr is already allocated but has different number of components
4576  *         than \a field.
4577  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4578  *  \sa setFieldNoProfileSBT()
4579  */
4580 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4581 {
4582   if(!field)
4583     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4584   if(!arrOfVals || !arrOfVals->isAllocated())
4585     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4586   TypeOfField type=field->getTypeOfField();
4587   std::vector<DataArrayInt *> idsInPflPerType;
4588   std::vector<DataArrayInt *> idsPerType;
4589   std::vector<int> code,code2;
4590   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4591   if(type!=ON_NODES)
4592     {
4593       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4594       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4595       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4596       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4597       // start of check
4598       MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4599       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4600       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4601         {
4602           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4603           throw INTERP_KERNEL::Exception(oss.str().c_str());
4604         }
4605       // end of check
4606       int start=copyTinyInfoFrom(field,arrOfVals);
4607       code2=m->getDistributionOfTypes();
4608       //
4609       int pos=addNewEntryIfNecessary(m);
4610       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4611     }
4612   else
4613     {
4614       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4615         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4616       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4617       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4618       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4619       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4620         {
4621           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4622           throw INTERP_KERNEL::Exception(oss.str().c_str());
4623         }
4624       int start=copyTinyInfoFrom(field,arrOfVals);
4625       int pos=addNewEntryIfNecessary(m);
4626       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4627     }
4628 }
4629
4630 /*!
4631  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4632  */
4633 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4634 {
4635   if(_nb_of_tuples_to_be_allocated>=0)
4636     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 !");
4637   DataArray *arr(getOrCreateAndGetArray());
4638   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4639   _nb_of_tuples_to_be_allocated=-3;
4640 }
4641
4642 /*!
4643  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4644  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4645  * larger by the size of \a field. Returns an id of the first not filled
4646  * tuple of \a this->_arr.
4647  *  \param [in] field - the field to copy the info on components and the name from.
4648  *  \return int - the id of first not initialized tuple of \a this->_arr.
4649  *  \throw If the name of \a field is empty.
4650  *  \throw If the data array of \a field is not set.
4651  *  \throw If \a this->_arr is already allocated but has different number of components
4652  *         than \a field.
4653  */
4654 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4655 {
4656   if(!field)
4657     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4658   std::string name(field->getName());
4659   setName(name.c_str());
4660   setDtUnit(field->getTimeUnit());
4661   if(name.empty())
4662     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4663   if(!arr)
4664     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4665   if(!arr->isAllocated())
4666     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4667   _dt=field->getTime(_iteration,_order);
4668   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4669   if(!getOrCreateAndGetArray()->isAllocated())
4670     {
4671       allocNotFromFile(arr->getNumberOfTuples());
4672       return 0;
4673     }
4674   else
4675     {
4676       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4677       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4678       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4679       _nb_of_tuples_to_be_allocated=-3;
4680       return oldNbOfTuples;
4681     }
4682 }
4683
4684 /*!
4685  * Returns number of components in \a this field
4686  *  \return int - the number of components.
4687  */
4688 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4689 {
4690   return getOrCreateAndGetArray()->getNumberOfComponents();
4691 }
4692
4693 /*!
4694  * Change info on components in \a this.
4695  * \throw If size of \a infos is not equal to the number of components already in \a this.
4696  */
4697 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4698 {
4699   DataArray *arr=getOrCreateAndGetArray();
4700   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4701 }
4702
4703 /*!
4704  * Returns info on components of \a this field.
4705  *  \return const std::vector<std::string>& - a sequence of strings each being an
4706  *          information on _i_-th component.
4707  */
4708 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4709 {
4710   const DataArray *arr=getOrCreateAndGetArray();
4711   return arr->getInfoOnComponents();
4712 }
4713
4714 /*!
4715  * Returns a mutable info on components of \a this field.
4716  *  \return std::vector<std::string>& - a sequence of strings each being an
4717  *          information on _i_-th component.
4718  */
4719 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4720 {
4721   DataArray *arr=getOrCreateAndGetArray();
4722   return arr->getInfoOnComponents();
4723 }
4724
4725 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4726 {
4727   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4728     {
4729       const MEDFileFieldPerMesh *fpm(*it);
4730       if(!fpm)
4731         continue;
4732       if(fpm->presenceOfMultiDiscPerGeoType())
4733         return true;
4734     }
4735   return false;
4736 }
4737
4738 /*!
4739  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4740  *  \param [in] type - a spatial discretization of the new field.
4741  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4742  *  \param [in] mName - a name of the supporting mesh.
4743  *  \param [in] renumPol - specifies how to permute values of the result field according to
4744  *          the optional numbers of cells and nodes, if any. The valid values are
4745  *          - 0 - do not permute.
4746  *          - 1 - permute cells.
4747  *          - 2 - permute nodes.
4748  *          - 3 - permute cells and nodes.
4749  *
4750  *  \param [in] glob - the global data storing profiles and localization.
4751  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4752  *          caller is to delete this field using decrRef() as it is no more needed. 
4753  *  \throw If the MED file is not readable.
4754  *  \throw If there is no mesh named \a mName in the MED file.
4755  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4756  *  \throw If no field of \a this is lying on the mesh \a mName.
4757  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4758  */
4759 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4760 {
4761   MCAuto<MEDFileMesh> mm;
4762   if(mName.empty())
4763     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4764   else
4765     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4766   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4767 }
4768
4769 /*!
4770  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4771  *  \param [in] type - a spatial discretization of the new field.
4772  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4773  *  \param [in] renumPol - specifies how to permute values of the result field according to
4774  *          the optional numbers of cells and nodes, if any. The valid values are
4775  *          - 0 - do not permute.
4776  *          - 1 - permute cells.
4777  *          - 2 - permute nodes.
4778  *          - 3 - permute cells and nodes.
4779  *
4780  *  \param [in] glob - the global data storing profiles and localization.
4781  *  \param [in] mesh - the supporting mesh.
4782  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4783  *          caller is to delete this field using decrRef() as it is no more needed. 
4784  *  \throw If the MED file is not readable.
4785  *  \throw If no field of \a this is lying on \a mesh.
4786  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4787  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4788  */
4789 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4790 {
4791   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4792   const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4793   const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4794   if(meshDimRelToMax==1)
4795     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4796   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4797 }
4798
4799 /*!
4800  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4801  * given mesh. 
4802  *  \param [in] type - a spatial discretization of the new field.
4803  *  \param [in] mName - a name of the supporting mesh.
4804  *  \param [in] renumPol - specifies how to permute values of the result field according to
4805  *          the optional numbers of cells and nodes, if any. The valid values are
4806  *          - 0 - do not permute.
4807  *          - 1 - permute cells.
4808  *          - 2 - permute nodes.
4809  *          - 3 - permute cells and nodes.
4810  *
4811  *  \param [in] glob - the global data storing profiles and localization.
4812  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4813  *          caller is to delete this field using decrRef() as it is no more needed. 
4814  *  \throw If the MED file is not readable.
4815  *  \throw If there is no mesh named \a mName in the MED file.
4816  *  \throw If there are no mesh entities in the mesh.
4817  *  \throw If no field values of the given \a type are available.
4818  */
4819 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4820 {
4821   MCAuto<MEDFileMesh> mm;
4822   if(mName.empty())
4823     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4824   else
4825     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4826   int absDim=getDimension();
4827   int meshDimRelToMax=absDim-mm->getMeshDimension();
4828   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4829 }
4830
4831 /*!
4832  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4833  *  \param [in] type - a spatial discretization of the new field.
4834  *  \param [in] renumPol - specifies how to permute values of the result field according to
4835  *          the optional numbers of cells and nodes, if any. The valid values are
4836  *          - 0 - do not permute.
4837  *          - 1 - permute cells.
4838  *          - 2 - permute nodes.
4839  *          - 3 - permute cells and nodes.
4840  *
4841  *  \param [in] glob - the global data storing profiles and localization.
4842  *  \param [in] mesh - the supporting mesh.
4843  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4844  *         field according to \a renumPol.
4845  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4846  *         field according to \a renumPol.
4847  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4848  *          caller is to delete this field using decrRef() as it is no more needed. 
4849  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4850  *  \throw If no field of \a this is lying on \a mesh.
4851  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4852  */
4853 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
4854 {
4855   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4856   int meshId=getMeshIdFromMeshName(mesh->getName());
4857   bool isPfl=false;
4858   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4859   switch(renumPol)
4860   {
4861     case 0:
4862       {
4863         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4864         return ret.retn();
4865       }
4866     case 3:
4867     case 1:
4868       {
4869         if(isPfl)
4870           throw INTERP_KERNEL::Exception(msg1);
4871         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4872         if(cellRenum)
4873           {
4874             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4875               {
4876                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4877                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4878                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4879               }
4880             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4881             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4882             std::vector<DataArray *> arrOut2(1,arrOut);
4883             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4884             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4885             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4886           }
4887         if(renumPol==1)
4888           return ret.retn();
4889       }
4890     case 2:
4891       {
4892         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4893         if(isPfl)
4894           throw INTERP_KERNEL::Exception(msg1);
4895         if(nodeRenum)
4896           {
4897             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4898               {
4899                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4900                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4901                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4902               }
4903             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4904             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4905               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4906             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4907           }
4908         return ret.retn();
4909       }
4910     default:
4911       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4912   }
4913 }
4914
4915 /*!
4916  * Returns values and a profile of the field of a given type lying on a given support.
4917  *  \param [in] type - a spatial discretization of the field.
4918  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4919  *  \param [in] mesh - the supporting mesh.
4920  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4921  *          field of interest lies on. If the field lies on all entities of the given
4922  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4923  *          using decrRef() as it is no more needed.  
4924  *  \param [in] glob - the global data storing profiles and localization.
4925  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4926  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4927  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4928  *  \throw If no field of \a this is lying on \a mesh.
4929  *  \throw If no field values of the given \a type are available.
4930  */
4931 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4932 {
4933   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4934   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4935   MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4936   ret->setName(nasc.getName().c_str());
4937   return ret.retn();
4938 }
4939
4940 //= MEDFileField1TSWithoutSDA
4941
4942 /*!
4943  * Throws if a given value is not a valid (non-extended) relative dimension.
4944  *  \param [in] meshDimRelToMax - the relative dimension value.
4945  *  \throw If \a meshDimRelToMax > 0.
4946  */
4947 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4948 {
4949   if(meshDimRelToMax>0)
4950     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4951 }
4952
4953 /*!
4954  * Checks if elements of a given mesh are in the order suitable for writing 
4955  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4956  * vector describing types of elements and their number.
4957  *  \param [in] mesh - the mesh to check.
4958  *  \return std::vector<int> - a vector holding for each element type (1) item of
4959  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
4960  *          These values are in full-interlace mode.
4961  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4962  */
4963 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4964 {
4965   if(!mesh)
4966     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4967   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4968   int nbOfTypes=geoTypes.size();
4969   std::vector<int> code(3*nbOfTypes);
4970   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
4971   arr1->alloc(nbOfTypes,1);
4972   int *arrPtr=arr1->getPointer();
4973   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4974   for(int i=0;i<nbOfTypes;i++,it++)
4975     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4976   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4977   const int *arrPtr2=arr2->getConstPointer();
4978   int i=0;
4979   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4980     {
4981       int pos=arrPtr2[i];
4982       int nbCells=mesh->getNumberOfCellsWithType(*it);
4983       code[3*pos]=(int)(*it);
4984       code[3*pos+1]=nbCells;
4985       code[3*pos+2]=-1;//no profiles
4986     }
4987   std::vector<const DataArrayInt *> idsPerType;//no profiles
4988   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4989   if(da)
4990     {
4991       da->decrRef();
4992       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4993     }
4994   return code;
4995 }
4996
4997 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4998 {
4999   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5000 }
5001
5002 /*!
5003  * Returns all attributes and values of parts of \a this field lying on a given mesh.
5004  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5005  * item of every of returned sequences refers to the _i_-th part of \a this field.
5006  * Thus all sequences returned by this method are of the same length equal to number
5007  * of different types of supporting entities.<br>
5008  * A field part can include sub-parts with several different spatial discretizations,
5009  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5010  * for example. Hence, some of the returned sequences contains nested sequences, and an item
5011  * of a nested sequence corresponds to a type of spatial discretization.<br>
5012  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5013  * The overhead is due to selecting values into new instances of DataArrayDouble.
5014  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5015  *          for the case with only one underlying mesh. (Actually, the number of meshes is
5016  *          not checked if \a mname == \c NULL).
5017  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5018  *          a field part is returned. 
5019  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5020  *          A field part can include sub-parts with several different spatial discretizations,
5021  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
5022  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5023  *          This sequence is of the same length as \a types. 
5024  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5025  *          discretization. A profile name can be empty.
5026  *          Length of this and of nested sequences is the same as that of \a typesF.
5027  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
5028  *          discretization. A localization name can be empty.
5029  *          Length of this and of nested sequences is the same as that of \a typesF.
5030  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5031  *          per each type of spatial discretization within one mesh entity type.
5032  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5033  *          Length of this and of nested sequences is the same as that of \a typesF.
5034  *  \throw If no field is lying on \a mname.
5035  */
5036 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
5037 {
5038   int meshId=0;
5039   if(!mname.empty())
5040     meshId=getMeshIdFromMeshName(mname);
5041   else
5042     if(_field_per_mesh.empty())
5043       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5044   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5045   int nbOfRet=ret0.size();
5046   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5047   for(int i=0;i<nbOfRet;i++)
5048     {
5049       const std::vector< std::pair<int,int> >& p=ret0[i];
5050       int nbOfRet1=p.size();
5051       ret[i].resize(nbOfRet1);
5052       for(int j=0;j<nbOfRet1;j++)
5053         {
5054           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5055           ret[i][j]=tmp;
5056         }
5057     }
5058   return ret;
5059 }
5060
5061 /*!
5062  * Returns a pointer to the underground DataArrayDouble instance. So the
5063  * caller should not decrRef() it. This method allows for a direct access to the field
5064  * values. This method is quite unusable if there is more than a nodal field or a cell
5065  * field on single geometric cell type. 
5066  *  \return DataArrayDouble * - the pointer to the field values array.
5067  */
5068 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5069 {
5070   const DataArrayDouble *ret=_arr;
5071   if(ret)
5072     return const_cast<DataArrayDouble *>(ret);
5073   else
5074     return 0;
5075 }
5076
5077 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5078 {
5079   return TYPE_STR;
5080 }
5081
5082 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5083 {
5084   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5085   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5086   ret->deepCpyLeavesFrom(*this);
5087   const DataArrayDouble *arr(_arr);
5088   if(arr)
5089     {
5090       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5091       ret->setArray(arr2);
5092     }
5093   return ret.retn();
5094 }
5095
5096 /*!
5097  * Returns a pointer to the underground DataArrayDouble instance. So the
5098  * caller should not decrRef() it. This method allows for a direct access to the field
5099  * values. This method is quite unusable if there is more than a nodal field or a cell
5100  * field on single geometric cell type. 
5101  *  \return DataArrayDouble * - the pointer to the field values array.
5102  */
5103 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5104 {
5105   return getUndergroundDataArrayDouble();
5106 }
5107
5108 /*!
5109  * Returns a pointer to the underground DataArrayDouble instance and a
5110  * sequence describing parameters of a support of each part of \a this field. The
5111  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5112  * direct access to the field values. This method is intended for the field lying on one
5113  * mesh only.
5114  *  \param [in,out] entries - the sequence describing parameters of a support of each
5115  *         part of \a this field. Each item of this sequence consists of two parts. The
5116  *         first part describes a type of mesh entity and an id of discretization of a
5117  *         current field part. The second part describes a range of values [begin,end)
5118  *         within the returned array relating to the current field part.
5119  *  \return DataArrayDouble * - the pointer to the field values array.
5120  *  \throw If the number of underlying meshes is not equal to 1.
5121  *  \throw If no field values are available.
5122  *  \sa getUndergroundDataArray()
5123  */
5124 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5125 {
5126   if(_field_per_mesh.size()!=1)
5127     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5128   if(_field_per_mesh[0]==0)
5129     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5130   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5131   return getUndergroundDataArrayDouble();
5132 }
5133
5134 /*!
5135  * Returns a pointer to the underground DataArrayDouble instance and a
5136  * sequence describing parameters of a support of each part of \a this field. The
5137  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5138  * direct access to the field values. This method is intended for the field lying on one
5139  * mesh only.
5140  *  \param [in,out] entries - the sequence describing parameters of a support of each
5141  *         part of \a this field. Each item of this sequence consists of two parts. The
5142  *         first part describes a type of mesh entity and an id of discretization of a
5143  *         current field part. The second part describes a range of values [begin,end)
5144  *         within the returned array relating to the current field part.
5145  *  \return DataArrayDouble * - the pointer to the field values array.
5146  *  \throw If the number of underlying meshes is not equal to 1.
5147  *  \throw If no field values are available.
5148  *  \sa getUndergroundDataArray()
5149  */
5150 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5151 {
5152   return getUndergroundDataArrayDoubleExt(entries);
5153 }
5154
5155 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5156 {
5157   DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5158   arr->setInfoAndChangeNbOfCompo(infos);
5159 }
5160
5161 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5162 {
5163 }
5164
5165 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5166 {
5167   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5168   ret->deepCpyLeavesFrom(*this);
5169   return ret.retn();
5170 }
5171
5172 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5173 {
5174   MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5175   if((const DataArrayDouble *)_arr)
5176     ret->_arr=_arr->deepCopy();
5177   return ret.retn();
5178 }
5179
5180 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5181 {
5182   if(!arr)
5183     {
5184       _nb_of_tuples_to_be_allocated=-1;
5185       _arr=0;
5186       return ;
5187     }
5188   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5189   if(!arrC)
5190     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5191   else
5192     _nb_of_tuples_to_be_allocated=-3;
5193   arrC->incrRef();
5194   _arr=arrC;
5195 }
5196
5197 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5198 {
5199   return DataArrayDouble::New();
5200 }
5201
5202 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5203 {
5204   DataArrayDouble *ret=_arr;
5205   if(ret)
5206     return ret;
5207   _arr=DataArrayDouble::New();
5208   return _arr;
5209 }
5210
5211 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5212 {
5213   return getOrCreateAndGetArrayDouble();
5214 }
5215
5216 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5217 {
5218   const DataArrayDouble *ret=_arr;
5219   if(ret)
5220     return ret;
5221   DataArrayDouble *ret2=DataArrayDouble::New();
5222   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5223   return ret2;
5224 }
5225
5226 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5227 {
5228   return getOrCreateAndGetArrayDouble();
5229 }
5230
5231 //= MEDFileIntField1TSWithoutSDA
5232
5233 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5234 {
5235   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5236 }
5237
5238 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5239 {
5240 }
5241
5242 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5243                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5244 {
5245   DataArrayInt *arr(getOrCreateAndGetArrayInt());
5246   arr->setInfoAndChangeNbOfCompo(infos);
5247 }
5248
5249 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5250 {
5251   return TYPE_STR;
5252 }
5253
5254 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5255 {
5256   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5257   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5258   ret->deepCpyLeavesFrom(*this);
5259   const DataArrayInt *arr(_arr);
5260   if(arr)
5261     {
5262       MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5263       ret->setArray(arr2);
5264     }
5265   return ret.retn();
5266 }
5267
5268 /*!
5269  * Returns a pointer to the underground DataArrayInt instance. So the
5270  * caller should not decrRef() it. This method allows for a direct access to the field
5271  * values. This method is quite unusable if there is more than a nodal field or a cell
5272  * field on single geometric cell type. 
5273  *  \return DataArrayInt * - the pointer to the field values array.
5274  */
5275 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5276 {
5277   return getUndergroundDataArrayInt();
5278 }
5279
5280 /*!
5281  * Returns a pointer to the underground DataArrayInt instance. So the
5282  * caller should not decrRef() it. This method allows for a direct access to the field
5283  * values. This method is quite unusable if there is more than a nodal field or a cell
5284  * field on single geometric cell type. 
5285  *  \return DataArrayInt * - the pointer to the field values array.
5286  */
5287 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5288 {
5289   const DataArrayInt *ret=_arr;
5290   if(ret)
5291     return const_cast<DataArrayInt *>(ret);
5292   else
5293     return 0;
5294 }
5295
5296 /*!
5297  * Returns a pointer to the underground DataArrayInt instance and a
5298  * sequence describing parameters of a support of each part of \a this field. The
5299  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5300  * direct access to the field values. This method is intended for the field lying on one
5301  * mesh only.
5302  *  \param [in,out] entries - the sequence describing parameters of a support of each
5303  *         part of \a this field. Each item of this sequence consists of two parts. The
5304  *         first part describes a type of mesh entity and an id of discretization of a
5305  *         current field part. The second part describes a range of values [begin,end)
5306  *         within the returned array relating to the current field part.
5307  *  \return DataArrayInt * - the pointer to the field values array.
5308  *  \throw If the number of underlying meshes is not equal to 1.
5309  *  \throw If no field values are available.
5310  *  \sa getUndergroundDataArray()
5311  */
5312 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5313 {
5314   return getUndergroundDataArrayIntExt(entries);
5315 }
5316
5317 /*!
5318  * Returns a pointer to the underground DataArrayInt instance and a
5319  * sequence describing parameters of a support of each part of \a this field. The
5320  * caller should not decrRef() the returned DataArrayInt. This method allows for a
5321  * direct access to the field values. This method is intended for the field lying on one
5322  * mesh only.
5323  *  \param [in,out] entries - the sequence describing parameters of a support of each
5324  *         part of \a this field. Each item of this sequence consists of two parts. The
5325  *         first part describes a type of mesh entity and an id of discretization of a
5326  *         current field part. The second part describes a range of values [begin,end)
5327  *         within the returned array relating to the current field part.
5328  *  \return DataArrayInt * - the pointer to the field values array.
5329  *  \throw If the number of underlying meshes is not equal to 1.
5330  *  \throw If no field values are available.
5331  *  \sa getUndergroundDataArray()
5332  */
5333 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5334 {
5335   if(_field_per_mesh.size()!=1)
5336     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5337   if(_field_per_mesh[0]==0)
5338     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5339   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5340   return getUndergroundDataArrayInt();
5341 }
5342
5343 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5344 {
5345   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5346   ret->deepCpyLeavesFrom(*this);
5347   return ret.retn();
5348 }
5349
5350 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5351 {
5352   MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5353   if((const DataArrayInt *)_arr)
5354     ret->_arr=_arr->deepCopy();
5355   return ret.retn();
5356 }
5357
5358 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5359 {
5360   if(!arr)
5361     {
5362       _nb_of_tuples_to_be_allocated=-1;
5363       _arr=0;
5364       return ;
5365     }
5366   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5367   if(!arrC)
5368     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5369   else
5370     _nb_of_tuples_to_be_allocated=-3;
5371   arrC->incrRef();
5372   _arr=arrC;
5373 }
5374
5375 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5376 {
5377   return DataArrayInt::New();
5378 }
5379
5380 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5381 {
5382   DataArrayInt *ret=_arr;
5383   if(ret)
5384     return ret;
5385   _arr=DataArrayInt::New();
5386   return _arr;
5387 }
5388
5389 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5390 {
5391   return getOrCreateAndGetArrayInt();
5392 }
5393
5394 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5395 {
5396   const DataArrayInt *ret=_arr;
5397   if(ret)
5398     return ret;
5399   DataArrayInt *ret2=DataArrayInt::New();
5400   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5401   return ret2;
5402 }
5403
5404 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5405 {
5406   return getOrCreateAndGetArrayInt();
5407 }
5408
5409 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5410 {
5411 }
5412
5413 //= MEDFileAnyTypeField1TS
5414
5415 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5416 {
5417   med_field_type typcha;
5418   //
5419   std::vector<std::string> infos;
5420   std::string dtunit,fieldName;
5421   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5422   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5423   switch(typcha)
5424   {
5425     case MED_FLOAT64:
5426       {
5427         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5428         break;
5429       }
5430     case MED_INT32:
5431       {
5432         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5433         break;
5434       }
5435     default:
5436       {
5437         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5438         throw INTERP_KERNEL::Exception(oss.str().c_str());
5439       }
5440   }
5441   ret->setDtUnit(dtunit.c_str());
5442   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5443   //
5444   med_int numdt,numit;
5445   med_float dt;
5446   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5447   ret->setTime(numdt,numit,dt);
5448   ret->_csit=1;
5449   if(loadAll)
5450     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5451   else
5452     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5453   return ret.retn();
5454 }
5455
5456 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5457 try:MEDFileFieldGlobsReal(fileName)
5458 {
5459   MEDFileUtilities::CheckFileForRead(fileName);
5460   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5461   _content=BuildContentFrom(fid,fileName,loadAll,ms);
5462   loadGlobals(fid);
5463 }
5464 catch(INTERP_KERNEL::Exception& e)
5465 {
5466     throw e;
5467 }
5468
5469 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5470 {
5471   med_field_type typcha;
5472   std::vector<std::string> infos;
5473   std::string dtunit;
5474   int iii=-1;
5475   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5476   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5477   switch(typcha)
5478   {
5479     case MED_FLOAT64:
5480       {
5481         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5482         break;
5483       }
5484     case MED_INT32:
5485       {
5486         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5487         break;
5488       }
5489     default:
5490       {
5491         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5492         throw INTERP_KERNEL::Exception(oss.str().c_str());
5493       }
5494   }
5495   ret->setDtUnit(dtunit.c_str());
5496   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5497   //
5498   if(nbSteps<1)
5499     {
5500       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5501       throw INTERP_KERNEL::Exception(oss.str().c_str());
5502     }
5503   //
5504   med_int numdt,numit;
5505   med_float dt;
5506   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5507   ret->setTime(numdt,numit,dt);
5508   ret->_csit=1;
5509   if(loadAll)
5510     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5511   else
5512     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5513   return ret.retn();
5514 }
5515
5516 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5517 try:MEDFileFieldGlobsReal(fileName)
5518 {
5519   MEDFileUtilities::CheckFileForRead(fileName);
5520   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5521   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5522   loadGlobals(fid);
5523 }
5524 catch(INTERP_KERNEL::Exception& e)
5525 {
5526     throw e;
5527 }
5528
5529 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5530 {
5531   if(!c)
5532     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5533   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5534     {
5535       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5536       ret->setFileName(fileName);
5537       ret->_content=c; c->incrRef();
5538       return ret.retn();
5539     }
5540   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5541     {
5542       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5543       ret->setFileName(fileName);
5544       ret->_content=c; c->incrRef();
5545       return ret.retn();
5546     }
5547   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5548 }
5549
5550 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5551 {
5552   MEDFileUtilities::CheckFileForRead(fileName);
5553   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5554   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5555   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5556   ret->loadGlobals(fid);
5557   return ret.retn();
5558 }
5559
5560 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5561 {
5562   MEDFileUtilities::CheckFileForRead(fileName);
5563   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5564   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5565   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5566   ret->loadGlobals(fid);
5567   return ret.retn();
5568 }
5569
5570 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5571 {
5572   MEDFileUtilities::CheckFileForRead(fileName);
5573   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5574   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5575   MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5576   ret->loadGlobals(fid);
5577   return ret.retn();
5578 }
5579
5580 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5581 {
5582   med_field_type typcha;
5583   std::vector<std::string> infos;
5584   std::string dtunit;
5585   int iii=-1;
5586   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5587   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5588   switch(typcha)
5589   {
5590     case MED_FLOAT64:
5591       {
5592         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5593         break;
5594       }
5595     case MED_INT32:
5596       {
5597         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5598         break;
5599       }
5600     default:
5601       {
5602         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fileName,fieldName,iteration,order) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5603         throw INTERP_KERNEL::Exception(oss.str().c_str());
5604       }
5605   }
5606   ret->setDtUnit(dtunit.c_str());
5607   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5608   //
5609   bool found=false;
5610   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5611   for(int i=0;i<nbOfStep2 && !found;i++)
5612     {
5613       med_int numdt,numit;
5614       med_float dt;
5615       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5616       if(numdt==iteration && numit==order)
5617         {
5618           found=true;
5619           ret->_csit=i+1;
5620         }
5621       else
5622         dtits[i]=std::pair<int,int>(numdt,numit);
5623     }
5624   if(!found)
5625     {
5626       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5627       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5628         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5629       throw INTERP_KERNEL::Exception(oss.str().c_str());
5630     }
5631   if(loadAll)
5632     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5633   else
5634     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5635   return ret.retn();
5636 }
5637
5638 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5639 try:MEDFileFieldGlobsReal(fileName)
5640 {
5641   MEDFileUtilities::CheckFileForRead(fileName);
5642   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5643   _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5644   loadGlobals(fid);
5645 }
5646 catch(INTERP_KERNEL::Exception& e)
5647 {
5648     throw e;
5649 }
5650
5651 /*!
5652  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5653  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5654  *
5655  * \warning this is a shallow copy constructor
5656  */
5657 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5658 {
5659   if(!shallowCopyOfContent)
5660     {
5661       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5662       otherPtr->incrRef();
5663       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5664     }
5665   else
5666     {
5667       _content=other.shallowCpy();
5668     }
5669 }
5670
5671 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5672 {
5673   if(checkFieldId)
5674     {
5675       int nbFields=MEDnField(fid);
5676       if(fieldIdCFormat>=nbFields)
5677         {
5678           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5679           throw INTERP_KERNEL::Exception(oss.str().c_str());
5680         }
5681     }
5682   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5683   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5684   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5685   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5686   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5687   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5688   med_bool localMesh;
5689   int nbOfStep;
5690   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5691   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5692   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5693   infos.clear(); infos.resize(ncomp);
5694   for(int j=0;j<ncomp;j++)
5695     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5696   return nbOfStep;
5697 }
5698
5699 /*!
5700  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5701  * 
5702  * \param [out]
5703  * \return in case of success the number of time steps available for the field with name \a fieldName.
5704  */
5705 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5706 {
5707   int nbFields=MEDnField(fid);
5708   bool found=false;
5709   std::vector<std::string> fns(nbFields);
5710   int nbOfStep2=-1;
5711   for(int i=0;i<nbFields && !found;i++)
5712     {
5713       std::string tmp;
5714       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5715       fns[i]=tmp;
5716       found=(tmp==fieldName);
5717       if(found)
5718         posCFormat=i;
5719     }
5720   if(!found)
5721     {
5722       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5723       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5724         oss << "\"" << *it << "\" ";
5725       throw INTERP_KERNEL::Exception(oss.str().c_str());
5726     }
5727   return nbOfStep2;
5728 }
5729
5730 /*!
5731  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5732  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5733  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5734  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5735  * to keep a valid instance.
5736  * 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.
5737  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5738  * 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.
5739  *
5740  * \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.
5741  * \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.
5742  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5743  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5744  * \param [in] newLocName is the new localization name.
5745  * \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.
5746  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5747  */
5748 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5749 {
5750   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5751   std::string oldPflName=disc->getProfile();
5752   std::vector<std::string> vv=getPflsReallyUsedMulti();
5753   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5754   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5755     {
5756       disc->setProfile(newPflName);
5757       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5758       pfl->setName(newPflName);
5759     }
5760   else
5761     {
5762       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5763       throw INTERP_KERNEL::Exception(oss.str().c_str());
5764     }
5765 }
5766
5767 /*!
5768  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5769  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5770  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5771  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5772  * to keep a valid instance.
5773  * 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.
5774  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5775  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5776  * 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.
5777  *
5778  * \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.
5779  * \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.
5780  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5781  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5782  * \param [in] newLocName is the new localization name.
5783  * \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.
5784  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5785  */
5786 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5787 {
5788   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5789   std::string oldLocName=disc->getLocalization();
5790   std::vector<std::string> vv=getLocsReallyUsedMulti();
5791   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5792   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5793     {
5794       disc->setLocalization(newLocName);
5795       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5796       loc.setName(newLocName);
5797     }
5798   else
5799     {
5800       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5801       throw INTERP_KERNEL::Exception(oss.str().c_str());
5802     }
5803 }
5804
5805 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5806 {
5807   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5808   if(!ret)
5809     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5810   return ret;
5811 }
5812
5813 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5814 {
5815   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5816   if(!ret)
5817     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5818   return ret;
5819 }
5820
5821 /*!
5822  * Writes \a this field into a MED file specified by its name.
5823  *  \param [in] fileName - the MED file name.
5824  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5825  * - 2 - erase; an existing file is removed.
5826  * - 1 - append; same data should not be present in an existing file.
5827  * - 0 - overwrite; same data present in an existing file is overwritten.
5828  *  \throw If the field name is not set.
5829  *  \throw If no field data is set.
5830  *  \throw If \a mode == 1 and the same data is present in an existing file.
5831  */
5832 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5833 {
5834   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5835   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5836   writeLL(fid);
5837 }
5838
5839 /*!
5840  * This method alloc the arrays and load potentially huge arrays contained in this field.
5841  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5842  * This method can be also called to refresh or reinit values from a file.
5843  * 
5844  * \throw If the fileName is not set or points to a non readable MED file.
5845  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5846  */
5847 void MEDFileAnyTypeField1TS::loadArrays()
5848 {
5849   if(getFileName().empty())
5850     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5851   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5852   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5853 }
5854
5855 /*!
5856  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5857  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5858  * this method does not throw if \a this does not come from file read.
5859  * 
5860  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5861  */
5862 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5863 {
5864   if(!getFileName().empty())
5865     {
5866       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5867       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5868     }
5869 }
5870
5871 /*!
5872  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5873  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5874  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5875  * 
5876  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5877  */
5878 void MEDFileAnyTypeField1TS::unloadArrays()
5879 {
5880   contentNotNullBase()->unloadArrays();
5881 }
5882
5883 /*!
5884  * 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.
5885  * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5886  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5887  * 
5888  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5889  */
5890 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5891 {
5892   if(!getFileName().empty())
5893     contentNotNullBase()->unloadArrays();
5894 }
5895
5896 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5897 {
5898   int nbComp=getNumberOfComponents();
5899   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5900   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5901   for(int i=0;i<nbComp;i++)
5902     {
5903       std::string info=getInfo()[i];
5904       std::string c,u;
5905       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5906       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5907       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5908     }
5909   if(getName().empty())
5910     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5911   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5912   writeGlobals(fid,*this);
5913   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5914 }
5915
5916 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5917 {
5918   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5919 }
5920
5921 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5922 {
5923   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5924   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5925   return ret;
5926 }
5927
5928 /*!
5929  * Returns a string describing \a this field. This string is outputted 
5930  * by \c print Python command.
5931  */
5932 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5933 {
5934   std::ostringstream oss;
5935   contentNotNullBase()->simpleRepr(0,oss,-1);
5936   simpleReprGlobs(oss);
5937   return oss.str();
5938 }
5939
5940 /*!
5941  * This method returns all profiles whose name is non empty used.
5942  * \b WARNING If profile is used several times it will be reported \b only \b once.
5943  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5944  */
5945 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5946 {
5947   return contentNotNullBase()->getPflsReallyUsed2();
5948 }
5949
5950 /*!
5951  * This method returns all localizations whose name is non empty used.
5952  * \b WARNING If localization is used several times it will be reported \b only \b once.
5953  */
5954 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5955 {
5956   return contentNotNullBase()->getLocsReallyUsed2();
5957 }
5958
5959 /*!
5960  * This method returns all profiles whose name is non empty used.
5961  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5962  */
5963 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5964 {
5965   return contentNotNullBase()->getPflsReallyUsedMulti2();
5966 }
5967
5968 /*!
5969  * This method returns all localizations whose name is non empty used.
5970  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5971  */
5972 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5973 {
5974   return contentNotNullBase()->getLocsReallyUsedMulti2();
5975 }
5976
5977 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5978 {
5979   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5980 }
5981
5982 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5983 {
5984   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5985 }
5986
5987 int MEDFileAnyTypeField1TS::getDimension() const
5988 {
5989   return contentNotNullBase()->getDimension();
5990 }
5991
5992 int MEDFileAnyTypeField1TS::getIteration() const
5993 {
5994   return contentNotNullBase()->getIteration();
5995 }
5996
5997 int MEDFileAnyTypeField1TS::getOrder() const
5998 {
5999   return contentNotNullBase()->getOrder();
6000 }
6001
6002 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6003 {
6004   return contentNotNullBase()->getTime(iteration,order);
6005 }
6006
6007 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6008 {
6009   contentNotNullBase()->setTime(iteration,order,val);
6010 }
6011
6012 std::string MEDFileAnyTypeField1TS::getName() const
6013 {
6014   return contentNotNullBase()->getName();
6015 }
6016
6017 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6018 {
6019   contentNotNullBase()->setName(name);
6020 }
6021
6022 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6023 {
6024   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6025 }
6026
6027 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6028 {
6029   return contentNotNullBase()->getDtUnit();
6030 }
6031
6032 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6033 {
6034   contentNotNullBase()->setDtUnit(dtUnit);
6035 }
6036
6037 std::string MEDFileAnyTypeField1TS::getMeshName() const
6038 {
6039   return contentNotNullBase()->getMeshName();
6040 }
6041
6042 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6043 {
6044   contentNotNullBase()->setMeshName(newMeshName);
6045 }
6046
6047 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6048 {
6049   return contentNotNullBase()->changeMeshNames(modifTab);
6050 }
6051
6052 int MEDFileAnyTypeField1TS::getMeshIteration() const
6053 {
6054   return contentNotNullBase()->getMeshIteration();
6055 }
6056
6057 int MEDFileAnyTypeField1TS::getMeshOrder() const
6058 {
6059   return contentNotNullBase()->getMeshOrder();
6060 }
6061
6062 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6063 {
6064   return contentNotNullBase()->getNumberOfComponents();
6065 }
6066
6067 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6068 {
6069   return contentNotNullBase()->isDealingTS(iteration,order);
6070 }
6071
6072 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6073 {
6074   return contentNotNullBase()->getDtIt();
6075 }
6076
6077 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6078 {
6079   contentNotNullBase()->fillIteration(p);
6080 }
6081
6082 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6083 {
6084   contentNotNullBase()->fillTypesOfFieldAvailable(types);
6085 }
6086
6087 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6088 {
6089   contentNotNullBase()->setInfo(infos);
6090 }
6091
6092 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6093 {
6094   return contentNotNullBase()->getInfo();
6095 }
6096 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6097 {
6098   return contentNotNullBase()->getInfo();
6099 }
6100
6101 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6102 {
6103   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6104 }
6105
6106 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6107 {
6108   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6109 }
6110
6111 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6112 {
6113   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6114 }
6115
6116 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6117 {
6118   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6119 }
6120
6121 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6122 {
6123   return contentNotNullBase()->getTypesOfFieldAvailable();
6124 }
6125
6126 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,
6127                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6128 {
6129   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6130 }
6131
6132 /*!
6133  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6134  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6135  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6136  */
6137 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6138 {
6139   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6140   if(!content)
6141     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6142   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6143   std::size_t sz(contentsSplit.size());
6144   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6145   for(std::size_t i=0;i<sz;i++)
6146     {
6147       ret[i]=shallowCpy();
6148       ret[i]->_content=contentsSplit[i];
6149     }
6150   return ret;
6151 }
6152
6153 /*!
6154  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6155  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6156  */
6157 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6158 {
6159   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6160   if(!content)
6161     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6162   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6163   std::size_t sz(contentsSplit.size());
6164   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6165   for(std::size_t i=0;i<sz;i++)
6166     {
6167       ret[i]=shallowCpy();
6168       ret[i]->_content=contentsSplit[i];
6169     }
6170   return ret;
6171 }
6172
6173 /*!
6174  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6175  * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6176  */
6177 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6178 {
6179   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6180   if(!content)
6181     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6182   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6183   std::size_t sz(contentsSplit.size());
6184   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6185   for(std::size_t i=0;i<sz;i++)
6186     {
6187       ret[i]=shallowCpy();
6188       ret[i]->_content=contentsSplit[i];
6189     }
6190   return ret;
6191 }
6192
6193 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6194 {
6195   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6196   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6197     ret->_content=_content->deepCopy();
6198   ret->deepCpyGlobs(*this);
6199   return ret.retn();
6200 }
6201
6202 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6203 {
6204   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6205 }
6206
6207 //= MEDFileField1TS
6208
6209 /*!
6210  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6211  * the first field that has been read from a specified MED file.
6212  *  \param [in] fileName - the name of the MED file to read.
6213  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6214  *          is to delete this field using decrRef() as it is no more needed.
6215  *  \throw If reading the file fails.
6216  */
6217 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6218 {
6219   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6220   ret->contentNotNull();
6221   return ret.retn();
6222 }
6223
6224 /*!
6225  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
6226  * a given field that has been read from a specified MED file.
6227  *  \param [in] fileName - the name of the MED file to read.
6228  *  \param [in] fieldName - the name of the field to read.
6229  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6230  *          is to delete this field using decrRef() as it is no more needed.
6231  *  \throw If reading the file fails.
6232  *  \throw If there is no field named \a fieldName in the file.
6233  */
6234 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6235 {
6236   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6237   ret->contentNotNull();
6238   return ret.retn();
6239 }
6240
6241 /*!
6242  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
6243  * a given field that has been read from a specified MED file.
6244  *  \param [in] fileName - the name of the MED file to read.
6245  *  \param [in] fieldName - the name of the field to read.
6246  *  \param [in] iteration - the iteration number of a required time step.
6247  *  \param [in] order - the iteration order number of required time step.
6248  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6249  *          is to delete this field using decrRef() as it is no more needed.
6250  *  \throw If reading the file fails.
6251  *  \throw If there is no field named \a fieldName in the file.
6252  *  \throw If the required time step is missing from the file.
6253  */
6254 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6255 {
6256   MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6257   ret->contentNotNull();
6258   return ret.retn();
6259 }
6260
6261 /*!
6262  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6263  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6264  *
6265  * Returns a new instance of MEDFileField1TS holding either a shallow copy
6266  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6267  * \warning this is a shallow copy constructor
6268  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6269  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6270  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6271  *          is to delete this field using decrRef() as it is no more needed.
6272  */
6273 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6274 {
6275   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6276   ret->contentNotNull();
6277   return ret.retn();
6278 }
6279
6280 /*!
6281  * Returns a new empty instance of MEDFileField1TS.
6282  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6283  *          is to delete this field using decrRef() as it is no more needed.
6284  */
6285 MEDFileField1TS *MEDFileField1TS::New()
6286 {
6287   MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6288   ret->contentNotNull();
6289   return ret.retn();
6290 }
6291
6292 /*!
6293  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6294  * following the given input policy.
6295  *
6296  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6297  *                            By default (true) the globals are deeply copied.
6298  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6299  */
6300 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6301 {
6302   MCAuto<MEDFileIntField1TS> ret;
6303   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6304   if(content)
6305     {
6306       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6307       if(!contc)
6308         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6309       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6310       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6311     }
6312   else
6313     ret=MEDFileIntField1TS::New();
6314   if(isDeepCpyGlobs)
6315     ret->deepCpyGlobs(*this);
6316   else
6317     ret->shallowCpyGlobs(*this);
6318   return ret.retn();
6319 }
6320
6321 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6322 {
6323   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6324   if(!pt)
6325     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6326   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6327   if(!ret)
6328     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 !");
6329   return ret;
6330 }
6331
6332 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6333 {
6334   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6335   if(!pt)
6336     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6337   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6338   if(!ret)
6339     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 !");
6340   return ret;
6341 }
6342
6343 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6344 {
6345   if(!f)
6346     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6347   if(!((DataArray*)arr))
6348     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6349   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6350   if(!arrOutC)
6351     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6352   f->setArray(arrOutC);
6353 }
6354
6355 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6356 {
6357   if(!((DataArray*)arr))
6358     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6359   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6360   if(!arrOutC)
6361     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6362   arrOutC->incrRef();
6363   return arrOutC;
6364 }
6365
6366 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6367 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6368 {
6369 }
6370 catch(INTERP_KERNEL::Exception& e)
6371 { throw e; }
6372
6373 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6374 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6375 {
6376 }
6377 catch(INTERP_KERNEL::Exception& e)
6378 { throw e; }
6379
6380 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6381 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6382 {
6383 }
6384 catch(INTERP_KERNEL::Exception& e)
6385 { throw e; }
6386
6387 /*!
6388  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6389  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6390  *
6391  * \warning this is a shallow copy constructor
6392  */
6393 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6394 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6395 {
6396 }
6397 catch(INTERP_KERNEL::Exception& e)
6398 { throw e; }
6399
6400 MEDFileField1TS::MEDFileField1TS()
6401 {
6402   _content=new MEDFileField1TSWithoutSDA;
6403 }
6404
6405 /*!
6406  * Returns a new MEDCouplingFieldDouble of a given type lying on
6407  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6408  * has not been constructed via file reading, an exception is thrown.
6409  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6410  *  \param [in] type - a spatial discretization of interest.
6411  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6412  *  \param [in] renumPol - specifies how to permute values of the result field according to
6413  *          the optional numbers of cells and nodes, if any. The valid values are
6414  *          - 0 - do not permute.
6415  *          - 1 - permute cells.
6416  *          - 2 - permute nodes.
6417  *          - 3 - permute cells and nodes.
6418  *
6419  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6420  *          caller is to delete this field using decrRef() as it is no more needed. 
6421  *  \throw If \a this field has not been constructed via file reading.
6422  *  \throw If the MED file is not readable.
6423  *  \throw If there is no mesh in the MED file.
6424  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6425  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6426  *  \sa getFieldOnMeshAtLevel()
6427  */
6428 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6429 {
6430   if(getFileName().empty())
6431     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6432   MCAuto<DataArray> arrOut;
6433   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6434   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6435   return ret.retn();
6436 }
6437
6438 /*!
6439  * Returns a new MEDCouplingFieldDouble of a given type lying on
6440  * the top level cells of the first mesh in MED file. If \a this field 
6441  * has not been constructed via file reading, an exception is thrown.
6442  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6443  *  \param [in] type - a spatial discretization of interest.
6444  *  \param [in] renumPol - specifies how to permute values of the result field according to
6445  *          the optional numbers of cells and nodes, if any. The valid values are
6446  *          - 0 - do not permute.
6447  *          - 1 - permute cells.
6448  *          - 2 - permute nodes.
6449  *          - 3 - permute cells and nodes.
6450  *
6451  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6452  *          caller is to delete this field using decrRef() as it is no more needed. 
6453  *  \throw If \a this field has not been constructed via file reading.
6454  *  \throw If the MED file is not readable.
6455  *  \throw If there is no mesh in the MED file.
6456  *  \throw If no field values of the given \a type.
6457  *  \throw If no field values lying on the top level support.
6458  *  \sa getFieldAtLevel()
6459  */
6460 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6461 {
6462   if(getFileName().empty())
6463     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6464   MCAuto<DataArray> arrOut;
6465   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6466   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6467   return ret.retn();
6468 }
6469
6470 /*!
6471  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6472  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6473  *  \param [in] type - a spatial discretization of the new field.
6474  *  \param [in] mesh - the supporting mesh.
6475  *  \param [in] renumPol - specifies how to permute values of the result field according to
6476  *          the optional numbers of cells and nodes, if any. The valid values are
6477  *          - 0 - do not permute.
6478  *          - 1 - permute cells.
6479  *          - 2 - permute nodes.
6480  *          - 3 - permute cells and nodes.
6481  *
6482  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6483  *          caller is to delete this field using decrRef() as it is no more needed. 
6484  *  \throw If no field of \a this is lying on \a mesh.
6485  *  \throw If the mesh is empty.
6486  *  \throw If no field values of the given \a type are available.
6487  *  \sa getFieldAtLevel()
6488  *  \sa getFieldOnMeshAtLevel() 
6489  */
6490 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6491 {
6492   MCAuto<DataArray> arrOut;
6493   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6494   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6495   return ret.retn();
6496 }
6497
6498 /*!
6499  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6500  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6501  *  \param [in] type - a spatial discretization of interest.
6502  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6503  *  \param [in] mesh - the supporting mesh.
6504  *  \param [in] renumPol - specifies how to permute values of the result field according to
6505  *          the optional numbers of cells and nodes, if any. The valid values are
6506  *          - 0 - do not permute.
6507  *          - 1 - permute cells.
6508  *          - 2 - permute nodes.
6509  *          - 3 - permute cells and nodes.
6510  *
6511  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6512  *          caller is to delete this field using decrRef() as it is no more needed. 
6513  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6514  *  \throw If no field of \a this is lying on \a mesh.
6515  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6516  *  \sa getFieldAtLevel()
6517  *  \sa getFieldOnMeshAtLevel() 
6518  */
6519 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6520 {
6521   MCAuto<DataArray> arrOut;
6522   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6523   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6524   return ret.retn();
6525 }
6526
6527 /*!
6528  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6529  * This method is called "Old" because in MED3 norm a field has only one meshName
6530  * attached, so this method is for readers of MED2 files. If \a this field 
6531  * has not been constructed via file reading, an exception is thrown.
6532  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6533  *  \param [in] type - a spatial discretization of interest.
6534  *  \param [in] mName - a name of the supporting mesh.
6535  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6536  *  \param [in] renumPol - specifies how to permute values of the result field according to
6537  *          the optional numbers of cells and nodes, if any. The valid values are
6538  *          - 0 - do not permute.
6539  *          - 1 - permute cells.
6540  *          - 2 - permute nodes.
6541  *          - 3 - permute cells and nodes.
6542  *
6543  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6544  *          caller is to delete this field using decrRef() as it is no more needed. 
6545  *  \throw If the MED file is not readable.
6546  *  \throw If there is no mesh named \a mName in the MED file.
6547  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6548  *  \throw If \a this field has not been constructed via file reading.
6549  *  \throw If no field of \a this is lying on the mesh named \a mName.
6550  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6551  *  \sa getFieldAtLevel()
6552  */
6553 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6554 {
6555   if(getFileName().empty())
6556     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6557   MCAuto<DataArray> arrOut;
6558   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6559   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6560   return ret.retn();
6561 }
6562
6563 /*!
6564  * Returns values and a profile of the field of a given type lying on a given support.
6565  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6566  *  \param [in] type - a spatial discretization of the field.
6567  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6568  *  \param [in] mesh - the supporting mesh.
6569  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6570  *          field of interest lies on. If the field lies on all entities of the given
6571  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6572  *          using decrRef() as it is no more needed.  
6573  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6574  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6575  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6576  *  \throw If no field of \a this is lying on \a mesh.
6577  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6578  */
6579 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6580 {
6581   MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6582   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6583 }
6584
6585 /*!
6586  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6587  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6588  * "Sort By Type"), if not, an exception is thrown. 
6589  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6590  *  \param [in] field - the field to add to \a this.
6591  *  \throw If the name of \a field is empty.
6592  *  \throw If the data array of \a field is not set.
6593  *  \throw If the data array is already allocated but has different number of components
6594  *         than \a field.
6595  *  \throw If the underlying mesh of \a field has no name.
6596  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6597  */
6598 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6599 {
6600   setFileName("");
6601   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6602 }
6603
6604 /*!
6605  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6606  * can be an aggregation of several MEDCouplingFieldDouble instances.
6607  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6608  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6609  * and \a profile.
6610  *
6611  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6612  * A new profile is added only if no equal profile is missing.
6613  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6614  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6615  *  \param [in] mesh - the supporting mesh of \a field.
6616  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6617  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6618  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6619  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6620  *  \throw If the data array of \a field is not set.
6621  *  \throw If the data array of \a this is already allocated but has different number of
6622  *         components than \a field.
6623  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6624  *  \sa setFieldNoProfileSBT()
6625  */
6626 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6627 {
6628   setFileName("");
6629   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6630 }
6631
6632 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6633 {
6634   return new MEDFileField1TS(*this);
6635 }
6636
6637 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6638 {
6639   return contentNotNull()->getUndergroundDataArrayDouble();
6640 }
6641
6642 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6643 {
6644   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6645 }
6646
6647 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6648                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6649 {
6650   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6651 }
6652
6653 //= MEDFileIntField1TS
6654
6655 MEDFileIntField1TS *MEDFileIntField1TS::New()
6656 {
6657   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6658   ret->contentNotNull();
6659   return ret.retn();
6660 }
6661
6662 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6663 {
6664   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6665   ret->contentNotNull();
6666   return ret.retn();
6667 }
6668
6669 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6670 {
6671   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6672   ret->contentNotNull();
6673   return ret.retn();
6674 }
6675
6676 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6677 {
6678   MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6679   ret->contentNotNull();
6680   return ret.retn();
6681 }
6682
6683 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6684 {
6685   MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6686   ret->contentNotNull();
6687   return ret.retn();
6688 }
6689
6690 MEDFileIntField1TS::MEDFileIntField1TS()
6691 {
6692   _content=new MEDFileIntField1TSWithoutSDA;
6693 }
6694
6695 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6696 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6697 {
6698 }
6699 catch(INTERP_KERNEL::Exception& e)
6700 { throw e; }
6701
6702 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6703 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6704 {
6705 }
6706 catch(INTERP_KERNEL::Exception& e)
6707 { throw e; }
6708
6709 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6710 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6711 {
6712 }
6713 catch(INTERP_KERNEL::Exception& e)
6714 { throw e; }
6715
6716 /*!
6717  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6718  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6719  *
6720  * \warning this is a shallow copy constructor
6721  */
6722 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6723 {
6724 }
6725
6726 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6727 {
6728   return new MEDFileIntField1TS(*this);
6729 }
6730
6731 /*!
6732  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6733  * following the given input policy.
6734  *
6735  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6736  *                            By default (true) the globals are deeply copied.
6737  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6738  */
6739 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6740 {
6741   MCAuto<MEDFileField1TS> ret;
6742   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6743   if(content)
6744     {
6745       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6746       if(!contc)
6747         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6748       MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6749       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6750     }
6751   else
6752     ret=MEDFileField1TS::New();
6753   if(isDeepCpyGlobs)
6754     ret->deepCpyGlobs(*this);
6755   else
6756     ret->shallowCpyGlobs(*this);
6757   return ret.retn();
6758 }
6759
6760 /*!
6761  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6762  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6763  * "Sort By Type"), if not, an exception is thrown. 
6764  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6765  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6766  *  \param [in] arrOfVals - the values of the field \a field used.
6767  *  \throw If the name of \a field is empty.
6768  *  \throw If the data array of \a field is not set.
6769  *  \throw If the data array is already allocated but has different number of components
6770  *         than \a field.
6771  *  \throw If the underlying mesh of \a field has no name.
6772  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6773  */
6774 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6775 {
6776   setFileName("");
6777   contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6778 }
6779
6780 /*!
6781  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6782  * can be an aggregation of several MEDCouplingFieldDouble instances.
6783  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6784  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6785  * and \a profile.
6786  *
6787  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6788  * A new profile is added only if no equal profile is missing.
6789  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6790  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6791  *  \param [in] arrOfVals - the values of the field \a field used.
6792  *  \param [in] mesh - the supporting mesh of \a field.
6793  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6794  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6795  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6796  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6797  *  \throw If the data array of \a field is not set.
6798  *  \throw If the data array of \a this is already allocated but has different number of
6799  *         components than \a field.
6800  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6801  *  \sa setFieldNoProfileSBT()
6802  */
6803 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6804 {
6805   setFileName("");
6806   contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6807 }
6808
6809 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6810 {
6811   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6812   if(!pt)
6813     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6814   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6815   if(!ret)
6816     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 !");
6817   return ret;
6818 }
6819
6820 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6821 {
6822   if(getFileName().empty())
6823     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6824   MCAuto<DataArray> arrOut2;
6825   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6826   DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6827   if(!arrOutC)
6828     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6829   arrOut=arrOutC;
6830   arrOut->incrRef();  // arrOut2 dies at the end of the func
6831   return ret.retn();
6832 }
6833
6834 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6835 {
6836   if(!((DataArray *)arr))
6837     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6838   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6839   if(!arrC)
6840     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6841   arrC->incrRef();
6842   return arrC;
6843 }
6844
6845 /*!
6846  * Returns a new MEDCouplingFieldDouble of a given type lying on
6847  * the top level cells of the first mesh in MED file. If \a this field 
6848  * has not been constructed via file reading, an exception is thrown.
6849  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6850  *  \param [in] type - a spatial discretization of interest.
6851  *  \param [out] arrOut - the DataArrayInt containing values of field.
6852  *  \param [in] renumPol - specifies how to permute values of the result field according to
6853  *          the optional numbers of cells and nodes, if any. The valid values are
6854  *          - 0 - do not permute.
6855  *          - 1 - permute cells.
6856  *          - 2 - permute nodes.
6857  *          - 3 - permute cells and nodes.
6858  *
6859  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6860  *          caller is to delete this field using decrRef() as it is no more needed. 
6861  *  \throw If \a this field has not been constructed via file reading.
6862  *  \throw If the MED file is not readable.
6863  *  \throw If there is no mesh in the MED file.
6864  *  \throw If no field values of the given \a type.
6865  *  \throw If no field values lying on the top level support.
6866  *  \sa getFieldAtLevel()
6867  */
6868 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6869 {
6870   if(getFileName().empty())
6871     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6872   MCAuto<DataArray> arr;
6873   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6874   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6875   return ret.retn();
6876 }
6877
6878 /*!
6879  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6880  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6881  *  \param [in] type - a spatial discretization of the new field.
6882  *  \param [in] mesh - the supporting mesh.
6883  *  \param [out] arrOut - the DataArrayInt containing values of field.
6884  *  \param [in] renumPol - specifies how to permute values of the result field according to
6885  *          the optional numbers of cells and nodes, if any. The valid values are
6886  *          - 0 - do not permute.
6887  *          - 1 - permute cells.
6888  *          - 2 - permute nodes.
6889  *          - 3 - permute cells and nodes.
6890  *
6891  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6892  *          caller is to delete this field using decrRef() as it is no more needed. 
6893  *  \throw If no field of \a this is lying on \a mesh.
6894  *  \throw If the mesh is empty.
6895  *  \throw If no field values of the given \a type are available.
6896  *  \sa getFieldAtLevel()
6897  *  \sa getFieldOnMeshAtLevel() 
6898  */
6899 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6900 {
6901   MCAuto<DataArray> arr;
6902   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6903   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6904   return ret.retn();
6905 }
6906
6907 /*!
6908  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6909  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6910  *  \param [in] type - a spatial discretization of interest.
6911  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6912  *  \param [out] arrOut - the DataArrayInt containing values of field.
6913  *  \param [in] mesh - the supporting mesh.
6914  *  \param [in] renumPol - specifies how to permute values of the result field according to
6915  *          the optional numbers of cells and nodes, if any. The valid values are
6916  *          - 0 - do not permute.
6917  *          - 1 - permute cells.
6918  *          - 2 - permute nodes.
6919  *          - 3 - permute cells and nodes.
6920  *
6921  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6922  *          caller is to delete this field using decrRef() as it is no more needed. 
6923  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6924  *  \throw If no field of \a this is lying on \a mesh.
6925  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6926  *  \sa getFieldAtLevel()
6927  *  \sa getFieldOnMeshAtLevel() 
6928  */
6929 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6930 {
6931   MCAuto<DataArray> arr;
6932   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6933   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6934   return ret.retn();
6935 }
6936
6937 /*!
6938  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6939  * This method is called "Old" because in MED3 norm a field has only one meshName
6940  * attached, so this method is for readers of MED2 files. If \a this field 
6941  * has not been constructed via file reading, an exception is thrown.
6942  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6943  *  \param [in] type - a spatial discretization of interest.
6944  *  \param [in] mName - a name of the supporting mesh.
6945  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6946  *  \param [out] arrOut - the DataArrayInt containing values of field.
6947  *  \param [in] renumPol - specifies how to permute values of the result field according to
6948  *          the optional numbers of cells and nodes, if any. The valid values are
6949  *          - 0 - do not permute.
6950  *          - 1 - permute cells.
6951  *          - 2 - permute nodes.
6952  *          - 3 - permute cells and nodes.
6953  *
6954  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6955  *          caller is to delete this field using decrRef() as it is no more needed. 
6956  *  \throw If the MED file is not readable.
6957  *  \throw If there is no mesh named \a mName in the MED file.
6958  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6959  *  \throw If \a this field has not been constructed via file reading.
6960  *  \throw If no field of \a this is lying on the mesh named \a mName.
6961  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6962  *  \sa getFieldAtLevel()
6963  */
6964 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6965 {
6966   if(getFileName().empty())
6967     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6968   MCAuto<DataArray> arr;
6969   MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6970   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6971   return ret.retn();
6972 }
6973
6974 /*!
6975  * Returns values and a profile of the field of a given type lying on a given support.
6976  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6977  *  \param [in] type - a spatial discretization of the field.
6978  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6979  *  \param [in] mesh - the supporting mesh.
6980  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6981  *          field of interest lies on. If the field lies on all entities of the given
6982  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6983  *          using decrRef() as it is no more needed.  
6984  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6985  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6986  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6987  *  \throw If no field of \a this is lying on \a mesh.
6988  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6989  */
6990 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6991 {
6992   MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6993   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6994 }
6995
6996 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6997 {
6998   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6999   if(!pt)
7000     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7001   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7002   if(!ret)
7003     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 !");
7004   return ret;
7005 }
7006
7007 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7008 {
7009   return contentNotNull()->getUndergroundDataArrayInt();
7010 }
7011
7012 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7013
7014 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7015 {
7016 }
7017
7018 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7019 {
7020 }
7021
7022 /*!
7023  * \param [in] fieldId field id in C mode
7024  */
7025 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7026 {
7027   med_field_type typcha;
7028   std::string dtunitOut;
7029   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7030   setDtUnit(dtunitOut.c_str());
7031   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7032 }
7033
7034 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7035 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7036 {
7037   setDtUnit(dtunit.c_str());
7038   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7039 }
7040 catch(INTERP_KERNEL::Exception& e)
7041 {
7042     throw e;
7043 }
7044
7045 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7046 {
7047   std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7048   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7049     ret+=(*it).capacity();
7050   return ret;
7051 }
7052
7053 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7054 {
7055   std::vector<const BigMemoryObject *> ret;
7056   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7057     ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7058   return ret;
7059 }
7060
7061 /*!
7062  * 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
7063  * NULL.
7064  */
7065 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7066 {
7067   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7068   ret->setInfo(_infos);
7069   int sz=(int)_time_steps.size();
7070   for(const int *id=startIds;id!=endIds;id++)
7071     {
7072       if(*id>=0 && *id<sz)
7073         {
7074           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7075           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7076           if(tse)
7077             {
7078               tse->incrRef();
7079               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7080             }
7081           ret->pushBackTimeStep(tse2);
7082         }
7083       else
7084         {
7085           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7086           oss << " ! Should be in [0," << sz << ") !";
7087           throw INTERP_KERNEL::Exception(oss.str().c_str());
7088         }
7089     }
7090   if(ret->getNumberOfTS()>0)
7091     ret->synchronizeNameScope();
7092   ret->copyNameScope(*this);
7093   return ret.retn();
7094 }
7095
7096 /*!
7097  * 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
7098  * NULL.
7099  */
7100 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7101 {
7102   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7103   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7104   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7105   ret->setInfo(_infos);
7106   int sz=(int)_time_steps.size();
7107   int j=bg;
7108   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7109     {
7110       if(j>=0 && j<sz)
7111         {
7112           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7113           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7114           if(tse)
7115             {
7116               tse->incrRef();
7117               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7118             }
7119           ret->pushBackTimeStep(tse2);
7120         }
7121       else
7122         {
7123           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7124           oss << " ! Should be in [0," << sz << ") !";
7125           throw INTERP_KERNEL::Exception(oss.str().c_str());
7126         }
7127     }
7128   if(ret->getNumberOfTS()>0)
7129     ret->synchronizeNameScope();
7130   ret->copyNameScope(*this);
7131   return ret.retn();
7132 }
7133
7134 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7135 {
7136   int id=0;
7137   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7138   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7139     {
7140       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7141       if(!cur)
7142         continue;
7143       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7144       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7145         ids->pushBackSilent(id);
7146     }
7147   return buildFromTimeStepIds(ids->begin(),ids->end());
7148 }
7149
7150 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7151 {
7152   int id=0;
7153   MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7154   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7155     {
7156       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7157       if(!cur)
7158         continue;
7159       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7160       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7161         ids->pushBackSilent(id);
7162     }
7163   return buildFromTimeStepIds(ids->begin(),ids->end());
7164 }
7165
7166 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7167 {
7168   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7169     {
7170       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7171       if(!cur)
7172         continue;
7173       if(cur->presenceOfMultiDiscPerGeoType())
7174         return true;
7175     }
7176   return false;
7177 }
7178
7179 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7180 {
7181   return _infos;
7182 }
7183
7184 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7185 {
7186   _infos=info;
7187 }
7188
7189 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7190 {
7191   int ret=0;
7192   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7193     {
7194       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7195       if(pt->isDealingTS(iteration,order))
7196         return ret;
7197     }
7198   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7199   std::vector< std::pair<int,int> > vp=getIterations();
7200   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7201     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7202   throw INTERP_KERNEL::Exception(oss.str().c_str());
7203 }
7204
7205 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7206 {
7207   return *_time_steps[getTimeStepPos(iteration,order)];
7208 }
7209
7210 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7211 {
7212   return *_time_steps[getTimeStepPos(iteration,order)];
7213 }
7214
7215 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7216 {
7217   if(_time_steps.empty())
7218     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7219   return _time_steps[0]->getMeshName();
7220 }
7221
7222 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7223 {
7224   std::string oldName(getMeshName());
7225   std::vector< std::pair<std::string,std::string> > v(1);
7226   v[0].first=oldName; v[0].second=newMeshName;
7227   changeMeshNames(v);
7228 }
7229
7230 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7231 {
7232   bool ret=false;
7233   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7234     {
7235       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7236       if(cur)
7237         ret=cur->changeMeshNames(modifTab) || ret;
7238     }
7239   return ret;
7240 }
7241
7242 /*!
7243  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7244  */
7245 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7246 {
7247   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7248 }
7249
7250 /*!
7251  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7252  */
7253 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7254 {
7255   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7256 }
7257
7258 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7259                                                                        MEDFileFieldGlobsReal& glob)
7260 {
7261   bool ret=false;
7262   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7263     {
7264       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7265       if(f1ts)
7266         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7267     }
7268   return ret;
7269 }
7270
7271 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7272 {
7273   std::string startLine(bkOffset,' ');
7274   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7275   if(fmtsId>=0)
7276     oss << " (" << fmtsId << ")";
7277   oss << " has the following name: \"" << _name << "\"." << std::endl;
7278   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7279   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7280     {
7281       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
7282     }
7283   int i=0;
7284   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7285     {
7286       std::string chapter(17,'0'+i);
7287       oss << startLine << chapter << std::endl;
7288       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7289       if(cur)
7290         cur->simpleRepr(bkOffset+2,oss,i);
7291       else
7292         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
7293       oss << startLine << chapter << std::endl;
7294     }
7295 }
7296
7297 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7298 {
7299   std::size_t sz=_time_steps.size();
7300   std::vector< std::pair<int,int> > ret(sz);
7301   ret1.resize(sz);
7302   for(std::size_t i=0;i<sz;i++)
7303     {
7304       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7305       if(f1ts)
7306         {
7307           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7308         }
7309       else
7310         {
7311           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7312           throw INTERP_KERNEL::Exception(oss.str().c_str());
7313         }
7314     }
7315   return ret;
7316 }
7317
7318 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7319 {
7320   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7321   if(!tse2)
7322     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7323   checkCoherencyOfType(tse2);
7324   if(_time_steps.empty())
7325     {
7326       setName(tse2->getName().c_str());
7327       setInfo(tse2->getInfo());
7328     }
7329   checkThatComponentsMatch(tse2->getInfo());
7330   _time_steps.push_back(tse);
7331 }
7332
7333 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7334 {
7335   std::size_t nbOfCompo=_infos.size();
7336   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7337     {
7338       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7339       if(cur)
7340         {
7341           if((cur->getInfo()).size()!=nbOfCompo)
7342             {
7343               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7344               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7345               throw INTERP_KERNEL::Exception(oss.str().c_str());
7346             }
7347           cur->copyNameScope(*this);
7348         }
7349     }
7350 }
7351
7352 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7353 {
7354   _time_steps.resize(nbPdt);
7355   for(int i=0;i<nbPdt;i++)
7356     {
7357       std::vector< std::pair<int,int> > ts;
7358       med_int numdt=0,numo=0;
7359       med_int meshIt=0,meshOrder=0;
7360       med_float dt=0.0;
7361       MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7362       switch(fieldTyp)
7363       {
7364         case MED_FLOAT64:
7365           {
7366             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7367             break;
7368           }
7369         case MED_INT32:
7370           {
7371             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7372             break;
7373           }
7374         default:
7375           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7376       }
7377       if(loadAll)
7378         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7379       else
7380         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7381     }
7382 }
7383
7384 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7385 {
7386   if(_time_steps.empty())
7387     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7388   checkThatNbOfCompoOfTSMatchThis();
7389   std::vector<std::string> infos(getInfo());
7390   int nbComp=infos.size();
7391   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7392   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7393   for(int i=0;i<nbComp;i++)
7394     {
7395       std::string info=infos[i];
7396       std::string c,u;
7397       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7398       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7399       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7400     }
7401   if(_name.empty())
7402     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7403   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7404   int nbOfTS=_time_steps.size();
7405   for(int i=0;i<nbOfTS;i++)
7406     _time_steps[i]->writeLL(fid,opts,*this);
7407 }
7408
7409 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7410 {
7411   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7412     {
7413       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7414       if(elt)
7415         elt->loadBigArraysRecursively(fid,nasc);
7416     }
7417 }
7418
7419 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7420 {
7421   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7422     {
7423       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7424       if(elt)
7425         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7426     }
7427 }
7428
7429 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7430 {
7431   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7432     {
7433       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7434       if(elt)
7435         elt->unloadArrays();
7436     }
7437 }
7438
7439 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7440 {
7441   return _time_steps.size();
7442 }
7443
7444 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7445 {
7446   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7447   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7448     {
7449       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7450       if(tmp)
7451         newTS.push_back(*it);
7452     }
7453   _time_steps=newTS;
7454 }
7455
7456 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7457 {
7458   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7459   int maxId=(int)_time_steps.size();
7460   int ii=0;
7461   std::set<int> idsToDel;
7462   for(const int *id=startIds;id!=endIds;id++,ii++)
7463     {
7464       if(*id>=0 && *id<maxId)
7465         {
7466           idsToDel.insert(*id);
7467         }
7468       else
7469         {
7470           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7471           throw INTERP_KERNEL::Exception(oss.str().c_str());
7472         }
7473     }
7474   for(int iii=0;iii<maxId;iii++)
7475     if(idsToDel.find(iii)==idsToDel.end())
7476       newTS.push_back(_time_steps[iii]);
7477   _time_steps=newTS;
7478 }
7479
7480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7481 {
7482   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7483   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7484   if(nbOfEntriesToKill==0)
7485     return ;
7486   std::size_t sz=_time_steps.size();
7487   std::vector<bool> b(sz,true);
7488   int j=bg;
7489   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7490     b[j]=false;
7491   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7492   for(std::size_t i=0;i<sz;i++)
7493     if(b[i])
7494       newTS.push_back(_time_steps[i]);
7495   _time_steps=newTS;
7496 }
7497
7498 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7499 {
7500   int ret=0;
7501   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7502   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7503     {
7504       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7505       if(tmp)
7506         {
7507           int it2,ord;
7508           tmp->getTime(it2,ord);
7509           if(it2==iteration && order==ord)
7510             return ret;
7511           else
7512             oss << "(" << it2 << ","  << ord << "), ";
7513         }
7514     }
7515   throw INTERP_KERNEL::Exception(oss.str().c_str());
7516 }
7517
7518 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7519 {
7520   int ret=0;
7521   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7522   oss.precision(15);
7523   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7524     {
7525       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7526       if(tmp)
7527         {
7528           int it2,ord;
7529           double ti=tmp->getTime(it2,ord);
7530           if(fabs(time-ti)<eps)
7531             return ret;
7532           else
7533             oss << ti << ", ";
7534         }
7535     }
7536   throw INTERP_KERNEL::Exception(oss.str().c_str());
7537 }
7538
7539 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7540 {
7541   int lgth=_time_steps.size();
7542   std::vector< std::pair<int,int> > ret(lgth);
7543   for(int i=0;i<lgth;i++)
7544     _time_steps[i]->fillIteration(ret[i]);
7545   return ret;
7546 }
7547
7548 /*!
7549  * 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'
7550  * This method returns two things.
7551  * - The absolute dimension of 'this' in first parameter. 
7552  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7553  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7554  *
7555  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7556  * Only these 3 discretizations will be taken into account here.
7557  *
7558  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7559  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7560  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7561  *
7562  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7563  * 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'.
7564  * 
7565  * Let's consider the typical following case :
7566  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7567  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7568  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7569  *   TETRA4 and SEG2
7570  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7571  *
7572  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7573  * 
7574  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7575  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7576  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7577  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7578  */
7579 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7580 {
7581   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7582 }
7583
7584 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7585 {
7586   if(pos<0 || pos>=(int)_time_steps.size())
7587     {
7588       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7589       throw INTERP_KERNEL::Exception(oss.str().c_str());
7590     }
7591   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7592   if(item==0)
7593     {
7594       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7595       oss << "\nTry to use following method eraseEmptyTS !";
7596       throw INTERP_KERNEL::Exception(oss.str().c_str());
7597     }
7598   return item;
7599 }
7600
7601 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7602 {
7603   if(pos<0 || pos>=(int)_time_steps.size())
7604     {
7605       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7606       throw INTERP_KERNEL::Exception(oss.str().c_str());
7607     }
7608   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7609   if(item==0)
7610     {
7611       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7612       oss << "\nTry to use following method eraseEmptyTS !";
7613       throw INTERP_KERNEL::Exception(oss.str().c_str());
7614     }
7615   return item;
7616 }
7617
7618 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7619 {
7620   std::vector<std::string> ret;
7621   std::set<std::string> ret2;
7622   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7623     {
7624       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7625       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7626         if(ret2.find(*it2)==ret2.end())
7627           {
7628             ret.push_back(*it2);
7629             ret2.insert(*it2);
7630           }
7631     }
7632   return ret;
7633 }
7634
7635 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7636 {
7637   std::vector<std::string> ret;
7638   std::set<std::string> ret2;
7639   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7640     {
7641       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7642       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7643         if(ret2.find(*it2)==ret2.end())
7644           {
7645             ret.push_back(*it2);
7646             ret2.insert(*it2);
7647           }
7648     }
7649   return ret;
7650 }
7651
7652 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7653 {
7654   std::vector<std::string> ret;
7655   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7656     {
7657       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7658       ret.insert(ret.end(),tmp.begin(),tmp.end());
7659     }
7660   return ret;
7661 }
7662
7663 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7664 {
7665   std::vector<std::string> ret;
7666   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7667     {
7668       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7669       ret.insert(ret.end(),tmp.begin(),tmp.end());
7670     }
7671   return ret;
7672 }
7673
7674 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7675 {
7676   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7677     (*it)->changePflsRefsNamesGen2(mapOfModif);
7678 }
7679
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7681 {
7682   for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7683     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7684 }
7685
7686 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7687 {
7688   int lgth=_time_steps.size();
7689   std::vector< std::vector<TypeOfField> > ret(lgth);
7690   for(int i=0;i<lgth;i++)
7691     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7692   return ret;
7693 }
7694
7695 /*!
7696  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7697  */
7698 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
7699 {
7700   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7701 }
7702
7703 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7704 {
7705   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7706   std::size_t i=0;
7707   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7708     {
7709       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7710         ret->_time_steps[i]=(*it)->deepCopy();
7711     }
7712   return ret.retn();
7713 }
7714
7715 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7716 {
7717   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7718   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7719   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7720   for(std::size_t i=0;i<sz;i++)
7721     {
7722       ret[i]=shallowCpy();
7723       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7724     }
7725   for(std::size_t i=0;i<sz2;i++)
7726     {
7727       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7728       if(ret1.size()!=sz)
7729         {
7730           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7731           throw INTERP_KERNEL::Exception(oss.str().c_str());
7732         }
7733       ts[i]=ret1;
7734     }
7735   for(std::size_t i=0;i<sz;i++)
7736     for(std::size_t j=0;j<sz2;j++)
7737       ret[i]->_time_steps[j]=ts[j][i];
7738   return ret;
7739 }
7740
7741 /*!
7742  * This method splits into discretization each time steps in \a this.
7743  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7744  */
7745 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7746 {
7747   std::size_t sz(_time_steps.size());
7748   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7749   for(std::size_t i=0;i<sz;i++)
7750     {
7751       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7752       if(!timeStep)
7753         {
7754           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7755           throw INTERP_KERNEL::Exception(oss.str().c_str());
7756         }
7757       items[i]=timeStep->splitDiscretizations();  
7758     }
7759   //
7760   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7761   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7762   std::vector< TypeOfField > types;
7763   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7764     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7765       {
7766         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7767         if(ts.size()!=1)
7768           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7769         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7770         if(it2==types.end())
7771           types.push_back(ts[0]);
7772       }
7773   ret.resize(types.size()); ret2.resize(types.size());
7774   for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7775     for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7776       {
7777         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7778         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7779         ret2[pos].push_back(*it1);
7780       }
7781   for(std::size_t i=0;i<types.size();i++)
7782     {
7783       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7784       for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7785         elt->pushBackTimeStep(*it1);//also updates infos in elt
7786       ret[i]=elt;
7787       elt->MEDFileFieldNameScope::operator=(*this);
7788     }
7789   return ret;
7790 }
7791
7792 /*!
7793  * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7794  */
7795 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7796 {
7797   std::size_t sz(_time_steps.size());
7798   std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7799   std::size_t szOut(std::numeric_limits<std::size_t>::max());
7800   for(std::size_t i=0;i<sz;i++)
7801     {
7802       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7803       if(!timeStep)
7804         {
7805           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7806           throw INTERP_KERNEL::Exception(oss.str().c_str());
7807         }
7808       items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7809       if(szOut==std::numeric_limits<std::size_t>::max())
7810         szOut=items[i].size();
7811       else
7812         if(items[i].size()!=szOut)
7813           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7814     }
7815   if(szOut==std::numeric_limits<std::size_t>::max())
7816     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7817   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7818   for(std::size_t i=0;i<szOut;i++)
7819     {
7820       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7821       for(std::size_t j=0;j<sz;j++)
7822         elt->pushBackTimeStep(items[j][i]);
7823       ret[i]=elt;
7824       elt->MEDFileFieldNameScope::operator=(*this);
7825     }
7826   return ret;
7827 }
7828
7829 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7830 {
7831   _name=field->getName();
7832   if(_name.empty())
7833     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7834   if(!arr)
7835     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7836   _infos=arr->getInfoOnComponents();
7837 }
7838
7839 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7840 {
7841   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7842   if(_name!=field->getName())
7843     {
7844       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7845       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7846       throw INTERP_KERNEL::Exception(oss.str().c_str());
7847     }
7848   if(!arr)
7849     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7850   checkThatComponentsMatch(arr->getInfoOnComponents());
7851 }
7852
7853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7854 {
7855   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7856   if(getInfo().size()!=compos.size())
7857     {
7858       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7859       oss << " number of components of element to append (" << compos.size() << ") !";
7860       throw INTERP_KERNEL::Exception(oss.str().c_str());
7861     }
7862   if(_infos!=compos)
7863     {
7864       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7865       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7866       oss << " But compo in input fields are : ";
7867       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7868       oss << " !";
7869       throw INTERP_KERNEL::Exception(oss.str().c_str());
7870     }
7871 }
7872
7873 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7874 {
7875   std::size_t sz=_infos.size();
7876   int j=0;
7877   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7878     {
7879       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7880       if(elt)
7881         if(elt->getInfo().size()!=sz)
7882           {
7883             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7884             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7885             throw INTERP_KERNEL::Exception(oss.str().c_str());
7886           }
7887     }
7888 }
7889
7890 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7891 {
7892   if(!field)
7893     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7894   if(!_time_steps.empty())
7895     checkCoherencyOfTinyInfo(field,arr);
7896   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7897   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7898   objC->setFieldNoProfileSBT(field,arr,glob,*this);
7899   copyTinyInfoFrom(field,arr);
7900   _time_steps.push_back(obj);
7901 }
7902
7903 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7904 {
7905   if(!field)
7906     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7907   if(!_time_steps.empty())
7908     checkCoherencyOfTinyInfo(field,arr);
7909   MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7910   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7911   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7912   copyTinyInfoFrom(field,arr);
7913   _time_steps.push_back(obj);
7914 }
7915
7916 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7917 {
7918   int sz=(int)_time_steps.size();
7919   if(i<0 || i>=sz)
7920     {
7921       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7922       throw INTERP_KERNEL::Exception(oss.str().c_str());
7923     }
7924   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7925   if(tsPtr)
7926     {
7927       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7928         {
7929           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
7930           throw INTERP_KERNEL::Exception(oss.str().c_str());
7931         }
7932     }
7933   _time_steps[i]=ts;
7934 }
7935
7936 //= MEDFileFieldMultiTSWithoutSDA
7937
7938 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7939 {
7940   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7941 }
7942
7943 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7944 {
7945 }
7946
7947 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7948 {
7949 }
7950
7951 /*!
7952  * \param [in] fieldId field id in C mode
7953  */
7954 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7955 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
7956 {
7957 }
7958 catch(INTERP_KERNEL::Exception& e)
7959 { throw e; }
7960
7961 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7962 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
7963 {
7964 }
7965 catch(INTERP_KERNEL::Exception& e)
7966 { throw e; }
7967
7968 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7969 {
7970   return new MEDFileField1TSWithoutSDA;
7971 }
7972
7973 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7974 {
7975   if(!f1ts)
7976     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7977   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7978   if(!f1tsC)
7979     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7980 }
7981
7982 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7983 {
7984   return MEDFileField1TSWithoutSDA::TYPE_STR;
7985 }
7986
7987 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7988 {
7989   return new MEDFileFieldMultiTSWithoutSDA(*this);
7990 }
7991
7992 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7993 {
7994   return new MEDFileFieldMultiTSWithoutSDA;
7995 }
7996
7997 /*!
7998  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7999  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8000  */
8001 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
8002 {
8003   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8004   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8005   if(!myF1TSC)
8006     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8007   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8008 }
8009
8010 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8011 {
8012   MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8013   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8014   int i=0;
8015   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8016     {
8017       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8018       if(eltToConv)
8019         {
8020           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8021           if(!eltToConvC)
8022             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8023           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8024           ret->setIteration(i,elt);
8025         }
8026     }
8027   return ret.retn();
8028 }
8029
8030 //= MEDFileAnyTypeFieldMultiTS
8031
8032 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8033 {
8034 }
8035
8036 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8037 try:MEDFileFieldGlobsReal(fileName)
8038 {
8039   MEDFileUtilities::CheckFileForRead(fileName);
8040   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8041   _content=BuildContentFrom(fid,fileName,loadAll,ms);
8042   loadGlobals(fid);
8043 }
8044 catch(INTERP_KERNEL::Exception& e)
8045 {
8046     throw e;
8047 }
8048
8049 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8050 {
8051   med_field_type typcha;
8052   std::vector<std::string> infos;
8053   std::string dtunit;
8054   int i=-1;
8055   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8056   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8057   switch(typcha)
8058   {
8059     case MED_FLOAT64:
8060       {
8061         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8062         break;
8063       }
8064     case MED_INT32:
8065       {
8066         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8067         break;
8068       }
8069     default:
8070       {
8071         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8072         throw INTERP_KERNEL::Exception(oss.str().c_str());
8073       }
8074   }
8075   ret->setDtUnit(dtunit.c_str());
8076   return ret.retn();
8077 }
8078
8079 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8080 {
8081   med_field_type typcha;
8082   //
8083   std::vector<std::string> infos;
8084   std::string dtunit,fieldName;
8085   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8086   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8087   switch(typcha)
8088   {
8089     case MED_FLOAT64:
8090       {
8091         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8092         break;
8093       }
8094     case MED_INT32:
8095       {
8096         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8097         break;
8098       }
8099     default:
8100       {
8101         std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fileName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8102         throw INTERP_KERNEL::Exception(oss.str().c_str());
8103       }
8104   }
8105   ret->setDtUnit(dtunit.c_str());
8106   return ret.retn();
8107 }
8108
8109 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8110 {
8111   if(!c)
8112     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8113   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8114     {
8115       MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8116       ret->setFileName(fileName);
8117       ret->_content=c;  c->incrRef();
8118       return ret.retn();
8119     }
8120   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8121     {
8122       MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8123       ret->setFileName(fileName);
8124       ret->_content=c;  c->incrRef();
8125       return ret.retn();
8126     }
8127   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8128 }
8129
8130 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8131 try:MEDFileFieldGlobsReal(fileName)
8132 {
8133   MEDFileUtilities::CheckFileForRead(fileName);
8134   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8135   _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8136   loadGlobals(fid);
8137 }
8138 catch(INTERP_KERNEL::Exception& e)
8139 {
8140     throw e;
8141 }
8142
8143 //= MEDFileIntFieldMultiTSWithoutSDA
8144
8145 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8146 {
8147   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8148 }
8149
8150 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8151 {
8152 }
8153
8154 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8155 {
8156 }
8157
8158 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8159 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8160 {
8161 }
8162 catch(INTERP_KERNEL::Exception& e)
8163 { throw e; }
8164
8165 /*!
8166  * \param [in] fieldId field id in C mode
8167  */
8168 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8169 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8170 {
8171 }
8172 catch(INTERP_KERNEL::Exception& e)
8173 { throw e; }
8174
8175 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8176 {
8177   return new MEDFileIntField1TSWithoutSDA;
8178 }
8179
8180 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8181 {
8182   if(!f1ts)
8183     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8184   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8185   if(!f1tsC)
8186     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8187 }
8188
8189 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8190 {
8191   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8192 }
8193
8194 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8195 {
8196   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8197 }
8198
8199 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8200 {
8201   return new MEDFileIntFieldMultiTSWithoutSDA;
8202 }
8203
8204 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8205 {
8206   MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8207   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8208   int i=0;
8209   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8210     {
8211       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8212       if(eltToConv)
8213         {
8214           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8215           if(!eltToConvC)
8216             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8217           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8218           ret->setIteration(i,elt);
8219         }
8220     }
8221   return ret.retn();
8222 }
8223
8224 //= MEDFileAnyTypeFieldMultiTS
8225
8226 /*!
8227  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8228  * that has been read from a specified MED file.
8229  *  \param [in] fileName - the name of the MED file to read.
8230  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8231  *          is to delete this field using decrRef() as it is no more needed.
8232  *  \throw If reading the file fails.
8233  */
8234 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8235 {
8236   MEDFileUtilities::CheckFileForRead(fileName);
8237   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8238   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8239   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8240   ret->loadGlobals(fid);
8241   return ret.retn();
8242 }
8243
8244 /*!
8245  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8246  * that has been read from a specified MED file.
8247  *  \param [in] fileName - the name of the MED file to read.
8248  *  \param [in] fieldName - the name of the field to read.
8249  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8250  *          is to delete this field using decrRef() as it is no more needed.
8251  *  \throw If reading the file fails.
8252  *  \throw If there is no field named \a fieldName in the file.
8253  */
8254 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8255 {
8256   MEDFileUtilities::CheckFileForRead(fileName);
8257   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8258   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8259   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8260   ret->loadGlobals(fid);
8261   return ret.retn();
8262 }
8263
8264 /*!
8265  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8266  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8267  *
8268  * \warning this is a shallow copy constructor
8269  */
8270 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8271 {
8272   if(!shallowCopyOfContent)
8273     {
8274       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8275       otherPtr->incrRef();
8276       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8277     }
8278   else
8279     {
8280       _content=other.shallowCpy();
8281     }
8282 }
8283
8284 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8285 {
8286   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8287   if(!ret)
8288     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8289   return ret;
8290 }
8291
8292 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8293 {
8294   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8295   if(!ret)
8296     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8297   return ret;
8298 }
8299
8300 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8301 {
8302   return contentNotNullBase()->getPflsReallyUsed2();
8303 }
8304
8305 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8306 {
8307   return contentNotNullBase()->getLocsReallyUsed2();
8308 }
8309
8310 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8311 {
8312   return contentNotNullBase()->getPflsReallyUsedMulti2();
8313 }
8314
8315 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8316 {
8317   return contentNotNullBase()->getLocsReallyUsedMulti2();
8318 }
8319
8320 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8321 {
8322   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8323 }
8324
8325 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8326 {
8327   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8328 }
8329
8330 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8331 {
8332   return contentNotNullBase()->getNumberOfTS();
8333 }
8334
8335 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8336 {
8337   contentNotNullBase()->eraseEmptyTS();
8338 }
8339
8340 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8341 {
8342   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8343 }
8344
8345 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8346 {
8347   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8348 }
8349
8350 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8351 {
8352   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8353   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8354   ret->_content=c;
8355   return ret.retn();
8356 }
8357
8358 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8359 {
8360   MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8361   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8362   ret->_content=c;
8363   return ret.retn();
8364 }
8365
8366 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8367 {
8368   return contentNotNullBase()->getIterations();
8369 }
8370
8371 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8372 {
8373   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8374     pushBackTimeStep(*it);
8375 }
8376
8377 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8378 {
8379   if(!fmts)
8380     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8381   int nbOfTS(fmts->getNumberOfTS());
8382   for(int i=0;i<nbOfTS;i++)
8383     {
8384       MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8385       pushBackTimeStep(elt);
8386     }
8387 }
8388
8389 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8390 {
8391   if(!f1ts)
8392     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8393   checkCoherencyOfType(f1ts);
8394   f1ts->incrRef();
8395   MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8396   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8397   c->incrRef();
8398   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8399   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8400     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8401   _content->pushBackTimeStep(cSafe);
8402   appendGlobs(*f1ts,1e-12);
8403 }
8404
8405 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8406 {
8407   contentNotNullBase()->synchronizeNameScope();
8408 }
8409
8410 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8411 {
8412   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8413 }
8414
8415 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8416 {
8417   return contentNotNullBase()->getPosGivenTime(time,eps);
8418 }
8419
8420 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8421 {
8422   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8423 }
8424
8425 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8426 {
8427   return contentNotNullBase()->getTypesOfFieldAvailable();
8428 }
8429
8430 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
8431 {
8432   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8433 }
8434
8435 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8436 {
8437   return contentNotNullBase()->getName();
8438 }
8439
8440 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8441 {
8442   contentNotNullBase()->setName(name);
8443 }
8444
8445 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8446 {
8447   return contentNotNullBase()->getDtUnit();
8448 }
8449
8450 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8451 {
8452   contentNotNullBase()->setDtUnit(dtUnit);
8453 }
8454
8455 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8456 {
8457   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8458 }
8459
8460 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8461 {
8462   return contentNotNullBase()->getTimeSteps(ret1);
8463 }
8464
8465 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8466 {
8467   return contentNotNullBase()->getMeshName();
8468 }
8469
8470 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8471 {
8472   contentNotNullBase()->setMeshName(newMeshName);
8473 }
8474
8475 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8476 {
8477   return contentNotNullBase()->changeMeshNames(modifTab);
8478 }
8479
8480 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8481 {
8482   return contentNotNullBase()->getInfo();
8483 }
8484
8485 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8486 {
8487   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8488 }
8489
8490 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8491 {
8492   return contentNotNullBase()->setInfo(info);
8493 }
8494
8495 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8496 {
8497   const std::vector<std::string> ret=getInfo();
8498   return (int)ret.size();
8499 }
8500
8501 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8502 {
8503   writeGlobals(fid,*this);
8504   contentNotNullBase()->writeLL(fid,*this);
8505 }
8506
8507 /*!
8508  * Writes \a this field into a MED file specified by its name.
8509  *  \param [in] fileName - the MED file name.
8510  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8511  * - 2 - erase; an existing file is removed.
8512  * - 1 - append; same data should not be present in an existing file.
8513  * - 0 - overwrite; same data present in an existing file is overwritten.
8514  *  \throw If the field name is not set.
8515  *  \throw If no field data is set.
8516  *  \throw If \a mode == 1 and the same data is present in an existing file.
8517  */
8518 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8519 {
8520   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8521   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8522   writeLL(fid);
8523 }
8524
8525 /*!
8526  * This method alloc the arrays and load potentially huge arrays contained in this field.
8527  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8528  * This method can be also called to refresh or reinit values from a file.
8529  * 
8530  * \throw If the fileName is not set or points to a non readable MED file.
8531  */
8532 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8533 {
8534   if(getFileName().empty())
8535     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8536   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8537   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8538 }
8539
8540 /*!
8541  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8542  * But once data loaded once, this method does nothing.
8543  * 
8544  * \throw If the fileName is not set or points to a non readable MED file.
8545  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8546  */
8547 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8548 {
8549   if(!getFileName().empty())
8550     {
8551       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8552       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8553     }
8554 }
8555
8556 /*!
8557  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8558  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8559  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8560  * 
8561  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8562  */
8563 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8564 {
8565   contentNotNullBase()->unloadArrays();
8566 }
8567
8568 /*!
8569  * 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.
8570  * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8571  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8572  * 
8573  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8574  */
8575 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8576 {
8577   if(!getFileName().empty())
8578     contentNotNullBase()->unloadArrays();
8579 }
8580
8581 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8582 {
8583   std::ostringstream oss;
8584   contentNotNullBase()->simpleRepr(0,oss,-1);
8585   simpleReprGlobs(oss);
8586   return oss.str();
8587 }
8588
8589 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8590 {
8591   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8592 }
8593
8594 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8595 {
8596   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8597   ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8598   return ret;
8599 }
8600
8601 /*!
8602  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8603  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8604  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8605  */
8606 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8607 {
8608   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8609   if(!content)
8610     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8611   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8612   std::size_t sz(contentsSplit.size());
8613   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8614   for(std::size_t i=0;i<sz;i++)
8615     {
8616       ret[i]=shallowCpy();
8617       ret[i]->_content=contentsSplit[i];
8618     }
8619   return ret;
8620 }
8621
8622 /*!
8623  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8624  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8625  */
8626 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8627 {
8628   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8629   if(!content)
8630     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8631   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8632   std::size_t sz(contentsSplit.size());
8633   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8634   for(std::size_t i=0;i<sz;i++)
8635     {
8636       ret[i]=shallowCpy();
8637       ret[i]->_content=contentsSplit[i];
8638     }
8639   return ret;
8640 }
8641
8642 /*!
8643  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8644  * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8645  */
8646 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8647 {
8648   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8649   if(!content)
8650     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8651   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8652   std::size_t sz(contentsSplit.size());
8653   std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8654   for(std::size_t i=0;i<sz;i++)
8655     {
8656       ret[i]=shallowCpy();
8657       ret[i]->_content=contentsSplit[i];
8658     }
8659   return ret;
8660 }
8661
8662 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8663 {
8664   MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8665   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8666     ret->_content=_content->deepCopy();
8667   ret->deepCpyGlobs(*this);
8668   return ret.retn();
8669 }
8670
8671 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8672 {
8673   return _content;
8674 }
8675
8676 /*!
8677  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8678  *  \param [in] iteration - the iteration number of a required time step.
8679  *  \param [in] order - the iteration order number of required time step.
8680  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8681  *          delete this field using decrRef() as it is no more needed.
8682  *  \throw If there is no required time step in \a this field.
8683  */
8684 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8685 {
8686   int pos=getPosOfTimeStep(iteration,order);
8687   return getTimeStepAtPos(pos);
8688 }
8689
8690 /*!
8691  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8692  *  \param [in] time - the time of the time step of interest.
8693  *  \param [in] eps - a precision used to compare time values.
8694  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8695  *          delete this field using decrRef() as it is no more needed.
8696  *  \throw If there is no required time step in \a this field.
8697  */
8698 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8699 {
8700   int pos=getPosGivenTime(time,eps);
8701   return getTimeStepAtPos(pos);
8702 }
8703
8704 /*!
8705  * 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.
8706  * The float64 value of time attached to the pair of integers are not considered here.
8707  * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8708  *
8709  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8710  * \throw If there is a null pointer in \a vectFMTS.
8711  */
8712 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8713 {
8714   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8715   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8716   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8717   while(!lstFMTS.empty())
8718     {
8719       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8720       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8721       if(!curIt)
8722         throw INTERP_KERNEL::Exception(msg);
8723       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8724       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8725       elt.push_back(curIt); it=lstFMTS.erase(it);
8726       while(it!=lstFMTS.end())
8727         {
8728           curIt=*it;
8729           if(!curIt)
8730             throw INTERP_KERNEL::Exception(msg);
8731           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8732           if(refIts==curIts)
8733             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8734           else
8735             it++;
8736         }
8737       ret.push_back(elt);
8738     }
8739   return ret;
8740 }
8741
8742 /*!
8743  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8744  * All returned instances in a subvector can be safely loaded, rendered along time
8745  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8746  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8747  * 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).
8748  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8749  * 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.
8750  *
8751  * \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().
8752  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8753  * \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.
8754  * \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.
8755  *
8756  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8757  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8758  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8759  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8760  * \throw If mesh is null.
8761  * \throw If an element in \a vectFMTS is null.
8762  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8763  */
8764 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8765 {
8766   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8767   if(!mesh)
8768     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8769   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8770   if(vectFMTS.empty())
8771     return ret;
8772   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8773   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8774   if(!frstElt)
8775     throw INTERP_KERNEL::Exception(msg);
8776   std::size_t i=0;
8777   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8778   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8779   for(;it!=vectFMTS.end();it++,i++)
8780     {
8781       if(!(*it))
8782         throw INTERP_KERNEL::Exception(msg);
8783       TypeOfField tof0,tof1;
8784       if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8785         {
8786           if(tof1!=ON_NODES)
8787             vectFMTSNotNodes.push_back(*it);
8788           else
8789             vectFMTSNodes.push_back(*it);
8790         }
8791       else
8792         vectFMTSNotNodes.push_back(*it);
8793     }
8794   std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8795   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8796   ret=retCell;
8797   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8798     {
8799       i=0;
8800       bool isFetched(false);
8801       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8802         {
8803           if((*it0).empty())
8804             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8805           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8806             { ret[i].push_back(*it2); isFetched=true; }
8807         }
8808       if(!isFetched)
8809         {
8810           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8811           MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8812           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8813         }
8814     }
8815   fsc=cmps;
8816   return ret;
8817 }
8818
8819 /*!
8820  * 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.
8821  * \param [out] cmps - same size than the returned vector.
8822  */
8823 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8824 {
8825   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8826   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8827   while(!lstFMTS.empty())
8828     {
8829       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8830       MEDFileAnyTypeFieldMultiTS *ref(*it);
8831       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8832       elt.push_back(ref); it=lstFMTS.erase(it);
8833       MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8834       MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8835       while(it!=lstFMTS.end())
8836         {
8837           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8838           if(cmp->isEqual(curIt))
8839             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8840           else
8841             it++;
8842         }
8843       ret.push_back(elt); cmps.push_back(cmp);
8844     }
8845   return ret;
8846 }
8847
8848 /*!
8849  * 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.
8850  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8851  *
8852  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8853  * \throw If \a f0 or \a f1 change of spatial discretization along time.
8854  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8855  * \thorw If \a f0 and \a f1 do not have the same times steps.
8856  * \throw If mesh is null.
8857  * \throw If \a f0 or \a f1 is null.
8858  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8859  */
8860 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8861 {
8862   if(!mesh)
8863     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8864   if(!f0 || !f1)
8865     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8866   if(f0->getMeshName()!=mesh->getName())
8867     {
8868       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8869       throw INTERP_KERNEL::Exception(oss.str().c_str());
8870     }
8871   if(f1->getMeshName()!=mesh->getName())
8872     {
8873       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8874       throw INTERP_KERNEL::Exception(oss.str().c_str());
8875     }
8876   int nts=f0->getNumberOfTS();
8877   if(nts!=f1->getNumberOfTS())
8878     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8879   if(nts==0)
8880     return nts;
8881   for(int i=0;i<nts;i++)
8882     {
8883       MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8884       MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8885       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8886       if(tofs0.size()!=1 || tofs1.size()!=1)
8887         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8888       if(i!=0)
8889         {
8890           if(tof0!=tofs0[0] || tof1!=tofs1[0])
8891             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8892         }
8893       else
8894         { tof0=tofs0[0]; tof1=tofs1[0]; }
8895       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8896         {
8897           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() << ") !";
8898           throw INTERP_KERNEL::Exception(oss.str().c_str());
8899         }
8900       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8901         {
8902           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() << ") !";
8903           throw INTERP_KERNEL::Exception(oss.str().c_str());
8904         }
8905       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8906         {
8907           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() << ") !";
8908           throw INTERP_KERNEL::Exception(oss.str().c_str());
8909         }
8910     }
8911   return nts;
8912 }
8913
8914 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8915 {
8916   return new MEDFileAnyTypeFieldMultiTSIterator(this);
8917 }
8918
8919 //= MEDFileFieldMultiTS
8920
8921 /*!
8922  * Returns a new empty instance of MEDFileFieldMultiTS.
8923  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8924  *          is to delete this field using decrRef() as it is no more needed.
8925  */
8926 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8927 {
8928   return new MEDFileFieldMultiTS;
8929 }
8930
8931 /*!
8932  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8933  * that has been read from a specified MED file.
8934  *  \param [in] fileName - the name of the MED file to read.
8935  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8936  *          is to delete this field using decrRef() as it is no more needed.
8937  *  \throw If reading the file fails.
8938  */
8939 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8940 {
8941   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8942   ret->contentNotNull();//to check that content type matches with \a this type.
8943   return ret.retn();
8944 }
8945
8946 /*!
8947  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8948  * that has been read from a specified MED file.
8949  *  \param [in] fileName - the name of the MED file to read.
8950  *  \param [in] fieldName - the name of the field to read.
8951  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8952  *          is to delete this field using decrRef() as it is no more needed.
8953  *  \throw If reading the file fails.
8954  *  \throw If there is no field named \a fieldName in the file.
8955  */
8956 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8957 {
8958   MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8959   ret->contentNotNull();//to check that content type matches with \a this type.
8960   return ret.retn();
8961 }
8962
8963 /*!
8964  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8965  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8966  *
8967  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8968  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8969  * \warning this is a shallow copy constructor
8970  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8971  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8972  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8973  *          is to delete this field using decrRef() as it is no more needed.
8974  */
8975 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8976 {
8977   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8978 }
8979
8980 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
8981 {
8982   MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
8983   ret->contentNotNull();//to check that content type matches with \a this type.
8984   return ret.retn();
8985 }
8986
8987 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8988 {
8989   return new MEDFileFieldMultiTS(*this);
8990 }
8991
8992 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8993 {
8994   if(!f1ts)
8995     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8996   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8997   if(!f1tsC)
8998     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8999 }
9000
9001 /*!
9002  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9003  * following the given input policy.
9004  *
9005  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9006  *                            By default (true) the globals are deeply copied.
9007  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9008  */
9009 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9010 {
9011   MCAuto<MEDFileIntFieldMultiTS> ret;
9012   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9013   if(content)
9014     {
9015       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9016       if(!contc)
9017         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9018       MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9019       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9020     }
9021   else
9022     ret=MEDFileIntFieldMultiTS::New();
9023   if(isDeepCpyGlobs)
9024     ret->deepCpyGlobs(*this);
9025   else
9026     ret->shallowCpyGlobs(*this);
9027   return ret.retn();
9028 }
9029
9030 /*!
9031  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9032  *  \param [in] pos - a time step id.
9033  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9034  *          delete this field using decrRef() as it is no more needed.
9035  *  \throw If \a pos is not a valid time step id.
9036  */
9037 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9038 {
9039   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9040   if(!item)
9041     {
9042       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9043       throw INTERP_KERNEL::Exception(oss.str().c_str());
9044     }
9045   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9046   if(itemC)
9047     {
9048       MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9049       ret->shallowCpyGlobs(*this);
9050       return ret.retn();
9051     }
9052   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9053   throw INTERP_KERNEL::Exception(oss.str().c_str());
9054 }
9055
9056 /*!
9057  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9058  * mesh entities of a given dimension of the first mesh in MED file.
9059  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9060  *  \param [in] type - a spatial discretization of interest.
9061  *  \param [in] iteration - the iteration number of a required time step.
9062  *  \param [in] order - the iteration order number of required time step.
9063  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9064  *  \param [in] renumPol - specifies how to permute values of the result field according to
9065  *          the optional numbers of cells and nodes, if any. The valid values are
9066  *          - 0 - do not permute.
9067  *          - 1 - permute cells.
9068  *          - 2 - permute nodes.
9069  *          - 3 - permute cells and nodes.
9070  *
9071  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9072  *          caller is to delete this field using decrRef() as it is no more needed. 
9073  *  \throw If the MED file is not readable.
9074  *  \throw If there is no mesh in the MED file.
9075  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9076  *  \throw If no field values of the required parameters are available.
9077  */
9078 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9079 {
9080   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9081   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9082   if(!myF1TSC)
9083     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9084   MCAuto<DataArray> arrOut;
9085   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9086   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9087   return ret.retn();
9088 }
9089
9090 /*!
9091  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9092  * the top level cells of the first mesh in MED file.
9093  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9094  *  \param [in] type - a spatial discretization of interest.
9095  *  \param [in] iteration - the iteration number of a required time step.
9096  *  \param [in] order - the iteration order number of required time step.
9097  *  \param [in] renumPol - specifies how to permute values of the result field according to
9098  *          the optional numbers of cells and nodes, if any. The valid values are
9099  *          - 0 - do not permute.
9100  *          - 1 - permute cells.
9101  *          - 2 - permute nodes.
9102  *          - 3 - permute cells and nodes.
9103  *
9104  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9105  *          caller is to delete this field using decrRef() as it is no more needed. 
9106  *  \throw If the MED file is not readable.
9107  *  \throw If there is no mesh in the MED file.
9108  *  \throw If no field values of the required parameters are available.
9109  */
9110 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9111 {
9112   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9113   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9114   if(!myF1TSC)
9115     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9116   MCAuto<DataArray> arrOut;
9117   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9118   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9119   return ret.retn();
9120 }
9121
9122 /*!
9123  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9124  * a given support.
9125  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9126  *  \param [in] type - a spatial discretization of interest.
9127  *  \param [in] iteration - the iteration number of a required time step.
9128  *  \param [in] order - the iteration order number of required time step.
9129  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9130  *  \param [in] mesh - the supporting mesh.
9131  *  \param [in] renumPol - specifies how to permute values of the result field according to
9132  *          the optional numbers of cells and nodes, if any. The valid values are
9133  *          - 0 - do not permute.
9134  *          - 1 - permute cells.
9135  *          - 2 - permute nodes.
9136  *          - 3 - permute cells and nodes.
9137  *
9138  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9139  *          caller is to delete this field using decrRef() as it is no more needed. 
9140  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9141  *  \throw If no field of \a this is lying on \a mesh.
9142  *  \throw If no field values of the required parameters are available.
9143  */
9144 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9145 {
9146   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9147   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9148   if(!myF1TSC)
9149     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9150   MCAuto<DataArray> arrOut;
9151   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9152   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9153   return ret.retn();
9154 }
9155
9156 /*!
9157  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9158  * given support. 
9159  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9160  *  \param [in] type - a spatial discretization of the new field.
9161  *  \param [in] iteration - the iteration number of a required time step.
9162  *  \param [in] order - the iteration order number of required time step.
9163  *  \param [in] mesh - the supporting mesh.
9164  *  \param [in] renumPol - specifies how to permute values of the result field according to
9165  *          the optional numbers of cells and nodes, if any. The valid values are
9166  *          - 0 - do not permute.
9167  *          - 1 - permute cells.
9168  *          - 2 - permute nodes.
9169  *          - 3 - permute cells and nodes.
9170  *
9171  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9172  *          caller is to delete this field using decrRef() as it is no more needed. 
9173  *  \throw If no field of \a this is lying on \a mesh.
9174  *  \throw If no field values of the required parameters are available.
9175  */
9176 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9177 {
9178   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9179   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9180   if(!myF1TSC)
9181     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9182   MCAuto<DataArray> arrOut;
9183   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9184   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9185   return ret.retn();
9186 }
9187
9188 /*!
9189  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9190  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9191  * This method is useful for MED2 file format when field on different mesh was autorized.
9192  */
9193 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9194 {
9195   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9196   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9197   if(!myF1TSC)
9198     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9199   MCAuto<DataArray> arrOut;
9200   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9201   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9202   return ret.retn();
9203 }
9204
9205 /*!
9206  * Returns values and a profile of the field of a given type, of a given time step,
9207  * lying on a given support.
9208  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9209  *  \param [in] type - a spatial discretization of the field.
9210  *  \param [in] iteration - the iteration number of a required time step.
9211  *  \param [in] order - the iteration order number of required time step.
9212  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9213  *  \param [in] mesh - the supporting mesh.
9214  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9215  *          field of interest lies on. If the field lies on all entities of the given
9216  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9217  *          using decrRef() as it is no more needed.  
9218  *  \param [in] glob - the global data storing profiles and localization.
9219  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9220  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9221  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9222  *  \throw If no field of \a this is lying on \a mesh.
9223  *  \throw If no field values of the required parameters are available.
9224  */
9225 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9226 {
9227   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9228   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9229   if(!myF1TSC)
9230     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9231   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9232   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9233 }
9234
9235 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9236 {
9237   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9238   if(!pt)
9239     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9240   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9241   if(!ret)
9242     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 !");
9243   return ret;
9244 }
9245
9246 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9247 {
9248   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9249   if(!pt)
9250     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9251   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9252   if(!ret)
9253     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 !");
9254   return ret;
9255 }
9256
9257 /*!
9258  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9259  * the given field is checked if its elements are sorted suitable for writing to MED file
9260  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9261  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9262  *  \param [in] field - the field to add to \a this.
9263  *  \throw If the name of \a field is empty.
9264  *  \throw If the data array of \a field is not set.
9265  *  \throw If existing time steps have different name or number of components than \a field.
9266  *  \throw If the underlying mesh of \a field has no name.
9267  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9268  */
9269 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9270 {
9271   const DataArrayDouble *arr=0;
9272   if(field)
9273     arr=field->getArray();
9274   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9275 }
9276
9277 /*!
9278  * Adds a MEDCouplingFieldDouble to \a this as another time step.
9279  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9280  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9281  * and \a profile.
9282  *
9283  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9284  * A new profile is added only if no equal profile is missing.
9285  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9286  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9287  *  \param [in] mesh - the supporting mesh of \a field.
9288  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9289  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9290  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9291  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9292  *  \throw If the data array of \a field is not set.
9293  *  \throw If the data array of \a this is already allocated but has different number of
9294  *         components than \a field.
9295  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9296  *  \sa setFieldNoProfileSBT()
9297  */
9298 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9299 {
9300   const DataArrayDouble *arr=0;
9301   if(field)
9302     arr=field->getArray();
9303   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9304 }
9305
9306 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9307 {
9308   _content=new MEDFileFieldMultiTSWithoutSDA;
9309 }
9310
9311 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9312 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9313 {
9314 }
9315 catch(INTERP_KERNEL::Exception& e)
9316 { throw e; }
9317
9318 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9319 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9320 {
9321 }
9322 catch(INTERP_KERNEL::Exception& e)
9323 { throw e; }
9324
9325 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9326 {
9327 }
9328
9329 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
9330 {
9331   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9332 }
9333
9334 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9335 {
9336   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9337 }
9338
9339 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9340 {
9341   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9342 }
9343
9344 //= MEDFileAnyTypeFieldMultiTSIterator
9345
9346 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9347 {
9348   if(fmts)
9349     {
9350       fmts->incrRef();
9351       _nb_iter=fmts->getNumberOfTS();
9352     }
9353 }
9354
9355 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
9356 {
9357 }
9358
9359 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9360 {
9361   if(_iter_id<_nb_iter)
9362     {
9363       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9364       if(fmts)
9365         return fmts->getTimeStepAtPos(_iter_id++);
9366       else
9367         return 0;
9368     }
9369   else
9370     return 0;
9371 }
9372
9373 //= MEDFileIntFieldMultiTS
9374
9375 /*!
9376  * Returns a new empty instance of MEDFileFieldMultiTS.
9377  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9378  *          is to delete this field using decrRef() as it is no more needed.
9379  */
9380 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9381 {
9382   return new MEDFileIntFieldMultiTS;
9383 }
9384
9385 /*!
9386  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9387  * that has been read from a specified MED file.
9388  *  \param [in] fileName - the name of the MED file to read.
9389  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9390  *          is to delete this field using decrRef() as it is no more needed.
9391  *  \throw If reading the file fails.
9392  */
9393 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9394 {
9395   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9396   ret->contentNotNull();//to check that content type matches with \a this type.
9397   return ret.retn();
9398 }
9399
9400 /*!
9401  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9402  * that has been read from a specified MED file.
9403  *  \param [in] fileName - the name of the MED file to read.
9404  *  \param [in] fieldName - the name of the field to read.
9405  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9406  *          is to delete this field using decrRef() as it is no more needed.
9407  *  \throw If reading the file fails.
9408  *  \throw If there is no field named \a fieldName in the file.
9409  */
9410 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9411 {
9412   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9413   ret->contentNotNull();//to check that content type matches with \a this type.
9414   return ret.retn();
9415 }
9416
9417 /*!
9418  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9419  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9420  *
9421  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9422  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9423  * \warning this is a shallow copy constructor
9424  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9425  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9426  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9427  *          is to delete this field using decrRef() as it is no more needed.
9428  */
9429 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9430 {
9431   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9432 }
9433
9434 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9435 {
9436   MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9437   ret->contentNotNull();//to check that content type matches with \a this type.
9438   return ret.retn();
9439 }
9440
9441 /*!
9442  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9443  * following the given input policy.
9444  *
9445  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9446  *                            By default (true) the globals are deeply copied.
9447  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9448  */
9449 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9450 {
9451   MCAuto<MEDFileFieldMultiTS> ret;
9452   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9453   if(content)
9454     {
9455       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9456       if(!contc)
9457         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9458       MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9459       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9460     }
9461   else
9462     ret=MEDFileFieldMultiTS::New();
9463   if(isDeepCpyGlobs)
9464     ret->deepCpyGlobs(*this);
9465   else
9466     ret->shallowCpyGlobs(*this);
9467   return ret.retn();
9468 }
9469
9470 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9471 {
9472   return new MEDFileIntFieldMultiTS(*this);
9473 }
9474
9475 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9476 {
9477   if(!f1ts)
9478     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9479   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9480   if(!f1tsC)
9481     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9482 }
9483
9484 /*!
9485  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9486  * mesh entities of a given dimension of the first mesh in MED file.
9487  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9488  *  \param [in] type - a spatial discretization of interest.
9489  *  \param [in] iteration - the iteration number of a required time step.
9490  *  \param [in] order - the iteration order number of required time step.
9491  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9492  *  \param [out] arrOut - the DataArrayInt containing values of field.
9493  *  \param [in] renumPol - specifies how to permute values of the result field according to
9494  *          the optional numbers of cells and nodes, if any. The valid values are
9495  *          - 0 - do not permute.
9496  *          - 1 - permute cells.
9497  *          - 2 - permute nodes.
9498  *          - 3 - permute cells and nodes.
9499  *
9500  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9501  *          caller is to delete this field using decrRef() as it is no more needed. 
9502  *  \throw If the MED file is not readable.
9503  *  \throw If there is no mesh in the MED file.
9504  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9505  *  \throw If no field values of the required parameters are available.
9506  */
9507 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9508 {
9509   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9510   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9511   if(!myF1TSC)
9512     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9513   MCAuto<DataArray> arr;
9514   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9515   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9516   return ret.retn();
9517 }
9518
9519 /*!
9520  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9521  * the top level cells of the first mesh in MED file.
9522  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9523  *  \param [in] type - a spatial discretization of interest.
9524  *  \param [in] iteration - the iteration number of a required time step.
9525  *  \param [in] order - the iteration order number of required time step.
9526  *  \param [out] arrOut - the DataArrayInt containing values of field.
9527  *  \param [in] renumPol - specifies how to permute values of the result field according to
9528  *          the optional numbers of cells and nodes, if any. The valid values are
9529  *          - 0 - do not permute.
9530  *          - 1 - permute cells.
9531  *          - 2 - permute nodes.
9532  *          - 3 - permute cells and nodes.
9533  *
9534  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9535  *          caller is to delete this field using decrRef() as it is no more needed. 
9536  *  \throw If the MED file is not readable.
9537  *  \throw If there is no mesh in the MED file.
9538  *  \throw If no field values of the required parameters are available.
9539  */
9540 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9541 {
9542   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9543   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9544   if(!myF1TSC)
9545     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9546   MCAuto<DataArray> arr;
9547   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9548   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9549   return ret.retn();
9550 }
9551
9552 /*!
9553  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9554  * a given support.
9555  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9556  *  \param [in] type - a spatial discretization of interest.
9557  *  \param [in] iteration - the iteration number of a required time step.
9558  *  \param [in] order - the iteration order number of required time step.
9559  *  \param [out] arrOut - the DataArrayInt containing values of field.
9560  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9561  *  \param [in] mesh - the supporting mesh.
9562  *  \param [in] renumPol - specifies how to permute values of the result field according to
9563  *          the optional numbers of cells and nodes, if any. The valid values are
9564  *          - 0 - do not permute.
9565  *          - 1 - permute cells.
9566  *          - 2 - permute nodes.
9567  *          - 3 - permute cells and nodes.
9568  *
9569  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9570  *          caller is to delete this field using decrRef() as it is no more needed. 
9571  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9572  *  \throw If no field of \a this is lying on \a mesh.
9573  *  \throw If no field values of the required parameters are available.
9574  */
9575 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9576 {
9577   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9578   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9579   if(!myF1TSC)
9580     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9581   MCAuto<DataArray> arr;
9582   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9583   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9584   return ret.retn();
9585 }
9586
9587 /*!
9588  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9589  * given support. 
9590  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9591  *  \param [in] type - a spatial discretization of the new field.
9592  *  \param [in] iteration - the iteration number of a required time step.
9593  *  \param [in] order - the iteration order number of required time step.
9594  *  \param [in] mesh - the supporting mesh.
9595  *  \param [out] arrOut - the DataArrayInt containing values of field.
9596  *  \param [in] renumPol - specifies how to permute values of the result field according to
9597  *          the optional numbers of cells and nodes, if any. The valid values are
9598  *          - 0 - do not permute.
9599  *          - 1 - permute cells.
9600  *          - 2 - permute nodes.
9601  *          - 3 - permute cells and nodes.
9602  *
9603  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9604  *          caller is to delete this field using decrRef() as it is no more needed. 
9605  *  \throw If no field of \a this is lying on \a mesh.
9606  *  \throw If no field values of the required parameters are available.
9607  */
9608 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9609 {
9610   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9611   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9612   if(!myF1TSC)
9613     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9614   MCAuto<DataArray> arr;
9615   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9616   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9617   return ret.retn();
9618 }
9619
9620 /*!
9621  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9622  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9623  * This method is useful for MED2 file format when field on different mesh was autorized.
9624  */
9625 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9626 {
9627   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9628   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9629   if(!myF1TSC)
9630     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9631   MCAuto<DataArray> arr;
9632   MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9633   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9634   return ret.retn();
9635 }
9636
9637 /*!
9638  * Returns values and a profile of the field of a given type, of a given time step,
9639  * lying on a given support.
9640  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9641  *  \param [in] type - a spatial discretization of the field.
9642  *  \param [in] iteration - the iteration number of a required time step.
9643  *  \param [in] order - the iteration order number of required time step.
9644  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9645  *  \param [in] mesh - the supporting mesh.
9646  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9647  *          field of interest lies on. If the field lies on all entities of the given
9648  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9649  *          using decrRef() as it is no more needed.  
9650  *  \param [in] glob - the global data storing profiles and localization.
9651  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9652  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9653  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9654  *  \throw If no field of \a this is lying on \a mesh.
9655  *  \throw If no field values of the required parameters are available.
9656  */
9657 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9658 {
9659   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9660   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9661   if(!myF1TSC)
9662     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9663   MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9664   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9665 }
9666
9667 /*!
9668  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9669  *  \param [in] pos - a time step id.
9670  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9671  *          delete this field using decrRef() as it is no more needed.
9672  *  \throw If \a pos is not a valid time step id.
9673  */
9674 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9675 {
9676   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9677   if(!item)
9678     {
9679       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9680       throw INTERP_KERNEL::Exception(oss.str().c_str());
9681     }
9682   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9683   if(itemC)
9684     {
9685       MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9686       ret->shallowCpyGlobs(*this);
9687       return ret.retn();
9688     }
9689   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9690   throw INTERP_KERNEL::Exception(oss.str().c_str());
9691 }
9692
9693 /*!
9694  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9695  * the given field is checked if its elements are sorted suitable for writing to MED file
9696  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9697  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9698  *  \param [in] field - the field to add to \a this.
9699  *  \throw If the name of \a field is empty.
9700  *  \throw If the data array of \a field is not set.
9701  *  \throw If existing time steps have different name or number of components than \a field.
9702  *  \throw If the underlying mesh of \a field has no name.
9703  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9704  */
9705 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9706 {
9707   contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9708 }
9709
9710 /*!
9711  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
9712  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9713  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9714  * and \a profile.
9715  *
9716  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9717  * A new profile is added only if no equal profile is missing.
9718  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9719  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9720  *  \param [in] arrOfVals - the values of the field \a field used.
9721  *  \param [in] mesh - the supporting mesh of \a field.
9722  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9723  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9724  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9725  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9726  *  \throw If the data array of \a field is not set.
9727  *  \throw If the data array of \a this is already allocated but has different number of
9728  *         components than \a field.
9729  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9730  *  \sa setFieldNoProfileSBT()
9731  */
9732 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9733 {
9734   contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9735 }
9736
9737 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9738 {
9739   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9740   if(!pt)
9741     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9742   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9743   if(!ret)
9744     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 !");
9745   return ret;
9746 }
9747
9748 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9749 {
9750   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9751   if(!pt)
9752     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9753   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9754   if(!ret)
9755     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 !");
9756   return ret;
9757 }
9758
9759 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9760 {
9761   _content=new MEDFileIntFieldMultiTSWithoutSDA;
9762 }
9763
9764 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9765 {
9766 }
9767
9768 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9769 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9770 {
9771 }
9772 catch(INTERP_KERNEL::Exception& e)
9773 { throw e; }
9774
9775 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9776 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9777 {
9778 }
9779 catch(INTERP_KERNEL::Exception& e)
9780 { throw e; }
9781
9782 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9783 {
9784   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9785 }
9786
9787 //= MEDFileFields
9788
9789 MEDFileFields *MEDFileFields::New()
9790 {
9791   return new MEDFileFields;
9792 }
9793
9794 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9795 {
9796   return new MEDFileFields(fileName,loadAll,0,0);
9797 }
9798
9799 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9800 {
9801   return new MEDFileFields(fileName,loadAll,ms,0);
9802 }
9803
9804 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9805 {
9806   return new MEDFileFields(fileName,loadAll,0,&entities);
9807 }
9808
9809 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9810 {
9811   std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9812   ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9813   return ret;
9814 }
9815
9816 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9817 {
9818   std::vector<const BigMemoryObject *> ret;
9819   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9820     ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9821   return ret;
9822 }
9823
9824 MEDFileFields *MEDFileFields::deepCopy() const
9825 {
9826   MCAuto<MEDFileFields> ret=shallowCpy();
9827   std::size_t i=0;
9828   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9829     {
9830       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9831         ret->_fields[i]=(*it)->deepCopy();
9832     }
9833   ret->deepCpyGlobs(*this);
9834   return ret.retn();
9835 }
9836
9837 MEDFileFields *MEDFileFields::shallowCpy() const
9838 {
9839   return new MEDFileFields(*this);
9840 }
9841
9842 /*!
9843  * 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
9844  * 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.
9845  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9846  *
9847  * \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.
9848  * \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.
9849  * 
9850  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9851  */
9852 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9853 {
9854   std::set< std::pair<int,int> > s;
9855   bool firstShot=true;
9856   areThereSomeForgottenTS=false;
9857   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9858     {
9859       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9860         continue;
9861       std::vector< std::pair<int,int> > v=(*it)->getIterations();
9862       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9863       if(firstShot)
9864         { s=s1; firstShot=false; }
9865       else
9866         {
9867           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9868           if(s!=s2)
9869             areThereSomeForgottenTS=true;
9870           s=s2;
9871         }
9872     }
9873   std::vector< std::pair<int,int> > ret;
9874   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9875   return ret;
9876 }
9877
9878 int MEDFileFields::getNumberOfFields() const
9879 {
9880   return _fields.size();
9881 }
9882
9883 std::vector<std::string> MEDFileFields::getFieldsNames() const
9884 {
9885   std::vector<std::string> ret(_fields.size());
9886   int i=0;
9887   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9888     {
9889       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9890       if(f)
9891         {
9892           ret[i]=f->getName();
9893         }
9894       else
9895         {
9896           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9897           throw INTERP_KERNEL::Exception(oss.str().c_str());
9898         }
9899     }
9900   return ret;
9901 }
9902
9903 std::vector<std::string> MEDFileFields::getMeshesNames() const
9904 {
9905   std::vector<std::string> ret;
9906   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9907     {
9908       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9909       if(cur)
9910         ret.push_back(cur->getMeshName());
9911     }
9912   return ret;
9913 }
9914
9915 std::string MEDFileFields::simpleRepr() const
9916 {
9917   std::ostringstream oss;
9918   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9919   simpleRepr(0,oss);
9920   return oss.str();
9921 }
9922
9923 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9924 {
9925   int nbOfFields=getNumberOfFields();
9926   std::string startLine(bkOffset,' ');
9927   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9928   int i=0;
9929   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9930     {
9931       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9932       if(cur)
9933         {
9934           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9935         }
9936       else
9937         {
9938           oss << startLine << "  - not defined !" << std::endl;
9939         }
9940     }
9941   i=0;
9942   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9943     {
9944       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9945       std::string chapter(17,'0'+i);
9946       oss << startLine << chapter << std::endl;
9947       if(cur)
9948         {
9949           cur->simpleRepr(bkOffset+2,oss,i);
9950         }
9951       else
9952         {
9953           oss << startLine << "  - not defined !" << std::endl;
9954         }
9955       oss << startLine << chapter << std::endl;
9956     }
9957   simpleReprGlobs(oss);
9958 }
9959
9960 MEDFileFields::MEDFileFields()
9961 {
9962 }
9963
9964 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9965 try:MEDFileFieldGlobsReal(fileName)
9966 {
9967   MEDFileUtilities::CheckFileForRead(fileName);
9968   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9969   int nbFields(MEDnField(fid));
9970   _fields.resize(nbFields);
9971   med_field_type typcha;
9972   for(int i=0;i<nbFields;i++)
9973     {
9974       std::vector<std::string> infos;
9975       std::string fieldName,dtunit;
9976       int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9977       switch(typcha)
9978       {
9979         case MED_FLOAT64:
9980           {
9981             _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9982             break;
9983           }
9984         case MED_INT32:
9985           {
9986             _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9987             break;
9988           }
9989         default:
9990           {
9991             std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << fileName << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
9992             throw INTERP_KERNEL::Exception(oss.str().c_str());
9993           }
9994       }
9995     }
9996   loadAllGlobals(fid);
9997 }
9998 catch(INTERP_KERNEL::Exception& e)
9999 {
10000     throw e;
10001 }
10002
10003 void MEDFileFields::writeLL(med_idt fid) const
10004 {
10005   int i=0;
10006   writeGlobals(fid,*this);
10007   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10008     {
10009       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10010       if(!elt)
10011         {
10012           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10013           throw INTERP_KERNEL::Exception(oss.str().c_str());
10014         }
10015       elt->writeLL(fid,*this);
10016     }
10017 }
10018
10019 void MEDFileFields::write(const std::string& fileName, int mode) const
10020 {
10021   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10022   MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10023   writeLL(fid);
10024 }
10025
10026 /*!
10027  * This method alloc the arrays and load potentially huge arrays contained in this field.
10028  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10029  * This method can be also called to refresh or reinit values from a file.
10030  * 
10031  * \throw If the fileName is not set or points to a non readable MED file.
10032  */
10033 void MEDFileFields::loadArrays()
10034 {
10035   if(getFileName().empty())
10036     throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10037   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10038   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10039     {
10040       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10041       if(elt)
10042         elt->loadBigArraysRecursively(fid,*elt);
10043     }
10044 }
10045
10046 /*!
10047  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10048  * But once data loaded once, this method does nothing.
10049  * 
10050  * \throw If the fileName is not set or points to a non readable MED file.
10051  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10052  */
10053 void MEDFileFields::loadArraysIfNecessary()
10054 {
10055   if(!getFileName().empty())
10056     {
10057       MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10058       for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10059         {
10060           MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10061           if(elt)
10062             elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10063         }
10064     }
10065 }
10066
10067 /*!
10068  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10069  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10070  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10071  * 
10072  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10073  */
10074 void MEDFileFields::unloadArrays()
10075 {
10076   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10077     {
10078       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10079       if(elt)
10080         elt->unloadArrays();
10081     }
10082 }
10083
10084 /*!
10085  * 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.
10086  * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10087  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10088  * 
10089  * \sa MEDFileFields::loadArraysIfNecessary
10090  */
10091 void MEDFileFields::unloadArraysWithoutDataLoss()
10092 {
10093   if(!getFileName().empty())
10094     unloadArrays();
10095 }
10096
10097 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10098 {
10099   std::vector<std::string> ret;
10100   std::set<std::string> ret2;
10101   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10102     {
10103       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10104       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10105         if(ret2.find(*it2)==ret2.end())
10106           {
10107             ret.push_back(*it2);
10108             ret2.insert(*it2);
10109           }
10110     }
10111   return ret;
10112 }
10113
10114 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10115 {
10116   std::vector<std::string> ret;
10117   std::set<std::string> ret2;
10118   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10119     {
10120       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10121       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10122         if(ret2.find(*it2)==ret2.end())
10123           {
10124             ret.push_back(*it2);
10125             ret2.insert(*it2);
10126           }
10127     }
10128   return ret;
10129 }
10130
10131 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10132 {
10133   std::vector<std::string> ret;
10134   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10135     {
10136       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10137       ret.insert(ret.end(),tmp.begin(),tmp.end());
10138     }
10139   return ret;
10140 }
10141
10142 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10143 {
10144   std::vector<std::string> ret;
10145   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10146     {
10147       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10148       ret.insert(ret.end(),tmp.begin(),tmp.end());
10149     }
10150   return ret;
10151 }
10152
10153 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10154 {
10155   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10156     (*it)->changePflsRefsNamesGen2(mapOfModif);
10157 }
10158
10159 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10160 {
10161   for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10162     (*it)->changeLocsRefsNamesGen2(mapOfModif);
10163 }
10164
10165 void MEDFileFields::resize(int newSize)
10166 {
10167   _fields.resize(newSize);
10168 }
10169
10170 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10171 {
10172   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10173     pushField(*it);
10174 }
10175
10176 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10177 {
10178   if(!field)
10179     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10180   _fields.push_back(field->getContent());
10181   appendGlobs(*field,1e-12);
10182 }
10183
10184 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10185 {
10186   if(!field)
10187     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10188   if(i>=(int)_fields.size())
10189     _fields.resize(i+1);
10190   _fields[i]=field->getContent();
10191   appendGlobs(*field,1e-12);
10192 }
10193
10194 void MEDFileFields::destroyFieldAtPos(int i)
10195 {
10196   destroyFieldsAtPos(&i,&i+1);
10197 }
10198
10199 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10200 {
10201   std::vector<bool> b(_fields.size(),true);
10202   for(const int *i=startIds;i!=endIds;i++)
10203     {
10204       if(*i<0 || *i>=(int)_fields.size())
10205         {
10206           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10207           throw INTERP_KERNEL::Exception(oss.str().c_str());
10208         }
10209       b[*i]=false;
10210     }
10211   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10212   std::size_t j=0;
10213   for(std::size_t i=0;i<_fields.size();i++)
10214     if(b[i])
10215       fields[j++]=_fields[i];
10216   _fields=fields;
10217 }
10218
10219 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10220 {
10221   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10222   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10223   std::vector<bool> b(_fields.size(),true);
10224   int k=bg;
10225   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10226     {
10227       if(k<0 || k>=(int)_fields.size())
10228         {
10229           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10230           throw INTERP_KERNEL::Exception(oss.str().c_str());
10231         }
10232       b[k]=false;
10233     }
10234   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10235   std::size_t j=0;
10236   for(std::size_t i=0;i<_fields.size();i++)
10237     if(b[i])
10238       fields[j++]=_fields[i];
10239   _fields=fields;
10240 }
10241
10242 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10243 {
10244   bool ret=false;
10245   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10246     {
10247       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10248       if(cur)
10249         ret=cur->changeMeshNames(modifTab) || ret;
10250     }
10251   return ret;
10252 }
10253
10254 /*!
10255  * \param [in] meshName the name of the mesh that will be renumbered.
10256  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10257  *             This code corresponds to the distribution of types in the corresponding mesh.
10258  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10259  * \param [in] renumO2N the old to new renumber array.
10260  * \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 
10261  *         field in \a this.
10262  */
10263 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10264 {
10265   bool ret=false;
10266   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10267     {
10268       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10269       if(fmts)
10270         {
10271           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10272         }
10273     }
10274   return ret;
10275 }
10276
10277 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10278 {
10279   if(i<0 || i>=(int)_fields.size())
10280     {
10281       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10282       throw INTERP_KERNEL::Exception(oss.str().c_str());
10283     }
10284   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10285   if(!fmts)
10286     return 0;
10287   MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10288   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10289   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10290   if(fmtsC)
10291     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10292   else if(fmtsC2)
10293     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10294   else
10295     {
10296       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10297       throw INTERP_KERNEL::Exception(oss.str().c_str());
10298     }
10299   ret->shallowCpyGlobs(*this);
10300   return ret.retn();
10301 }
10302
10303 /*!
10304  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10305  * This method is accessible in python using __getitem__ with a list in input.
10306  * \return a new object that the caller should deal with.
10307  */
10308 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10309 {
10310   MCAuto<MEDFileFields> ret=shallowCpy();
10311   std::size_t sz=std::distance(startIds,endIds);
10312   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10313   int j=0;
10314   for(const int *i=startIds;i!=endIds;i++,j++)
10315     {
10316       if(*i<0 || *i>=(int)_fields.size())
10317         {
10318           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10319           throw INTERP_KERNEL::Exception(oss.str().c_str());
10320         }
10321       fields[j]=_fields[*i];
10322     }
10323   ret->_fields=fields;
10324   return ret.retn();
10325 }
10326
10327 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10328 {
10329   return getFieldAtPos(getPosFromFieldName(fieldName));
10330 }
10331
10332 /*!
10333  * This method removes, if any, fields in \a this having no time steps.
10334  * 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.
10335  * 
10336  * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10337  */
10338 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10339 {
10340   std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10341   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10342     {
10343       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10344       if(elt)
10345         {
10346           if(elt->getNumberOfTS()>0)
10347             newFields.push_back(*it);
10348         }
10349     }
10350   if(_fields.size()==newFields.size())
10351     return false;
10352   _fields=newFields;
10353   return true;
10354 }
10355
10356 /*!
10357  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10358  * This method can be seen as a filter applied on \a this, that returns an object containing
10359  * 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
10360  * shallow copied from \a this.
10361  * 
10362  * \param [in] meshName - the name of the mesh on w
10363  * \return a new object that the caller should deal with.
10364  */
10365 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10366 {
10367   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10368   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10369     {
10370       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10371       if(!cur)
10372         continue;
10373       if(cur->getMeshName()==meshName)
10374         {
10375           cur->incrRef();
10376           MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10377           ret->_fields.push_back(cur2);
10378         }
10379     }
10380   ret->shallowCpyOnlyUsedGlobs(*this);
10381   return ret.retn();
10382 }
10383
10384 /*!
10385  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10386  * Input time steps are specified using a pair of integer (iteration, order).
10387  * 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,
10388  * but for each multitimestep only the time steps in \a timeSteps are kept.
10389  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10390  * 
10391  * The returned object points to shallow copy of elements in \a this.
10392  * 
10393  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10394  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10395  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10396  */
10397 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10398 {
10399   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10400   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10401     {
10402       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10403       if(!cur)
10404         continue;
10405       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10406       ret->_fields.push_back(elt);
10407     }
10408   ret->shallowCpyOnlyUsedGlobs(*this);
10409   return ret.retn();
10410 }
10411
10412 /*!
10413  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10414  */
10415 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10416 {
10417   MCAuto<MEDFileFields> ret=MEDFileFields::New();
10418   for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10419     {
10420       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10421       if(!cur)
10422         continue;
10423       MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10424       if(elt->getNumberOfTS()!=0)
10425         ret->_fields.push_back(elt);
10426     }
10427   ret->shallowCpyOnlyUsedGlobs(*this);
10428   return ret.retn();
10429 }
10430
10431 MEDFileFieldsIterator *MEDFileFields::iterator()
10432 {
10433   return new MEDFileFieldsIterator(this);
10434 }
10435
10436 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10437 {
10438   std::string tmp(fieldName);
10439   std::vector<std::string> poss;
10440   for(std::size_t i=0;i<_fields.size();i++)
10441     {
10442       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10443       if(f)
10444         {
10445           std::string fname(f->getName());
10446           if(tmp==fname)
10447             return i;
10448           else
10449             poss.push_back(fname);
10450         }
10451     }
10452   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10453   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10454   oss << " !";
10455   throw INTERP_KERNEL::Exception(oss.str().c_str());
10456 }
10457
10458 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10459 {
10460   if(fs)
10461     {
10462       fs->incrRef();
10463       _nb_iter=fs->getNumberOfFields();
10464     }
10465 }
10466
10467 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
10468 {
10469 }
10470
10471 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10472 {
10473   if(_iter_id<_nb_iter)
10474     {
10475       MEDFileFields *fs(_fs);
10476       if(fs)
10477         return fs->getFieldAtPos(_iter_id++);
10478       else
10479         return 0;
10480     }
10481   else
10482     return 0;
10483 }