Salome HOME
b40a58df65bf50e09ffd5adf0046f9c091a6be28
[modules/med.git] / src / MEDLoader / MEDFileField.cxx
1 // Copyright (C) 2007-2013  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.
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 "MEDFileFieldOverView.hxx"
26
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
29
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
32
33 #include <algorithm>
34 #include <iterator>
35
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[32];
40
41 using namespace ParaMEDMEM;
42
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
45
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
47 {
48   return new MEDFileFieldLoc(fid,locName);
49 }
50
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
52 {
53   return new MEDFileFieldLoc(fid,id);
54 }
55
56 MEDFileFieldLoc *MEDFileFieldLoc::New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
57 {
58   return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
59 }
60
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const char *locName):_name(locName)
62 {
63   med_geometry_type geotype;
64   med_geometry_type sectiongeotype;
65   int nsectionmeshcell;
66   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68   MEDlocalizationInfoByName(fid,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
69   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
70   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71   _nb_node_per_cell=cm.getNumberOfNodes();
72   _ref_coo.resize(_dim*_nb_node_per_cell);
73   _gs_coo.resize(_dim*_nb_gauss_pt);
74   _w.resize(_nb_gauss_pt);
75   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
76 }
77
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
79 {
80   med_geometry_type geotype;
81   med_geometry_type sectiongeotype;
82   int nsectionmeshcell;
83   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84   INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85   INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86   MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,&sectiongeotype);
87   _name=locName;
88   _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,geotype)));
89   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90   _nb_node_per_cell=cm.getNumberOfNodes();
91   _ref_coo.resize(_dim*_nb_node_per_cell);
92   _gs_coo.resize(_dim*_nb_gauss_pt);
93   _w.resize(_nb_gauss_pt);
94   MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
95 }
96
97 MEDFileFieldLoc::MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType,
98                                  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),
99                                                                                                                                     _w(w)
100 {
101   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102   _dim=cm.getDimension();
103   _nb_node_per_cell=cm.getNumberOfNodes();
104   _nb_gauss_pt=_w.size();
105 }
106
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
108 {
109   return new MEDFileFieldLoc(*this);
110 }
111
112 std::size_t MEDFileFieldLoc::getHeapMemorySize() const
113 {
114   return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
115 }
116
117 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
118 {
119   static const char OFF7[]="\n    ";
120   oss << "\"" << _name << "\"" << OFF7;
121   oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
122   oss << "Dimension=" << _dim << OFF7;
123   oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
124   oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
125   oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
126   oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
127   oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
128 }
129
130 void MEDFileFieldLoc::setName(const char *name)
131 {
132   _name=name;
133 }
134
135 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
136 {
137   if(_name!=other._name)
138     return false;
139   if(_dim!=other._dim)
140     return false;
141   if(_nb_gauss_pt!=other._nb_gauss_pt)
142     return false;
143   if(_nb_node_per_cell!=other._nb_node_per_cell)
144     return false;
145   if(_geo_type!=other._geo_type)
146     return false;
147   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
148     return false;
149   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
150     return false;
151   if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
152     return false;
153   
154   return true;
155 }
156
157 void MEDFileFieldLoc::writeLL(med_idt fid) const
158 {
159   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);
160 }
161
162 std::string MEDFileFieldLoc::repr() const
163 {
164   std::ostringstream oss; oss.precision(15);
165   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
166   oss << "Localization \"" << _name << "\" :\n" << "  - Geometric Type : " << cm.getRepr();
167   oss << "\n  - Dimension : " << _dim << "\n  - Number of gauss points : ";
168   oss << _nb_gauss_pt << "\n  - Number of nodes in cell : " << _nb_node_per_cell;
169   oss << "\n  - Ref coords are : ";
170   int sz=_ref_coo.size();
171   if(sz%_dim==0)
172     {
173       int nbOfTuples=sz/_dim;
174       for(int i=0;i<nbOfTuples;i++)
175         {
176           oss << "(";
177           for(int j=0;j<_dim;j++)
178             { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
179           oss << ") ";
180         }
181     }
182   else
183     std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
184   oss << "\n  - Gauss coords in reference element : ";
185   sz=_gs_coo.size();
186   if(sz%_dim==0)
187     {
188       int nbOfTuples=sz/_dim;
189       for(int i=0;i<nbOfTuples;i++)
190         {
191           oss << "(";
192           for(int j=0;j<_dim;j++)
193             { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
194           oss << ") ";
195         }
196     }
197   else
198     std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
199   oss << "\n  - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
200   return oss.str();
201 }
202
203 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
204 {
205   _type=field->getTypeOfField();
206   _start=start;
207   switch(_type)
208     {
209     case ON_CELLS:
210       {
211         getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
212         _end=_start+nbOfCells;
213         _nval=nbOfCells;
214         break;
215       }
216     case ON_GAUSS_NE:
217       {
218         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
219         const int *arrPtr=arr->getConstPointer();
220         getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
221         _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
222         _nval=nbOfCells;
223         break;
224       }
225     case ON_GAUSS_PT:
226       {
227         const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
228         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
229         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
230         if(!disc2)
231           throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
232         const DataArrayInt *dai=disc2->getArrayOfDiscIds();
233         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
234         const int *dai2Ptr=dai2->getConstPointer();
235         int nbi=gsLoc.getWeights().size();
236         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
237         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
238         const int *da3Ptr=da3->getConstPointer();
239         if(da3->getNumberOfTuples()!=nbOfCells)
240           {//profile : for gauss even in NoProfile !!!
241             std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
242             _profile=oss.str();
243             da3->setName(_profile.c_str());
244             glob.appendProfile(da3);
245           }
246         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
247         _nval=da3->getNbOfElems();
248         da4->alloc(_nval*nbi,1);
249         int *da4Ptr=da4->getPointer();
250         for(int i=0;i<_nval;i++)
251           {
252             int ref=dai2Ptr[offset+da3Ptr[i]];
253             for(int j=0;j<nbi;j++)
254               *da4Ptr++=ref+j;
255           }
256         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
257         _localization=oss2.str();
258         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
259         _end=_start+_nval*nbi;
260         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
261         break;
262       }
263     default:
264       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
265     }
266   start=_end;
267 }
268
269 /*!
270  * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
271  * \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).
272  * \param [in] multiTypePfl is the end user profile specified in high level API
273  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
274  * \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.
275  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
276  * \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.
277  */
278 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
279 {
280   _profile.clear();
281   _type=field->getTypeOfField();
282   std::string pflName(multiTypePfl->getName());
283   std::ostringstream oss; oss << pflName;
284   if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" <<  cm.getRepr(); } else { oss << "_NODE"; }
285   if(locIds)
286     {
287       if(pflName.empty())
288         throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
289       if(_type!=ON_GAUSS_PT)
290         {
291           locIds->setName(oss.str().c_str());
292           glob.appendProfile(locIds);
293           _profile=oss.str();
294         }
295     }
296   _start=start;
297   switch(_type)
298     {
299     case ON_NODES:
300       {
301          _nval=idsInPfl->getNumberOfTuples();
302          getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
303          _end=_start+_nval;
304          break;
305       }
306     case ON_CELLS:
307       {
308         _nval=idsInPfl->getNumberOfTuples();
309         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
310         _end=_start+_nval;
311         break;
312       }
313     case ON_GAUSS_NE:
314       {
315         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
316         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
317         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
318         arr3->computeOffsets2();
319         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
320         int trueNval=tmp->getNumberOfTuples();
321         _nval=idsInPfl->getNumberOfTuples();
322         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
323         _end=_start+trueNval;
324         break;
325       }
326     case ON_GAUSS_PT:
327       {
328         const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
329         if(!disc2)
330           throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
331         const DataArrayInt *da1=disc2->getArrayOfDiscIds();
332         const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
333         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
334         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
335         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
336         //
337         MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
338         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
339         //
340         MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
341         int trueNval=0;
342         for(const int *pt=da4->begin();pt!=da4->end();pt++)
343           trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
344         tmp->alloc(trueNval,1);
345         int *tmpPtr=tmp->getPointer();
346         for(const int *pt=da4->begin();pt!=da4->end();pt++)
347           for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
348             *tmpPtr++=j;
349         //
350         _nval=da4->getNumberOfTuples();
351         getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
352         _end=_start+trueNval;
353         oss << "_loc_" << _loc_id;
354         if(locIds)
355           {
356             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
357             da5->setName(oss.str().c_str());
358             glob.appendProfile(da5);
359             _profile=oss.str();
360           }
361         else
362           {
363             if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
364               {
365                 da3->setName(oss.str().c_str());
366                 glob.appendProfile(da3);
367                 _profile=oss.str();
368               }
369           }
370         std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
371         _localization=oss2.str();
372         glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
373         break;
374       }
375     default:
376       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
377     }
378   start=_end;
379 }
380
381 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
382 {
383   _start=start;
384   _nval=arrr->getNumberOfTuples();
385   getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
386   _end=_start+_nval;
387   start=_end;
388 }
389
390 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
391 {
392   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
393 }
394
395 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
396 {
397   return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
398 }
399
400 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
401 {
402   return new MEDFileFieldPerMeshPerTypePerDisc(other);
403 }
404
405 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySize() const
406 {
407   return _profile.capacity()+_localization.capacity()+5*sizeof(int);
408 }
409
410 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception)
411 {
412   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
413   ret->_father=father;
414   return ret.retn();
415 }
416
417 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
418 try:_type(atype),_father(fath),_profile_it(profileIt)
419   {
420   }
421 catch(INTERP_KERNEL::Exception& e)
422 {
423   throw e;
424 }
425
426 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
427 {
428 }
429
430 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& 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),_tmp_work1(other._tmp_work1)
431 {
432 }
433
434 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
435                                                                        _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
436 {
437 }
438
439 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
440 {
441   return _father;
442 }
443
444 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
445 {
446   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
447   INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
448   std::string fieldName=nasc.getName();
449   std::string meshName=getMeshName();
450   int iteration=getIteration();
451   int order=getOrder();
452   TypeOfField type=getType();
453   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
454   int profilesize,nbi;
455   med_geometry_type mgeoti;
456   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
457   _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it,MED_COMPACT_PFLMODE,
458                                   pflname,&profilesize,locname,&nbi);
459   _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
460   _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
461   _start=start;
462   _end=start+_nval*nbi;
463   start=_end;
464   if(type==ON_CELLS && !_localization.empty())
465     {
466       if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
467         setType(ON_GAUSS_PT);
468       else
469         {
470           setType(ON_GAUSS_NE);
471           _localization.clear();
472         }
473     }
474 }
475
476 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
477 {
478   std::string fieldName=nasc.getName();
479   std::string meshName=getMeshName();
480   int iteration=getIteration();
481   int order=getOrder();
482   TypeOfField type=getType();
483   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
484   med_geometry_type mgeoti;
485   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
486   if(_start>_end)
487     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
488   if(_start==_end)
489     return ;
490   DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
491   if(_start<0 || _start>=arr->getNumberOfTuples())
492     {
493       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
494       throw INTERP_KERNEL::Exception(oss.str().c_str());
495     }
496   if(_end<0 || _end>arr->getNumberOfTuples())
497     {
498       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
499       throw INTERP_KERNEL::Exception(oss.str().c_str());
500     }
501   med_int tmp1,nbi;
502   INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
503   med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
504   int nbOfCompo=arr->getNumberOfComponents();
505   if(_end-_start!=nbValsInFile*nbi)
506     {
507       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi <<  " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
508       throw INTERP_KERNEL::Exception(oss.str().c_str());
509     }
510   DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
511   if(arrD)
512     {
513       double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
514       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
515                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
516       return ;
517     }
518   DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
519   if(arrI)
520     {
521       int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
522       MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
523                                  _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
524       return ;
525     }
526   throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
527 }
528
529 /*!
530  * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
531  */
532 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception)
533 {
534   int delta=_end-_start;
535   _start=newValueOfStart;
536   _end=_start+delta;
537 }
538
539 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
540 {
541   return _father->getIteration();
542 }
543
544 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
545 {
546   return _father->getOrder();
547 }
548
549 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
550 {
551   return _father->getTime();
552 }
553
554 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
555 {
556   return _father->getMeshName();
557 }
558
559 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
560 {
561   const char startLine[]="    ## ";
562   std::string startLine2(bkOffset,' ');
563   startLine2+=startLine;
564   MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
565   oss << startLine2 << "Localization #" << id << "." << std::endl;
566   oss << startLine2 << "  Type=" << tmp->getRepr() << "." << std::endl;
567   delete tmp;
568   oss << startLine2 << "  This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
569   oss << startLine2 << "  This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
570   oss << startLine2 << "  This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
571 }
572
573 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
574 {
575   return _type;
576 }
577
578 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
579 {
580   types.insert(_type);
581 }
582
583 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
584 {
585   _type=newType;
586 }
587
588 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
589 {
590   return _father->getGeoType();
591 }
592
593 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
594 {
595   return _father->getNumberOfComponents();
596 }
597
598 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
599 {
600   return _end-_start;
601 }
602
603 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
604 {
605   return _father->getOrCreateAndGetArray();
606 }
607
608 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
609 {
610   const MEDFileFieldPerMeshPerType *fath=_father;
611   return fath->getOrCreateAndGetArray();
612 }
613
614 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
615 {
616   return _father->getInfo();
617 }
618
619 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
620 {
621   return _profile;
622 }
623
624 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
625 {
626   _profile=newPflName;
627 }
628
629 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
630 {
631   return _localization;
632 }
633
634 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
635 {
636   _localization=newLocName;
637 }
638
639 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
640 {
641   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
642     {
643       if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
644         {
645           _profile=(*it2).second;
646           return;
647         }
648     }
649 }
650
651 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
652 {
653   for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
654     {
655       if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
656         {
657           _localization=(*it2).second;
658           return;
659         }
660     }
661 }
662
663 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
664 {
665   if(type!=_type)
666     return ;
667   dads.push_back(std::pair<int,int>(_start,_end));
668   geoTypes.push_back(getGeoType());
669   if(_profile.empty())
670     pfls.push_back(0);
671   else
672     {
673       pfls.push_back(glob->getProfile(_profile.c_str()));
674     }
675   if(_localization.empty())
676     locs.push_back(-1);
677   else
678     {
679       locs.push_back(glob->getLocalizationId(_localization.c_str()));
680     }
681 }
682
683 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
684 {
685   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));
686   startEntryId++;
687 }
688
689 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
690 {
691   TypeOfField type=getType();
692   INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
693   med_geometry_type mgeoti;
694   med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
695   const DataArray *arr=getOrCreateAndGetArray();
696   if(!arr)
697     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
698   const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
699   const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
700   const unsigned char *locToWrite=0;
701   if(arrD)
702     locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
703   else if(arrI)
704     locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
705   else
706     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
707   MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
708                              MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
709                              locToWrite);
710 }
711
712 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception)
713 {
714   type=_type;
715   pfl=_profile;
716   loc=_localization;
717   dad.first=_start; dad.second=_end;
718 }
719
720 /*!
721  * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
722  *             This code corresponds to the distribution of types in the corresponding mesh.
723  * \param [out] ptToFill memory zone where the output will be stored.
724  * \return the size of data pushed into output param \a ptToFill
725  */
726 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception)
727 {
728   _loc_id=offset;
729   std::ostringstream oss;
730   std::size_t nbOfType=codeOfMesh.size()/3;
731   int found=-1;
732   for(std::size_t i=0;i<nbOfType && found==-1;i++)
733     if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
734       found=(int)i;
735   if(found==-1)
736     {
737       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
738       oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
739       throw INTERP_KERNEL::Exception(oss.str().c_str());
740     }
741   int *work=ptToFill;
742   if(_profile.empty())
743     {
744       if(_nval!=codeOfMesh[3*found+1])
745         {
746           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
747           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
748           oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
749           throw INTERP_KERNEL::Exception(oss.str().c_str());
750         }
751       for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
752         *work++=ii;
753     }
754   else
755     {
756       const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
757       if(pfl->getNumberOfTuples()!=_nval)
758         {
759           const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
760           oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
761           oss << _nval;
762           oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
763           throw INTERP_KERNEL::Exception(oss.str().c_str());
764         }
765       int offset2=codeOfMesh[3*found+2];
766       for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
767         {
768           if(*pflId<codeOfMesh[3*found+1])
769             *work++=offset2+*pflId;
770         }
771     }
772   return _nval;
773 }
774
775 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception)
776 {
777   for(int i=_start;i<_end;i++)
778     *ptToFill++=i;
779   return _end-_start;
780 }
781
782 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception)
783 {
784   switch(type)
785     {
786     case ON_CELLS:
787       return -2;
788     case ON_GAUSS_NE:
789       return -1;
790     case ON_GAUSS_PT:
791       return locId;
792     default:
793       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
794     }
795 }
796
797 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
798 {
799   int id=0;
800   std::map<std::pair<std::string,TypeOfField>,int> m;
801   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
802   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
803     if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
804       m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
805   ret.resize(id);
806   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
807     ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
808   return ret;
809 }
810
811 /*!
812  * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
813  * 
814  * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
815  * \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.
816  * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
817  * \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)
818  * \param [in,out] glob if necessary by the method, new profiles can be added to it
819  * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
820  * \param [out] result All new entries will be appended on it.
821  * \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 !)
822  */
823 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
824                                                        const DataArrayInt *explicitIdsInMesh,
825                                                        const std::vector<int>& newCode,
826                                                        MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
827                                                        std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
828 {
829   if(entriesOnSameDisc.empty())
830     return false;
831   TypeOfField type=entriesOnSameDisc[0]->getType();
832   int szEntities=0,szTuples=0;
833   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
834     { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
835   int nbi=szTuples/szEntities;
836   if(szTuples%szEntities!=0)
837     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
838   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
839   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
840   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
841   std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
842   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
843   std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
844   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
845   int id=0;
846   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
847     {
848       int startOfEltIdOfChunk=(*it)->_start;
849       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
850       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
851       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
852       //
853       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
854       newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
855       //
856       newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
857       newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
858     }
859   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
860   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
861   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
862   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
863   //
864   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
865   //
866   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
867   arrPart->renumberInPlace(renumTupleIds->begin());
868   arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
869   bool ret=false;
870   const int *idIt=diffVals->begin();
871   std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
872   int offset2=0;
873   for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
874     {
875       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
876       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
877       int nbEntityElts=subIds->getNumberOfTuples();
878       bool ret2;
879       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
880         NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
881                                     offset+offset2,
882                                     li,glob,ret2);
883       ret=ret || ret2;
884       result.push_back(eltToAdd);
885       offset2+=nbEntityElts*nbi;
886     }
887   ret=ret || li.empty();
888   return ret;
889 }
890
891 /*!
892  * \param [in] typeF type of field of new chunk
893  * \param [in] geoType the geometric type of the chunk
894  * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
895  * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
896  * \param [in] nbi number of integration points
897  * \param [in] offset The offset in the **global array of data**.
898  * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
899  *                 to the new chunk to create.
900  * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
901  * \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
902  *              and corresponding entry erased from \a entriesOnSameDisc.
903  * \return a newly allocated chunk
904  */
905 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
906                                                                                                   bool isPfl, int nbi, int offset,
907                                                                                                   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
908                                                                                                   MEDFileFieldGlobsReal& glob,
909                                                                                                   bool &notInExisting) throw(INTERP_KERNEL::Exception)
910 {
911   int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
912   std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
913   for(;it!=entriesOnSameDisc.end();it++)
914     {
915       if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
916         {
917           if(!isPfl)
918             {
919               if((*it)->_profile.empty())
920                 break;
921               else
922                 if(!(*it)->_profile.empty())
923                   {
924                     const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
925                     if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
926                       break;
927                   }
928             }
929         }
930     }
931   if(it==entriesOnSameDisc.end())
932     {
933       notInExisting=true;
934       MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
935       ret->_type=typeF;
936       ret->_loc_id=(int)geoType;
937       ret->_nval=nbMeshEntities;
938       ret->_start=offset;
939       ret->_end=ret->_start+ret->_nval*nbi;
940       if(isPfl)
941         {
942           idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
943           glob.appendProfile(idsOfMeshElt);
944           ret->_profile=idsOfMeshElt->getName();
945         }
946       //tony treatment of localization
947       return ret;
948     }
949   else
950     {
951       notInExisting=false;
952       MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
953       ret->_loc_id=(int)geoType;
954       ret->setNewStart(offset);
955       entriesOnSameDisc.erase(it);
956       return ret;
957     }
958   
959 }
960
961 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
962 {
963   return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
964 }
965
966 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception)
967 {
968   return new MEDFileFieldPerMeshPerType(fath,geoType);
969 }
970
971 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySize() const
972 {
973   std::size_t ret=_field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
974   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
975     ret+=(*it)->getHeapMemorySize();
976   return ret;
977 }
978
979 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception)
980 {
981   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
982   ret->_father=father;
983   std::size_t i=0;
984   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
985     {
986       if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
987         ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
988     }
989   return ret.retn();
990 }
991
992 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
993 {
994   std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
995   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
996     _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
997 }
998
999 /*!
1000  * This method is the most general one. No optimization is done here.
1001  * \param [in] multiTypePfl is the end user profile specified in high level API
1002  * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1003  * \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.
1004  *             \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1005  * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1006  * \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.
1007  */
1008 void MEDFileFieldPerMeshPerType::assignFieldProfile(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) throw(INTERP_KERNEL::Exception)
1009 {
1010   std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1011   for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1012     _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1013 }
1014
1015 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1016 {
1017   _field_pm_pt_pd.resize(1);
1018   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1019   _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1020 }
1021
1022 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1023 {
1024   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1025   if(!arr || !arr->isAllocated())
1026     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1027   _field_pm_pt_pd.resize(1);
1028   _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1029   _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1030 }
1031
1032 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1033 {
1034   TypeOfField type=field->getTypeOfField();
1035   if(type!=ON_GAUSS_PT)
1036     {
1037       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1038       int sz=_field_pm_pt_pd.size();
1039       bool found=false;
1040       for(int j=0;j<sz && !found;j++)
1041         {
1042           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1043             {
1044               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1045               found=true;
1046             }
1047         }
1048       if(!found)
1049         {
1050           _field_pm_pt_pd.resize(sz+1);
1051           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1052         }
1053       std::vector<int> ret(1,(int)sz);
1054       return ret;
1055     }
1056   else
1057     {
1058       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1059       int sz2=ret2.size();
1060       std::vector<int> ret3(sz2);
1061       int k=0;
1062       for(int i=0;i<sz2;i++)
1063         {
1064           int sz=_field_pm_pt_pd.size();
1065           int locIdToFind=ret2[i];
1066           bool found=false;
1067           for(int j=0;j<sz && !found;j++)
1068             {
1069               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1070                 {
1071                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1072                   ret3[k++]=j;
1073                   found=true;
1074                 }
1075             }
1076           if(!found)
1077             {
1078               _field_pm_pt_pd.resize(sz+1);
1079               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1080               ret3[k++]=sz;
1081             }
1082         }
1083       return ret3;
1084     }
1085 }
1086
1087 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception)
1088 {
1089   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1090   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1091   if(!disc2)
1092     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1093   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1094   if(!da)
1095     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1096   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1097   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1098   if(retTmp->presenceOfValue(-1))
1099     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1100   std::vector<int> ret(retTmp->begin(),retTmp->end());
1101   return ret;
1102 }
1103
1104 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1105 {
1106   TypeOfField type=field->getTypeOfField();
1107   if(type!=ON_GAUSS_PT)
1108     {
1109       int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1110       int sz=_field_pm_pt_pd.size();
1111       bool found=false;
1112       for(int j=0;j<sz && !found;j++)
1113         {
1114           if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1115             {
1116               _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1117               found=true;
1118             }
1119         }
1120       if(!found)
1121         {
1122           _field_pm_pt_pd.resize(sz+1);
1123           _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1124         }
1125       std::vector<int> ret(1,0);
1126       return ret;
1127     }
1128   else
1129     {
1130       std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1131       int sz2=ret2.size();
1132       std::vector<int> ret3(sz2);
1133       int k=0;
1134       for(int i=0;i<sz2;i++)
1135         {
1136           int sz=_field_pm_pt_pd.size();
1137           int locIdToFind=ret2[i];
1138           bool found=false;
1139           for(int j=0;j<sz && !found;j++)
1140             {
1141               if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1142                 {
1143                   _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144                   ret3[k++]=j;
1145                   found=true;
1146                 }
1147             }
1148           if(!found)
1149             {
1150               _field_pm_pt_pd.resize(sz+1);
1151               _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1152               ret3[k++]=sz;
1153             }
1154         }
1155       return ret3;
1156     }
1157 }
1158
1159 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception)
1160 {
1161   const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1162   const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1163   if(!disc2)
1164     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1165   const DataArrayInt *da=disc2->getArrayOfDiscIds();
1166   if(!da)
1167     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1168   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1169   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1170   if(retTmp->presenceOfValue(-1))
1171     throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1172   std::vector<int> ret(retTmp->begin(),retTmp->end());
1173   return ret;
1174 }
1175
1176 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1177 {
1178   return _father;
1179 }
1180
1181 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1182 {
1183   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1184   int curDim=(int)cm.getDimension();
1185   dim=std::max(dim,curDim);
1186 }
1187
1188 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1189 {
1190   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1191     {
1192       (*it)->fillTypesOfFieldAvailable(types);
1193     }
1194 }
1195
1196 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 throw(INTERP_KERNEL::Exception)
1197 {
1198   int sz=_field_pm_pt_pd.size();
1199   dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1200   for(int i=0;i<sz;i++)
1201     {
1202       _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1203     }
1204 }
1205
1206 int MEDFileFieldPerMeshPerType::getIteration() const
1207 {
1208   return _father->getIteration();
1209 }
1210
1211 int MEDFileFieldPerMeshPerType::getOrder() const
1212 {
1213   return _father->getOrder();
1214 }
1215
1216 double MEDFileFieldPerMeshPerType::getTime() const
1217 {
1218   return _father->getTime();
1219 }
1220
1221 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1222 {
1223   return _father->getMeshName();
1224 }
1225
1226 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1227 {
1228   const char startLine[]="  ## ";
1229   std::string startLine2(bkOffset,' ');
1230   std::string startLine3(startLine2);
1231   startLine3+=startLine;
1232   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1233     {
1234       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1235       oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1236     }
1237   else
1238     oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1239   oss << startLine3 << "Entry is defined on " <<  _field_pm_pt_pd.size() << " localizations." << std::endl;
1240   int i=0;
1241   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1242     {
1243       const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1244       if(cur)
1245         cur->simpleRepr(bkOffset,oss,i);
1246       else
1247         {
1248           oss << startLine2 << "    ## " << "Localization #" << i << " is empty !" << std::endl;
1249         }
1250     }
1251 }
1252
1253 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1254 {
1255   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1256     {
1257       globalSz+=(*it)->getNumberOfTuples();
1258     }
1259   nbOfEntries+=(int)_field_pm_pt_pd.size();
1260 }
1261
1262 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1263 {
1264   return _geo_type;
1265 }
1266
1267
1268 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1269 {
1270   return _father->getNumberOfComponents();
1271 }
1272
1273 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1274 {
1275   return _father->getOrCreateAndGetArray();
1276 }
1277
1278 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1279 {
1280   const MEDFileFieldPerMesh *fath=_father;
1281   return fath->getOrCreateAndGetArray();
1282 }
1283
1284 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1285 {
1286   return _father->getInfo();
1287 }
1288
1289 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1290 {
1291   std::vector<std::string> ret;
1292   std::set<std::string> ret2;
1293   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1294     {
1295       std::string tmp=(*it1)->getProfile();
1296       if(!tmp.empty())
1297         if(ret2.find(tmp)==ret2.end())
1298           {
1299             ret.push_back(tmp);
1300             ret2.insert(tmp);
1301           }
1302     }
1303   return ret;
1304 }
1305
1306 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1307 {
1308   std::vector<std::string> ret;
1309   std::set<std::string> ret2;
1310   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1311     {
1312       std::string tmp=(*it1)->getLocalization();
1313       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1314         if(ret2.find(tmp)==ret2.end())
1315           {
1316             ret.push_back(tmp);
1317             ret2.insert(tmp);
1318           }
1319     }
1320   return ret;
1321 }
1322
1323 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1324 {
1325   std::vector<std::string> ret;
1326   std::set<std::string> ret2;
1327   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1328     {
1329       std::string tmp=(*it1)->getProfile();
1330       if(!tmp.empty())
1331         ret.push_back(tmp);
1332     }
1333   return ret;
1334 }
1335
1336 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1337 {
1338   std::vector<std::string> ret;
1339   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1340     {
1341       std::string tmp=(*it1)->getLocalization();
1342       if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1343         ret.push_back(tmp);
1344     }
1345   return ret;
1346 }
1347
1348 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1349 {
1350   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1351     (*it1)->changePflsRefsNamesGen(mapOfModif);
1352 }
1353
1354 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
1355 {
1356   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1357     (*it1)->changeLocsRefsNamesGen(mapOfModif);
1358 }
1359
1360 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception)
1361 {
1362   if(_field_pm_pt_pd.empty())
1363     {
1364       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1365       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1366       throw INTERP_KERNEL::Exception(oss.str().c_str());
1367     }
1368   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1369     return _field_pm_pt_pd[locId];
1370   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1371   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1372   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1373   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1374   return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1375 }
1376
1377 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception)
1378 {
1379   if(_field_pm_pt_pd.empty())
1380     {
1381       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1382       std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1383       throw INTERP_KERNEL::Exception(oss.str().c_str());
1384     }
1385   if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1386     return _field_pm_pt_pd[locId];
1387   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1388   std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1389   oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1390   throw INTERP_KERNEL::Exception(oss2.str().c_str());
1391   return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1392 }
1393
1394 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
1395 {
1396   if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1397     {
1398       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1399       if(meshDim!=(int)cm.getDimension())
1400         return ;
1401     }
1402   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1403     (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1404 }
1405
1406 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1407 {
1408   int i=0;
1409   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1410     {
1411       (*it)->fillValues(i,startEntryId,entries);
1412     }
1413 }
1414
1415 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1416 {
1417   _field_pm_pt_pd=leaves;
1418   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1419     (*it)->setFather(this);
1420 }
1421
1422 /*!
1423  *  \param [in,out] globalNum a global numbering counter for the renumbering. 
1424  *  \param [out] its - list of pair (start,stop) kept
1425  *  \return bool - false if the type of field \a tof is not contained in \a this.
1426  */
1427 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1428 {
1429   bool ret=false;
1430   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1431   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1432     if((*it)->getType()==tof)
1433       {
1434         newPmPtPd.push_back(*it);
1435         std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1436         (*it)->setNewStart(globalNum);
1437         globalNum=(*it)->getEnd();
1438         its.push_back(bgEnd);
1439         ret=true;
1440       }
1441   if(ret)
1442     _field_pm_pt_pd=newPmPtPd;
1443   return ret;
1444 }
1445
1446 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1447 {
1448 }
1449
1450 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_father(fath),_geo_type(geoType)
1451 {
1452   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1453   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1454   med_geometry_type mgeoti;
1455   med_entity_type menti;
1456   menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1457   int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1458   _field_pm_pt_pd.resize(nbProfiles);
1459   for(int i=0;i<nbProfiles;i++)
1460     {
1461       _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1462     }
1463   if(type==ON_CELLS)
1464     {
1465       int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1466       for(int i=0;i<nbProfiles2;i++)
1467         _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i+1));
1468     }
1469 }
1470
1471 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1472 {
1473   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1474     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1475 }
1476
1477 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1478 {
1479   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1480     (*it)->loadBigArray(fid,nasc);
1481 }
1482
1483 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1484 {
1485   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1486     {
1487       (*it)->copyOptionsFrom(*this);
1488       (*it)->writeLL(fid,nasc);
1489     }
1490 }
1491
1492 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1493 {
1494   switch(ikType)
1495     {
1496     case ON_CELLS:
1497       medfGeoType=typmai3[(int)ikGeoType];
1498       return MED_CELL;
1499     case ON_NODES:
1500       medfGeoType=MED_NONE;
1501       return MED_NODE;
1502     case ON_GAUSS_NE:
1503       medfGeoType=typmai3[(int)ikGeoType];
1504       return MED_NODE_ELEMENT;
1505     case ON_GAUSS_PT:
1506       medfGeoType=typmai3[(int)ikGeoType];
1507       return MED_CELL;
1508     default:
1509       throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1510     }
1511   return MED_UNDEF_ENTITY_TYPE;
1512 }
1513
1514 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1515 {
1516   return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1517 }
1518
1519 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1520 {
1521   return new MEDFileFieldPerMesh(fath,mesh);
1522 }
1523
1524 std::size_t MEDFileFieldPerMesh::getHeapMemorySize() const
1525 {
1526   std::size_t ret=_mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1527   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1528     if((const MEDFileFieldPerMeshPerType *)*it)
1529       ret+=(*it)->getHeapMemorySize();
1530   return ret;
1531 }
1532
1533 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception)
1534 {
1535   MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1536   ret->_father=father;
1537   std::size_t i=0;
1538   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1539     {
1540       if((const MEDFileFieldPerMeshPerType *)*it)
1541         ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1542     }
1543   return ret.retn();
1544 }
1545
1546 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1547 {
1548   std::string startLine(bkOffset,' ');
1549   oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1550   oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1551   int i=0;
1552   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1553     {
1554       const MEDFileFieldPerMeshPerType *cur=*it;
1555       if(cur)
1556         cur->simpleRepr(bkOffset,oss,i);
1557       else
1558         {
1559           oss << startLine << "  ## Entry geometry type #" << i << " is empty !" << std::endl;
1560         }
1561     }
1562 }
1563
1564 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1565 {
1566   _mesh_name=mesh->getName();
1567   mesh->getTime(_mesh_iteration,_mesh_order);
1568 }
1569
1570 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1571 {
1572   int nbOfTypes=code.size()/3;
1573   int offset=0;
1574   for(int i=0;i<nbOfTypes;i++)
1575     {
1576       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1577       int nbOfCells=code[3*i+1];
1578       int pos=addNewEntryIfNecessary(type);
1579       _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1580       offset+=nbOfCells;
1581     }
1582 }
1583
1584 /*!
1585  * This method is the most general one. No optimization is done here.
1586  * \param [in] multiTypePfl is the end user profile specified in high level API
1587  * \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].
1588  * \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.
1589  * \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.
1590  * \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.
1591  * \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.
1592  */
1593 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) throw(INTERP_KERNEL::Exception)
1594 {
1595   int nbOfTypes=code.size()/3;
1596   for(int i=0;i<nbOfTypes;i++)
1597     {
1598       INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1599       int pos=addNewEntryIfNecessary(type);
1600       DataArrayInt *pfl=0;
1601       if(code[3*i+2]!=-1)
1602         pfl=idsPerType[code[3*i+2]];
1603       int nbOfTupes2=code2.size()/3;
1604       int found=0;
1605       for(;found<nbOfTupes2;found++)
1606         if(code[3*i]==code2[3*found])
1607           break;
1608       if(found==nbOfTupes2)
1609         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1610       _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1611     }
1612 }
1613
1614 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1615 {
1616   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1617   _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1618 }
1619
1620 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1621 {
1622   int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1623   _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1624 }
1625
1626 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1627 {
1628   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1629     (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1630 }
1631
1632 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
1633 {
1634   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1635     (*it)->loadBigArraysRecursively(fid,nasc);
1636 }
1637
1638 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
1639 {
1640   int nbOfTypes=_field_pm_pt.size();
1641   for(int i=0;i<nbOfTypes;i++)
1642     {
1643       _field_pm_pt[i]->copyOptionsFrom(*this);
1644       _field_pm_pt[i]->writeLL(fid,nasc);
1645     }
1646 }
1647
1648 void MEDFileFieldPerMesh::getDimension(int& dim) const
1649 {
1650   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1651     (*it)->getDimension(dim);
1652 }
1653
1654 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
1655 {
1656   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1657     (*it)->fillTypesOfFieldAvailable(types);
1658 }
1659
1660 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 throw(INTERP_KERNEL::Exception)
1661 {
1662   int sz=_field_pm_pt.size();
1663   std::vector< std::vector<std::pair<int,int> > > ret(sz);
1664   types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1665   for(int i=0;i<sz;i++)
1666     {
1667       types[i]=_field_pm_pt[i]->getGeoType();
1668       _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1669     }
1670   return ret;
1671 }
1672
1673 double MEDFileFieldPerMesh::getTime() const
1674 {
1675   int tmp1,tmp2;
1676   return _father->getTime(tmp1,tmp2);
1677 }
1678
1679 int MEDFileFieldPerMesh::getIteration() const
1680 {
1681   return _father->getIteration();
1682 }
1683
1684 int MEDFileFieldPerMesh::getOrder() const
1685 {
1686   return _father->getOrder();
1687 }
1688
1689 int MEDFileFieldPerMesh::getNumberOfComponents() const
1690 {
1691   return _father->getNumberOfComponents();
1692 }
1693
1694 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1695 {
1696   if(!_father)
1697     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1698   return _father->getOrCreateAndGetArray();
1699 }
1700
1701 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1702 {
1703   if(!_father)
1704     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1705   return _father->getOrCreateAndGetArray();
1706 }
1707
1708 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1709 {
1710   return _father->getInfo();
1711 }
1712
1713 /*!
1714  * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1715  * 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.
1716  * It returns 2 output vectors :
1717  * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1718  * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1719  * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1720  */
1721 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)
1722 {
1723   int notNullPflsSz=0;
1724   int nbOfArrs=geoTypes.size();
1725   for(int i=0;i<nbOfArrs;i++)
1726     if(pfls[i])
1727       notNullPflsSz++;
1728   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1729   int nbOfDiffGeoTypes=geoTypes3.size();
1730   code.resize(3*nbOfDiffGeoTypes);
1731   notNullPfls.resize(notNullPflsSz);
1732   notNullPflsSz=0;
1733   int j=0;
1734   for(int i=0;i<nbOfDiffGeoTypes;i++)
1735     {
1736       int startZone=j;
1737       INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1738       std::vector<const DataArrayInt *> notNullTmp;
1739       if(pfls[j])
1740         notNullTmp.push_back(pfls[j]);
1741       j++;
1742       for(;j<nbOfArrs;j++)
1743         if(geoTypes[j]==refType)
1744           {
1745             if(pfls[j])
1746               notNullTmp.push_back(pfls[j]);
1747           }
1748         else
1749           break;
1750       std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1751       std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1752       std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1753       code[3*i]=(int)refType;
1754       std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1755       code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1756       if(notNullTmp.empty())
1757         code[3*i+2]=-1;
1758       else
1759         {
1760           notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1761           code[3*i+2]=notNullPflsSz++;
1762         }
1763     }
1764 }
1765
1766 /*!
1767  * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1768  */
1769 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) throw(INTERP_KERNEL::Exception)
1770 {
1771   int sz=dads.size();
1772   int ret=0;
1773   for(int i=0;i<sz;i++)
1774     {
1775       if(locs[i]==-1)
1776         {
1777           if(type!=ON_GAUSS_NE)
1778             ret+=dads[i].second-dads[i].first;
1779           else
1780             {
1781               const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1782               ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1783             }
1784         }
1785       else
1786         {
1787           int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1788           ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1789         }
1790     }
1791   return ret;
1792 }
1793
1794 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1795 {
1796   std::vector<std::string> ret;
1797   std::set<std::string> ret2;
1798   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1799     {
1800       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1801       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1802         if(ret2.find(*it2)==ret2.end())
1803           {
1804             ret.push_back(*it2);
1805             ret2.insert(*it2);
1806           }
1807     }
1808   return ret;
1809 }
1810
1811 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1812 {
1813   std::vector<std::string> ret;
1814   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1815     {
1816       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1817       ret.insert(ret.end(),tmp.begin(),tmp.end());
1818     }
1819   return ret;
1820 }
1821
1822 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1823 {
1824   std::vector<std::string> ret;
1825   std::set<std::string> ret2;
1826   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1827     {
1828       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1829       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1830         if(ret2.find(*it2)==ret2.end())
1831           {
1832             ret.push_back(*it2);
1833             ret2.insert(*it2);
1834           }
1835     }
1836   return ret;
1837 }
1838
1839 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1840 {
1841   std::vector<std::string> ret;
1842   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1843     {
1844       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1845       ret.insert(ret.end(),tmp.begin(),tmp.end());
1846     }
1847   return ret;
1848 }
1849
1850 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
1851 {
1852   for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1853     {
1854       if((*it).first==_mesh_name)
1855         {
1856           _mesh_name=(*it).second;
1857           return true;
1858         }
1859     }
1860   return false;
1861 }
1862
1863 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1864                                                       MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
1865 {
1866   if(_mesh_name!=meshName)
1867     return false;
1868   std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1869   for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1870   std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1871   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1872   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1873   getUndergroundDataArrayExt(entries);
1874   DataArray *arr0=getOrCreateAndGetArray();//tony
1875   if(!arr0)
1876     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1877   DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1878   if(!arr0)
1879     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1880   int sz=0;
1881   if(!arr)
1882     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1883   for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1884     {
1885       if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1886         {
1887           entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1888           sz+=(*it).second.second-(*it).second.first;
1889         }
1890       else
1891         otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1892     }
1893   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1894   ////////////////////
1895   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1896   int *workI2=explicitIdsOldInMesh->getPointer();
1897   int sz1=0,sz2=0,sid=1;
1898   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1899   // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1900   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1901     {
1902       //  tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1903       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1904       int *workI=explicitIdsOldInArr->getPointer();
1905       for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1906         {
1907           int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1908           (*itL2)->setLocId(sz2);
1909           (*itL2)->_tmp_work1=(*itL2)->getStart();
1910           int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1911         }
1912       renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1913     }
1914   explicitIdsOldInMesh->reAlloc(sz2);
1915   int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1916   ////////////////////
1917   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1918   // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1919   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1920   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1921     {
1922       otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1923       otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1924       otherEntriesNew.back()->setLocId((*it)->getGeoType());
1925     }
1926   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1927   std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1928   for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1929     {
1930       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1931       int newStart=elt->getLocId();
1932       elt->setLocId((*it)->getGeoType());
1933       elt->setNewStart(newStart);
1934       elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1935       entriesKeptNew.push_back(elt);
1936       entriesKeptNew2.push_back(elt);
1937     }
1938   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1939   // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1940   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1941   std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1942   bool ret=false;
1943   for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1944     {
1945       sid=0;
1946       /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1947         {
1948           MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1949           curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1950           }*/
1951       ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1952                                                             glob,arr2,otherEntriesNew) || ret;
1953     }
1954   if(!ret)
1955     return false;
1956   // Assign new dispatching
1957   assignNewLeaves(otherEntriesNew);
1958   arr->cpyFrom(*arr2);
1959   return true;
1960 }
1961
1962 /*!
1963  * \param [in,out] globalNum a global numbering counter for the renumbering.
1964  * \param [out] its - list of pair (start,stop) kept
1965  */
1966 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
1967 {
1968   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1969   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1970     {
1971       std::vector< std::pair<int,int> > its2;
1972       if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
1973         {
1974           ret.push_back(*it);
1975           its.insert(its.end(),its2.begin(),its2.end());
1976         }
1977     }
1978   _field_pm_pt=ret;
1979 }
1980
1981 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception)
1982 {
1983   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
1984   for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
1985     types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
1986   //
1987   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
1988   std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
1989   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
1990   for(;it1!=types.end();it1++,it2++)
1991     {
1992       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
1993       elt->setLeaves((*it1).second);
1994       *it2=elt;
1995     }
1996   _field_pm_pt=fieldPmPt;
1997 }
1998
1999 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2000 {
2001   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2002     (*it)->changePflsRefsNamesGen(mapOfModif);
2003 }
2004
2005 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2006 {
2007   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2008     (*it)->changeLocsRefsNamesGen(mapOfModif);
2009 }
2010
2011 /*!
2012  * \param [in] mesh is the whole mesh
2013  */
2014 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2015 {
2016   if(_field_pm_pt.empty())
2017     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2018   //
2019   std::vector< std::pair<int,int> > dads;
2020   std::vector<const DataArrayInt *> pfls;
2021   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2022   std::vector<int> locs,code;
2023   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2024   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2025     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2026   // Sort by types
2027   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2028   if(code.empty())
2029     {
2030       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2031       throw INTERP_KERNEL::Exception(oss.str().c_str());
2032     }
2033   //
2034   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2035   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2036   if(type!=ON_NODES)
2037     {
2038       DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2039       if(!arr)
2040         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2041       else
2042         {
2043           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2044           return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2045         }
2046     }
2047   else
2048     {
2049       if(code.size()!=3)
2050         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2051       int nb=code[1];
2052       if(code[2]==-1)
2053         {
2054           if(nb!=mesh->getNumberOfNodes())
2055             {
2056               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2057               oss << " nodes in mesh !";
2058               throw INTERP_KERNEL::Exception(oss.str().c_str());
2059             }
2060           return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2061         }
2062       else
2063         return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2064     }
2065 }
2066
2067 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2068 {
2069   if(_field_pm_pt.empty())
2070     throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2071   //
2072   std::vector<std::pair<int,int> > dads;
2073   std::vector<const DataArrayInt *> pfls;
2074   std::vector<DataArrayInt *> notNullPflsPerGeoType;
2075   std::vector<int> locs,code;
2076   std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2077   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2078     (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2079   // Sort by types
2080   SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2081   if(code.empty())
2082     {
2083       std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2084       throw INTERP_KERNEL::Exception(oss.str().c_str());
2085     }
2086   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2087   std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2088   if(type!=ON_NODES)
2089     {
2090       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2091       return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2092     }
2093   else
2094     {
2095       if(code.size()!=3)
2096         throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2097       int nb=code[1];
2098       if(code[2]==-1)
2099         {
2100           if(nb!=mesh->getNumberOfNodes())
2101             {
2102               std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2103               oss << " nodes in mesh !";
2104               throw INTERP_KERNEL::Exception(oss.str().c_str());
2105             }
2106         }
2107       return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2108     }
2109   //
2110   return 0;
2111 }
2112
2113 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
2114 {
2115   int globalSz=0;
2116   int nbOfEntries=0;
2117   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2118     {
2119       (*it)->getSizes(globalSz,nbOfEntries);
2120     }
2121   entries.resize(nbOfEntries);
2122   nbOfEntries=0;
2123   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124     {
2125       (*it)->fillValues(nbOfEntries,entries);
2126     }
2127 }
2128
2129 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
2130 {
2131   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2132     {
2133       if((*it)->getGeoType()==typ)
2134         return (*it)->getLeafGivenLocId(locId);
2135     }
2136   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2137   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2138   oss << "Possiblities are : ";
2139   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2140     {
2141       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2142       oss << "\"" << cm2.getRepr() << "\", ";
2143     }
2144   throw INTERP_KERNEL::Exception(oss.str().c_str());
2145 }
2146
2147 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
2148 {
2149   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2150     {
2151       if((*it)->getGeoType()==typ)
2152         return (*it)->getLeafGivenLocId(locId);
2153     }
2154   const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2155   std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2156   oss << "Possiblities are : ";
2157   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158     {
2159       const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2160       oss << "\"" << cm2.getRepr() << "\", ";
2161     }
2162   throw INTERP_KERNEL::Exception(oss.str().c_str());
2163 }
2164
2165 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2166 {
2167   int i=0;
2168   int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2169   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2170   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2171     {
2172       INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2173       if(type==curType)
2174         return i;
2175       else
2176         {
2177           int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2178           if(pos>pos2)
2179             it2=it+1;
2180         }
2181     }
2182   int ret=std::distance(_field_pm_pt.begin(),it2);
2183   _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2184   return ret;
2185 }
2186
2187 /*!
2188  * 'dads' and 'locs' input parameters have the same number of elements
2189  * \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
2190  */
2191 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2192                                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2193                                                          const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2194 {
2195   isPfl=false;
2196   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2197   ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2198   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2199   const std::vector<std::string>& infos=getInfo();
2200   da->setInfoOnComponents(infos);
2201   da->setName("");
2202   if(type==ON_GAUSS_PT)
2203     {
2204       int offset=0;
2205       int nbOfArrs=dads.size();
2206       for(int i=0;i<nbOfArrs;i++)
2207         {
2208           std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2209           const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2210           int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2211           MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2212           di->alloc(nbOfElems,1);
2213           di->iota(offset);
2214           const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2215           ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2216           offset+=nbOfElems;
2217         }
2218     }
2219   arrOut=da;
2220   return ret.retn();
2221 }
2222
2223 /*!
2224  * 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.
2225  * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2226  * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2227  * The order of cells in the returned field is those imposed by the profile.
2228  * \param [in] mesh is the global mesh.
2229  */
2230 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2231                                                           const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2232                                                           const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2233                                                           const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2234 {
2235   if(da->isIdentity())
2236     {
2237       int nbOfTuples=da->getNumberOfTuples();
2238       if(nbOfTuples==mesh->getNumberOfCells())
2239         return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2240     }
2241   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2242   m2->setName(mesh->getName().c_str());
2243   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2244   isPfl=true;
2245   return ret.retn();
2246 }
2247
2248 /*!
2249  * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2250  */
2251 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2252                                                               const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2253                                                               const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2254 {
2255   if(da->isIdentity())
2256     {
2257       int nbOfTuples=da->getNumberOfTuples();
2258       if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2259         return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2260     }
2261   // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2262   const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2263   if(meshu)
2264     {
2265       if(meshu->getNodalConnectivity()==0)
2266         {
2267           MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2268           int nb=da->getNbOfElems();
2269           const int *ptr=da->getConstPointer();
2270           MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2271           meshuc->allocateCells(nb);
2272           for(int i=0;i<nb;i++)
2273             meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2274           meshuc->finishInsertingCells();
2275           ret->setMesh(meshuc);
2276           const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2277           if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2278           disc->checkCoherencyBetween(meshuc,arrOut);
2279           return ret.retn();
2280         }
2281     }
2282   //
2283   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2284   isPfl=true;
2285   DataArrayInt *arr2=0;
2286   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2287   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2288   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2289   int nnodes=mesh2->getNumberOfNodes();
2290   if(nnodes==(int)da->getNbOfElems())
2291     {
2292       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2293       arrOut->renumberInPlace(da3->getConstPointer());
2294       mesh2->setName(mesh->getName().c_str());
2295       ret->setMesh(mesh2);
2296       return ret.retn();
2297     }
2298   else
2299     {
2300       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 !!!";
2301       oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2302       oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2303       oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2304       oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2305       oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2306       throw INTERP_KERNEL::Exception(oss.str().c_str());
2307     }
2308   return 0;
2309 }
2310
2311 /*!
2312  * This method is the most light method of field retrieving.
2313  */
2314 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception)
2315 {
2316   if(!pflIn)
2317     {
2318       pflOut=DataArrayInt::New();
2319       pflOut->alloc(nbOfElems,1);
2320       pflOut->iota(0);
2321     }
2322   else
2323     {
2324       pflOut=const_cast<DataArrayInt*>(pflIn);
2325       pflOut->incrRef();
2326     }
2327   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2328   MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2329   const std::vector<std::string>& infos=getInfo();
2330   int nbOfComp=infos.size();
2331   for(int i=0;i<nbOfComp;i++)
2332     da->setInfoOnComponent(i,infos[i].c_str());
2333   safePfl->incrRef();
2334   return da.retn();
2335 }
2336
2337 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2338                                                                                                                                                                                                                  _mesh_csit(meshCsit),_father(fath)
2339 {
2340   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2341   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2342   INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2343   for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2344     {
2345       int nbProfile =MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL        ,typmai[i],_mesh_csit,meshName,pflName,locName);
2346       std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2347       int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2348       std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2349       if(nbProfile>0 || nbProfile2>0)
2350         {
2351           _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2352           if(nbProfile>0)
2353             _mesh_name=name0;
2354           else
2355             _mesh_name=name1;
2356         }
2357     }
2358   int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2359   if(nbProfile>0)
2360     {
2361       _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2362       _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2363     }
2364 }
2365
2366 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2367 {
2368   copyTinyInfoFrom(mesh);
2369 }
2370
2371 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
2372 {
2373   if(id>=(int)_pfls.size())
2374     _pfls.resize(id+1);
2375   _pfls[id]=DataArrayInt::New();
2376   int lgth=MEDprofileSizeByName(fid,pflName);
2377   _pfls[id]->setName(pflName);
2378   _pfls[id]->alloc(lgth,1);
2379   MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2380   _pfls[id]->applyLin(1,-1,0);//Converting into C format
2381 }
2382
2383 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2384 {
2385   INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2386   int sz;
2387   MEDprofileInfo(fid,i+1,pflName,&sz);
2388   std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2389   if(i>=(int)_pfls.size())
2390     _pfls.resize(i+1);
2391   _pfls[i]=DataArrayInt::New();
2392   _pfls[i]->alloc(sz,1);
2393   _pfls[i]->setName(pflCpp.c_str());
2394   MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2395   _pfls[i]->applyLin(1,-1,0);//Converting into C format
2396 }
2397
2398 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
2399 {
2400   int nbOfPfls=_pfls.size();
2401   for(int i=0;i<nbOfPfls;i++)
2402     {
2403       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2404       cpy->applyLin(1,1,0);
2405       INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2406       MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2407       MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2408     }
2409   //
2410   int nbOfLocs=_locs.size();
2411   for(int i=0;i<nbOfLocs;i++)
2412     _locs[i]->writeLL(fid);
2413 }
2414
2415 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception)
2416 {
2417   std::vector<std::string> pfls=getPfls();
2418   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2419     {
2420       std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2421       if(it2==pfls.end())
2422         {
2423           _pfls.push_back(*it);
2424         }
2425       else
2426         {
2427           int id=std::distance(pfls.begin(),it2);
2428           if(!(*it)->isEqual(*_pfls[id]))
2429             {
2430               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2431               throw INTERP_KERNEL::Exception(oss.str().c_str());
2432             }
2433         }
2434     }
2435   std::vector<std::string> locs=getLocs();
2436   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2437     {
2438       std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2439       if(it2==locs.end())
2440         {
2441           _locs.push_back(*it);
2442         }
2443       else
2444         {
2445           int id=std::distance(locs.begin(),it2);
2446           if(!(*it)->isEqual(*_locs[id],eps))
2447             {
2448               std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2449               throw INTERP_KERNEL::Exception(oss.str().c_str());
2450             }
2451         }
2452     }
2453 }
2454
2455 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const throw(INTERP_KERNEL::Exception)
2456 {
2457   for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2458     getProfile((*it).c_str());
2459 }
2460
2461 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const throw(INTERP_KERNEL::Exception)
2462 {
2463   for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2464     getLocalization((*it).c_str());
2465 }
2466
2467 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception)
2468 {
2469   std::vector<std::string> profiles=real.getPflsReallyUsed();
2470   int sz=profiles.size();
2471   _pfls.resize(sz);
2472   for(int i=0;i<sz;i++)
2473     loadProfileInFile(fid,i,profiles[i].c_str());
2474   //
2475   std::vector<std::string> locs=real.getLocsReallyUsed();
2476   sz=locs.size();
2477   _locs.resize(sz);
2478   for(int i=0;i<sz;i++)
2479     _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2480 }
2481
2482 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
2483 {
2484   int nProfil=MEDnProfile(fid);
2485   for(int i=0;i<nProfil;i++)
2486     loadProfileInFile(fid,i);
2487   int sz=MEDnLocalization(fid);
2488   _locs.resize(sz);
2489   for(int i=0;i<sz;i++)
2490     {
2491       _locs[i]=MEDFileFieldLoc::New(fid,i);
2492     }
2493 }
2494
2495 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2496 {
2497   return new MEDFileFieldGlobs(fname);
2498 }
2499
2500 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2501 {
2502   return new MEDFileFieldGlobs;
2503 }
2504
2505 std::size_t MEDFileFieldGlobs::getHeapMemorySize() const
2506 {
2507   std::size_t ret=_file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2508   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2509     ret+=(*it)->getHeapMemorySize();
2510   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2511     ret+=(*it)->getHeapMemorySize();
2512   return ret;
2513 }
2514
2515 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const throw(INTERP_KERNEL::Exception)
2516 {
2517   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2518   std::size_t i=0;
2519   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2520     {
2521       if((const DataArrayInt *)*it)
2522         ret->_pfls[i]=(*it)->deepCpy();
2523     }
2524   i=0;
2525   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2526     {
2527       if((const MEDFileFieldLoc*)*it)
2528         ret->_locs[i]=(*it)->deepCpy();
2529     }
2530   return ret.retn();
2531 }
2532
2533 /*!
2534  * \throw if a profile in \a pfls in not in \a this.
2535  * \throw if a localization in \a locs in not in \a this.
2536  * \sa MEDFileFieldGlobs::deepCpyPart
2537  */
2538 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2539 {
2540   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2541   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2542     {
2543       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2544       if(!pfl)
2545         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2546       pfl->incrRef();
2547       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2548       ret->_pfls.push_back(pfl2);
2549     }
2550   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2551     {
2552       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2553       if(!loc)
2554         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2555       loc->incrRef();
2556       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2557       ret->_locs.push_back(loc2);
2558     }
2559   ret->setFileName(getFileName());
2560   return ret.retn();
2561 }
2562
2563 /*!
2564  * \throw if a profile in \a pfls in not in \a this.
2565  * \throw if a localization in \a locs in not in \a this.
2566  * \sa MEDFileFieldGlobs::shallowCpyPart
2567  */
2568 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception)
2569 {
2570   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2571   for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2572     {
2573       DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2574       if(!pfl)
2575         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2576       ret->_pfls.push_back(pfl->deepCpy());
2577     }
2578   for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2579     {
2580       MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2581       if(!loc)
2582         throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2583       ret->_locs.push_back(loc->deepCpy());
2584     }
2585   ret->setFileName(getFileName());
2586   return ret.retn();
2587 }
2588
2589 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2590 {
2591 }
2592
2593 MEDFileFieldGlobs::MEDFileFieldGlobs()
2594 {
2595 }
2596
2597 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2598 {
2599 }
2600
2601 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2602 {
2603   oss << "Profiles :\n";
2604   std::size_t n=_pfls.size();
2605   for(std::size_t i=0;i<n;i++)
2606     {
2607       oss << "  - #" << i << " ";
2608       const DataArrayInt *pfl=_pfls[i];
2609       if(pfl)
2610         oss << "\"" << pfl->getName() << "\"\n";
2611       else
2612         oss << "EMPTY !\n";
2613     }
2614   n=_locs.size();
2615   oss << "Localizations :\n";
2616   for(std::size_t i=0;i<n;i++)
2617     {
2618       oss << "  - #" << i << " ";
2619       const MEDFileFieldLoc *loc=_locs[i];
2620       if(loc)
2621         loc->simpleRepr(oss);
2622       else
2623         oss<< "EMPTY !\n";
2624     }
2625 }
2626
2627 void MEDFileFieldGlobs::setFileName(const char *fileName)
2628 {
2629   _file_name=fileName;
2630 }
2631
2632 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2633 {
2634   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2635     {
2636       DataArrayInt *elt(*it);
2637       if(elt)
2638         {
2639           std::string name(elt->getName());
2640           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2641             {
2642               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2643                 {
2644                   elt->setName((*it2).second.c_str());
2645                   return;
2646                 }
2647             }
2648         }
2649     }
2650 }
2651
2652 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
2653 {
2654   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2655     {
2656       MEDFileFieldLoc *elt(*it);
2657       if(elt)
2658         {
2659           std::string name(elt->getName());
2660           for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2661             {
2662               if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2663                 {
2664                   elt->setName((*it2).second.c_str());
2665                   return;
2666                 }
2667             }
2668         }
2669     }
2670 }
2671
2672 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
2673 {
2674   if(locId<0 || locId>=(int)_locs.size())
2675     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2676   return _locs[locId]->getNbOfGaussPtPerCell();
2677 }
2678
2679 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
2680 {
2681   return getLocalizationFromId(getLocalizationId(locName));
2682 }
2683
2684 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
2685 {
2686   if(locId<0 || locId>=(int)_locs.size())
2687     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2688   return *_locs[locId];
2689 }
2690
2691 namespace ParaMEDMEMImpl
2692 {
2693   class LocFinder
2694   {
2695   public:
2696     LocFinder(const char *loc):_loc(loc) { }
2697     bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2698   private:
2699     const char *_loc;
2700   };
2701
2702   class PflFinder
2703   {
2704   public:
2705     PflFinder(const std::string& pfl):_pfl(pfl) { }
2706     bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2707   private:
2708     const std::string& _pfl;
2709   };
2710 }
2711
2712 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
2713 {
2714   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2715   if(it==_locs.end())
2716     {
2717       std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2718       for(it=_locs.begin();it!=_locs.end();it++)
2719         oss << "\"" << (*it)->getName() << "\", ";
2720       throw INTERP_KERNEL::Exception(oss.str().c_str());
2721     }
2722   return std::distance(_locs.begin(),it);
2723 }
2724
2725 /*!
2726  * The returned value is never null.
2727  */
2728 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
2729 {
2730   std::string pflNameCpp(pflName);
2731   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2732   if(it==_pfls.end())
2733     {
2734       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2735       for(it=_pfls.begin();it!=_pfls.end();it++)
2736         oss << "\"" << (*it)->getName() << "\", ";
2737       throw INTERP_KERNEL::Exception(oss.str().c_str());
2738     }
2739   return *it;
2740 }
2741
2742 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
2743 {
2744   if(pflId<0 || pflId>=(int)_pfls.size())
2745     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2746   return _pfls[pflId];
2747 }
2748
2749 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
2750 {
2751   if(locId<0 || locId>=(int)_locs.size())
2752     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2753   return *_locs[locId];
2754 }
2755
2756 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
2757 {
2758   return getLocalizationFromId(getLocalizationId(locName));
2759 }
2760
2761 /*!
2762  * The returned value is never null.
2763  */
2764 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
2765 {
2766   std::string pflNameCpp(pflName);
2767   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2768   if(it==_pfls.end())
2769     {
2770       std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2771       for(it=_pfls.begin();it!=_pfls.end();it++)
2772         oss << "\"" << (*it)->getName() << "\", ";
2773       throw INTERP_KERNEL::Exception(oss.str().c_str());
2774     }
2775   return *it;
2776 }
2777
2778 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
2779 {
2780   if(pflId<0 || pflId>=(int)_pfls.size())
2781     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2782   return _pfls[pflId];
2783 }
2784
2785 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
2786 {
2787   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2788   int i=0;
2789   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2790     {
2791       if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2792         newPfls.push_back(*it);
2793     }
2794   _pfls=newPfls;
2795 }
2796
2797 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
2798 {
2799   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2800   int i=0;
2801   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2802     {
2803       if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2804         newLocs.push_back(*it);
2805     }
2806   _locs=newLocs;
2807 }
2808
2809 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2810 {
2811   int sz=_pfls.size();
2812   std::vector<std::string> ret(sz);
2813   for(int i=0;i<sz;i++)
2814     ret[i]=_pfls[i]->getName();
2815   return ret;
2816 }
2817
2818 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2819 {
2820   int sz=_locs.size();
2821   std::vector<std::string> ret(sz);
2822   for(int i=0;i<sz;i++)
2823     ret[i]=_locs[i]->getName();
2824   return ret;
2825 }
2826
2827 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2828 {
2829   std::vector<std::string> v=getPfls();
2830   std::string s(pflName);
2831   return std::find(v.begin(),v.end(),s)!=v.end();
2832 }
2833
2834 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2835 {
2836   std::vector<std::string> v=getLocs();
2837   std::string s(locName);
2838   return std::find(v.begin(),v.end(),s)!=v.end();
2839 }
2840
2841 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2842 {
2843   std::map<int,std::vector<int> > m;
2844   int i=0;
2845   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2846     {
2847       const DataArrayInt *tmp=(*it);
2848       if(tmp)
2849         {
2850           m[tmp->getHashCode()].push_back(i);
2851         }
2852     }
2853   std::vector< std::vector<int> > ret;
2854   for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2855     {
2856       if((*it2).second.size()>1)
2857         {
2858           std::vector<int> ret0;
2859           bool equalityOrNot=false;
2860           for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2861             {
2862               std::vector<int>::const_iterator it4=it3; it4++;
2863               for(;it4!=(*it2).second.end();it4++)
2864                 {
2865                   if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2866                     {
2867                       if(!equalityOrNot)
2868                         ret0.push_back(*it3);
2869                       ret0.push_back(*it4);
2870                       equalityOrNot=true;
2871                     }
2872                 }
2873             }
2874           if(!ret0.empty())
2875             ret.push_back(ret0);
2876         }
2877     }
2878   return ret;
2879 }
2880
2881 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2882 {
2883   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2884 }
2885
2886 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
2887 {
2888   std::string name(pfl->getName());
2889   if(name.empty())
2890     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2891   for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2892     if(name==(*it)->getName())
2893       {
2894         if(!pfl->isEqual(*(*it)))
2895           {
2896             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2897             throw INTERP_KERNEL::Exception(oss.str().c_str());
2898           }
2899       }
2900   pfl->incrRef();
2901   _pfls.push_back(pfl);
2902 }
2903
2904 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
2905 {
2906   std::string name(locName);
2907   if(name.empty())
2908     throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2909   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2910   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2911     if((*it)->isName(locName))
2912       {
2913         if(!(*it)->isEqual(*obj,1e-12))
2914           {
2915             std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2916             throw INTERP_KERNEL::Exception(oss.str().c_str());
2917           }
2918       }
2919   _locs.push_back(obj);
2920 }
2921
2922 std::string MEDFileFieldGlobs::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
2923 {
2924   std::vector<std::string> names=getPfls();
2925   return CreateNewNameNotIn("NewPfl_",names);
2926 }
2927
2928 std::string MEDFileFieldGlobs::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
2929 {
2930   std::vector<std::string> names=getLocs();
2931   return CreateNewNameNotIn("NewLoc_",names);
2932 }
2933
2934 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception)
2935 {
2936   for(std::size_t sz=0;sz<100000;sz++)
2937     {
2938       std::ostringstream tryName;
2939       tryName << prefix << sz;
2940       if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2941         return tryName.str();
2942     }
2943   throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2944 }
2945
2946 /*!
2947  * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2948  *  \param [in] fname - the file name.
2949  */
2950 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2951 {
2952 }
2953
2954 /*!
2955  * Creates an empty MEDFileFieldGlobsReal.
2956  */
2957 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2958 {
2959 }
2960
2961 std::size_t MEDFileFieldGlobsReal::getHeapMemorySize() const
2962 {
2963   std::size_t ret=0;
2964   if((const MEDFileFieldGlobs *)_globals)
2965     ret+=_globals->getHeapMemorySize();
2966   return ret;
2967 }
2968
2969 /*!
2970  * Returns a string describing profiles and Gauss points held in \a this.
2971  *  \return std::string - the description string.
2972  */
2973 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
2974 {
2975   const MEDFileFieldGlobs *glob=_globals;
2976   std::ostringstream oss2; oss2 << glob;
2977   std::string stars(oss2.str().length(),'*');
2978   oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars  << "\n\n";
2979   if(glob)
2980     glob->simpleRepr(oss);
2981   else
2982     oss << "NO GLOBAL INFORMATION !\n";
2983 }
2984
2985 void MEDFileFieldGlobsReal::resetContent()
2986 {
2987   _globals=MEDFileFieldGlobs::New();
2988 }
2989
2990 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
2991 {
2992 }
2993
2994 /*!
2995  * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
2996  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
2997  */
2998 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
2999 {
3000   _globals=other._globals;
3001 }
3002
3003 /*!
3004  * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3005  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3006  */
3007 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3008 {
3009   const MEDFileFieldGlobs *otherg(other._globals);
3010   if(!otherg)
3011     return ;
3012   _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3013 }
3014
3015 /*!
3016  * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3017  *  \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3018  */
3019 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception)
3020 {
3021   const MEDFileFieldGlobs *otherg(other._globals);
3022   if(!otherg)
3023     return ;
3024   _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3025 }
3026
3027 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3028 {
3029   _globals=other._globals;
3030   if((const MEDFileFieldGlobs *)_globals)
3031     _globals=other._globals->deepCpy();
3032 }
3033
3034 /*!
3035  * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3036  *  \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3037  *  \param [in] eps - a precision used to compare Gauss points with same name held by
3038  *         \a this and \a other MEDFileFieldGlobsReal.
3039  *  \throw If \a this and \a other hold profiles with equal names but different ids.
3040  *  \throw If  \a this and \a other hold different Gauss points with equal names.
3041  */
3042 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception)
3043 {
3044   const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3045   if(thisGlobals==otherGlobals)
3046     return ;
3047   if(!thisGlobals)
3048     {
3049       _globals=other._globals;
3050       return ;
3051     }
3052   _globals->appendGlobs(*other._globals,eps);
3053 }
3054
3055 void MEDFileFieldGlobsReal::checkGlobsCoherency() const throw(INTERP_KERNEL::Exception)
3056 {
3057   checkGlobsPflsPartCoherency();
3058   checkGlobsLocsPartCoherency();
3059 }
3060
3061 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception)
3062 {
3063   contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3064 }
3065
3066 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception)
3067 {
3068   contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3069 }
3070
3071 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception)
3072 {
3073   contentNotNull()->loadProfileInFile(fid,id,pflName);
3074 }
3075
3076 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3077 {
3078   contentNotNull()->loadProfileInFile(fid,id);
3079 }
3080
3081 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3082 {
3083   contentNotNull()->loadGlobals(fid,*this);
3084 }
3085
3086 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception)
3087 {
3088   contentNotNull()->loadAllGlobals(fid);
3089 }
3090
3091 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception)
3092 {
3093   contentNotNull()->writeGlobals(fid,opt);
3094 }
3095
3096 /*!
3097  * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3098  * or getPflsReallyUsedMulti().
3099  *  \return std::vector<std::string> - a sequence of names of all profiles.
3100  */
3101 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3102 {
3103   return contentNotNull()->getPfls();
3104 }
3105
3106 /*!
3107  * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3108  * or getLocsReallyUsedMulti().
3109  *  \return std::vector<std::string> - a sequence of names of all localizations.
3110  */
3111 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3112 {
3113   return contentNotNull()->getLocs();
3114 }
3115
3116 /*!
3117  * Checks if the profile with a given name exists.
3118  *  \param [in] pflName - the profile name of interest.
3119  *  \return bool - \c true if the profile named \a pflName exists.
3120  */
3121 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3122 {
3123   return contentNotNull()->existsPfl(pflName);
3124 }
3125
3126 /*!
3127  * Checks if the localization with a given name exists.
3128  *  \param [in] locName - the localization name of interest.
3129  *  \return bool - \c true if the localization named \a locName exists.
3130  */
3131 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3132 {
3133   return contentNotNull()->existsLoc(locName);
3134 }
3135
3136 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const throw(INTERP_KERNEL::Exception)
3137 {
3138   return contentNotNull()->createNewNameOfPfl();
3139 }
3140
3141 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const throw(INTERP_KERNEL::Exception)
3142 {
3143   return contentNotNull()->createNewNameOfLoc();
3144 }
3145
3146 /*!
3147  * Sets the name of a MED file.
3148  *  \param [inout] fileName - the file name.
3149  */
3150 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3151 {
3152   contentNotNull()->setFileName(fileName);
3153 }
3154
3155 /*!
3156  * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3157  * in the same order.
3158  *  \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3159  *          Each item of this sequence is a vector containing ids of equal profiles.
3160  */
3161 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3162 {
3163   return contentNotNull()->whichAreEqualProfiles();
3164 }
3165
3166 /*!
3167  * Finds equal localizations.
3168  *  \param [in] eps - a precision used to compare real values of the localizations.
3169  *  \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3170  *          Each item of this sequence is a vector containing ids of equal localizations.
3171  */
3172 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3173 {
3174   return contentNotNull()->whichAreEqualLocs(eps);
3175 }
3176
3177 /*!
3178  * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3179  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3180  *        this sequence is a pair whose 
3181  *        - the first item is a vector of profile names to replace by the second item,
3182  *        - the second item is a profile name to replace every profile name of the first item.
3183  */
3184 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3185 {
3186   contentNotNull()->changePflsNamesInStruct(mapOfModif);
3187 }
3188
3189 /*!
3190  * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3191  * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3192  *        this sequence is a pair whose 
3193  *        - the first item is a vector of localization names to replace by the second item,
3194  *        - the second item is a localization name to replace every localization name of the first item.
3195  */
3196 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3197 {
3198   contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3199 }
3200
3201 /*!
3202  * Replaces references to some profiles (a reference is a profile name) by references
3203  * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3204  * them-selves accordingly. <br>
3205  * This method is a generalization of changePflName().
3206  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3207  *        this sequence is a pair whose 
3208  *        - the first item is a vector of profile names to replace by the second item,
3209  *        - the second item is a profile name to replace every profile of the first item.
3210  * \sa changePflsRefsNamesGen()
3211  * \sa changePflName()
3212  */
3213 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3214 {
3215   changePflsRefsNamesGen(mapOfModif);
3216   changePflsNamesInStruct(mapOfModif);
3217 }
3218
3219 /*!
3220  * Replaces references to some localizations (a reference is a localization name) by references
3221  * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3222  * them-selves accordingly. <br>
3223  * This method is a generalization of changeLocName().
3224  * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3225  *        this sequence is a pair whose 
3226  *        - the first item is a vector of localization names to replace by the second item,
3227  *        - the second item is a localization name to replace every localization of the first item.
3228  * \sa changeLocsRefsNamesGen()
3229  * \sa changeLocName()
3230  */
3231 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3232 {
3233   changeLocsRefsNamesGen(mapOfModif);
3234   changeLocsNamesInStruct(mapOfModif);
3235 }
3236
3237 /*!
3238  * Renames the profile having a given name and updates references to this profile.
3239  *  \param [in] oldName - the name of the profile to rename.
3240  *  \param [in] newName - a new name of the profile.
3241  * \sa changePflsNames().
3242  */
3243 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3244 {
3245   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3246   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3247   mapOfModif[0]=p;
3248   changePflsNames(mapOfModif);
3249 }
3250
3251 /*!
3252  * Renames the localization having a given name and updates references to this localization.
3253  *  \param [in] oldName - the name of the localization to rename.
3254  *  \param [in] newName - a new name of the localization.
3255  * \sa changeLocsNames().
3256  */
3257 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception)
3258 {
3259   std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3260   std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3261   mapOfModif[0]=p;
3262   changeLocsNames(mapOfModif);
3263 }
3264
3265 /*!
3266  * Removes duplicated profiles. Returns a map used to update references to removed 
3267  * profiles via changePflsRefsNamesGen().
3268  * Equal profiles are found using whichAreEqualProfiles().
3269  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3270  *          a sequence describing the performed replacements of profiles. Each element of
3271  *          this sequence is a pair whose
3272  *          - the first item is a vector of profile names replaced by the second item,
3273  *          - the second item is a profile name replacing every profile of the first item.
3274  */
3275 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames() throw(INTERP_KERNEL::Exception)
3276 {
3277   std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3278   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3279   int i=0;
3280   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3281     {
3282       std::vector< std::string > tmp((*it).size());
3283       int j=0;
3284       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3285         tmp[j]=std::string(getProfileFromId(*it2)->getName());
3286       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3287       ret[i]=p;
3288       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3289       killProfileIds(tmp2);
3290     }
3291   changePflsRefsNamesGen(ret);
3292   return ret;
3293 }
3294
3295 /*!
3296  * Removes duplicated localizations. Returns a map used to update references to removed 
3297  * localizations via changeLocsRefsNamesGen().
3298  * Equal localizations are found using whichAreEqualLocs().
3299  *  \param [in] eps - a precision used to compare real values of the localizations.
3300  *  \return std::vector< std::pair<std::vector<std::string>, std::string > > - 
3301  *          a sequence describing the performed replacements of localizations. Each element of
3302  *          this sequence is a pair whose
3303  *          - the first item is a vector of localization names replaced by the second item,
3304  *          - the second item is a localization name replacing every localization of the first item.
3305  */
3306 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps) throw(INTERP_KERNEL::Exception)
3307 {
3308   std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3309   std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3310   int i=0;
3311   for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3312     {
3313       std::vector< std::string > tmp((*it).size());
3314       int j=0;
3315       for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3316         tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3317       std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3318       ret[i]=p;
3319       std::vector<int> tmp2((*it).begin()+1,(*it).end());
3320       killLocalizationIds(tmp2);
3321     }
3322   changeLocsRefsNamesGen(ret);
3323   return ret;
3324 }
3325
3326 /*!
3327  * Returns number of Gauss points per cell in a given localization.
3328  *  \param [in] locId - an id of the localization of interest.
3329  *  \return int - the number of the Gauss points per cell.
3330  */
3331 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception)
3332 {
3333   return contentNotNull()->getNbOfGaussPtPerCell(locId);
3334 }
3335
3336 /*!
3337  * Returns an id of a localization by its name.
3338  *  \param [in] loc - the localization name of interest.
3339  *  \return int - the id of the localization.
3340  *  \throw If there is no a localization named \a loc.
3341  */
3342 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception)
3343 {
3344   return contentNotNull()->getLocalizationId(loc);
3345 }
3346
3347 /*!
3348  * Returns the name of the MED file.
3349  *  \return const char * - the MED file name.
3350  */
3351 const char *MEDFileFieldGlobsReal::getFileName() const
3352 {
3353   return contentNotNull()->getFileName();
3354 }
3355
3356 std::string MEDFileFieldGlobsReal::getFileName2() const
3357 {
3358   return contentNotNull()->getFileName2();
3359 }
3360
3361 /*!
3362  * Returns a localization object by its name.
3363  *  \param [in] locName - the name of the localization of interest.
3364  *  \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3365  *  \throw If there is no a localization named \a locName.
3366  */
3367 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception)
3368 {
3369   return contentNotNull()->getLocalization(locName);
3370 }
3371
3372 /*!
3373  * Returns a localization object by its id.
3374  *  \param [in] locId - the id of the localization of interest.
3375  *  \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3376  *  \throw If there is no a localization with id \a locId.
3377  */
3378 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception)
3379 {
3380   return contentNotNull()->getLocalizationFromId(locId);
3381 }
3382
3383 /*!
3384  * Returns a profile array by its name.
3385  *  \param [in] pflName - the name of the profile of interest.
3386  *  \return const DataArrayInt * - the profile array having the name \a pflName.
3387  *  \throw If there is no a profile named \a pflName.
3388  */
3389 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception)
3390 {
3391   return contentNotNull()->getProfile(pflName);
3392 }
3393
3394 /*!
3395  * Returns a profile array by its id.
3396  *  \param [in] pflId - the id of the profile of interest.
3397  *  \return const DataArrayInt * - the profile array having the id \a pflId.
3398  *  \throw If there is no a profile with id \a pflId.
3399  */
3400 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception)
3401 {
3402   return contentNotNull()->getProfileFromId(pflId);
3403 }
3404
3405 /*!
3406  * Returns a localization object, apt for modification, by its id.
3407  *  \param [in] locId - the id of the localization of interest.
3408  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3409  *          having the id \a locId.
3410  *  \throw If there is no a localization with id \a locId.
3411  */
3412 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception)
3413 {
3414   return contentNotNull()->getLocalizationFromId(locId);
3415 }
3416
3417 /*!
3418  * Returns a localization object, apt for modification, by its name.
3419  *  \param [in] locName - the name of the localization of interest.
3420  *  \return MEDFileFieldLoc& - a non-const reference to the localization object
3421  *          having the name \a locName.
3422  *  \throw If there is no a localization named \a locName.
3423  */
3424 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) throw(INTERP_KERNEL::Exception)
3425 {
3426   return contentNotNull()->getLocalization(locName);
3427 }
3428
3429 /*!
3430  * Returns a profile array, apt for modification, by its name.
3431  *  \param [in] pflName - the name of the profile of interest.
3432  *  \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3433  *  \throw If there is no a profile named \a pflName.
3434  */
3435 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) throw(INTERP_KERNEL::Exception)
3436 {
3437   return contentNotNull()->getProfile(pflName);
3438 }
3439
3440 /*!
3441  * Returns a profile array, apt for modification, by its id.
3442  *  \param [in] pflId - the id of the profile of interest.
3443  *  \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3444  *  \throw If there is no a profile with id \a pflId.
3445  */
3446 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception)
3447 {
3448   return contentNotNull()->getProfileFromId(pflId);
3449 }
3450
3451 /*!
3452  * Removes profiles given by their ids. No data is updated to track this removal.
3453  *  \param [in] pflIds - a sequence of ids of the profiles to remove.
3454  */
3455 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception)
3456 {
3457   contentNotNull()->killProfileIds(pflIds);
3458 }
3459
3460 /*!
3461  * Removes localizations given by their ids. No data is updated to track this removal.
3462  *  \param [in] locIds - a sequence of ids of the localizations to remove.
3463  */
3464 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception)
3465 {
3466   contentNotNull()->killLocalizationIds(locIds);
3467 }
3468
3469 /*!
3470  * Stores a profile array.
3471  *  \param [in] pfl - the profile array to store.
3472  *  \throw If the name of \a pfl is empty.
3473  *  \throw If a profile with the same name as that of \a pfl already exists but contains
3474  *         different ids.
3475  */
3476 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception)
3477 {
3478   contentNotNull()->appendProfile(pfl);
3479 }
3480
3481 /*!
3482  * Adds a new localization of Gauss points.
3483  *  \param [in] locName - the name of the new localization.
3484  *  \param [in] geoType - a geometrical type of the reference cell.
3485  *  \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3486  *         must be \c nbOfNodesPerCell * \c dimOfType.
3487  *  \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3488  *         must be  _wg_.size() * \c dimOfType.
3489  *  \param [in] w - the weights of Gauss points.
3490  *  \throw If \a locName is empty.
3491  *  \throw If a localization with the name \a locName already exists but is
3492  *         different form the new one.
3493  */
3494 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception)
3495 {
3496   contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3497 }
3498
3499 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() throw(INTERP_KERNEL::Exception)
3500 {
3501   MEDFileFieldGlobs *g(_globals);
3502   if(!g)
3503     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3504   return g;
3505 }
3506
3507 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const throw(INTERP_KERNEL::Exception)
3508 {
3509   const MEDFileFieldGlobs *g(_globals);
3510   if(!g)
3511     throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3512   return g;
3513 }
3514
3515 //= MEDFileFieldNameScope
3516
3517 MEDFileFieldNameScope::MEDFileFieldNameScope()
3518 {
3519 }
3520
3521 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3522 {
3523 }
3524
3525 /*!
3526  * Returns the name of \a this field.
3527  *  \return std::string - a string containing the field name.
3528  */
3529 std::string MEDFileFieldNameScope::getName() const throw(INTERP_KERNEL::Exception)
3530 {
3531   return _name;
3532 }
3533
3534 /*!
3535  * Sets name of \a this field
3536  *  \param [in] name - the new field name.
3537  */
3538 void MEDFileFieldNameScope::setName(const char *fieldName) throw(INTERP_KERNEL::Exception)
3539 {
3540   _name=fieldName;
3541 }
3542
3543 std::string MEDFileFieldNameScope::getDtUnit() const throw(INTERP_KERNEL::Exception)
3544 {
3545   return _dt_unit;
3546 }
3547
3548 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
3549 {
3550   _dt_unit=dtUnit;
3551 }
3552
3553 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3554 {
3555   _name=other._name;
3556   _dt_unit=other._dt_unit;
3557 }
3558
3559 //= MEDFileAnyTypeField1TSWithoutSDA
3560
3561 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception)
3562 {
3563   _field_per_mesh.resize(other._field_per_mesh.size());
3564   std::size_t i=0;
3565   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3566     {
3567       if((const MEDFileFieldPerMesh *)*it)
3568         _field_per_mesh[i]=(*it)->deepCpy(this);
3569     }
3570 }
3571
3572 /*!
3573  * Prints a string describing \a this field into a stream. This string is outputted 
3574  * by \c print Python command.
3575  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3576  *  \param [in,out] oss - the out stream.
3577  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3578  *          info id printed, else, not.
3579  */
3580 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3581 {
3582   std::string startOfLine(bkOffset,' ');
3583   oss << startOfLine << "Field ";
3584   if(bkOffset==0)
3585     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3586   oss << "on one time Step ";
3587   if(f1tsId>=0)
3588     oss << "(" << f1tsId << ") ";
3589   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3590   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3591   const DataArray *arr=getUndergroundDataArray();
3592   if(arr)
3593     {
3594       const std::vector<std::string> &comps=arr->getInfoOnComponents();
3595       if(f1tsId<0)
3596         {
3597           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3598           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3599             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
3600         }
3601       if(arr->isAllocated())
3602         {
3603           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3604         }
3605       else
3606         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3607     }
3608   else
3609     {
3610       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3611     }
3612   oss << startOfLine << "----------------------" << std::endl;
3613   if(!_field_per_mesh.empty())
3614     {
3615       int i=0;
3616       for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3617         {
3618           const MEDFileFieldPerMesh *cur=(*it2);
3619           if(cur)
3620             cur->simpleRepr(bkOffset,oss,i);
3621           else
3622             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3623         }
3624     }
3625   else
3626     {
3627       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3628     }
3629   oss << startOfLine << "----------------------" << std::endl;
3630 }
3631
3632 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
3633 {
3634   const DataArray *arr(getUndergroundDataArray());
3635   if(!arr)
3636     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3637   int nbOfCompo=arr->getNumberOfComponents();
3638   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3639   for(int i=0;i<nbOfCompo;i++)
3640     {
3641       ret[i]=deepCpy();
3642       std::vector<int> v(1,i);
3643       MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3644       ret[i]->setArray(arr2);
3645     }
3646   return ret;
3647 }
3648
3649 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3650 {
3651 }
3652
3653 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3654 {
3655 }
3656
3657 /*!
3658  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3659  * empty. Returns -1 if this in on nodes.
3660  *  \return int - the dimension of \a this.
3661  */
3662 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3663 {
3664   int ret=-2;
3665   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3666     (*it)->getDimension(ret);
3667   return ret;
3668 }
3669
3670 /*!
3671  * Returns the mesh name.
3672  *  \return std::string - a string holding the mesh name.
3673  *  \throw If \c _field_per_mesh.empty()
3674  */
3675 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
3676 {
3677   if(_field_per_mesh.empty())
3678     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3679   return _field_per_mesh[0]->getMeshName();
3680 }
3681
3682 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
3683 {
3684   std::string oldName(getMeshName());
3685   std::vector< std::pair<std::string,std::string> > v(1);
3686   v[0].first=oldName; v[0].second=newMeshName;
3687   changeMeshNames(v);
3688 }
3689
3690 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
3691 {
3692   bool ret=false;
3693   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3694     {
3695       MEDFileFieldPerMesh *cur(*it);
3696       if(cur)
3697         ret=cur->changeMeshNames(modifTab) || ret;
3698     }
3699   return ret;
3700 }
3701
3702 /*!
3703  * Returns the number of iteration of the state of underlying mesh.
3704  *  \return int - the iteration number.
3705  *  \throw If \c _field_per_mesh.empty()
3706  */
3707 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const throw(INTERP_KERNEL::Exception)
3708 {
3709   if(_field_per_mesh.empty())
3710     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3711   return _field_per_mesh[0]->getMeshIteration();
3712 }
3713
3714 /*!
3715  * Returns the order number of iteration of the state of underlying mesh.
3716  *  \return int - the order number.
3717  *  \throw If \c _field_per_mesh.empty()
3718  */
3719 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const throw(INTERP_KERNEL::Exception)
3720 {
3721   if(_field_per_mesh.empty())
3722     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3723   return _field_per_mesh[0]->getMeshOrder();
3724 }
3725
3726 /*!
3727  * Checks if \a this field is tagged by a given iteration number and a given
3728  * iteration order number.
3729  *  \param [in] iteration - the iteration number of interest.
3730  *  \param [in] order - the iteration order number of interest.
3731  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
3732  *          \a this->getOrder() == \a order.
3733  */
3734 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3735 {
3736   return iteration==_iteration && order==_order;
3737 }
3738
3739 /*!
3740  * Returns number of iteration and order number of iteration when
3741  * \a this field has been calculated.
3742  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
3743  *          order number.
3744  */
3745 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3746 {
3747   std::pair<int,int> p;
3748   fillIteration(p);
3749   return p;
3750 }
3751
3752 /*!
3753  * Returns number of iteration and order number of iteration when
3754  * \a this field has been calculated.
3755  *  \param [in,out] p - a pair returning the iteration number and the iteration
3756  *          order number.
3757  */
3758 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3759 {
3760   p.first=_iteration;
3761   p.second=_order;
3762 }
3763
3764 /*!
3765  * Returns all types of spatial discretization of \a this field.
3766  *  \param [in,out] types - a sequence of types of \a this field.
3767  */
3768 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
3769 {
3770   std::set<TypeOfField> types2;
3771   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3772     {
3773       (*it)->fillTypesOfFieldAvailable(types2);
3774     }
3775   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3776   std::copy(types2.begin(),types2.end(),bi);
3777 }
3778
3779 /*!
3780  * Returns all types of spatial discretization of \a this field.
3781  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3782  *          of \a this field.
3783  */
3784 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
3785 {
3786   std::vector<TypeOfField> ret;
3787   fillTypesOfFieldAvailable(ret);
3788   return ret;
3789 }
3790
3791 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3792 {
3793   std::vector<std::string> ret;
3794   std::set<std::string> ret2;
3795   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3796     {
3797       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3798       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3799         if(ret2.find(*it2)==ret2.end())
3800           {
3801             ret.push_back(*it2);
3802             ret2.insert(*it2);
3803           }
3804     }
3805   return ret;
3806 }
3807
3808 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3809 {
3810   std::vector<std::string> ret;
3811   std::set<std::string> ret2;
3812   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3813     {
3814       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3815       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3816         if(ret2.find(*it2)==ret2.end())
3817           {
3818             ret.push_back(*it2);
3819             ret2.insert(*it2);
3820           }
3821     }
3822   return ret;
3823 }
3824
3825 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3826 {
3827   std::vector<std::string> ret;
3828   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3829     {
3830       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3831       ret.insert(ret.end(),tmp.begin(),tmp.end());
3832     }
3833   return ret;
3834 }
3835
3836 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3837 {
3838   std::vector<std::string> ret;
3839   std::set<std::string> ret2;
3840   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3841     {
3842       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3843       ret.insert(ret.end(),tmp.begin(),tmp.end());
3844     }
3845   return ret;
3846 }
3847
3848 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3849 {
3850   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3851     (*it)->changePflsRefsNamesGen(mapOfModif);
3852 }
3853
3854 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
3855 {
3856   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3857     (*it)->changeLocsRefsNamesGen(mapOfModif);
3858 }
3859
3860 /*!
3861  * Returns all attributes of parts of \a this field lying on a given mesh.
3862  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3863  * item of every of returned sequences refers to the _i_-th part of \a this field.
3864  * Thus all sequences returned by this method are of the same length equal to number
3865  * of different types of supporting entities.<br>
3866  * A field part can include sub-parts with several different spatial discretizations,
3867  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3868  * for example. Hence, some of the returned sequences contains nested sequences, and an item
3869  * of a nested sequence corresponds to a type of spatial discretization.<br>
3870  * This method allows for iteration over MEDFile DataStructure without any overhead.
3871  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3872  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3873  *          not checked if \a mname == \c NULL).
3874  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3875  *          a field part is returned. 
3876  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3877  *          This sequence is of the same length as \a types. 
3878  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3879  *          discretization. A profile name can be empty.
3880  *          Length of this and of nested sequences is the same as that of \a typesF.
3881  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
3882  *          discretization. A localization name can be empty.
3883  *          Length of this and of nested sequences is the same as that of \a typesF.
3884  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3885  *          of ids of tuples within the data array, per each type of spatial
3886  *          discretization within one mesh entity type. 
3887  *          Length of this and of nested sequences is the same as that of \a typesF.
3888  *  \throw If no field is lying on \a mname.
3889  */
3890 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception)
3891 {
3892   int meshId=0;
3893   if(mname)
3894     meshId=getMeshIdFromMeshName(mname);
3895   else
3896     if(_field_per_mesh.empty())
3897       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3898   return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3899 }
3900
3901 /*!
3902  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3903  * maximal absolute dimension and values returned via the out parameter \a levs are 
3904  * dimensions relative to the maximal absolute dimension. <br>
3905  * This method is designed for MEDFileField1TS instances that have a discretization
3906  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS", 
3907  * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT", 
3908  * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3909  * Only these 3 discretizations will be taken into account here. If \a this is
3910  * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3911  * This method is useful to make the link between the dimension of the underlying mesh
3912  * and the levels of \a this, because it is possible that the highest dimension of \a this
3913  * field is not equal to the dimension of the underlying mesh.
3914  * 
3915  * Let's consider the following case:
3916  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3917  * TETRA4, HEXA8, TRI3 and SEG2.
3918  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3919  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3920  *
3921  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3922  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3923  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3924  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3925  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3926  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3927  * For example<br>
3928  * to retrieve the highest level of
3929  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
3930  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3931  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3932  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3933  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3934  *          for the case with only one underlying mesh. (Actually, the number of meshes is
3935  *          not checked if \a mname == \c NULL).
3936  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3937  *          absolute one. They are in decreasing order. This sequence is cleared before
3938  *          filling it in.
3939  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
3940  *  \throw If no field is lying on \a mname.
3941  */
3942 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
3943 {
3944   levs.clear();
3945   int meshId=getMeshIdFromMeshName(mname);
3946   std::vector<INTERP_KERNEL::NormalizedCellType> types;
3947   std::vector< std::vector<TypeOfField> > typesF;
3948   std::vector< std::vector<std::string> > pfls, locs;
3949   _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3950   if(types.empty())
3951     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3952   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3953   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3954     return -1;
3955   st.erase(INTERP_KERNEL::NORM_ERROR);
3956   std::set<int> ret1;
3957   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3958     {
3959       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3960       ret1.insert((int)cm.getDimension());
3961     }
3962   int ret=*std::max_element(ret1.begin(),ret1.end());
3963   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3964   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3965   return ret;
3966 }
3967
3968 /*!
3969  * \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.
3970  * \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.
3971  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3972  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3973  */
3974 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
3975 {
3976   int mid=getMeshIdFromMeshName(mName);
3977   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3978 }
3979
3980 /*!
3981  * \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.
3982  * \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.
3983  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
3984  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
3985  */
3986 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
3987 {
3988   int mid=getMeshIdFromMeshName(mName);
3989   return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
3990 }
3991
3992 /*!
3993  * \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.
3994  */
3995 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception)
3996 {
3997   if(_field_per_mesh.empty())
3998     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
3999   if(mName==0)
4000     return 0;
4001   std::string mName2(mName);
4002   int ret=0;
4003   std::vector<std::string> msg;
4004   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4005     if(mName2==(*it)->getMeshName())
4006       return ret;
4007     else
4008       msg.push_back((*it)->getMeshName());
4009   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4010   oss << "Possible meshes are : ";
4011   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4012     oss << "\"" << (*it2) << "\" ";
4013   throw INTERP_KERNEL::Exception(oss.str().c_str());
4014 }
4015
4016 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4017 {
4018   if(!mesh)
4019     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4020   std::string tmp(mesh->getName());
4021   if(tmp.empty())
4022     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4023   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4024   int i=0;
4025   for(;it!=_field_per_mesh.end();it++,i++)
4026     {
4027       if((*it)->getMeshName()==tmp)
4028         return i;
4029     }
4030   int sz=_field_per_mesh.size();
4031   _field_per_mesh.resize(sz+1);
4032   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4033   return sz;
4034 }
4035
4036 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4037                                                             MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
4038 {
4039   bool ret=false;
4040   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4041     {
4042       MEDFileFieldPerMesh *fpm(*it);
4043       if(fpm)
4044         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4045     }
4046   return ret;
4047 }
4048
4049 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
4050 {
4051   std::vector<INTERP_KERNEL::NormalizedCellType> types;
4052   std::vector< std::vector<TypeOfField> > typesF;
4053   std::vector< std::vector<std::string> > pfls,locs;
4054   std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4055   std::set<TypeOfField> allEnt;
4056   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4057     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4058       allEnt.insert(*it2);
4059   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4060   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4061   for(std::size_t i=0;i<allEnt.size();i++,it3++)
4062     {
4063       std::vector< std::pair<int,int> > its;
4064       ret[i]=shallowCpy();
4065       int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4066       ret[i]->updateData(newLgth,its);
4067     }
4068   return ret;
4069 }
4070
4071 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception)
4072 {
4073   int globalCounter=0;
4074   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4075     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4076   return globalCounter;
4077 }
4078
4079 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops) throw(INTERP_KERNEL::Exception)
4080 {
4081   if(_nb_of_tuples_to_be_allocated>=0)
4082     {
4083       _nb_of_tuples_to_be_allocated=newLgth;
4084       return ;
4085     }
4086   if(_nb_of_tuples_to_be_allocated==-1)
4087     return ;
4088   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4089     {
4090       const DataArray *oldArr=getUndergroundDataArray();
4091       if(!oldArr || !oldArr->isAllocated())
4092         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4093       MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4094       newArr->alloc(newLgth,getNumberOfComponents());
4095       int pos=0;
4096       for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4097         {
4098           if((*it).second<(*it).first)
4099             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4100           newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4101           pos+=(*it).second-(*it).first;
4102         }
4103       setArray(newArr);
4104       return ;
4105     }
4106   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4107 }
4108
4109 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4110 {
4111   if(_field_per_mesh.empty())
4112     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4113   if(_field_per_mesh.size()>1)
4114     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4115   _field_per_mesh[0]->copyOptionsFrom(opts);
4116   _field_per_mesh[0]->writeLL(fid,nasc);
4117 }
4118
4119 /*!
4120  * 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.
4121  * If false is returned the memory allocation is not required.
4122  */
4123 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception)
4124 {
4125   if(_nb_of_tuples_to_be_allocated>=0)
4126     {
4127       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4128       _nb_of_tuples_to_be_allocated=-2;
4129       return true;
4130     }
4131   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4132     return false;
4133   if(_nb_of_tuples_to_be_allocated==-1)
4134     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4135   if(_nb_of_tuples_to_be_allocated<-3)
4136     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4137   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4138 }
4139
4140 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4141 {
4142   med_int numdt,numit;
4143   med_float dt;
4144   med_int nmesh;
4145   med_bool localMesh;
4146   med_int meshnumdt,meshnumit;
4147   INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4148   MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4149   MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4150   if(_iteration!=numdt || _order!=numit)
4151     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4152   _field_per_mesh.resize(nmesh);
4153   for(int i=0;i<nmesh;i++)
4154     _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4155   _nb_of_tuples_to_be_allocated=0;
4156   for(int i=0;i<nmesh;i++)
4157     _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4158 }
4159
4160 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4161 {
4162   allocIfNecessaryTheArrayToReceiveDataFromFile();
4163   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4164     (*it)->loadBigArraysRecursively(fid,nasc);
4165 }
4166
4167 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4168 {
4169   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4170     for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4171       (*it)->loadBigArraysRecursively(fid,nasc);
4172 }
4173
4174 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4175 {
4176   loadOnlyStructureOfDataRecursively(fid,nasc);
4177   loadBigArraysRecursively(fid,nasc);
4178 }
4179
4180 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays() throw(INTERP_KERNEL::Exception)
4181 {
4182   DataArray *thisArr(getUndergroundDataArray());
4183   if(thisArr && thisArr->isAllocated())
4184     {
4185       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4186       thisArr->desallocate();
4187     }
4188 }
4189
4190 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const
4191 {
4192   std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4193   if(getUndergroundDataArray())
4194     ret+=getUndergroundDataArray()->getHeapMemorySize();
4195   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4196     ret+=(*it)->getHeapMemorySize();
4197   return ret;
4198 }
4199
4200 /*!
4201  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4202  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4203  * "Sort By Type"), if not, an exception is thrown. 
4204  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
4205  *  \param [in] arr - the array of values.
4206  *  \param [in,out] glob - the global data where profiles and localization present in
4207  *          \a field, if any, are added.
4208  *  \throw If the name of \a field is empty.
4209  *  \throw If the data array of \a field is not set.
4210  *  \throw If \a this->_arr is already allocated but has different number of components
4211  *         than \a field.
4212  *  \throw If the underlying mesh of \a field has no name.
4213  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4214  */
4215 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4216 {
4217   const MEDCouplingMesh *mesh=field->getMesh();
4218   //
4219   TypeOfField type=field->getTypeOfField();
4220   std::vector<DataArrayInt *> dummy;
4221   int start=copyTinyInfoFrom(field,arr);
4222   int pos=addNewEntryIfNecessary(mesh);
4223   if(type!=ON_NODES)
4224     {
4225       std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4226       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4227     }
4228   else
4229     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4230 }
4231
4232 /*!
4233  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4234  * of a given mesh are used as the support of the given field (a real support is not used). 
4235  * Elements of the given mesh must be sorted suitable for writing to MED file. 
4236  * Order of underlying mesh entities of the given field specified by \a profile parameter
4237  * is not prescribed; this method permutes field values to have them sorted by element
4238  * type as required for writing to MED file. A new profile is added only if no equal
4239  * profile is missing. 
4240  *  \param [in] field - the field to add to \a this. The field double values are ignored.
4241  *  \param [in] arrOfVals - the values of the field \a field used.
4242  *  \param [in] mesh - the supporting mesh of \a field.
4243  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4244  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
4245  *  \param [in,out] glob - the global data where profiles and localization present in
4246  *          \a field, if any, are added.
4247  *  \throw If either \a field or \a mesh or \a profile has an empty name.
4248  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4249  *  \throw If the data array of \a field is not set.
4250  *  \throw If \a this->_arr is already allocated but has different number of components
4251  *         than \a field.
4252  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4253  *  \sa setFieldNoProfileSBT()
4254  */
4255 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
4256 {
4257   if(!field)
4258     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4259   if(!arrOfVals || !arrOfVals->isAllocated())
4260     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4261   TypeOfField type=field->getTypeOfField();
4262   std::vector<DataArrayInt *> idsInPflPerType;
4263   std::vector<DataArrayInt *> idsPerType;
4264   std::vector<int> code,code2;
4265   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4266   if(type!=ON_NODES)
4267     {
4268       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4269       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4270       std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
4271       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4272       // start of check
4273       MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4274       if(type==ON_GAUSS_NE)
4275         {
4276           MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4277           field2->setMesh(mPart);
4278         }
4279       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4280       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4281         {
4282           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4283           throw INTERP_KERNEL::Exception(oss.str().c_str());
4284         }
4285       // end of check
4286       int start=copyTinyInfoFrom(field,arrOfVals);
4287       code2=m->getDistributionOfTypes();
4288       //
4289       int pos=addNewEntryIfNecessary(m);
4290       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4291     }
4292   else
4293     {
4294       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4295         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4296       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4297       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4298       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4299       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4300         {
4301           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4302           throw INTERP_KERNEL::Exception(oss.str().c_str());
4303         }
4304       int start=copyTinyInfoFrom(field,arrOfVals);
4305       int pos=addNewEntryIfNecessary(m);
4306       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4307     }
4308 }
4309
4310 /*!
4311  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4312  */
4313 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception)
4314 {
4315   if(_nb_of_tuples_to_be_allocated>=0)
4316     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 !");
4317   DataArray *arr(getOrCreateAndGetArray());
4318   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4319   _nb_of_tuples_to_be_allocated=-3;
4320 }
4321
4322 /*!
4323  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4324  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4325  * larger by the size of \a field. Returns an id of the first not filled
4326  * tuple of \a this->_arr.
4327  *  \param [in] field - the field to copy the info on components and the name from.
4328  *  \return int - the id of first not initialized tuple of \a this->_arr.
4329  *  \throw If the name of \a field is empty.
4330  *  \throw If the data array of \a field is not set.
4331  *  \throw If \a this->_arr is already allocated but has different number of components
4332  *         than \a field.
4333  */
4334 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
4335 {
4336   if(!field)
4337     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4338   std::string name(field->getName());
4339   setName(name.c_str());
4340   setDtUnit(field->getTimeUnit());
4341   if(name.empty())
4342     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4343   if(!arr)
4344     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4345   if(!arr->isAllocated())
4346     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4347   _dt=field->getTime(_iteration,_order);
4348   int nbOfComponents=arr->getNumberOfComponents();
4349   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4350   if(!getOrCreateAndGetArray()->isAllocated())
4351     {
4352       allocNotFromFile(arr->getNumberOfTuples());
4353       return 0;
4354     }
4355   else
4356     {
4357       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4358       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4359       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4360       _nb_of_tuples_to_be_allocated=-3;
4361       return oldNbOfTuples;
4362     }
4363 }
4364
4365 /*!
4366  * Returns number of components in \a this field
4367  *  \return int - the number of components.
4368  */
4369 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4370 {
4371   return getOrCreateAndGetArray()->getNumberOfComponents();
4372 }
4373
4374 /*!
4375  * Change info on components in \a this.
4376  * \throw If size of \a infos is not equal to the number of components already in \a this.
4377  */
4378 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
4379 {
4380   DataArray *arr=getOrCreateAndGetArray();
4381   arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4382 }
4383
4384 /*!
4385  * Returns info on components of \a this field.
4386  *  \return const std::vector<std::string>& - a sequence of strings each being an
4387  *          information on _i_-th component.
4388  */
4389 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4390 {
4391   const DataArray *arr=getOrCreateAndGetArray();
4392   return arr->getInfoOnComponents();
4393 }
4394
4395 /*!
4396  * Returns a mutable info on components of \a this field.
4397  *  \return std::vector<std::string>& - a sequence of strings each being an
4398  *          information on _i_-th component.
4399  */
4400 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4401 {
4402   DataArray *arr=getOrCreateAndGetArray();
4403   return arr->getInfoOnComponents();
4404 }
4405
4406 /*!
4407  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4408  *  \param [in] type - a spatial discretization of the new field.
4409  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4410  *  \param [in] mName - a name of the supporting mesh.
4411  *  \param [in] renumPol - specifies how to permute values of the result field according to
4412  *          the optional numbers of cells and nodes, if any. The valid values are
4413  *          - 0 - do not permute.
4414  *          - 1 - permute cells.
4415  *          - 2 - permute nodes.
4416  *          - 3 - permute cells and nodes.
4417  *
4418  *  \param [in] glob - the global data storing profiles and localization.
4419  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4420  *          caller is to delete this field using decrRef() as it is no more needed. 
4421  *  \throw If the MED file is not readable.
4422  *  \throw If there is no mesh named \a mName in the MED file.
4423  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4424  *  \throw If no field of \a this is lying on the mesh \a mName.
4425  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4426  */
4427 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4428 {
4429   MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4430   if(mName==0)
4431     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4432   else
4433     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4434   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4435 }
4436
4437 /*!
4438  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4439  *  \param [in] type - a spatial discretization of the new field.
4440  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4441  *  \param [in] renumPol - specifies how to permute values of the result field according to
4442  *          the optional numbers of cells and nodes, if any. The valid values are
4443  *          - 0 - do not permute.
4444  *          - 1 - permute cells.
4445  *          - 2 - permute nodes.
4446  *          - 3 - permute cells and nodes.
4447  *
4448  *  \param [in] glob - the global data storing profiles and localization.
4449  *  \param [in] mesh - the supporting mesh.
4450  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4451  *          caller is to delete this field using decrRef() as it is no more needed. 
4452  *  \throw If the MED file is not readable.
4453  *  \throw If no field of \a this is lying on \a mesh.
4454  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4455  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4456  */
4457 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4458 {
4459   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4460   const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4461   const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4462   if(meshDimRelToMax==1)
4463     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4464   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4465 }
4466
4467 /*!
4468  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4469  * given mesh. 
4470  *  \param [in] type - a spatial discretization of the new field.
4471  *  \param [in] mName - a name of the supporting mesh.
4472  *  \param [in] renumPol - specifies how to permute values of the result field according to
4473  *          the optional numbers of cells and nodes, if any. The valid values are
4474  *          - 0 - do not permute.
4475  *          - 1 - permute cells.
4476  *          - 2 - permute nodes.
4477  *          - 3 - permute cells and nodes.
4478  *
4479  *  \param [in] glob - the global data storing profiles and localization.
4480  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4481  *          caller is to delete this field using decrRef() as it is no more needed. 
4482  *  \throw If the MED file is not readable.
4483  *  \throw If there is no mesh named \a mName in the MED file.
4484  *  \throw If there are no mesh entities in the mesh.
4485  *  \throw If no field values of the given \a type are available.
4486  */
4487 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4488 {
4489    MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4490   if(mName==0)
4491     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4492   else
4493     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4494   int absDim=getDimension();
4495   int meshDimRelToMax=absDim-mm->getMeshDimension();
4496   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4497 }
4498
4499 /*!
4500  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4501  *  \param [in] type - a spatial discretization of the new field.
4502  *  \param [in] renumPol - specifies how to permute values of the result field according to
4503  *          the optional numbers of cells and nodes, if any. The valid values are
4504  *          - 0 - do not permute.
4505  *          - 1 - permute cells.
4506  *          - 2 - permute nodes.
4507  *          - 3 - permute cells and nodes.
4508  *
4509  *  \param [in] glob - the global data storing profiles and localization.
4510  *  \param [in] mesh - the supporting mesh.
4511  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
4512  *         field according to \a renumPol.
4513  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
4514  *         field according to \a renumPol.
4515  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4516  *          caller is to delete this field using decrRef() as it is no more needed. 
4517  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4518  *  \throw If no field of \a this is lying on \a mesh.
4519  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4520  */
4521 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4522 {
4523   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4524   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4525   bool isPfl=false;
4526   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4527   switch(renumPol)
4528     {
4529     case 0:
4530       {
4531         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4532         return ret.retn();
4533       }
4534     case 3:
4535     case 1:
4536       {
4537         if(isPfl)
4538           throw INTERP_KERNEL::Exception(msg1);
4539         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4540         if(cellRenum)
4541           {
4542             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4543               {
4544                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4545                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4546                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4547               }
4548             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4549             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4550             std::vector<DataArray *> arrOut2(1,arrOut);
4551             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4552             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4553             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4554           }
4555         if(renumPol==1)
4556           return ret.retn();
4557       }
4558     case 2:
4559       {
4560         //no need to test _field_per_mesh.empty() because geMeshName has already done it
4561         if(isPfl)
4562           throw INTERP_KERNEL::Exception(msg1);
4563         if(nodeRenum)
4564           {
4565             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4566               {
4567                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4568                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4569                 throw INTERP_KERNEL::Exception(oss.str().c_str());
4570               }
4571             MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4572             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4573               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4574             ret->renumberNodes(nodeRenumSafe->getConstPointer());
4575           }
4576         return ret.retn();
4577       }
4578     default:
4579       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4580     }
4581 }
4582
4583 /*!
4584  * Returns values and a profile of the field of a given type lying on a given support.
4585  *  \param [in] type - a spatial discretization of the field.
4586  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4587  *  \param [in] mesh - the supporting mesh.
4588  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4589  *          field of interest lies on. If the field lies on all entities of the given
4590  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
4591  *          using decrRef() as it is no more needed.  
4592  *  \param [in] glob - the global data storing profiles and localization.
4593  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4594  *          field. The caller is to delete this array using decrRef() as it is no more needed.
4595  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4596  *  \throw If no field of \a this is lying on \a mesh.
4597  *  \throw If no field values of the given \a type are available.
4598  */
4599 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
4600 {
4601   MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4602   int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4603   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4604   ret->setName(nasc.getName().c_str());
4605   return ret.retn();
4606 }
4607
4608 //= MEDFileField1TSWithoutSDA
4609
4610 /*!
4611  * Throws if a given value is not a valid (non-extended) relative dimension.
4612  *  \param [in] meshDimRelToMax - the relative dimension value.
4613  *  \throw If \a meshDimRelToMax > 0.
4614  */
4615 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception)
4616 {
4617   if(meshDimRelToMax>0)
4618     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4619 }
4620
4621 /*!
4622  * Checks if elements of a given mesh are in the order suitable for writing 
4623  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4624  * vector describing types of elements and their number.
4625  *  \param [in] mesh - the mesh to check.
4626  *  \return std::vector<int> - a vector holding for each element type (1) item of
4627  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
4628  *          These values are in full-interlace mode.
4629  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4630  */
4631 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
4632 {
4633   if(!mesh)
4634     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4635   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4636   int nbOfTypes=geoTypes.size();
4637   std::vector<int> code(3*nbOfTypes);
4638   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4639   arr1->alloc(nbOfTypes,1);
4640   int *arrPtr=arr1->getPointer();
4641   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4642   for(int i=0;i<nbOfTypes;i++,it++)
4643     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4644   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4645   const int *arrPtr2=arr2->getConstPointer();
4646   int i=0;
4647   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4648     {
4649       int pos=arrPtr2[i];
4650       int nbCells=mesh->getNumberOfCellsWithType(*it);
4651       code[3*pos]=(int)(*it);
4652       code[3*pos+1]=nbCells;
4653       code[3*pos+2]=-1;//no profiles
4654     }
4655   std::vector<const DataArrayInt *> idsPerType;//no profiles
4656   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4657   if(da)
4658     {
4659       da->decrRef();
4660       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4661     }
4662   return code;
4663 }
4664
4665 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4666 {
4667   return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4668 }
4669
4670 /*!
4671  * Returns all attributes and values of parts of \a this field lying on a given mesh.
4672  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4673  * item of every of returned sequences refers to the _i_-th part of \a this field.
4674  * Thus all sequences returned by this method are of the same length equal to number
4675  * of different types of supporting entities.<br>
4676  * A field part can include sub-parts with several different spatial discretizations,
4677  * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4678  * for example. Hence, some of the returned sequences contains nested sequences, and an item
4679  * of a nested sequence corresponds to a type of spatial discretization.<br>
4680  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4681  * The overhead is due to selecting values into new instances of DataArrayDouble.
4682  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4683  *          for the case with only one underlying mesh. (Actually, the number of meshes is
4684  *          not checked if \a mname == \c NULL).
4685  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4686  *          a field part is returned. 
4687  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4688  *          A field part can include sub-parts with several different spatial discretizations,
4689  *          \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and 
4690  *          \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4691  *          This sequence is of the same length as \a types. 
4692  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4693  *          discretization. A profile name can be empty.
4694  *          Length of this and of nested sequences is the same as that of \a typesF.
4695  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
4696  *          discretization. A localization name can be empty.
4697  *          Length of this and of nested sequences is the same as that of \a typesF.
4698  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4699  *          per each type of spatial discretization within one mesh entity type.
4700  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4701  *          Length of this and of nested sequences is the same as that of \a typesF.
4702  *  \throw If no field is lying on \a mname.
4703  */
4704 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception)
4705 {
4706   int meshId=0;
4707   if(mname)
4708     meshId=getMeshIdFromMeshName(mname);
4709   else
4710     if(_field_per_mesh.empty())
4711       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4712   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4713   int nbOfRet=ret0.size();
4714   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4715   for(int i=0;i<nbOfRet;i++)
4716     {
4717       const std::vector< std::pair<int,int> >& p=ret0[i];
4718       int nbOfRet1=p.size();
4719       ret[i].resize(nbOfRet1);
4720       for(int j=0;j<nbOfRet1;j++)
4721         {
4722           DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4723           ret[i][j]=tmp;
4724         }
4725     }
4726   return ret;
4727 }
4728
4729 /*!
4730  * Returns a pointer to the underground DataArrayDouble instance. So the
4731  * caller should not decrRef() it. This method allows for a direct access to the field
4732  * values. This method is quite unusable if there is more than a nodal field or a cell
4733  * field on single geometric cell type. 
4734  *  \return DataArrayDouble * - the pointer to the field values array.
4735  */
4736 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception)
4737 {
4738   const DataArrayDouble *ret=_arr;
4739   if(ret)
4740     return const_cast<DataArrayDouble *>(ret);
4741   else
4742     return 0;
4743 }
4744
4745 const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4746 {
4747   return TYPE_STR;
4748 }
4749
4750 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
4751 {
4752   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4753   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4754   ret->deepCpyLeavesFrom(*this);
4755   const DataArrayDouble *arr(_arr);
4756   if(arr)
4757     {
4758       MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4759       ret->setArray(arr2);
4760     }
4761   return ret.retn();
4762 }
4763
4764 /*!
4765  * Returns a pointer to the underground DataArrayDouble instance. So the
4766  * caller should not decrRef() it. This method allows for a direct access to the field
4767  * values. This method is quite unusable if there is more than a nodal field or a cell
4768  * field on single geometric cell type. 
4769  *  \return DataArrayDouble * - the pointer to the field values array.
4770  */
4771 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4772 {
4773   return getUndergroundDataArrayDouble();
4774 }
4775
4776 /*!
4777  * Returns a pointer to the underground DataArrayDouble instance and a
4778  * sequence describing parameters of a support of each part of \a this field. The
4779  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4780  * direct access to the field values. This method is intended for the field lying on one
4781  * mesh only.
4782  *  \param [in,out] entries - the sequence describing parameters of a support of each
4783  *         part of \a this field. Each item of this sequence consists of two parts. The
4784  *         first part describes a type of mesh entity and an id of discretization of a
4785  *         current field part. The second part describes a range of values [begin,end)
4786  *         within the returned array relating to the current field part.
4787  *  \return DataArrayDouble * - the pointer to the field values array.
4788  *  \throw If the number of underlying meshes is not equal to 1.
4789  *  \throw If no field values are available.
4790  *  \sa getUndergroundDataArray()
4791  */
4792 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4793 {
4794   if(_field_per_mesh.size()!=1)
4795     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4796   if(_field_per_mesh[0]==0)
4797     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4798   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4799   return getUndergroundDataArrayDouble();
4800 }
4801
4802 /*!
4803  * Returns a pointer to the underground DataArrayDouble instance and a
4804  * sequence describing parameters of a support of each part of \a this field. The
4805  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4806  * direct access to the field values. This method is intended for the field lying on one
4807  * mesh only.
4808  *  \param [in,out] entries - the sequence describing parameters of a support of each
4809  *         part of \a this field. Each item of this sequence consists of two parts. The
4810  *         first part describes a type of mesh entity and an id of discretization of a
4811  *         current field part. The second part describes a range of values [begin,end)
4812  *         within the returned array relating to the current field part.
4813  *  \return DataArrayDouble * - the pointer to the field values array.
4814  *  \throw If the number of underlying meshes is not equal to 1.
4815  *  \throw If no field values are available.
4816  *  \sa getUndergroundDataArray()
4817  */
4818 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4819 {
4820   return getUndergroundDataArrayDoubleExt(entries);
4821 }
4822
4823 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4824                                                      const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4825 {
4826   DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4827   arr->setInfoAndChangeNbOfCompo(infos);
4828 }
4829
4830 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4831 {
4832 }
4833
4834 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
4835 {
4836   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4837   ret->deepCpyLeavesFrom(*this);
4838   return ret.retn();
4839 }
4840
4841 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
4842 {
4843   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4844   if((const DataArrayDouble *)_arr)
4845     ret->_arr=_arr->deepCpy();
4846   return ret.retn();
4847 }
4848
4849 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
4850 {
4851   if(!arr)
4852     {
4853       _nb_of_tuples_to_be_allocated=-1;
4854       _arr=0;
4855       return ;
4856     }
4857   DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4858   if(!arrC)
4859     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4860   else
4861     _nb_of_tuples_to_be_allocated=-3;
4862   arrC->incrRef();
4863   _arr=arrC;
4864 }
4865
4866 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4867 {
4868   return DataArrayDouble::New();
4869 }
4870
4871 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4872 {
4873   DataArrayDouble *ret=_arr;
4874   if(ret)
4875     return ret;
4876   _arr=DataArrayDouble::New();
4877   return _arr;
4878 }
4879
4880 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4881 {
4882   return getOrCreateAndGetArrayDouble();
4883 }
4884
4885 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4886 {
4887   const DataArrayDouble *ret=_arr;
4888   if(ret)
4889     return ret;
4890   DataArrayDouble *ret2=DataArrayDouble::New();
4891   const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4892   return ret2;
4893 }
4894
4895 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4896 {
4897   return getOrCreateAndGetArrayDouble();
4898 }
4899
4900 //= MEDFileIntField1TSWithoutSDA
4901
4902 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4903                                                                 const std::vector<std::string>& infos)
4904 {
4905   return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4906 }
4907
4908 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4909 {
4910 }
4911
4912 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4913                                                            const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4914 {
4915   DataArrayInt *arr=getOrCreateAndGetArrayInt();
4916   arr->setInfoAndChangeNbOfCompo(infos);
4917 }
4918
4919 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
4920 {
4921   return TYPE_STR;
4922 }
4923
4924 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
4925 {
4926   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4927   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4928   ret->deepCpyLeavesFrom(*this);
4929   const DataArrayInt *arr(_arr);
4930   if(arr)
4931     {
4932       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4933       ret->setArray(arr2);
4934     }
4935   return ret.retn();
4936 }
4937
4938 /*!
4939  * Returns a pointer to the underground DataArrayInt instance. So the
4940  * caller should not decrRef() it. This method allows for a direct access to the field
4941  * values. This method is quite unusable if there is more than a nodal field or a cell
4942  * field on single geometric cell type. 
4943  *  \return DataArrayInt * - the pointer to the field values array.
4944  */
4945 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
4946 {
4947   return getUndergroundDataArrayInt();
4948 }
4949
4950 /*!
4951  * Returns a pointer to the underground DataArrayInt instance. So the
4952  * caller should not decrRef() it. This method allows for a direct access to the field
4953  * values. This method is quite unusable if there is more than a nodal field or a cell
4954  * field on single geometric cell type. 
4955  *  \return DataArrayInt * - the pointer to the field values array.
4956  */
4957 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception)
4958 {
4959   const DataArrayInt *ret=_arr;
4960   if(ret)
4961     return const_cast<DataArrayInt *>(ret);
4962   else
4963     return 0;
4964 }
4965
4966 /*!
4967  * Returns a pointer to the underground DataArrayInt instance and a
4968  * sequence describing parameters of a support of each part of \a this field. The
4969  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4970  * direct access to the field values. This method is intended for the field lying on one
4971  * mesh only.
4972  *  \param [in,out] entries - the sequence describing parameters of a support of each
4973  *         part of \a this field. Each item of this sequence consists of two parts. The
4974  *         first part describes a type of mesh entity and an id of discretization of a
4975  *         current field part. The second part describes a range of values [begin,end)
4976  *         within the returned array relating to the current field part.
4977  *  \return DataArrayInt * - the pointer to the field values array.
4978  *  \throw If the number of underlying meshes is not equal to 1.
4979  *  \throw If no field values are available.
4980  *  \sa getUndergroundDataArray()
4981  */
4982 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
4983 {
4984   return getUndergroundDataArrayIntExt(entries);
4985 }
4986
4987 /*!
4988  * Returns a pointer to the underground DataArrayInt instance and a
4989  * sequence describing parameters of a support of each part of \a this field. The
4990  * caller should not decrRef() the returned DataArrayInt. This method allows for a
4991  * direct access to the field values. This method is intended for the field lying on one
4992  * mesh only.
4993  *  \param [in,out] entries - the sequence describing parameters of a support of each
4994  *         part of \a this field. Each item of this sequence consists of two parts. The
4995  *         first part describes a type of mesh entity and an id of discretization of a
4996  *         current field part. The second part describes a range of values [begin,end)
4997  *         within the returned array relating to the current field part.
4998  *  \return DataArrayInt * - the pointer to the field values array.
4999  *  \throw If the number of underlying meshes is not equal to 1.
5000  *  \throw If no field values are available.
5001  *  \sa getUndergroundDataArray()
5002  */
5003 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
5004 {
5005   if(_field_per_mesh.size()!=1)
5006     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5007   if(_field_per_mesh[0]==0)
5008     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5009   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5010   return getUndergroundDataArrayInt();
5011 }
5012
5013 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
5014 {
5015   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5016   ret->deepCpyLeavesFrom(*this);
5017   return ret.retn();
5018 }
5019
5020 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
5021 {
5022   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5023   if((const DataArrayInt *)_arr)
5024     ret->_arr=_arr->deepCpy();
5025   return ret.retn();
5026 }
5027
5028 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception)
5029 {
5030   if(!arr)
5031     {
5032       _nb_of_tuples_to_be_allocated=-1;
5033       _arr=0;
5034       return ;
5035     }
5036   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5037   if(!arrC)
5038     throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5039   else
5040     _nb_of_tuples_to_be_allocated=-3;
5041   arrC->incrRef();
5042   _arr=arrC;
5043 }
5044
5045 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5046 {
5047   return DataArrayInt::New();
5048 }
5049
5050 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5051 {
5052   DataArrayInt *ret=_arr;
5053   if(ret)
5054     return ret;
5055   _arr=DataArrayInt::New();
5056   return _arr;
5057 }
5058
5059 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5060 {
5061   return getOrCreateAndGetArrayInt();
5062 }
5063
5064 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5065 {
5066   const DataArrayInt *ret=_arr;
5067   if(ret)
5068     return ret;
5069   DataArrayInt *ret2=DataArrayInt::New();
5070   const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5071   return ret2;
5072 }
5073
5074 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5075 {
5076   return getOrCreateAndGetArrayInt();
5077 }
5078
5079 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5080 {
5081 }
5082
5083 //= MEDFileAnyTypeField1TS
5084
5085 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5086 {
5087   med_field_type typcha;
5088   //
5089   std::vector<std::string> infos;
5090   std::string dtunit,fieldName;
5091   LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5092   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5093   switch(typcha)
5094     {
5095     case MED_FLOAT64:
5096       {
5097         ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5098         break;
5099       }
5100     case MED_INT32:
5101       {
5102         ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5103         break;
5104       }
5105     default:
5106       {
5107         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] !";
5108         throw INTERP_KERNEL::Exception(oss.str().c_str());
5109       }
5110     }
5111   ret->setDtUnit(dtunit.c_str());
5112   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5113   //
5114   med_int numdt,numit;
5115   med_float dt;
5116   MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5117   ret->setTime(numdt,numit,dt);
5118   ret->_csit=1;
5119   if(loadAll)
5120     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5121   else
5122     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5123   return ret.retn();
5124 }
5125
5126 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5127 try:MEDFileFieldGlobsReal(fileName)
5128 {
5129   MEDFileUtilities::CheckFileForRead(fileName);
5130   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5131   _content=BuildContentFrom(fid,fileName,loadAll);
5132   loadGlobals(fid);
5133 }
5134 catch(INTERP_KERNEL::Exception& e)
5135   {
5136     throw e;
5137   }
5138
5139 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5140 {
5141   med_field_type typcha;
5142   std::vector<std::string> infos;
5143   std::string dtunit;
5144   int iii=-1;
5145   int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5146   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5147   switch(typcha)
5148     {
5149     case MED_FLOAT64:
5150       {
5151         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5152         break;
5153       }
5154     case MED_INT32:
5155       {
5156         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5157         break;
5158       }
5159     default:
5160       {
5161         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] !";
5162         throw INTERP_KERNEL::Exception(oss.str().c_str());
5163       }
5164     }
5165   ret->setDtUnit(dtunit.c_str());
5166   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5167   //
5168   if(nbSteps<1)
5169     {
5170       std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5171       throw INTERP_KERNEL::Exception(oss.str().c_str());
5172     }
5173   //
5174   med_int numdt,numit;
5175   med_float dt;
5176   MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5177   ret->setTime(numdt,numit,dt);
5178   ret->_csit=1;
5179   if(loadAll)
5180     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5181   else
5182     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5183   return ret.retn();
5184 }
5185
5186 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5187 try:MEDFileFieldGlobsReal(fileName)
5188 {
5189   MEDFileUtilities::CheckFileForRead(fileName);
5190   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5191   _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5192   loadGlobals(fid);
5193 }
5194 catch(INTERP_KERNEL::Exception& e)
5195   {
5196     throw e;
5197   }
5198
5199 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
5200 {
5201   if(!c)
5202     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5203   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5204     {
5205       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5206       ret->setFileName(fileName);
5207       ret->_content=c; c->incrRef();
5208       return ret.retn();
5209     }
5210   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5211     {
5212       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5213       ret->setFileName(fileName);
5214       ret->_content=c; c->incrRef();
5215       return ret.retn();
5216     }
5217   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5218 }
5219
5220 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5221 {
5222   MEDFileUtilities::CheckFileForRead(fileName);
5223   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5224   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5225   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5226   ret->loadGlobals(fid);
5227   return ret.retn();
5228 }
5229
5230 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5231 {
5232   MEDFileUtilities::CheckFileForRead(fileName);
5233   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5234   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5235   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5236   ret->loadGlobals(fid);
5237   return ret.retn();
5238 }
5239
5240 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5241 {
5242   MEDFileUtilities::CheckFileForRead(fileName);
5243   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5244   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5245   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5246   ret->loadGlobals(fid);
5247   return ret.retn();
5248 }
5249
5250 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5251 {
5252   med_field_type typcha;
5253   std::vector<std::string> infos;
5254   std::string dtunit;
5255   int iii=-1;
5256   int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5257   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5258   switch(typcha)
5259     {
5260     case MED_FLOAT64:
5261       {
5262         ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5263         break;
5264       }
5265     case MED_INT32:
5266       {
5267         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5268         break;
5269       }
5270     default:
5271       {
5272         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] !";
5273         throw INTERP_KERNEL::Exception(oss.str().c_str());
5274       }
5275     }
5276   ret->setDtUnit(dtunit.c_str());
5277   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5278   //
5279   bool found=false;
5280   std::vector< std::pair<int,int> > dtits(nbOfStep2);
5281   for(int i=0;i<nbOfStep2 && !found;i++)
5282     {
5283       med_int numdt,numit;
5284       med_float dt;
5285       MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5286       if(numdt==iteration && numit==order)
5287         {
5288           found=true;
5289           ret->_csit=i+1;
5290         }
5291       else
5292         dtits[i]=std::pair<int,int>(numdt,numit);
5293     }
5294   if(!found)
5295     {
5296       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5297       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5298         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5299       throw INTERP_KERNEL::Exception(oss.str().c_str());
5300     }
5301   if(loadAll)
5302     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5303   else
5304     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5305   return ret.retn();
5306 }
5307
5308 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5309 try:MEDFileFieldGlobsReal(fileName)
5310 {
5311   MEDFileUtilities::CheckFileForRead(fileName);
5312   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5313   _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5314   loadGlobals(fid);
5315 }
5316 catch(INTERP_KERNEL::Exception& e)
5317   {
5318     throw e;
5319   }
5320
5321 /*!
5322  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5323  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5324  *
5325  * \warning this is a shallow copy constructor
5326  */
5327 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5328 {
5329   if(!shallowCopyOfContent)
5330     {
5331       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5332       otherPtr->incrRef();
5333       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5334     }
5335   else
5336     {
5337       _content=other.shallowCpy();
5338     }
5339 }
5340
5341 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5342 {
5343   if(checkFieldId)
5344     {
5345       int nbFields=MEDnField(fid);
5346       if(fieldIdCFormat>=nbFields)
5347         {
5348           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5349           throw INTERP_KERNEL::Exception(oss.str().c_str());
5350         }
5351     }
5352   int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5353   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5354   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5355   INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5356   INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5357   INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5358   med_bool localMesh;
5359   int nbOfStep;
5360   MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5361   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5362   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5363   infos.clear(); infos.resize(ncomp);
5364   for(int j=0;j<ncomp;j++)
5365     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5366   return nbOfStep;
5367 }
5368
5369 /*!
5370  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5371  * 
5372  * \param [out]
5373  * \return in case of success the number of time steps available for the field with name \a fieldName.
5374  */
5375 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception)
5376 {
5377   int nbFields=MEDnField(fid);
5378   bool found=false;
5379   std::vector<std::string> fns(nbFields);
5380   int nbOfStep2=-1;
5381   for(int i=0;i<nbFields && !found;i++)
5382     {
5383       std::string tmp;
5384       nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5385       fns[i]=tmp;
5386       found=(tmp==fieldName);
5387       if(found)
5388         posCFormat=i;
5389     }
5390   if(!found)
5391     {
5392       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5393       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5394         oss << "\"" << *it << "\" ";
5395       throw INTERP_KERNEL::Exception(oss.str().c_str());
5396     }
5397   return nbOfStep2;
5398 }
5399
5400 /*!
5401  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5402  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5403  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5404  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5405  * to keep a valid instance.
5406  * 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.
5407  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5408  * 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.
5409  *
5410  * \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.
5411  * \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.
5412  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5413  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5414  * \param [in] newLocName is the new localization name.
5415  * \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.
5416  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5417  */
5418 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5419 {
5420   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5421   std::string oldPflName=disc->getProfile();
5422   std::vector<std::string> vv=getPflsReallyUsedMulti();
5423   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5424   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5425     {
5426       disc->setProfile(newPflName);
5427       DataArrayInt *pfl=getProfile(oldPflName.c_str());
5428       pfl->setName(newPflName);
5429     }
5430   else
5431     {
5432       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5433       throw INTERP_KERNEL::Exception(oss.str().c_str());
5434     }
5435 }
5436
5437 /*!
5438  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5439  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5440  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5441  * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5442  * to keep a valid instance.
5443  * 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.
5444  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5445  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5446  * 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.
5447  *
5448  * \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.
5449  * \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.
5450  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
5451  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5452  * \param [in] newLocName is the new localization name.
5453  * \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.
5454  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5455  */
5456 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob) throw(INTERP_KERNEL::Exception)
5457 {
5458   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5459   std::string oldLocName=disc->getLocalization();
5460   std::vector<std::string> vv=getLocsReallyUsedMulti();
5461   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5462   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5463     {
5464       disc->setLocalization(newLocName);
5465       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5466       loc.setName(newLocName);
5467     }
5468   else
5469     {
5470       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5471       throw INTERP_KERNEL::Exception(oss.str().c_str());
5472     }
5473 }
5474
5475 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
5476 {
5477   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5478   if(!ret)
5479     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5480   return ret;
5481 }
5482
5483 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
5484 {
5485   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5486   if(!ret)
5487     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5488   return ret;
5489 }
5490
5491 /*!
5492  * Writes \a this field into a MED file specified by its name.
5493  *  \param [in] fileName - the MED file name.
5494  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5495  * - 2 - erase; an existing file is removed.
5496  * - 1 - append; same data should not be present in an existing file.
5497  * - 0 - overwrite; same data present in an existing file is overwritten.
5498  *  \throw If the field name is not set.
5499  *  \throw If no field data is set.
5500  *  \throw If \a mode == 1 and the same data is present in an existing file.
5501  */
5502 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
5503 {
5504   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5505   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5506   writeLL(fid);
5507 }
5508
5509 /*!
5510  * This method alloc the arrays and load potentially huge arrays contained in this field.
5511  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5512  * This method can be also called to refresh or reinit values from a file.
5513  * 
5514  * \throw If the fileName is not set or points to a non readable MED file.
5515  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5516  */
5517 void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception)
5518 {
5519   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5520   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5521 }
5522
5523 /*!
5524  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5525  * But once data loaded once, this method does nothing.
5526  * 
5527  * \throw If the fileName is not set or points to a non readable MED file.
5528  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5529  */
5530 void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
5531 {
5532   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5533   contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5534 }
5535
5536 /*!
5537  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5538  * This method does not release arrays set outside the context of a MED file.
5539  * 
5540  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5541  */
5542 void MEDFileAnyTypeField1TS::unloadArrays() throw(INTERP_KERNEL::Exception)
5543 {
5544   contentNotNullBase()->unloadArrays();
5545 }
5546
5547 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
5548 {
5549   int nbComp=getNumberOfComponents();
5550   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5551   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5552   for(int i=0;i<nbComp;i++)
5553     {
5554       std::string info=getInfo()[i];
5555       std::string c,u;
5556       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5557       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5558       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5559     }
5560   if(getName().empty())
5561     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5562   MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5563   writeGlobals(fid,*this);
5564   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5565 }
5566
5567 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySize() const
5568 {
5569   std::size_t ret=0;
5570   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5571     ret+=_content->getHeapMemorySize();
5572   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
5573 }
5574
5575 /*!
5576  * Returns a string describing \a this field. This string is outputted 
5577  * by \c print Python command.
5578  */
5579 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5580 {
5581   std::ostringstream oss;
5582   contentNotNullBase()->simpleRepr(0,oss,-1);
5583   simpleReprGlobs(oss);
5584   return oss.str();
5585 }
5586
5587 /*!
5588  * This method returns all profiles whose name is non empty used.
5589  * \b WARNING If profile is used several times it will be reported \b only \b once.
5590  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5591  */
5592 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5593 {
5594   return contentNotNullBase()->getPflsReallyUsed2();
5595 }
5596
5597 /*!
5598  * This method returns all localizations whose name is non empty used.
5599  * \b WARNING If localization is used several times it will be reported \b only \b once.
5600  */
5601 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5602 {
5603   return contentNotNullBase()->getLocsReallyUsed2();
5604 }
5605
5606 /*!
5607  * This method returns all profiles whose name is non empty used.
5608  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5609  */
5610 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5611 {
5612   return contentNotNullBase()->getPflsReallyUsedMulti2();
5613 }
5614
5615 /*!
5616  * This method returns all localizations whose name is non empty used.
5617  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5618  */
5619 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5620 {
5621   return contentNotNullBase()->getLocsReallyUsedMulti2();
5622 }
5623
5624 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5625 {
5626   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5627 }
5628
5629 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
5630 {
5631   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5632 }
5633
5634 int MEDFileAnyTypeField1TS::getDimension() const
5635 {
5636   return contentNotNullBase()->getDimension();
5637 }
5638
5639 int MEDFileAnyTypeField1TS::getIteration() const
5640 {
5641   return contentNotNullBase()->getIteration();
5642 }
5643
5644 int MEDFileAnyTypeField1TS::getOrder() const
5645 {
5646   return contentNotNullBase()->getOrder();
5647 }
5648
5649 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5650 {
5651   return contentNotNullBase()->getTime(iteration,order);
5652 }
5653
5654 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5655 {
5656   contentNotNullBase()->setTime(iteration,order,val);
5657 }
5658
5659 std::string MEDFileAnyTypeField1TS::getName() const
5660 {
5661   return contentNotNullBase()->getName();
5662 }
5663
5664 void MEDFileAnyTypeField1TS::setName(const char *name)
5665 {
5666   contentNotNullBase()->setName(name);
5667 }
5668
5669 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5670 {
5671   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5672 }
5673
5674 std::string MEDFileAnyTypeField1TS::getDtUnit() const throw(INTERP_KERNEL::Exception)
5675 {
5676   return contentNotNullBase()->getDtUnit();
5677 }
5678
5679 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
5680 {
5681   contentNotNullBase()->setDtUnit(dtUnit);
5682 }
5683
5684 std::string MEDFileAnyTypeField1TS::getMeshName() const throw(INTERP_KERNEL::Exception)
5685 {
5686   return contentNotNullBase()->getMeshName();
5687 }
5688
5689 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
5690 {
5691   contentNotNullBase()->setMeshName(newMeshName);
5692 }
5693
5694 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
5695 {
5696   return contentNotNullBase()->changeMeshNames(modifTab);
5697 }
5698
5699 int MEDFileAnyTypeField1TS::getMeshIteration() const throw(INTERP_KERNEL::Exception)
5700 {
5701   return contentNotNullBase()->getMeshIteration();
5702 }
5703
5704 int MEDFileAnyTypeField1TS::getMeshOrder() const throw(INTERP_KERNEL::Exception)
5705 {
5706   return contentNotNullBase()->getMeshOrder();
5707 }
5708
5709 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5710 {
5711   return contentNotNullBase()->getNumberOfComponents();
5712 }
5713
5714 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5715 {
5716   return contentNotNullBase()->isDealingTS(iteration,order);
5717 }
5718
5719 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5720 {
5721   return contentNotNullBase()->getDtIt();
5722 }
5723
5724 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5725 {
5726   contentNotNullBase()->fillIteration(p);
5727 }
5728
5729 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception)
5730 {
5731   contentNotNullBase()->fillTypesOfFieldAvailable(types);
5732 }
5733
5734 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos) throw(INTERP_KERNEL::Exception)
5735 {
5736   contentNotNullBase()->setInfo(infos);
5737 }
5738
5739 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5740 {
5741   return contentNotNullBase()->getInfo();
5742 }
5743 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5744 {
5745   return contentNotNullBase()->getInfo();
5746 }
5747
5748 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception)
5749 {
5750   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5751 }
5752
5753 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception)
5754 {
5755   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5756 }
5757
5758 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
5759 {
5760   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5761 }
5762
5763 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
5764 {
5765   return contentNotNullBase()->getTypesOfFieldAvailable();
5766 }
5767
5768 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5769                                                                                        std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5770 {
5771   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5772 }
5773
5774 /*!
5775  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5776  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5777  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5778  */
5779 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const throw(INTERP_KERNEL::Exception)
5780 {
5781   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5782   if(!content)
5783     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5784   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5785   std::size_t sz(contentsSplit.size());
5786   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5787   for(std::size_t i=0;i<sz;i++)
5788     {
5789       ret[i]=shallowCpy();
5790       ret[i]->_content=contentsSplit[i];
5791     }
5792   return ret;
5793 }
5794
5795 /*!
5796  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5797  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5798  */
5799 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
5800 {
5801   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5802   if(!content)
5803     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5804   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5805   std::size_t sz(contentsSplit.size());
5806   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5807   for(std::size_t i=0;i<sz;i++)
5808     {
5809       ret[i]=shallowCpy();
5810       ret[i]->_content=contentsSplit[i];
5811     }
5812   return ret;
5813 }
5814
5815 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const throw(INTERP_KERNEL::Exception)
5816 {
5817   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5818   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5819     ret->_content=_content->deepCpy();
5820   ret->deepCpyGlobs(*this);
5821   return ret.retn();
5822 }
5823
5824 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
5825 {
5826   return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5827 }
5828
5829 //= MEDFileField1TS
5830
5831 /*!
5832  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5833  * the first field that has been read from a specified MED file.
5834  *  \param [in] fileName - the name of the MED file to read.
5835  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5836  *          is to delete this field using decrRef() as it is no more needed.
5837  *  \throw If reading the file fails.
5838  */
5839 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5840 {
5841   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5842   ret->contentNotNull();
5843   return ret.retn();
5844 }
5845
5846 /*!
5847  * Returns a new instance of MEDFileField1TS holding data of the first time step of 
5848  * a given field that has been read from a specified MED file.
5849  *  \param [in] fileName - the name of the MED file to read.
5850  *  \param [in] fieldName - the name of the field to read.
5851  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5852  *          is to delete this field using decrRef() as it is no more needed.
5853  *  \throw If reading the file fails.
5854  *  \throw If there is no field named \a fieldName in the file.
5855  */
5856 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5857 {
5858   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5859   ret->contentNotNull();
5860   return ret.retn();
5861 }
5862
5863 /*!
5864  * Returns a new instance of MEDFileField1TS holding data of a given time step of 
5865  * a given field that has been read from a specified MED file.
5866  *  \param [in] fileName - the name of the MED file to read.
5867  *  \param [in] fieldName - the name of the field to read.
5868  *  \param [in] iteration - the iteration number of a required time step.
5869  *  \param [in] order - the iteration order number of required time step.
5870  *  \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5871  *          is to delete this field using decrRef() as it is no more needed.
5872  *  \throw If reading the file fails.
5873  *  \throw If there is no field named \a fieldName in the file.
5874  *  \throw If the required time step is missing from the file.
5875  */
5876 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
5877 {
5878   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5879   ret->contentNotNull();
5880   return ret.retn();
5881 }
5882
5883 /*!
5884  * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5885  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5886  *
5887  * Returns a new instance of MEDFileField1TS holding either a shallow copy
5888  * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5889  * \warning this is a shallow copy constructor
5890  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5891  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5892  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5893  *          is to delete this field using decrRef() as it is no more needed.
5894  */
5895 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5896 {
5897   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5898   ret->contentNotNull();
5899   return ret.retn();
5900 }
5901
5902 /*!
5903  * Returns a new empty instance of MEDFileField1TS.
5904  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5905  *          is to delete this field using decrRef() as it is no more needed.
5906  */
5907 MEDFileField1TS *MEDFileField1TS::New()
5908 {
5909   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5910   ret->contentNotNull();
5911   return ret.retn();
5912 }
5913
5914 /*!
5915  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5916  * following the given input policy.
5917  *
5918  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5919  *                            By default (true) the globals are deeply copied.
5920  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5921  */
5922 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
5923 {
5924   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5925   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5926   if(content)
5927     {
5928       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5929       if(!contc)
5930         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5931       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5932       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5933     }
5934   else
5935     ret=MEDFileIntField1TS::New();
5936   if(deepCpyGlobs)
5937     ret->deepCpyGlobs(*this);
5938   else
5939     ret->shallowCpyGlobs(*this);
5940   return ret.retn();
5941 }
5942
5943 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
5944 {
5945   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5946   if(!pt)
5947     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
5948   const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
5949   if(!ret)
5950     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 !");
5951   return ret;
5952 }
5953
5954 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
5955 {
5956   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
5957   if(!pt)
5958     throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
5959   MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
5960   if(!ret)
5961     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 !");
5962   return ret;
5963 }
5964
5965 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5966 {
5967   if(!f)
5968     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
5969   if(!((DataArray*)arr))
5970     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
5971   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5972   if(!arrOutC)
5973     throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5974   f->setArray(arrOutC);
5975 }
5976
5977 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
5978 {
5979   if(!((DataArray*)arr))
5980     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
5981   DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
5982   if(!arrOutC)
5983     throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
5984   arrOutC->incrRef();
5985   return arrOutC;
5986 }
5987
5988 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
5989 try:MEDFileAnyTypeField1TS(fileName,loadAll)
5990 {
5991 }
5992 catch(INTERP_KERNEL::Exception& e)
5993   { throw e; }
5994
5995 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
5996 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
5997 {
5998 }
5999 catch(INTERP_KERNEL::Exception& e)
6000   { throw e; }
6001
6002 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6003 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6004 {
6005 }
6006 catch(INTERP_KERNEL::Exception& e)
6007   { throw e; }
6008
6009 /*!
6010  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6011  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6012  *
6013  * \warning this is a shallow copy constructor
6014  */
6015 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6016 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6017 {
6018 }
6019 catch(INTERP_KERNEL::Exception& e)
6020   { throw e; }
6021
6022 MEDFileField1TS::MEDFileField1TS()
6023 {
6024   _content=new MEDFileField1TSWithoutSDA;
6025 }
6026
6027 /*!
6028  * Returns a new MEDCouplingFieldDouble of a given type lying on
6029  * mesh entities of a given dimension of the first mesh in MED file. If \a this field 
6030  * has not been constructed via file reading, an exception is thrown.
6031  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6032  *  \param [in] type - a spatial discretization of interest.
6033  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6034  *  \param [in] renumPol - specifies how to permute values of the result field according to
6035  *          the optional numbers of cells and nodes, if any. The valid values are
6036  *          - 0 - do not permute.
6037  *          - 1 - permute cells.
6038  *          - 2 - permute nodes.
6039  *          - 3 - permute cells and nodes.
6040  *
6041  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6042  *          caller is to delete this field using decrRef() as it is no more needed. 
6043  *  \throw If \a this field has not been constructed via file reading.
6044  *  \throw If the MED file is not readable.
6045  *  \throw If there is no mesh in the MED file.
6046  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6047  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6048  *  \sa getFieldOnMeshAtLevel()
6049  */
6050 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6051 {
6052   if(getFileName2().empty())
6053     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6054   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6055   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6056   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6057   return ret.retn();
6058 }
6059
6060 /*!
6061  * Returns a new MEDCouplingFieldDouble of a given type lying on
6062  * the top level cells of the first mesh in MED file. If \a this field 
6063  * has not been constructed via file reading, an exception is thrown.
6064  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6065  *  \param [in] type - a spatial discretization of interest.
6066  *  \param [in] renumPol - specifies how to permute values of the result field according to
6067  *          the optional numbers of cells and nodes, if any. The valid values are
6068  *          - 0 - do not permute.
6069  *          - 1 - permute cells.
6070  *          - 2 - permute nodes.
6071  *          - 3 - permute cells and nodes.
6072  *
6073  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6074  *          caller is to delete this field using decrRef() as it is no more needed. 
6075  *  \throw If \a this field has not been constructed via file reading.
6076  *  \throw If the MED file is not readable.
6077  *  \throw If there is no mesh in the MED file.
6078  *  \throw If no field values of the given \a type.
6079  *  \throw If no field values lying on the top level support.
6080  *  \sa getFieldAtLevel()
6081  */
6082 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const throw(INTERP_KERNEL::Exception)
6083 {
6084   if(getFileName2().empty())
6085     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6086   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6087   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6088   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6089   return ret.retn();
6090 }
6091
6092 /*!
6093  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6094  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6095  *  \param [in] type - a spatial discretization of the new field.
6096  *  \param [in] mesh - the supporting mesh.
6097  *  \param [in] renumPol - specifies how to permute values of the result field according to
6098  *          the optional numbers of cells and nodes, if any. The valid values are
6099  *          - 0 - do not permute.
6100  *          - 1 - permute cells.
6101  *          - 2 - permute nodes.
6102  *          - 3 - permute cells and nodes.
6103  *
6104  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6105  *          caller is to delete this field using decrRef() as it is no more needed. 
6106  *  \throw If no field of \a this is lying on \a mesh.
6107  *  \throw If the mesh is empty.
6108  *  \throw If no field values of the given \a type are available.
6109  *  \sa getFieldAtLevel()
6110  *  \sa getFieldOnMeshAtLevel() 
6111  */
6112 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6113 {
6114   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6115   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6116   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6117   return ret.retn();
6118 }
6119
6120 /*!
6121  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6122  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6123  *  \param [in] type - a spatial discretization of interest.
6124  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6125  *  \param [in] mesh - the supporting mesh.
6126  *  \param [in] renumPol - specifies how to permute values of the result field according to
6127  *          the optional numbers of cells and nodes, if any. The valid values are
6128  *          - 0 - do not permute.
6129  *          - 1 - permute cells.
6130  *          - 2 - permute nodes.
6131  *          - 3 - permute cells and nodes.
6132  *
6133  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6134  *          caller is to delete this field using decrRef() as it is no more needed. 
6135  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6136  *  \throw If no field of \a this is lying on \a mesh.
6137  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6138  *  \sa getFieldAtLevel()
6139  *  \sa getFieldOnMeshAtLevel() 
6140  */
6141 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
6142 {
6143   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6144   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6145   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6146   return ret.retn();
6147 }
6148
6149 /*!
6150  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6151  * This method is called "Old" because in MED3 norm a field has only one meshName
6152  * attached, so this method is for readers of MED2 files. If \a this field 
6153  * has not been constructed via file reading, an exception is thrown.
6154  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6155  *  \param [in] type - a spatial discretization of interest.
6156  *  \param [in] mName - a name of the supporting mesh.
6157  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6158  *  \param [in] renumPol - specifies how to permute values of the result field according to
6159  *          the optional numbers of cells and nodes, if any. The valid values are
6160  *          - 0 - do not permute.
6161  *          - 1 - permute cells.
6162  *          - 2 - permute nodes.
6163  *          - 3 - permute cells and nodes.
6164  *
6165  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6166  *          caller is to delete this field using decrRef() as it is no more needed. 
6167  *  \throw If the MED file is not readable.
6168  *  \throw If there is no mesh named \a mName in the MED file.
6169  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6170  *  \throw If \a this field has not been constructed via file reading.
6171  *  \throw If no field of \a this is lying on the mesh named \a mName.
6172  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6173  *  \sa getFieldAtLevel()
6174  */
6175 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
6176 {
6177   if(getFileName2().empty())
6178     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6179   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6180   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6181   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6182   return ret.retn();
6183 }
6184
6185 /*!
6186  * Returns values and a profile of the field of a given type lying on a given support.
6187  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6188  *  \param [in] type - a spatial discretization of the field.
6189  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6190  *  \param [in] mesh - the supporting mesh.
6191  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6192  *          field of interest lies on. If the field lies on all entities of the given
6193  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6194  *          using decrRef() as it is no more needed.  
6195  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6196  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6197  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6198  *  \throw If no field of \a this is lying on \a mesh.
6199  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6200  */
6201 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6202 {
6203   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6204   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6205 }
6206
6207 /*!
6208  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6209  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6210  * "Sort By Type"), if not, an exception is thrown. 
6211  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6212  *  \param [in] field - the field to add to \a this.
6213  *  \throw If the name of \a field is empty.
6214  *  \throw If the data array of \a field is not set.
6215  *  \throw If the data array is already allocated but has different number of components
6216  *         than \a field.
6217  *  \throw If the underlying mesh of \a field has no name.
6218  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6219  */
6220 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
6221 {
6222   setFileName("");
6223   contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6224 }
6225
6226 /*!
6227  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6228  * can be an aggregation of several MEDCouplingFieldDouble instances.
6229  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6230  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6231  * and \a profile.
6232  *
6233  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6234  * A new profile is added only if no equal profile is missing.
6235  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6236  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6237  *  \param [in] mesh - the supporting mesh of \a field.
6238  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6239  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6240  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6241  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6242  *  \throw If the data array of \a field is not set.
6243  *  \throw If the data array of \a this is already allocated but has different number of
6244  *         components than \a field.
6245  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6246  *  \sa setFieldNoProfileSBT()
6247  */
6248 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6249 {
6250   setFileName("");
6251   contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6252 }
6253
6254 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6255 {
6256   return new MEDFileField1TS(*this);
6257 }
6258
6259 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6260 {
6261   return contentNotNull()->getUndergroundDataArrayDouble();
6262 }
6263
6264 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6265 {
6266   return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6267 }
6268
6269 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6270                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6271 {
6272   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6273 }
6274
6275 //= MEDFileIntField1TS
6276
6277 MEDFileIntField1TS *MEDFileIntField1TS::New()
6278 {
6279   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6280   ret->contentNotNull();
6281   return ret.retn();
6282 }
6283
6284 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6285 {
6286   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6287   ret->contentNotNull();
6288   return ret.retn();
6289 }
6290
6291 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6292 {
6293   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6294   ret->contentNotNull();
6295   return ret.retn();
6296 }
6297
6298 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6299 {
6300   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6301   ret->contentNotNull();
6302   return ret.retn();
6303 }
6304
6305 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6306 {
6307   MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6308   ret->contentNotNull();
6309   return ret.retn();
6310 }
6311
6312 MEDFileIntField1TS::MEDFileIntField1TS()
6313 {
6314   _content=new MEDFileIntField1TSWithoutSDA;
6315 }
6316
6317 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
6318 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6319 {
6320 }
6321 catch(INTERP_KERNEL::Exception& e)
6322   { throw e; }
6323
6324 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
6325 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6326 {
6327 }
6328 catch(INTERP_KERNEL::Exception& e)
6329   { throw e; }
6330
6331 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception)
6332 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6333 {
6334 }
6335 catch(INTERP_KERNEL::Exception& e)
6336   { throw e; }
6337
6338 /*!
6339  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6340  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6341  *
6342  * \warning this is a shallow copy constructor
6343  */
6344 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6345 {
6346 }
6347
6348 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const throw(INTERP_KERNEL::Exception)
6349 {
6350   return new MEDFileIntField1TS(*this);
6351 }
6352
6353 /*!
6354  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6355  * following the given input policy.
6356  *
6357  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6358  *                            By default (true) the globals are deeply copied.
6359  * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6360  */
6361 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
6362 {
6363   MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6364   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6365   if(content)
6366     {
6367       const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6368       if(!contc)
6369         throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6370       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6371       ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6372     }
6373   else
6374     ret=MEDFileField1TS::New();
6375   if(deepCpyGlobs)
6376     ret->deepCpyGlobs(*this);
6377   else
6378     ret->shallowCpyGlobs(*this);
6379   return ret.retn();
6380 }
6381
6382 /*!
6383  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6384  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6385  * "Sort By Type"), if not, an exception is thrown. 
6386  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6387  *  \param [in] field - the field to add to \a this. The field double values are ignored.
6388  *  \param [in] arrOfVals - the values of the field \a field used.
6389  *  \throw If the name of \a field is empty.
6390  *  \throw If the data array of \a field is not set.
6391  *  \throw If the data array is already allocated but has different number of components
6392  *         than \a field.
6393  *  \throw If the underlying mesh of \a field has no name.
6394  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6395  */
6396 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
6397 {
6398   setFileName("");
6399   contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6400 }
6401
6402 /*!
6403  * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6404  * can be an aggregation of several MEDCouplingFieldDouble instances.
6405  * The mesh support of input parameter \a field is ignored here, it can be NULL.
6406  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6407  * and \a profile.
6408  *
6409  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6410  * A new profile is added only if no equal profile is missing.
6411  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6412  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6413  *  \param [in] arrOfVals - the values of the field \a field used.
6414  *  \param [in] mesh - the supporting mesh of \a field.
6415  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6416  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
6417  *  \throw If either \a field or \a mesh or \a profile has an empty name.
6418  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6419  *  \throw If the data array of \a field is not set.
6420  *  \throw If the data array of \a this is already allocated but has different number of
6421  *         components than \a field.
6422  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6423  *  \sa setFieldNoProfileSBT()
6424  */
6425 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
6426 {
6427   setFileName("");
6428   contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6429 }
6430
6431 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const throw(INTERP_KERNEL::Exception)
6432 {
6433   const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6434   if(!pt)
6435     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6436   const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6437   if(!ret)
6438     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 !");
6439   return ret;
6440 }
6441
6442 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6443 {
6444   if(getFileName2().empty())
6445     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6446   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6447   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6448   DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6449   if(!arrOutC)
6450     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6451   arrOut=arrOutC;
6452   return ret.retn();
6453 }
6454
6455 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr) throw(INTERP_KERNEL::Exception)
6456 {
6457   if(!((DataArray *)arr))
6458     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6459   DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6460   if(!arrC)
6461     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6462   arrC->incrRef();
6463   return arrC;
6464 }
6465
6466 /*!
6467  * Returns a new MEDCouplingFieldDouble of a given type lying on
6468  * the top level cells of the first mesh in MED file. If \a this field 
6469  * has not been constructed via file reading, an exception is thrown.
6470  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6471  *  \param [in] type - a spatial discretization of interest.
6472  *  \param [out] arrOut - the DataArrayInt containing values of field.
6473  *  \param [in] renumPol - specifies how to permute values of the result field according to
6474  *          the optional numbers of cells and nodes, if any. The valid values are
6475  *          - 0 - do not permute.
6476  *          - 1 - permute cells.
6477  *          - 2 - permute nodes.
6478  *          - 3 - permute cells and nodes.
6479  *
6480  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6481  *          caller is to delete this field using decrRef() as it is no more needed. 
6482  *  \throw If \a this field has not been constructed via file reading.
6483  *  \throw If the MED file is not readable.
6484  *  \throw If there is no mesh in the MED file.
6485  *  \throw If no field values of the given \a type.
6486  *  \throw If no field values lying on the top level support.
6487  *  \sa getFieldAtLevel()
6488  */
6489 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6490 {
6491   if(getFileName2().empty())
6492     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6493   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6494   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6495   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6496   return ret.retn();
6497 }
6498
6499 /*!
6500  * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6501  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6502  *  \param [in] type - a spatial discretization of the new field.
6503  *  \param [in] mesh - the supporting mesh.
6504  *  \param [out] arrOut - the DataArrayInt containing values of field.
6505  *  \param [in] renumPol - specifies how to permute values of the result field according to
6506  *          the optional numbers of cells and nodes, if any. The valid values are
6507  *          - 0 - do not permute.
6508  *          - 1 - permute cells.
6509  *          - 2 - permute nodes.
6510  *          - 3 - permute cells and nodes.
6511  *
6512  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6513  *          caller is to delete this field using decrRef() as it is no more needed. 
6514  *  \throw If no field of \a this is lying on \a mesh.
6515  *  \throw If the mesh is empty.
6516  *  \throw If no field values of the given \a type are available.
6517  *  \sa getFieldAtLevel()
6518  *  \sa getFieldOnMeshAtLevel() 
6519  */
6520 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6521 {
6522   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6523   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6524   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6525   return ret.retn();
6526 }
6527
6528 /*!
6529  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6530  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6531  *  \param [in] type - a spatial discretization of interest.
6532  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6533  *  \param [out] arrOut - the DataArrayInt containing values of field.
6534  *  \param [in] mesh - the supporting mesh.
6535  *  \param [in] renumPol - specifies how to permute values of the result field according to
6536  *          the optional numbers of cells and nodes, if any. The valid values are
6537  *          - 0 - do not permute.
6538  *          - 1 - permute cells.
6539  *          - 2 - permute nodes.
6540  *          - 3 - permute cells and nodes.
6541  *
6542  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6543  *          caller is to delete this field using decrRef() as it is no more needed. 
6544  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6545  *  \throw If no field of \a this is lying on \a mesh.
6546  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6547  *  \sa getFieldAtLevel()
6548  *  \sa getFieldOnMeshAtLevel() 
6549  */
6550 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6551 {
6552   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6553   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6554   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6555   return ret.retn();
6556 }
6557
6558 /*!
6559  * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6560  * This method is called "Old" because in MED3 norm a field has only one meshName
6561  * attached, so this method is for readers of MED2 files. If \a this field 
6562  * has not been constructed via file reading, an exception is thrown.
6563  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6564  *  \param [in] type - a spatial discretization of interest.
6565  *  \param [in] mName - a name of the supporting mesh.
6566  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6567  *  \param [out] arrOut - the DataArrayInt containing values of field.
6568  *  \param [in] renumPol - specifies how to permute values of the result field according to
6569  *          the optional numbers of cells and nodes, if any. The valid values are
6570  *          - 0 - do not permute.
6571  *          - 1 - permute cells.
6572  *          - 2 - permute nodes.
6573  *          - 3 - permute cells and nodes.
6574  *
6575  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6576  *          caller is to delete this field using decrRef() as it is no more needed. 
6577  *  \throw If the MED file is not readable.
6578  *  \throw If there is no mesh named \a mName in the MED file.
6579  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6580  *  \throw If \a this field has not been constructed via file reading.
6581  *  \throw If no field of \a this is lying on the mesh named \a mName.
6582  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6583  *  \sa getFieldAtLevel()
6584  */
6585 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
6586 {
6587   if(getFileName2().empty())
6588     throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6589   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6590   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6591   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6592   return ret.retn();
6593 }
6594
6595 /*!
6596  * Returns values and a profile of the field of a given type lying on a given support.
6597  * For more info, see \ref AdvMEDLoaderAPIFieldRW
6598  *  \param [in] type - a spatial discretization of the field.
6599  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6600  *  \param [in] mesh - the supporting mesh.
6601  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6602  *          field of interest lies on. If the field lies on all entities of the given
6603  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
6604  *          using decrRef() as it is no more needed.  
6605  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6606  *          field. The caller is to delete this array using decrRef() as it is no more needed.
6607  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6608  *  \throw If no field of \a this is lying on \a mesh.
6609  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6610  */
6611 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
6612 {
6613   MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6614   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6615 }
6616
6617 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() throw(INTERP_KERNEL::Exception)
6618 {
6619   MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6620   if(!pt)
6621     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6622   MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6623   if(!ret)
6624     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 !");
6625   return ret;
6626 }
6627
6628 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const throw(INTERP_KERNEL::Exception)
6629 {
6630   return contentNotNull()->getUndergroundDataArrayInt();
6631 }
6632
6633 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6634
6635 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6636 {
6637 }
6638
6639 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6640 {
6641 }
6642
6643 /*!
6644  * \param [in] fieldId field id in C mode
6645  */
6646 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
6647 {
6648   med_field_type typcha;
6649   std::string dtunitOut;
6650   int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6651   setDtUnit(dtunitOut.c_str());
6652   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6653 }
6654
6655 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
6656 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6657 {
6658   setDtUnit(dtunit.c_str());
6659   loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6660 }
6661 catch(INTERP_KERNEL::Exception& e)
6662 {
6663   throw e;
6664 }
6665
6666 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySize() const
6667 {
6668   std::size_t ret=_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>);
6669   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6670     ret+=(*it).capacity();
6671   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6672     if((const MEDFileAnyTypeField1TSWithoutSDA *)(*it))
6673       ret+=(*it)->getHeapMemorySize();
6674   return ret;
6675 }
6676
6677 /*!
6678  * 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
6679  * NULL.
6680  */
6681 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
6682 {
6683   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6684   ret->setInfo(_infos);
6685   int sz=(int)_time_steps.size();
6686   for(const int *id=startIds;id!=endIds;id++)
6687     {
6688       if(*id>=0 && *id<sz)
6689         {
6690           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6691           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6692           if(tse)
6693             {
6694               tse->incrRef();
6695               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6696             }
6697           ret->pushBackTimeStep(tse2);
6698         }
6699       else
6700         {
6701           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6702           oss << " ! Should be in [0," << sz << ") !";
6703           throw INTERP_KERNEL::Exception(oss.str().c_str());
6704         }
6705     }
6706   if(ret->getNumberOfTS()>0)
6707     ret->synchronizeNameScope();
6708   ret->copyNameScope(*this);
6709   return ret.retn();
6710 }
6711
6712 /*!
6713  * 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
6714  * NULL.
6715  */
6716 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
6717 {
6718   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6719   int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6720   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6721   ret->setInfo(_infos);
6722   int sz=(int)_time_steps.size();
6723   int j=bg;
6724   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6725     {
6726       if(j>=0 && j<sz)
6727         {
6728           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6729           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6730           if(tse)
6731             {
6732               tse->incrRef();
6733               tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6734             }
6735           ret->pushBackTimeStep(tse2);
6736         }
6737       else
6738         {
6739           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6740           oss << " ! Should be in [0," << sz << ") !";
6741           throw INTERP_KERNEL::Exception(oss.str().c_str());
6742         }
6743     }
6744   if(ret->getNumberOfTS()>0)
6745     ret->synchronizeNameScope();
6746   ret->copyNameScope(*this);
6747   return ret.retn();
6748 }
6749
6750 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6751 {
6752   int id=0;
6753   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6754   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6755     {
6756       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6757       if(!cur)
6758         continue;
6759       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6760       if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6761         ids->pushBackSilent(id);
6762     }
6763   return buildFromTimeStepIds(ids->begin(),ids->end());
6764 }
6765
6766 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
6767 {
6768   int id=0;
6769   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6770   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6771     {
6772       const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6773       if(!cur)
6774         continue;
6775       std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6776       if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6777         ids->pushBackSilent(id);
6778     }
6779   return buildFromTimeStepIds(ids->begin(),ids->end());
6780 }
6781
6782 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const throw(INTERP_KERNEL::Exception)
6783 {
6784   return _infos;
6785 }
6786
6787 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
6788 {
6789   _infos=info;
6790 }
6791
6792 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6793 {
6794   int ret=0;
6795   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6796     {
6797       const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6798       if(pt->isDealingTS(iteration,order))
6799         return ret;
6800     }
6801   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6802   std::vector< std::pair<int,int> > vp=getIterations();
6803   for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6804     oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6805   throw INTERP_KERNEL::Exception(oss.str().c_str());
6806 }
6807
6808 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6809 {
6810   return *_time_steps[getTimeStepPos(iteration,order)];
6811 }
6812
6813 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception)
6814 {
6815   return *_time_steps[getTimeStepPos(iteration,order)];
6816 }
6817
6818 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const throw(INTERP_KERNEL::Exception)
6819 {
6820   if(_time_steps.empty())
6821     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6822   return _time_steps[0]->getMeshName();
6823 }
6824
6825 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
6826 {
6827   std::string oldName(getMeshName());
6828   std::vector< std::pair<std::string,std::string> > v(1);
6829   v[0].first=oldName; v[0].second=newMeshName;
6830   changeMeshNames(v);
6831 }
6832
6833 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
6834 {
6835   bool ret=false;
6836   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6837     {
6838       MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6839       if(cur)
6840         ret=cur->changeMeshNames(modifTab) || ret;
6841     }
6842   return ret;
6843 }
6844
6845 /*!
6846  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6847  */
6848 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
6849 {
6850   return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6851 }
6852
6853 /*!
6854  * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6855  */
6856 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
6857 {
6858   return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6859 }
6860
6861 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6862                                                                 MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
6863 {
6864   bool ret=false;
6865   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6866     {
6867       MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6868       if(f1ts)
6869         ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6870     }
6871   return ret;
6872 }
6873
6874 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6875 {
6876   std::string startLine(bkOffset,' ');
6877   oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6878   if(fmtsId>=0)
6879     oss << " (" << fmtsId << ")";
6880   oss << " has the following name: \"" << _name << "\"." << std::endl;
6881   oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6882   for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6883     {
6884       oss << startLine << "  -  \"" << *it << "\"" << std::endl;
6885     }
6886   int i=0;
6887   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6888     {
6889       std::string chapter(17,'0'+i);
6890       oss << startLine << chapter << std::endl;
6891       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6892       if(cur)
6893         cur->simpleRepr(bkOffset+2,oss,i);
6894       else
6895         oss << startLine << "  Field on one time step #" << i << " is not defined !" << std::endl;
6896       oss << startLine << chapter << std::endl;
6897     }
6898 }
6899
6900 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
6901 {
6902   std::size_t sz=_time_steps.size();
6903   std::vector< std::pair<int,int> > ret(sz);
6904   ret1.resize(sz);
6905   for(std::size_t i=0;i<sz;i++)
6906     {
6907       const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6908       if(f1ts)
6909         {
6910           ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6911         }
6912       else
6913         {
6914           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6915           throw INTERP_KERNEL::Exception(oss.str().c_str());
6916         }
6917     }
6918   return ret;
6919 }
6920
6921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse) throw(INTERP_KERNEL::Exception)
6922 {
6923   MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6924   if(!tse2)
6925     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6926   checkCoherencyOfType(tse2);
6927   if(_time_steps.empty())
6928     {
6929       setName(tse2->getName().c_str());
6930       setInfo(tse2->getInfo());
6931     }
6932   checkThatComponentsMatch(tse2->getInfo());
6933   _time_steps.push_back(tse);
6934 }
6935
6936 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
6937 {
6938   std::size_t nbOfCompo=_infos.size();
6939   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6940     {
6941       MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6942       if(cur)
6943         {
6944           if((cur->getInfo()).size()!=nbOfCompo)
6945             {
6946               std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
6947               oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
6948               throw INTERP_KERNEL::Exception(oss.str().c_str());
6949             }
6950           cur->copyNameScope(*this);
6951         }
6952     }
6953 }
6954
6955 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception)
6956 {
6957   _time_steps.resize(nbPdt);
6958   for(int i=0;i<nbPdt;i++)
6959     {
6960       std::vector< std::pair<int,int> > ts;
6961       med_int numdt=0,numo=0;
6962       med_int meshIt=0,meshOrder=0;
6963       med_float dt=0.0;
6964       MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
6965       switch(fieldTyp)
6966         {
6967         case MED_FLOAT64:
6968           {
6969             _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6970             break;
6971           }
6972         case MED_INT32:
6973           {
6974             _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
6975             break;
6976           }
6977         default:
6978           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
6979         }
6980       if(loadAll)
6981         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
6982       else
6983         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
6984     }
6985 }
6986
6987 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception)
6988 {
6989   if(_time_steps.empty())
6990     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
6991   checkThatNbOfCompoOfTSMatchThis();
6992   std::vector<std::string> infos(getInfo());
6993   int nbComp=infos.size();
6994   INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6995   INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
6996   for(int i=0;i<nbComp;i++)
6997     {
6998       std::string info=infos[i];
6999       std::string c,u;
7000       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7001       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7002       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7003     }
7004   if(_name.empty())
7005     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7006   MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7007   int nbOfTS=_time_steps.size();
7008   for(int i=0;i<nbOfTS;i++)
7009     _time_steps[i]->writeLL(fid,opts,*this);
7010 }
7011
7012 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7013 {
7014   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7015     {
7016       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7017       if(elt)
7018         elt->loadBigArraysRecursively(fid,nasc);
7019     }
7020 }
7021   
7022 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception)
7023 {
7024   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7025     {
7026       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7027       if(elt)
7028         elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7029     }
7030 }
7031
7032 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays() throw(INTERP_KERNEL::Exception)
7033 {
7034   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7035     {
7036       MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7037       if(elt)
7038         elt->unloadArrays();
7039     }
7040 }
7041
7042 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7043 {
7044   return _time_steps.size();
7045 }
7046
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7048 {
7049   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  > newTS;
7050   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7051     {
7052       const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7053       if(tmp)
7054         newTS.push_back(*it);
7055     }
7056   _time_steps=newTS;
7057 }
7058
7059 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7060 {
7061   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7062   int maxId=(int)_time_steps.size();
7063   int ii=0;
7064   std::set<int> idsToDel;
7065   for(const int *id=startIds;id!=endIds;id++,ii++)
7066     {
7067       if(*id>=0 && *id<maxId)
7068         {
7069           idsToDel.insert(*id);
7070         }
7071       else
7072         {
7073           std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7074           throw INTERP_KERNEL::Exception(oss.str().c_str());
7075         }
7076     }
7077   for(int iii=0;iii<maxId;iii++)
7078     if(idsToDel.find(iii)==idsToDel.end())
7079       newTS.push_back(_time_steps[iii]);
7080   _time_steps=newTS;
7081 }
7082
7083 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7084 {
7085   static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7086   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7087   if(nbOfEntriesToKill==0)
7088     return ;
7089   std::size_t sz=_time_steps.size();
7090   std::vector<bool> b(sz,true);
7091   int j=bg;
7092   for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7093     b[j]=false;
7094   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7095   for(std::size_t i=0;i<sz;i++)
7096     if(b[i])
7097       newTS.push_back(_time_steps[i]);
7098   _time_steps=newTS;
7099 }
7100
7101 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7102 {
7103   int ret=0;
7104   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
7105   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7106     {
7107       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7108       if(tmp)
7109         {
7110           int it2,ord;
7111           tmp->getTime(it2,ord);
7112           if(it2==iteration && order==ord)
7113             return ret;
7114           else
7115             oss << "(" << it2 << ","  << ord << "), ";
7116         }
7117     }
7118   throw INTERP_KERNEL::Exception(oss.str().c_str());
7119 }
7120
7121 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7122 {
7123   int ret=0;
7124   std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7125   oss.precision(15);
7126   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7127     {
7128       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7129       if(tmp)
7130         {
7131           int it2,ord;
7132           double ti=tmp->getTime(it2,ord);
7133           if(fabs(time-ti)<eps)
7134             return ret;
7135           else
7136             oss << ti << ", ";
7137         }
7138     }
7139   throw INTERP_KERNEL::Exception(oss.str().c_str());
7140 }
7141
7142 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7143 {
7144   int lgth=_time_steps.size();
7145   std::vector< std::pair<int,int> > ret(lgth);
7146   for(int i=0;i<lgth;i++)
7147     _time_steps[i]->fillIteration(ret[i]);
7148   return ret;
7149 }
7150
7151 /*!
7152  * 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'
7153  * This method returns two things.
7154  * - The absolute dimension of 'this' in first parameter. 
7155  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7156  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
7157  *
7158  * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7159  * Only these 3 discretizations will be taken into account here.
7160  *
7161  * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7162  * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7163  * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7164  *
7165  * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7166  * 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'.
7167  * 
7168  * Let's consider the typical following case :
7169  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7170  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7171  * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7172  *   TETRA4 and SEG2
7173  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7174  *
7175  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7176  * 
7177  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7178  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7179  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7180  * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7181  */
7182 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7183 {
7184   return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7185 }
7186
7187 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception)
7188 {
7189   if(pos<0 || pos>=(int)_time_steps.size())
7190     {
7191       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7192       throw INTERP_KERNEL::Exception(oss.str().c_str());
7193     }
7194   const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7195   if(item==0)
7196     {
7197       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7198       oss << "\nTry to use following method eraseEmptyTS !";
7199       throw INTERP_KERNEL::Exception(oss.str().c_str());
7200     }
7201   return item;
7202 }
7203
7204 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception)
7205 {
7206   if(pos<0 || pos>=(int)_time_steps.size())
7207     {
7208       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7209       throw INTERP_KERNEL::Exception(oss.str().c_str());
7210     }
7211   MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7212   if(item==0)
7213     {
7214       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7215       oss << "\nTry to use following method eraseEmptyTS !";
7216       throw INTERP_KERNEL::Exception(oss.str().c_str());
7217     }
7218   return item;
7219 }
7220
7221 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7222 {
7223   std::vector<std::string> ret;
7224   std::set<std::string> ret2;
7225   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7226     {
7227       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7228       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7229         if(ret2.find(*it2)==ret2.end())
7230           {
7231             ret.push_back(*it2);
7232             ret2.insert(*it2);
7233           }
7234     }
7235   return ret;
7236 }
7237
7238 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7239 {
7240   std::vector<std::string> ret;
7241   std::set<std::string> ret2;
7242   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7243     {
7244       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7245       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7246         if(ret2.find(*it2)==ret2.end())
7247           {
7248             ret.push_back(*it2);
7249             ret2.insert(*it2);
7250           }
7251     }
7252   return ret;
7253 }
7254
7255 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7256 {
7257   std::vector<std::string> ret;
7258   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7259     {
7260       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7261       ret.insert(ret.end(),tmp.begin(),tmp.end());
7262     }
7263   return ret;
7264 }
7265
7266 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7267 {
7268   std::vector<std::string> ret;
7269   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7270     {
7271       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7272       ret.insert(ret.end(),tmp.begin(),tmp.end());
7273     }
7274   return ret;
7275 }
7276
7277 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7278 {
7279   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7280     (*it)->changePflsRefsNamesGen2(mapOfModif);
7281 }
7282
7283 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7284 {
7285   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7286     (*it)->changeLocsRefsNamesGen2(mapOfModif);
7287 }
7288
7289 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7290 {
7291   int lgth=_time_steps.size();
7292   std::vector< std::vector<TypeOfField> > ret(lgth);
7293   for(int i=0;i<lgth;i++)
7294     _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7295   return ret;
7296 }
7297
7298 /*!
7299  * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7300  */
7301 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7302 {
7303   return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7304 }
7305
7306 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const throw(INTERP_KERNEL::Exception)
7307 {
7308   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7309   std::size_t i=0;
7310   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7311     {
7312       if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7313         ret->_time_steps[i]=(*it)->deepCpy();
7314     }
7315   return ret.retn();
7316 }
7317
7318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const throw(INTERP_KERNEL::Exception)
7319 {
7320   std::size_t sz(_infos.size()),sz2(_time_steps.size());
7321   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7322   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7323   for(std::size_t i=0;i<sz;i++)
7324     {
7325       ret[i]=shallowCpy();
7326       ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7327     }
7328   for(std::size_t i=0;i<sz2;i++)
7329     {
7330       std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7331       if(ret1.size()!=sz)
7332         {
7333           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7334           throw INTERP_KERNEL::Exception(oss.str().c_str());
7335         }
7336       ts[i]=ret1;
7337     }
7338   for(std::size_t i=0;i<sz;i++)
7339     for(std::size_t j=0;j<sz2;j++)
7340       ret[i]->_time_steps[j]=ts[j][i];
7341   return ret;
7342 }
7343
7344 /*!
7345  * This method splits into discretization each time steps in \a this.
7346  * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7347  */
7348 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
7349 {
7350   std::size_t sz(_time_steps.size());
7351   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7352   for(std::size_t i=0;i<sz;i++)
7353     {
7354       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7355       if(!timeStep)
7356         {
7357           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
7358           throw INTERP_KERNEL::Exception(oss.str().c_str());
7359         }
7360       items[i]=timeStep->splitDiscretizations();  
7361     }
7362   //
7363   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7364   std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7365   std::vector< TypeOfField > types;
7366   for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7367     for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7368       {
7369         std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7370         if(ts.size()!=1)
7371           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7372         std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7373         if(it2==types.end())
7374           types.push_back(ts[0]);
7375       }
7376   ret.resize(types.size()); ret2.resize(types.size());
7377   for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7378     for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7379       {
7380         TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7381         std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7382         ret2[pos].push_back(*it1);
7383       }
7384   for(std::size_t i=0;i<types.size();i++)
7385     {
7386       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7387       for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7388         elt->pushBackTimeStep(*it1);//also updates infos in elt
7389       ret[i]=elt;
7390       elt->MEDFileFieldNameScope::operator=(*this);
7391     }
7392   return ret;
7393 }
7394
7395 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception)
7396 {
7397   _name=field->getName();
7398   if(_name.empty())
7399     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7400   if(!arr)
7401     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7402   _infos=arr->getInfoOnComponents();
7403 }
7404
7405 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception)
7406 {
7407   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7408   if(_name!=field->getName())
7409     {
7410       std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7411       oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7412       throw INTERP_KERNEL::Exception(oss.str().c_str());
7413     }
7414   if(!arr)
7415     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7416   checkThatComponentsMatch(arr->getInfoOnComponents());
7417 }
7418
7419 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const throw(INTERP_KERNEL::Exception)
7420 {
7421   static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7422   if(getInfo().size()!=compos.size())
7423     {
7424       std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7425       oss << " number of components of element to append (" << compos.size() << ") !";
7426       throw INTERP_KERNEL::Exception(oss.str().c_str());
7427     }
7428   if(_infos!=compos)
7429     {
7430       std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7431       std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7432       oss << " But compo in input fields are : ";
7433       std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7434       oss << " !";
7435       throw INTERP_KERNEL::Exception(oss.str().c_str());
7436     }
7437 }
7438
7439 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception)
7440 {
7441   std::size_t sz=_infos.size();
7442   int j=0;
7443   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7444     {
7445       const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7446       if(elt)
7447         if(elt->getInfo().size()!=sz)
7448           {
7449             std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7450             oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7451             throw INTERP_KERNEL::Exception(oss.str().c_str());
7452           }
7453     }
7454 }
7455
7456 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7457 {
7458   if(!field)
7459     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7460   if(!_time_steps.empty())
7461     checkCoherencyOfTinyInfo(field,arr);
7462   MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7463   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7464   objC->setFieldNoProfileSBT(field,arr,glob,*this);
7465   copyTinyInfoFrom(field,arr);
7466   _time_steps.push_back(obj);
7467 }
7468
7469 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception)
7470 {
7471   if(!field)
7472     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7473   if(!_time_steps.empty())
7474     checkCoherencyOfTinyInfo(field,arr);
7475   MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7476   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7477   objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7478   copyTinyInfoFrom(field,arr);
7479   _time_steps.push_back(obj);
7480 }
7481
7482 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts) throw(INTERP_KERNEL::Exception)
7483 {
7484   int sz=(int)_time_steps.size();
7485   if(i<0 || i>=sz)
7486     {
7487       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7488       throw INTERP_KERNEL::Exception(oss.str().c_str());
7489     }
7490   const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7491   if(tsPtr)
7492     {
7493       if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7494         {
7495           std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() <<  " !";
7496           throw INTERP_KERNEL::Exception(oss.str().c_str());
7497         }
7498     }
7499   _time_steps[i]=ts;
7500 }
7501
7502 //= MEDFileFieldMultiTSWithoutSDA
7503
7504 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7505 {
7506   return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7507 }
7508
7509 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7510 {
7511 }
7512
7513 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7514 {
7515 }
7516
7517 /*!
7518  * \param [in] fieldId field id in C mode
7519  */
7520 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7521 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7522 {
7523 }
7524 catch(INTERP_KERNEL::Exception& e)
7525   { throw e; }
7526
7527 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7528 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7529 {
7530 }
7531 catch(INTERP_KERNEL::Exception& e)
7532 { throw e; }
7533
7534 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7535 {
7536   return new MEDFileField1TSWithoutSDA;
7537 }
7538
7539 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7540 {
7541   if(!f1ts)
7542     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7543   const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7544   if(!f1tsC)
7545     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7546 }
7547
7548 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7549 {
7550   return MEDFileField1TSWithoutSDA::TYPE_STR;
7551 }
7552
7553 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7554 {
7555   return new MEDFileFieldMultiTSWithoutSDA(*this);
7556 }
7557
7558 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7559 {
7560   return new MEDFileFieldMultiTSWithoutSDA;
7561 }
7562
7563 /*!
7564  * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7565  * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7566  */
7567 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7568 {
7569   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7570   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7571   if(!myF1TSC)
7572     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7573   return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7574 }
7575
7576 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const throw(INTERP_KERNEL::Exception)
7577 {
7578   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7579   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7580   int i=0;
7581   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7582     {
7583       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7584       if(eltToConv)
7585         {
7586           const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7587           if(!eltToConvC)
7588             throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7589           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7590           ret->setIteration(i,elt);
7591         }
7592     }
7593   return ret.retn();
7594 }
7595
7596 //= MEDFileAnyTypeFieldMultiTS
7597
7598 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7599 {
7600 }
7601
7602 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7603 try:MEDFileFieldGlobsReal(fileName)
7604 {
7605   MEDFileUtilities::CheckFileForRead(fileName);
7606   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7607   _content=BuildContentFrom(fid,fileName,loadAll);
7608   loadGlobals(fid);
7609 }
7610 catch(INTERP_KERNEL::Exception& e)
7611   {
7612     throw e;
7613   }
7614
7615 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7616 {
7617   med_field_type typcha;
7618   std::vector<std::string> infos;
7619   std::string dtunit;
7620   int i=-1;
7621   MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7622   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7623   switch(typcha)
7624     {
7625     case MED_FLOAT64:
7626       {
7627         ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7628         break;
7629       }
7630     case MED_INT32:
7631       {
7632         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7633         break;
7634       }
7635     default:
7636       {
7637         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] !";
7638         throw INTERP_KERNEL::Exception(oss.str().c_str());
7639       }
7640     }
7641   ret->setDtUnit(dtunit.c_str());
7642   return ret.retn();
7643 }
7644
7645 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7646 {
7647   med_field_type typcha;
7648   //
7649   std::vector<std::string> infos;
7650   std::string dtunit,fieldName;
7651   MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7652   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7653   switch(typcha)
7654     {
7655     case MED_FLOAT64:
7656       {
7657         ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7658         break;
7659       }
7660     case MED_INT32:
7661       {
7662         ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7663         break;
7664       }
7665     default:
7666       {
7667         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] !";
7668         throw INTERP_KERNEL::Exception(oss.str().c_str());
7669       }
7670     }
7671   ret->setDtUnit(dtunit.c_str());
7672   return ret.retn();
7673 }
7674
7675 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception)
7676 {
7677   if(!c)
7678     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7679   if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7680     {
7681       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7682       ret->setFileName(fileName);
7683       ret->_content=c;  c->incrRef();
7684       return ret.retn();
7685     }
7686   if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7687     {
7688       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7689       ret->setFileName(fileName);
7690       ret->_content=c;  c->incrRef();
7691       return ret.retn();
7692     }
7693   throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7694 }
7695
7696 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7697 try:MEDFileFieldGlobsReal(fileName)
7698 {
7699   MEDFileUtilities::CheckFileForRead(fileName);
7700   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7701   _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7702   loadGlobals(fid);
7703 }
7704 catch(INTERP_KERNEL::Exception& e)
7705   {
7706     throw e;
7707   }
7708
7709 //= MEDFileIntFieldMultiTSWithoutSDA
7710
7711 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7712 {
7713   return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7714 }
7715
7716 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7717 {
7718 }
7719
7720 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7721 {
7722 }
7723
7724 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception)
7725 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7726 {
7727 }
7728 catch(INTERP_KERNEL::Exception& e)
7729 { throw e; }
7730
7731 /*!
7732  * \param [in] fieldId field id in C mode
7733  */
7734 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception)
7735 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7736 {
7737 }
7738 catch(INTERP_KERNEL::Exception& e)
7739   { throw e; }
7740
7741 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception)
7742 {
7743   return new MEDFileIntField1TSWithoutSDA;
7744 }
7745
7746 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception)
7747 {
7748   if(!f1ts)
7749     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7750   const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7751   if(!f1tsC)
7752     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7753 }
7754
7755 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
7756 {
7757   return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7758 }
7759
7760 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
7761 {
7762   return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7763 }
7764
7765 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const throw(INTERP_KERNEL::Exception)
7766 {
7767   return new MEDFileIntFieldMultiTSWithoutSDA;
7768 }
7769
7770 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const throw(INTERP_KERNEL::Exception)
7771 {
7772   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7773   ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7774   int i=0;
7775   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7776     {
7777       const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7778       if(eltToConv)
7779         {
7780           const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7781           if(!eltToConvC)
7782             throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7783           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7784           ret->setIteration(i,elt);
7785         }
7786     }
7787   return ret.retn();
7788 }
7789
7790 //= MEDFileAnyTypeFieldMultiTS
7791
7792 /*!
7793  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7794  * that has been read from a specified MED file.
7795  *  \param [in] fileName - the name of the MED file to read.
7796  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7797  *          is to delete this field using decrRef() as it is no more needed.
7798  *  \throw If reading the file fails.
7799  */
7800 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
7801 {
7802   MEDFileUtilities::CheckFileForRead(fileName);
7803   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7804   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7805   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7806   ret->loadGlobals(fid);
7807   return ret.retn();
7808 }
7809
7810 /*!
7811  * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7812  * that has been read from a specified MED file.
7813  *  \param [in] fileName - the name of the MED file to read.
7814  *  \param [in] fieldName - the name of the field to read.
7815  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7816  *          is to delete this field using decrRef() as it is no more needed.
7817  *  \throw If reading the file fails.
7818  *  \throw If there is no field named \a fieldName in the file.
7819  */
7820 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
7821 {
7822   MEDFileUtilities::CheckFileForRead(fileName);
7823   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7824   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7825   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7826   ret->loadGlobals(fid);
7827   return ret.retn();
7828 }
7829
7830 /*!
7831  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7832  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7833  *
7834  * \warning this is a shallow copy constructor
7835  */
7836 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7837 {
7838   if(!shallowCopyOfContent)
7839     {
7840       const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7841       otherPtr->incrRef();
7842       _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7843     }
7844   else
7845     {
7846       _content=other.shallowCpy();
7847     }
7848 }
7849
7850 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() throw(INTERP_KERNEL::Exception)
7851 {
7852   MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7853   if(!ret)
7854     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7855   return ret;
7856 }
7857
7858 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const throw(INTERP_KERNEL::Exception)
7859 {
7860   const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7861   if(!ret)
7862     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7863   return ret;
7864 }
7865
7866 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7867 {
7868   return contentNotNullBase()->getPflsReallyUsed2();
7869 }
7870
7871 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7872 {
7873   return contentNotNullBase()->getLocsReallyUsed2();
7874 }
7875
7876 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7877 {
7878   return contentNotNullBase()->getPflsReallyUsedMulti2();
7879 }
7880
7881 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7882 {
7883   return contentNotNullBase()->getLocsReallyUsedMulti2();
7884 }
7885
7886 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7887 {
7888   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7889 }
7890
7891 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
7892 {
7893   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7894 }
7895
7896 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7897 {
7898   return contentNotNullBase()->getNumberOfTS();
7899 }
7900
7901 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
7902 {
7903   contentNotNullBase()->eraseEmptyTS();
7904 }
7905
7906 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
7907 {
7908   contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7909 }
7910
7911 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
7912 {
7913   contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7914 }
7915
7916 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
7917 {
7918   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7919   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7920   ret->_content=c;
7921   return ret.retn();
7922 }
7923
7924 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception)
7925 {
7926   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7927   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7928   ret->_content=c;
7929   return ret.retn();
7930 }
7931
7932 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
7933 {
7934   return contentNotNullBase()->getIterations();
7935 }
7936
7937 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts) throw(INTERP_KERNEL::Exception)
7938 {
7939   for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
7940     pushBackTimeStep(*it);
7941 }
7942
7943 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception)
7944 {
7945   if(!f1ts)
7946     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
7947   checkCoherencyOfType(f1ts);
7948   f1ts->incrRef();
7949   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
7950   MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
7951   c->incrRef();
7952   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
7953   if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
7954     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
7955   _content->pushBackTimeStep(cSafe);
7956   appendGlobs(*f1ts,1e-12);
7957 }
7958
7959 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope() throw(INTERP_KERNEL::Exception)
7960 {
7961   contentNotNullBase()->synchronizeNameScope();
7962 }
7963
7964 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
7965 {
7966   return contentNotNullBase()->getPosOfTimeStep(iteration,order);
7967 }
7968
7969 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
7970 {
7971   return contentNotNullBase()->getPosGivenTime(time,eps);
7972 }
7973
7974 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception)
7975 {
7976   return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
7977 }
7978
7979 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception)
7980 {
7981   return contentNotNullBase()->getTypesOfFieldAvailable();
7982 }
7983
7984 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
7985 {
7986   return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
7987 }
7988
7989 std::string MEDFileAnyTypeFieldMultiTS::getName() const
7990 {
7991   return contentNotNullBase()->getName();
7992 }
7993
7994 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
7995 {
7996   contentNotNullBase()->setName(name);
7997 }
7998
7999 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const throw(INTERP_KERNEL::Exception)
8000 {
8001   return contentNotNullBase()->getDtUnit();
8002 }
8003
8004 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception)
8005 {
8006   contentNotNullBase()->setDtUnit(dtUnit);
8007 }
8008
8009 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8010 {
8011   contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8012 }
8013
8014 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception)
8015 {
8016   return contentNotNullBase()->getTimeSteps(ret1);
8017 }
8018
8019 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const throw(INTERP_KERNEL::Exception)
8020 {
8021   return contentNotNullBase()->getMeshName();
8022 }
8023
8024 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception)
8025 {
8026   contentNotNullBase()->setMeshName(newMeshName);
8027 }
8028
8029 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
8030 {
8031   return contentNotNullBase()->changeMeshNames(modifTab);
8032 }
8033
8034 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const throw(INTERP_KERNEL::Exception)
8035 {
8036   return contentNotNullBase()->getInfo();
8037 }
8038
8039 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info) throw(INTERP_KERNEL::Exception)
8040 {
8041   return contentNotNullBase()->setInfo(info);
8042 }
8043
8044 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const throw(INTERP_KERNEL::Exception)
8045 {
8046   const std::vector<std::string> ret=getInfo();
8047   return (int)ret.size();
8048 }
8049
8050 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
8051 {
8052   writeGlobals(fid,*this);
8053   contentNotNullBase()->writeLL(fid,*this);
8054 }
8055
8056 /*!
8057  * Writes \a this field into a MED file specified by its name.
8058  *  \param [in] fileName - the MED file name.
8059  *  \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8060  * - 2 - erase; an existing file is removed.
8061  * - 1 - append; same data should not be present in an existing file.
8062  * - 0 - overwrite; same data present in an existing file is overwritten.
8063  *  \throw If the field name is not set.
8064  *  \throw If no field data is set.
8065  *  \throw If \a mode == 1 and the same data is present in an existing file.
8066  */
8067 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
8068 {
8069   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8070   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8071   writeLL(fid);
8072 }
8073
8074 /*!
8075  * This method alloc the arrays and load potentially huge arrays contained in this field.
8076  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8077  * This method can be also called to refresh or reinit values from a file.
8078  * 
8079  * \throw If the fileName is not set or points to a non readable MED file.
8080  */
8081 void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception)
8082 {
8083   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8084   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8085 }
8086
8087 /*!
8088  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8089  * But once data loaded once, this method does nothing.
8090  * 
8091  * \throw If the fileName is not set or points to a non readable MED file.
8092  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8093  */
8094 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
8095 {
8096   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8097   contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8098 }
8099
8100 /*!
8101  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8102  * This method does not release arrays set outside the context of a MED file.
8103  * 
8104  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8105  */
8106 void MEDFileAnyTypeFieldMultiTS::unloadArrays() throw(INTERP_KERNEL::Exception)
8107 {
8108   contentNotNullBase()->unloadArrays();
8109 }
8110
8111 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8112 {
8113   std::ostringstream oss;
8114   contentNotNullBase()->simpleRepr(0,oss,-1);
8115   simpleReprGlobs(oss);
8116   return oss.str();
8117 }
8118
8119 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const
8120 {
8121   std::size_t ret=0;
8122   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)_content)
8123     ret+=_content->getHeapMemorySize();
8124   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
8125 }
8126
8127 /*!
8128  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8129  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8130  * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8131  */
8132 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const throw(INTERP_KERNEL::Exception)
8133 {
8134   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8135   if(!content)
8136     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8137   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8138   std::size_t sz(contentsSplit.size());
8139   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8140   for(std::size_t i=0;i<sz;i++)
8141     {
8142       ret[i]=shallowCpy();
8143       ret[i]->_content=contentsSplit[i];
8144     }
8145   return ret;
8146 }
8147
8148 /*!
8149  * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8150  * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8151  */
8152 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const throw(INTERP_KERNEL::Exception)
8153 {
8154   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8155   if(!content)
8156     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8157   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8158   std::size_t sz(contentsSplit.size());
8159   std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8160   for(std::size_t i=0;i<sz;i++)
8161     {
8162       ret[i]=shallowCpy();
8163       ret[i]->_content=contentsSplit[i];
8164     }
8165   return ret;
8166 }
8167
8168 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const throw(INTERP_KERNEL::Exception)
8169 {
8170   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8171   if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8172     ret->_content=_content->deepCpy();
8173   ret->deepCpyGlobs(*this);
8174   return ret.retn();
8175 }
8176
8177 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8178 {
8179   return _content;
8180 }
8181
8182 /*!
8183  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8184  *  \param [in] iteration - the iteration number of a required time step.
8185  *  \param [in] order - the iteration order number of required time step.
8186  *  \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8187  *          delete this field using decrRef() as it is no more needed.
8188  *  \throw If there is no required time step in \a this field.
8189  */
8190 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8191 {
8192   int pos=getPosOfTimeStep(iteration,order);
8193   return getTimeStepAtPos(pos);
8194 }
8195
8196 /*!
8197  * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8198  *  \param [in] time - the time of the time step of interest.
8199  *  \param [in] eps - a precision used to compare time values.
8200  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8201  *          delete this field using decrRef() as it is no more needed.
8202  *  \throw If there is no required time step in \a this field.
8203  */
8204 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
8205 {
8206   int pos=getPosGivenTime(time,eps);
8207   return getTimeStepAtPos(pos);
8208 }
8209
8210 /*!
8211  * 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.
8212  * The float64 value of time attached to the pair of integers are not considered here.
8213  * 
8214  * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8215  * \throw If there is a null pointer in \a vectFMTS.
8216  */
8217 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS) throw(INTERP_KERNEL::Exception)
8218 {
8219   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8220   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8221   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8222   while(!lstFMTS.empty())
8223     {
8224       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8225       MEDFileAnyTypeFieldMultiTS *curIt(*it);
8226       if(!curIt)
8227         throw INTERP_KERNEL::Exception(msg);
8228       std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8229       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8230       elt.push_back(curIt); it=lstFMTS.erase(it);
8231       while(it!=lstFMTS.end())
8232         {
8233           curIt=*it;
8234           if(!curIt)
8235             throw INTERP_KERNEL::Exception(msg);
8236           std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8237           if(refIts==curIts)
8238             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8239           else
8240             it++;
8241         }
8242       ret.push_back(elt);
8243     }
8244   return ret;
8245 }
8246
8247 /*!
8248  * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8249  * All returned instances in a subvector can be safely loaded, rendered along time
8250  * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8251  * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8252  * 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).
8253  * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8254  * 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.
8255  *
8256  * \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().
8257  * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8258  * \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.
8259  *
8260  * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8261  * \throw If an element in \a vectFMTS change of spatial discretization along time.
8262  * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8263  * \thorw If some elements in \a vectFMTS do not have the same times steps.
8264  * \throw If mesh is null.
8265  * \throw If an element in \a vectFMTS is null.
8266  * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8267  */
8268 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc) throw(INTERP_KERNEL::Exception)
8269 {
8270   static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8271   if(!mesh)
8272     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8273   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8274   if(vectFMTS.empty())
8275     return ret;
8276   std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8277   MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8278   std::size_t i=0;
8279   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8280   std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8281   for(;it!=vectFMTS.end();it++,i++)
8282     {
8283       TypeOfField tof0,tof1;
8284       int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
8285       if(ret>0)
8286         {
8287           if(tof1!=ON_NODES)
8288             vectFMTSNotNodes.push_back(*it);
8289           else
8290             vectFMTSNodes.push_back(*it);
8291         }
8292       else
8293         vectFMTSNotNodes.push_back(*it);
8294     }
8295   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8296   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8297   ret=retCell;
8298   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8299     {
8300       i=0;
8301       bool isFetched(false);
8302       for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8303         {
8304           if((*it0).empty())
8305             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8306           if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8307             { ret[i].push_back(*it2); isFetched=true; }
8308         }
8309       if(!isFetched)
8310         {
8311           std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8312           MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8313           ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8314         }
8315     }
8316   fsc=cmps;
8317   return ret;
8318 }
8319
8320 /*!
8321  * 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.
8322  * \param [out] cmps - same size than the returned vector.
8323  */
8324 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps) throw(INTERP_KERNEL::Exception)
8325 {
8326   std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8327   std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8328   while(!lstFMTS.empty())
8329     {
8330       std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8331       MEDFileAnyTypeFieldMultiTS *ref(*it);
8332       std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8333       elt.push_back(ref); it=lstFMTS.erase(it);
8334       MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8335       MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8336       while(it!=lstFMTS.end())
8337         {
8338           MEDFileAnyTypeFieldMultiTS *curIt(*it);
8339           if(cmp->isEqual(curIt))
8340             { elt.push_back(curIt); it=lstFMTS.erase(it); }
8341           else
8342             it++;
8343         }
8344       ret.push_back(elt); cmps.push_back(cmp);
8345     }
8346   return ret;
8347 }
8348
8349 /*!
8350  * 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.
8351  * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8352  *
8353  * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8354  * \throw If \a f0 or \a f1 change of spatial discretization along time.
8355  * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8356  * \thorw If \a f0 and \a f1 do not have the same times steps.
8357  * \throw If mesh is null.
8358  * \throw If \a f0 or \a f1 is null.
8359  * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8360  */
8361 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception)
8362 {
8363   if(!mesh)
8364     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8365   if(!f0 || !f1)
8366     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8367   if(f0->getMeshName()!=mesh->getName())
8368     {
8369       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8370       throw INTERP_KERNEL::Exception(oss.str().c_str());
8371     }
8372   if(f1->getMeshName()!=mesh->getName())
8373     {
8374       std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8375       throw INTERP_KERNEL::Exception(oss.str().c_str());
8376     }
8377   int nts=f0->getNumberOfTS();
8378   if(nts!=f1->getNumberOfTS())
8379     throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8380   if(nts==0)
8381     return nts;
8382   for(int i=0;i<nts;i++)
8383     {
8384       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8385       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8386       std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8387       if(tofs0.size()!=1 || tofs1.size()!=1)
8388         throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8389       if(i!=0)
8390         {
8391           if(tof0!=tofs0[0] || tof1!=tofs1[0])
8392             throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8393         }
8394       else
8395         { tof0=tofs0[0]; tof1=tofs1[0]; }
8396       if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8397         {
8398           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() << ") !";
8399           throw INTERP_KERNEL::Exception(oss.str().c_str());
8400         }
8401       if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8402         {
8403           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() << ") !";
8404           throw INTERP_KERNEL::Exception(oss.str().c_str());
8405         }
8406       if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8407         {
8408           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() << ") !";
8409           throw INTERP_KERNEL::Exception(oss.str().c_str());
8410         }
8411     }
8412   return nts;
8413 }
8414
8415 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator() throw(INTERP_KERNEL::Exception)
8416 {
8417   return new MEDFileAnyTypeFieldMultiTSIterator(this);
8418 }
8419
8420 //= MEDFileFieldMultiTS
8421
8422 /*!
8423  * Returns a new empty instance of MEDFileFieldMultiTS.
8424  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8425  *          is to delete this field using decrRef() as it is no more needed.
8426  */
8427 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8428 {
8429   return new MEDFileFieldMultiTS;
8430 }
8431
8432 /*!
8433  * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8434  * that has been read from a specified MED file.
8435  *  \param [in] fileName - the name of the MED file to read.
8436  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8437  *          is to delete this field using decrRef() as it is no more needed.
8438  *  \throw If reading the file fails.
8439  */
8440 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8441 {
8442   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8443   ret->contentNotNull();//to check that content type matches with \a this type.
8444   return ret.retn();
8445 }
8446
8447 /*!
8448  * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8449  * that has been read from a specified MED file.
8450  *  \param [in] fileName - the name of the MED file to read.
8451  *  \param [in] fieldName - the name of the field to read.
8452  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8453  *          is to delete this field using decrRef() as it is no more needed.
8454  *  \throw If reading the file fails.
8455  *  \throw If there is no field named \a fieldName in the file.
8456  */
8457 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8458 {
8459   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8460   ret->contentNotNull();//to check that content type matches with \a this type.
8461   return ret.retn();
8462 }
8463
8464 /*!
8465  * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8466  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8467  *
8468  * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8469  * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8470  * \warning this is a shallow copy constructor
8471  *  \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8472  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8473  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8474  *          is to delete this field using decrRef() as it is no more needed.
8475  */
8476 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8477 {
8478   return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8479 }
8480
8481 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8482 {
8483   return new MEDFileFieldMultiTS(*this);
8484 }
8485
8486 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8487 {
8488   if(!f1ts)
8489     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8490   const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8491   if(!f1tsC)
8492     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8493 }
8494
8495 /*!
8496  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8497  * following the given input policy.
8498  *
8499  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8500  *                            By default (true) the globals are deeply copied.
8501  * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8502  */
8503 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8504 {
8505   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8506   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8507   if(content)
8508     {
8509       const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8510       if(!contc)
8511         throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8512       MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8513       ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8514     }
8515   else
8516     ret=MEDFileIntFieldMultiTS::New();
8517   if(deepCpyGlobs)
8518     ret->deepCpyGlobs(*this);
8519   else
8520     ret->shallowCpyGlobs(*this);
8521   return ret.retn();
8522 }
8523
8524 /*!
8525  * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8526  *  \param [in] pos - a time step id.
8527  *  \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8528  *          delete this field using decrRef() as it is no more needed.
8529  *  \throw If \a pos is not a valid time step id.
8530  */
8531 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
8532 {
8533   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8534   if(!item)
8535     {
8536       std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8537       throw INTERP_KERNEL::Exception(oss.str().c_str());
8538     }
8539   const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8540   if(itemC)
8541     {
8542       MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8543       ret->shallowCpyGlobs(*this);
8544       return ret.retn();
8545     }
8546   std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8547   throw INTERP_KERNEL::Exception(oss.str().c_str());
8548 }
8549
8550 /*!
8551  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8552  * mesh entities of a given dimension of the first mesh in MED file.
8553  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8554  *  \param [in] type - a spatial discretization of interest.
8555  *  \param [in] iteration - the iteration number of a required time step.
8556  *  \param [in] order - the iteration order number of required time step.
8557  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8558  *  \param [in] renumPol - specifies how to permute values of the result field according to
8559  *          the optional numbers of cells and nodes, if any. The valid values are
8560  *          - 0 - do not permute.
8561  *          - 1 - permute cells.
8562  *          - 2 - permute nodes.
8563  *          - 3 - permute cells and nodes.
8564  *
8565  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8566  *          caller is to delete this field using decrRef() as it is no more needed. 
8567  *  \throw If the MED file is not readable.
8568  *  \throw If there is no mesh in the MED file.
8569  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8570  *  \throw If no field values of the required parameters are available.
8571  */
8572 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8573 {
8574   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8575   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8576   if(!myF1TSC)
8577     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8578   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8579   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8580   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8581   return ret.retn();
8582 }
8583
8584 /*!
8585  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8586  * the top level cells of the first mesh in MED file.
8587  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8588  *  \param [in] type - a spatial discretization of interest.
8589  *  \param [in] iteration - the iteration number of a required time step.
8590  *  \param [in] order - the iteration order number of required time step.
8591  *  \param [in] renumPol - specifies how to permute values of the result field according to
8592  *          the optional numbers of cells and nodes, if any. The valid values are
8593  *          - 0 - do not permute.
8594  *          - 1 - permute cells.
8595  *          - 2 - permute nodes.
8596  *          - 3 - permute cells and nodes.
8597  *
8598  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8599  *          caller is to delete this field using decrRef() as it is no more needed. 
8600  *  \throw If the MED file is not readable.
8601  *  \throw If there is no mesh in the MED file.
8602  *  \throw If no field values of the required parameters are available.
8603  */
8604 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const throw(INTERP_KERNEL::Exception)
8605 {
8606   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8607   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8608   if(!myF1TSC)
8609     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8610   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8611   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8612   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8613   return ret.retn();
8614 }
8615
8616 /*!
8617  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8618  * a given support.
8619  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8620  *  \param [in] type - a spatial discretization of interest.
8621  *  \param [in] iteration - the iteration number of a required time step.
8622  *  \param [in] order - the iteration order number of required time step.
8623  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8624  *  \param [in] mesh - the supporting mesh.
8625  *  \param [in] renumPol - specifies how to permute values of the result field according to
8626  *          the optional numbers of cells and nodes, if any. The valid values are
8627  *          - 0 - do not permute.
8628  *          - 1 - permute cells.
8629  *          - 2 - permute nodes.
8630  *          - 3 - permute cells and nodes.
8631  *
8632  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8633  *          caller is to delete this field using decrRef() as it is no more needed. 
8634  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8635  *  \throw If no field of \a this is lying on \a mesh.
8636  *  \throw If no field values of the required parameters are available.
8637  */
8638 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8639 {
8640   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8641   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8642   if(!myF1TSC)
8643     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8644   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8645   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8646   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8647   return ret.retn();
8648 }
8649
8650 /*!
8651  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8652  * given support. 
8653  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8654  *  \param [in] type - a spatial discretization of the new field.
8655  *  \param [in] iteration - the iteration number of a required time step.
8656  *  \param [in] order - the iteration order number of required time step.
8657  *  \param [in] mesh - the supporting mesh.
8658  *  \param [in] renumPol - specifies how to permute values of the result field according to
8659  *          the optional numbers of cells and nodes, if any. The valid values are
8660  *          - 0 - do not permute.
8661  *          - 1 - permute cells.
8662  *          - 2 - permute nodes.
8663  *          - 3 - permute cells and nodes.
8664  *
8665  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8666  *          caller is to delete this field using decrRef() as it is no more needed. 
8667  *  \throw If no field of \a this is lying on \a mesh.
8668  *  \throw If no field values of the required parameters are available.
8669  */
8670 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const throw(INTERP_KERNEL::Exception)
8671 {
8672   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8673   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8674   if(!myF1TSC)
8675     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8676   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8677   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8678   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8679   return ret.retn();
8680 }
8681
8682 /*!
8683  * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8684  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8685  * This method is useful for MED2 file format when field on different mesh was autorized.
8686  */
8687 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const throw(INTERP_KERNEL::Exception)
8688 {
8689   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8690   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8691   if(!myF1TSC)
8692     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8693   MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8694   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8695   MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8696   return ret.retn();
8697 }
8698
8699 /*!
8700  * Returns values and a profile of the field of a given type, of a given time step,
8701  * lying on a given support.
8702  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8703  *  \param [in] type - a spatial discretization of the field.
8704  *  \param [in] iteration - the iteration number of a required time step.
8705  *  \param [in] order - the iteration order number of required time step.
8706  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8707  *  \param [in] mesh - the supporting mesh.
8708  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8709  *          field of interest lies on. If the field lies on all entities of the given
8710  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
8711  *          using decrRef() as it is no more needed.  
8712  *  \param [in] glob - the global data storing profiles and localization.
8713  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8714  *          field. The caller is to delete this array using decrRef() as it is no more needed.
8715  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8716  *  \throw If no field of \a this is lying on \a mesh.
8717  *  \throw If no field values of the required parameters are available.
8718  */
8719 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
8720 {
8721   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8722   const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8723   if(!myF1TSC)
8724     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8725   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8726   return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8727 }
8728
8729 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
8730 {
8731   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8732   if(!pt)
8733     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8734   const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8735   if(!ret)
8736     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 !");
8737   return ret;
8738 }
8739
8740  MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
8741 {
8742   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8743   if(!pt)
8744     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8745   MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8746   if(!ret)
8747     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 !");
8748   return ret;
8749 }
8750
8751 /*!
8752  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8753  * the given field is checked if its elements are sorted suitable for writing to MED file
8754  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
8755  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8756  *  \param [in] field - the field to add to \a this.
8757  *  \throw If the name of \a field is empty.
8758  *  \throw If the data array of \a field is not set.
8759  *  \throw If existing time steps have different name or number of components than \a field.
8760  *  \throw If the underlying mesh of \a field has no name.
8761  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8762  */
8763 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
8764 {
8765   const DataArrayDouble *arr=0;
8766   if(field)
8767     arr=field->getArray();
8768   contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8769 }
8770
8771 /*!
8772  * Adds a MEDCouplingFieldDouble to \a this as another time step.
8773  * The mesh support of input parameter \a field is ignored here, it can be NULL.
8774  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8775  * and \a profile.
8776  *
8777  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8778  * A new profile is added only if no equal profile is missing.
8779  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8780  *  \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8781  *  \param [in] mesh - the supporting mesh of \a field.
8782  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8783  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
8784  *  \throw If either \a field or \a mesh or \a profile has an empty name.
8785  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8786  *  \throw If the data array of \a field is not set.
8787  *  \throw If the data array of \a this is already allocated but has different number of
8788  *         components than \a field.
8789  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8790  *  \sa setFieldNoProfileSBT()
8791  */
8792 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
8793 {
8794   const DataArrayDouble *arr=0;
8795   if(field)
8796     arr=field->getArray();
8797   contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8798 }
8799
8800 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8801 {
8802   _content=new MEDFileFieldMultiTSWithoutSDA;
8803 }
8804
8805 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8806 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8807 {
8808 }
8809 catch(INTERP_KERNEL::Exception& e)
8810   { throw e; }
8811
8812 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8813 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8814 {
8815 }
8816 catch(INTERP_KERNEL::Exception& e)
8817   { throw e; }
8818
8819 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8820 {
8821 }
8822
8823 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception)
8824 {
8825   return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8826 }
8827
8828 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
8829 {
8830   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8831 }
8832
8833 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception)
8834 {
8835   return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8836 }
8837
8838 //= MEDFileAnyTypeFieldMultiTSIterator
8839
8840 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8841 {
8842   if(fmts)
8843     {
8844       fmts->incrRef();
8845       _nb_iter=fmts->getNumberOfTS();
8846     }
8847 }
8848
8849 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
8850 {
8851 }
8852
8853 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt() throw(INTERP_KERNEL::Exception)
8854 {
8855   if(_iter_id<_nb_iter)
8856     {
8857       MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8858       if(fmts)
8859         return fmts->getTimeStepAtPos(_iter_id++);
8860       else
8861         return 0;
8862     }
8863   else
8864     return 0;
8865 }
8866
8867 //= MEDFileIntFieldMultiTS
8868
8869 /*!
8870  * Returns a new empty instance of MEDFileFieldMultiTS.
8871  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8872  *          is to delete this field using decrRef() as it is no more needed.
8873  */
8874 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8875 {
8876   return new MEDFileIntFieldMultiTS;
8877 }
8878
8879 /*!
8880  * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8881  * that has been read from a specified MED file.
8882  *  \param [in] fileName - the name of the MED file to read.
8883  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8884  *          is to delete this field using decrRef() as it is no more needed.
8885  *  \throw If reading the file fails.
8886  */
8887 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
8888 {
8889   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8890   ret->contentNotNull();//to check that content type matches with \a this type.
8891   return ret.retn();
8892 }
8893
8894 /*!
8895  * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8896  * that has been read from a specified MED file.
8897  *  \param [in] fileName - the name of the MED file to read.
8898  *  \param [in] fieldName - the name of the field to read.
8899  *  \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8900  *          is to delete this field using decrRef() as it is no more needed.
8901  *  \throw If reading the file fails.
8902  *  \throw If there is no field named \a fieldName in the file.
8903  */
8904 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
8905 {
8906   MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8907   ret->contentNotNull();//to check that content type matches with \a this type.
8908   return ret.retn();
8909 }
8910
8911 /*!
8912  * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8913  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8914  *
8915  * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8916  * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8917  * \warning this is a shallow copy constructor
8918  *  \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8919  *  \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8920  *  \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8921  *          is to delete this field using decrRef() as it is no more needed.
8922  */
8923 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8924 {
8925   return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
8926 }
8927
8928 /*!
8929  * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
8930  * following the given input policy.
8931  *
8932  * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8933  *                            By default (true) the globals are deeply copied.
8934  * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
8935  */
8936 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const throw(INTERP_KERNEL::Exception)
8937 {
8938   MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
8939   const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8940   if(content)
8941     {
8942       const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
8943       if(!contc)
8944         throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
8945       MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
8946       ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
8947     }
8948   else
8949     ret=MEDFileFieldMultiTS::New();
8950   if(deepCpyGlobs)
8951     ret->deepCpyGlobs(*this);
8952   else
8953     ret->shallowCpyGlobs(*this);
8954   return ret.retn();
8955 }
8956
8957 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const throw(INTERP_KERNEL::Exception)
8958 {
8959   return new MEDFileIntFieldMultiTS(*this);
8960 }
8961
8962 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception)
8963 {
8964   if(!f1ts)
8965     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8966   const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
8967   if(!f1tsC)
8968     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8969 }
8970
8971 /*!
8972  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8973  * mesh entities of a given dimension of the first mesh in MED file.
8974  * For more info, see \ref AdvMEDLoaderAPIFieldRW
8975  *  \param [in] type - a spatial discretization of interest.
8976  *  \param [in] iteration - the iteration number of a required time step.
8977  *  \param [in] order - the iteration order number of required time step.
8978  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8979  *  \param [out] arrOut - the DataArrayInt containing values of field.
8980  *  \param [in] renumPol - specifies how to permute values of the result field according to
8981  *          the optional numbers of cells and nodes, if any. The valid values are
8982  *          - 0 - do not permute.
8983  *          - 1 - permute cells.
8984  *          - 2 - permute nodes.
8985  *          - 3 - permute cells and nodes.
8986  *
8987  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8988  *          caller is to delete this field using decrRef() as it is no more needed. 
8989  *  \throw If the MED file is not readable.
8990  *  \throw If there is no mesh in the MED file.
8991  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8992  *  \throw If no field values of the required parameters are available.
8993  */
8994 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
8995 {
8996   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8997   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
8998   if(!myF1TSC)
8999     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9000   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9001   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
9002   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9003   return ret.retn();
9004 }
9005
9006 /*!
9007  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9008  * the top level cells of the first mesh in MED file.
9009  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9010  *  \param [in] type - a spatial discretization of interest.
9011  *  \param [in] iteration - the iteration number of a required time step.
9012  *  \param [in] order - the iteration order number of required time step.
9013  *  \param [out] arrOut - the DataArrayInt containing values of field.
9014  *  \param [in] renumPol - specifies how to permute values of the result field according to
9015  *          the optional numbers of cells and nodes, if any. The valid values are
9016  *          - 0 - do not permute.
9017  *          - 1 - permute cells.
9018  *          - 2 - permute nodes.
9019  *          - 3 - permute cells and nodes.
9020  *
9021  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9022  *          caller is to delete this field using decrRef() as it is no more needed. 
9023  *  \throw If the MED file is not readable.
9024  *  \throw If there is no mesh in the MED file.
9025  *  \throw If no field values of the required parameters are available.
9026  */
9027 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9028 {
9029   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9030   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9031   if(!myF1TSC)
9032     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9033   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9034   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
9035   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9036   return ret.retn();
9037 }
9038
9039 /*!
9040  * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9041  * a given support.
9042  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9043  *  \param [in] type - a spatial discretization of interest.
9044  *  \param [in] iteration - the iteration number of a required time step.
9045  *  \param [in] order - the iteration order number of required time step.
9046  *  \param [out] arrOut - the DataArrayInt containing values of field.
9047  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9048  *  \param [in] mesh - the supporting mesh.
9049  *  \param [in] renumPol - specifies how to permute values of the result field according to
9050  *          the optional numbers of cells and nodes, if any. The valid values are
9051  *          - 0 - do not permute.
9052  *          - 1 - permute cells.
9053  *          - 2 - permute nodes.
9054  *          - 3 - permute cells and nodes.
9055  *
9056  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9057  *          caller is to delete this field using decrRef() as it is no more needed. 
9058  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9059  *  \throw If no field of \a this is lying on \a mesh.
9060  *  \throw If no field values of the required parameters are available.
9061  */
9062 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9063 {
9064   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9065   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9066   if(!myF1TSC)
9067     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9068   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9069   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9070   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9071   return ret.retn();
9072 }
9073
9074 /*!
9075  * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9076  * given support. 
9077  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9078  *  \param [in] type - a spatial discretization of the new field.
9079  *  \param [in] iteration - the iteration number of a required time step.
9080  *  \param [in] order - the iteration order number of required time step.
9081  *  \param [in] mesh - the supporting mesh.
9082  *  \param [out] arrOut - the DataArrayInt containing values of field.
9083  *  \param [in] renumPol - specifies how to permute values of the result field according to
9084  *          the optional numbers of cells and nodes, if any. The valid values are
9085  *          - 0 - do not permute.
9086  *          - 1 - permute cells.
9087  *          - 2 - permute nodes.
9088  *          - 3 - permute cells and nodes.
9089  *
9090  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9091  *          caller is to delete this field using decrRef() as it is no more needed. 
9092  *  \throw If no field of \a this is lying on \a mesh.
9093  *  \throw If no field values of the required parameters are available.
9094  */
9095 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9096 {
9097   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9098   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9099   if(!myF1TSC)
9100     throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9101   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9102   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9103   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9104   return ret.retn();
9105 }
9106
9107 /*!
9108  * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9109  * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9110  * This method is useful for MED2 file format when field on different mesh was autorized.
9111  */
9112 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const throw(INTERP_KERNEL::Exception)
9113 {
9114   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9115   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9116   if(!myF1TSC)
9117     throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9118   MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9119   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9120   arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9121   return ret.retn();
9122 }
9123
9124 /*!
9125  * Returns values and a profile of the field of a given type, of a given time step,
9126  * lying on a given support.
9127  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9128  *  \param [in] type - a spatial discretization of the field.
9129  *  \param [in] iteration - the iteration number of a required time step.
9130  *  \param [in] order - the iteration order number of required time step.
9131  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9132  *  \param [in] mesh - the supporting mesh.
9133  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9134  *          field of interest lies on. If the field lies on all entities of the given
9135  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
9136  *          using decrRef() as it is no more needed.  
9137  *  \param [in] glob - the global data storing profiles and localization.
9138  *  \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9139  *          field. The caller is to delete this array using decrRef() as it is no more needed.
9140  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a 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 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception)
9145 {
9146   const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9147   const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9148   if(!myF1TSC)
9149     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9150   MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9151   return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9152 }
9153
9154 /*!
9155  * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9156  *  \param [in] pos - a time step id.
9157  *  \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9158  *          delete this field using decrRef() as it is no more needed.
9159  *  \throw If \a pos is not a valid time step id.
9160  */
9161 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
9162 {
9163   const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9164   if(!item)
9165     {
9166       std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9167       throw INTERP_KERNEL::Exception(oss.str().c_str());
9168     }
9169   const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9170   if(itemC)
9171     {
9172       MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9173       ret->shallowCpyGlobs(*this);
9174       return ret.retn();
9175     }
9176   std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9177   throw INTERP_KERNEL::Exception(oss.str().c_str());
9178 }
9179
9180 /*!
9181  * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9182  * the given field is checked if its elements are sorted suitable for writing to MED file
9183  * ("STB" stands for "Sort By Type"), if not, an exception is thrown. 
9184  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9185  *  \param [in] field - the field to add to \a this.
9186  *  \throw If the name of \a field is empty.
9187  *  \throw If the data array of \a field is not set.
9188  *  \throw If existing time steps have different name or number of components than \a field.
9189  *  \throw If the underlying mesh of \a field has no name.
9190  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9191  */
9192 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception)
9193 {
9194   contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9195 }
9196
9197 /*!
9198  * Adds a MEDCouplingFieldDouble to \a this as another time step. 
9199  * The mesh support of input parameter \a field is ignored here, it can be NULL.
9200  * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9201  * and \a profile.
9202  *
9203  * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9204  * A new profile is added only if no equal profile is missing.
9205  * For more info, see \ref AdvMEDLoaderAPIFieldRW
9206  *  \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9207  *  \param [in] arrOfVals - the values of the field \a field used.
9208  *  \param [in] mesh - the supporting mesh of \a field.
9209  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9210  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
9211  *  \throw If either \a field or \a mesh or \a profile has an empty name.
9212  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9213  *  \throw If the data array of \a field is not set.
9214  *  \throw If the data array of \a this is already allocated but has different number of
9215  *         components than \a field.
9216  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9217  *  \sa setFieldNoProfileSBT()
9218  */
9219 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception)
9220 {
9221   contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9222 }
9223
9224 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const throw(INTERP_KERNEL::Exception)
9225 {
9226   const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9227   if(!pt)
9228     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9229   const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9230   if(!ret)
9231     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 !");
9232   return ret;
9233 }
9234
9235  MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() throw(INTERP_KERNEL::Exception)
9236 {
9237   MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9238   if(!pt)
9239     throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9240   MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9241   if(!ret)
9242     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 !");
9243   return ret;
9244 }
9245
9246 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9247 {
9248   _content=new MEDFileIntFieldMultiTSWithoutSDA;
9249 }
9250
9251 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9252 {
9253 }
9254
9255 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9256 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9257 {
9258 }
9259 catch(INTERP_KERNEL::Exception& e)
9260   { throw e; }
9261
9262 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception)
9263 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9264 {
9265 }
9266 catch(INTERP_KERNEL::Exception& e)
9267   { throw e; }
9268
9269 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception)
9270 {
9271   return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9272 }
9273
9274 //= MEDFileFields
9275
9276 MEDFileFields *MEDFileFields::New()
9277 {
9278   return new MEDFileFields;
9279 }
9280
9281 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9282 {
9283   return new MEDFileFields(fileName,loadAll);
9284 }
9285
9286 std::size_t MEDFileFields::getHeapMemorySize() const
9287 {
9288   std::size_t ret=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9289   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9290     if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it)
9291       ret+=(*it)->getHeapMemorySize();
9292   return ret+MEDFileFieldGlobsReal::getHeapMemorySize();
9293 }
9294
9295 MEDFileFields *MEDFileFields::deepCpy() const throw(INTERP_KERNEL::Exception)
9296 {
9297   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9298   std::size_t i=0;
9299   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9300     {
9301       if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9302         ret->_fields[i]=(*it)->deepCpy();
9303     }
9304   ret->deepCpyGlobs(*this);
9305   return ret.retn();
9306 }
9307
9308 MEDFileFields *MEDFileFields::shallowCpy() const throw(INTERP_KERNEL::Exception)
9309 {
9310   return new MEDFileFields(*this);
9311 }
9312
9313 /*!
9314  * 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
9315  * 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.
9316  * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9317  *
9318  * \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.
9319  * \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.
9320  * 
9321  * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9322  */
9323 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception)
9324 {
9325   std::set< std::pair<int,int> > s;
9326   bool firstShot=true;
9327   areThereSomeForgottenTS=false;
9328   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9329     {
9330       if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9331         continue;
9332       std::vector< std::pair<int,int> > v=(*it)->getIterations();
9333       std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9334       if(firstShot)
9335         { s=s1; firstShot=false; }
9336       else
9337         {
9338           std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9339           if(s!=s2)
9340             areThereSomeForgottenTS=true;
9341           s=s2;
9342         }
9343     }
9344   std::vector< std::pair<int,int> > ret;
9345   std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9346   return ret;
9347 }
9348
9349 int MEDFileFields::getNumberOfFields() const
9350 {
9351   return _fields.size();
9352 }
9353
9354 std::vector<std::string> MEDFileFields::getFieldsNames() const throw(INTERP_KERNEL::Exception)
9355 {
9356   std::vector<std::string> ret(_fields.size());
9357   int i=0;
9358   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9359     {
9360       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9361       if(f)
9362         {
9363           ret[i]=f->getName();
9364         }
9365       else
9366         {
9367           std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9368           throw INTERP_KERNEL::Exception(oss.str().c_str());
9369         }
9370     }
9371   return ret;
9372 }
9373
9374 std::vector<std::string> MEDFileFields::getMeshesNames() const throw(INTERP_KERNEL::Exception)
9375 {
9376   std::vector<std::string> ret;
9377   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9378     {
9379       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9380       if(cur)
9381         ret.push_back(cur->getMeshName());
9382     }
9383   return ret;
9384 }
9385
9386 std::string MEDFileFields::simpleRepr() const
9387 {
9388   std::ostringstream oss;
9389   oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9390   simpleRepr(0,oss);
9391   return oss.str();
9392 }
9393
9394 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9395 {
9396   int nbOfFields=getNumberOfFields();
9397   std::string startLine(bkOffset,' ');
9398   oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9399   int i=0;
9400   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9401     {
9402       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9403       if(cur)
9404         {
9405           oss << startLine << "  - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9406         }
9407       else
9408         {
9409           oss << startLine << "  - not defined !" << std::endl;
9410         }
9411     }
9412   i=0;
9413   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9414     {
9415       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9416       std::string chapter(17,'0'+i);
9417       oss << startLine << chapter << std::endl;
9418       if(cur)
9419         {
9420           cur->simpleRepr(bkOffset+2,oss,i);
9421         }
9422       else
9423         {
9424           oss << startLine << "  - not defined !" << std::endl;
9425         }
9426       oss << startLine << chapter << std::endl;
9427     }
9428   simpleReprGlobs(oss);
9429 }
9430
9431 MEDFileFields::MEDFileFields()
9432 {
9433 }
9434
9435 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception)
9436 try:MEDFileFieldGlobsReal(fileName)
9437   {
9438     MEDFileUtilities::CheckFileForRead(fileName);
9439     MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9440     int nbFields=MEDnField(fid);
9441     _fields.resize(nbFields);
9442     med_field_type typcha;
9443     for(int i=0;i<nbFields;i++)
9444       {
9445         std::vector<std::string> infos;
9446         std::string fieldName,dtunit;
9447         int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9448         switch(typcha)
9449           {
9450           case MED_FLOAT64:
9451             {
9452               _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9453               break;
9454             }
9455           case MED_INT32:
9456             {
9457               _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9458               break;
9459             }
9460           default:
9461             {
9462               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] !";
9463               throw INTERP_KERNEL::Exception(oss.str().c_str());
9464             }
9465           }
9466       }
9467     loadAllGlobals(fid);
9468   }
9469 catch(INTERP_KERNEL::Exception& e)
9470   {
9471     throw e;
9472   }
9473
9474 void MEDFileFields::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception)
9475 {
9476   int i=0;
9477   writeGlobals(fid,*this);
9478   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9479     {
9480       const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9481       if(!elt)
9482         {
9483           std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9484           throw INTERP_KERNEL::Exception(oss.str().c_str());
9485         }
9486       elt->writeLL(fid,*this);
9487     }
9488 }
9489
9490 void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception)
9491 {
9492   med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9493   MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9494   writeLL(fid);
9495 }
9496
9497 /*!
9498  * This method alloc the arrays and load potentially huge arrays contained in this field.
9499  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9500  * This method can be also called to refresh or reinit values from a file.
9501  * 
9502  * \throw If the fileName is not set or points to a non readable MED file.
9503  */
9504 void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception)
9505 {
9506   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9507   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9508     {
9509       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9510       if(elt)
9511         elt->loadBigArraysRecursively(fid,*elt);
9512     }
9513 }
9514
9515 /*!
9516  * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9517  * But once data loaded once, this method does nothing.
9518  * 
9519  * \throw If the fileName is not set or points to a non readable MED file.
9520  * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9521  */
9522 void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception)
9523 {
9524   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9525   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9526     {
9527       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9528       if(elt)
9529         elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9530     }
9531 }
9532
9533 /*!
9534  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9535  * This method does not release arrays set outside the context of a MED file.
9536  * 
9537  * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9538  */
9539 void MEDFileFields::unloadArrays() throw(INTERP_KERNEL::Exception)
9540 {
9541   MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9542   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9543     {
9544       MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9545       if(elt)
9546         elt->unloadArrays();
9547     }
9548 }
9549
9550 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9551 {
9552   std::vector<std::string> ret;
9553   std::set<std::string> ret2;
9554   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9555     {
9556       std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9557       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9558         if(ret2.find(*it2)==ret2.end())
9559           {
9560             ret.push_back(*it2);
9561             ret2.insert(*it2);
9562           }
9563     }
9564   return ret;
9565 }
9566
9567 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9568 {
9569   std::vector<std::string> ret;
9570   std::set<std::string> ret2;
9571   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9572     {
9573       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9574       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9575         if(ret2.find(*it2)==ret2.end())
9576           {
9577             ret.push_back(*it2);
9578             ret2.insert(*it2);
9579           }
9580     }
9581   return ret;
9582 }
9583
9584 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9585 {
9586   std::vector<std::string> ret;
9587   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9588     {
9589       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9590       ret.insert(ret.end(),tmp.begin(),tmp.end());
9591     }
9592   return ret;
9593 }
9594
9595 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9596 {
9597   std::vector<std::string> ret;
9598   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9599     {
9600       std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9601       ret.insert(ret.end(),tmp.begin(),tmp.end());
9602     }
9603   return ret;
9604 }
9605
9606 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9607 {
9608   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9609     (*it)->changePflsRefsNamesGen2(mapOfModif);
9610 }
9611
9612 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception)
9613 {
9614   for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9615     (*it)->changeLocsRefsNamesGen2(mapOfModif);
9616 }
9617
9618 void MEDFileFields::resize(int newSize) throw(INTERP_KERNEL::Exception)
9619 {
9620   _fields.resize(newSize);
9621 }
9622
9623 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields) throw(INTERP_KERNEL::Exception)
9624 {
9625   for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9626     pushField(*it);
9627 }
9628
9629 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9630 {
9631   if(!field)
9632     throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9633   _fields.push_back(field->getContent());
9634   appendGlobs(*field,1e-12);
9635 }
9636
9637 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception)
9638 {
9639   if(!field)
9640     throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9641   if(i>=(int)_fields.size())
9642     _fields.resize(i+1);
9643   _fields[i]=field->getContent();
9644   appendGlobs(*field,1e-12);
9645 }
9646
9647 void MEDFileFields::destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception)
9648 {
9649   destroyFieldsAtPos(&i,&i+1);
9650 }
9651
9652 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception)
9653 {
9654   std::vector<bool> b(_fields.size(),true);
9655   for(const int *i=startIds;i!=endIds;i++)
9656     {
9657       if(*i<0 || *i>=(int)_fields.size())
9658         {
9659           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9660           throw INTERP_KERNEL::Exception(oss.str().c_str());
9661         }
9662       b[*i]=false;
9663     }
9664   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9665   std::size_t j=0;
9666   for(std::size_t i=0;i<_fields.size();i++)
9667     if(b[i])
9668       fields[j++]=_fields[i];
9669   _fields=fields;
9670 }
9671
9672 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception)
9673 {
9674   static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9675   int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9676   std::vector<bool> b(_fields.size(),true);
9677   int k=bg;
9678   for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9679     {
9680       if(k<0 || k>=(int)_fields.size())
9681         {
9682           std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9683           throw INTERP_KERNEL::Exception(oss.str().c_str());
9684         }
9685       b[k]=false;
9686     }
9687   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9688   std::size_t j=0;
9689   for(std::size_t i=0;i<_fields.size();i++)
9690     if(b[i])
9691       fields[j++]=_fields[i];
9692   _fields=fields;
9693 }
9694
9695 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception)
9696 {
9697   bool ret=false;
9698   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9699     {
9700       MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9701       if(cur)
9702         ret=cur->changeMeshNames(modifTab) || ret;
9703     }
9704   return ret;
9705 }
9706
9707 /*!
9708  * \param [in] meshName the name of the mesh that will be renumbered.
9709  * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9710  *             This code corresponds to the distribution of types in the corresponding mesh.
9711  * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9712  * \param [in] renumO2N the old to new renumber array.
9713  * \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 
9714  *         field in \a this.
9715  */
9716 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception)
9717 {
9718   bool ret=false;
9719   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9720     {
9721       MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9722       if(fmts)
9723         {
9724           ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9725         }
9726     }
9727   return ret;
9728 }
9729
9730 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception)
9731 {
9732   if(i<0 || i>=(int)_fields.size())
9733     {
9734       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9735       throw INTERP_KERNEL::Exception(oss.str().c_str());
9736     }
9737   const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9738   if(!fmts)
9739     return 0;
9740   MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9741   const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9742   const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9743   if(fmtsC)
9744     ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9745   else if(fmtsC2)
9746     ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9747   else
9748     {
9749       std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9750       throw INTERP_KERNEL::Exception(oss.str().c_str());
9751     }
9752   ret->shallowCpyGlobs(*this);
9753   return ret.retn();
9754 }
9755
9756 /*!
9757  * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9758  * This method is accessible in python using __getitem__ with a list in input.
9759  * \return a new object that the caller should deal with.
9760  */
9761 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception)
9762 {
9763   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9764   std::size_t sz=std::distance(startIds,endIds);
9765   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9766   int j=0;
9767   for(const int *i=startIds;i!=endIds;i++,j++)
9768     {
9769       if(*i<0 || *i>=(int)_fields.size())
9770         {
9771           std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9772           throw INTERP_KERNEL::Exception(oss.str().c_str());
9773         }
9774       fields[j]=_fields[*i];
9775     }
9776   ret->_fields=fields;
9777   return ret.retn();
9778 }
9779
9780 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9781 {
9782   return getFieldAtPos(getPosFromFieldName(fieldName));
9783 }
9784
9785 /*!
9786  * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9787  * This method can be seen as a filter applied on \a this, that returns an object containing
9788  * 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
9789  * shallow copied from \a this.
9790  * 
9791  * \param [in] meshName - the name of the mesh on w
9792  * \return a new object that the caller should deal with.
9793  */
9794 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception)
9795 {
9796   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9797   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9798     {
9799       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9800       if(!cur)
9801         continue;
9802       if(cur->getMeshName()==meshName)
9803         {
9804           cur->incrRef();
9805           MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9806           ret->_fields.push_back(cur2);
9807         }
9808     }
9809   ret->shallowCpyOnlyUsedGlobs(*this);
9810   return ret.retn();
9811 }
9812
9813 /*!
9814  * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9815  * Input time steps are specified using a pair of integer (iteration, order).
9816  * 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,
9817  * but for each multitimestep only the time steps in \a timeSteps are kept.
9818  * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9819  * 
9820  * The returned object points to shallow copy of elements in \a this.
9821  * 
9822  * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9823  * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9824  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9825  */
9826 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9827 {
9828   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9829   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9830     {
9831       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9832       if(!cur)
9833         continue;
9834       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9835       ret->_fields.push_back(elt);
9836     }
9837   ret->shallowCpyOnlyUsedGlobs(*this);
9838   return ret.retn();
9839 }
9840
9841 /*!
9842  * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9843  */
9844 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const throw(INTERP_KERNEL::Exception)
9845 {
9846   MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9847   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9848     {
9849       const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9850       if(!cur)
9851         continue;
9852       MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9853       if(elt->getNumberOfTS()!=0)
9854         ret->_fields.push_back(elt);
9855     }
9856   ret->shallowCpyOnlyUsedGlobs(*this);
9857   return ret.retn();
9858 }
9859
9860 MEDFileFieldsIterator *MEDFileFields::iterator() throw(INTERP_KERNEL::Exception)
9861 {
9862   return new MEDFileFieldsIterator(this);
9863 }
9864
9865 int MEDFileFields::getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception)
9866 {
9867   std::string tmp(fieldName);
9868   std::vector<std::string> poss;
9869   for(std::size_t i=0;i<_fields.size();i++)
9870     {
9871       const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9872       if(f)
9873         {
9874           std::string fname(f->getName());
9875           if(tmp==fname)
9876             return i;
9877           else
9878             poss.push_back(fname);
9879         }
9880     }
9881   std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9882   std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9883   oss << " !";
9884   throw INTERP_KERNEL::Exception(oss.str().c_str());
9885 }
9886
9887 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9888 {
9889   if(fs)
9890     {
9891       fs->incrRef();
9892       _nb_iter=fs->getNumberOfFields();
9893     }
9894 }
9895
9896 MEDFileFieldsIterator::~MEDFileFieldsIterator() 
9897 {
9898 }
9899
9900 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9901 {
9902   if(_iter_id<_nb_iter)
9903     {
9904       MEDFileFields *fs(_fs);
9905       if(fs)
9906         return fs->getFieldAtPos(_iter_id++);
9907       else
9908         return 0;
9909     }
9910   else
9911     return 0;
9912 }