]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/MEDLoader/MEDFileField1TS.cxx
Salome HOME
Management of int64 fields into medcoupling.
[tools/medcoupling.git] / src / MEDLoader / MEDFileField1TS.cxx
1 // Copyright (C) 2017-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #include "MEDFileField1TS.hxx"
22 #include "MEDFileFieldVisitor.hxx"
23 #include "MEDFileSafeCaller.txx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDFileField.txx"
26
27 #include "MEDCouplingFieldTemplate.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29
30 using namespace MEDCoupling;
31
32 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
33
34 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<Int32>;
35 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<Int64>;
36 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<float>;
37 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<double>;
38 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<Int32>;
39 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<Int64>;
40 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<float>;
41 template class MEDCoupling::MEDFileTemplateField1TS<Int32>;
42 template class MEDCoupling::MEDFileTemplateField1TS<Int64>;
43 template class MEDCoupling::MEDFileTemplateField1TS<float>;
44 template class MEDCoupling::MEDFileTemplateField1TS<double>;
45 template class MEDCoupling::MEDFileNDTemplateField1TS<Int32>;
46 template class MEDCoupling::MEDFileNDTemplateField1TS<Int64>;
47 template class MEDCoupling::MEDFileNDTemplateField1TS<float>;
48
49 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
50 const char MEDFileInt32Field1TSWithoutSDA::TYPE_STR[]="INT32";
51 const char MEDFileInt64Field1TSWithoutSDA::TYPE_STR[]="INT64";
52 const char MEDFileFloatField1TSWithoutSDA::TYPE_STR[]="FLOAT32";
53
54 //= MEDFileAnyTypeField1TSWithoutSDA
55
56 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
57 {
58   _field_per_mesh.resize(other._field_per_mesh.size());
59   std::size_t i=0;
60   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
61     {
62       if((const MEDFileFieldPerMesh *)*it)
63         _field_per_mesh[i]=(*it)->deepCopy(this);
64     }
65 }
66
67 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
68 {
69   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
70     if((*it).isNotNull())
71       {
72         visitor.newMeshEntry(*it);
73         (*it)->accept(visitor);
74         visitor.endMeshEntry(*it);
75       }
76 }
77
78 /*!
79  * Prints a string describing \a this field into a stream. This string is outputted 
80  * by \c print Python command.
81  *  \param [in] bkOffset - number of white spaces printed at the beginning of each line.
82  *  \param [in,out] oss - the out stream.
83  *  \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
84  *          info id printed, else, not.
85  */
86 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
87 {
88   std::string startOfLine(bkOffset,' ');
89   oss << startOfLine << "Field ";
90   if(bkOffset==0)
91     oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
92   oss << "on one time Step ";
93   if(f1tsId>=0)
94     oss << "(" << f1tsId << ") ";
95   oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
96   oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
97   const DataArray *arr=getUndergroundDataArray();
98   if(arr)
99     {
100       const std::vector<std::string> &comps=arr->getInfoOnComponents();
101       if(f1tsId<0)
102         {
103           oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
104           for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
105             oss << startOfLine << "  -  \"" << (*it) << "\"" << std::endl;
106         }
107       if(arr->isAllocated())
108         {
109           oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
110         }
111       else
112         oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
113     }
114   else
115     {
116       oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
117     }
118   oss << startOfLine << "----------------------" << std::endl;
119   if(!_field_per_mesh.empty())
120     {
121       int i=0;
122       for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
123         {
124           const MEDFileFieldPerMesh *cur=(*it2);
125           if(cur)
126             cur->simpleRepr(bkOffset,oss,i);
127           else
128             oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
129         }
130     }
131   else
132     {
133       oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
134     }
135   oss << startOfLine << "----------------------" << std::endl;
136 }
137
138 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
139 {
140   const DataArray *arr(getUndergroundDataArray());
141   if(!arr)
142     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
143   std::size_t nbOfCompo=arr->getNumberOfComponents();
144   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
145   for(std::size_t i=0;i<nbOfCompo;i++)
146     {
147       ret[i]=deepCopy();
148       std::vector<std::size_t> v(1,i);
149       MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
150       ret[i]->setArray(arr2);
151     }
152   return ret;
153 }
154
155 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName,meshName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
156 {
157 }
158
159 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
160 {
161 }
162
163 /*!
164  * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
165  * empty. Returns -1 if this in on nodes.
166  *  \return int - the dimension of \a this.
167  */
168 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
169 {
170   int ret=-2;
171   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
172     (*it)->getDimension(ret);
173   return ret;
174 }
175
176 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
177 {
178   bool ret=false;
179   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
180     {
181       MEDFileFieldPerMesh *cur(*it);
182       if(cur)
183         ret=cur->changeMeshNames(modifTab) || ret;
184     }
185   return ret;
186 }
187
188 /*!
189  * Returns the number of iteration of the state of underlying mesh.
190  *  \return int - the iteration number.
191  *  \throw If \c _field_per_mesh.empty()
192  */
193 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
194 {
195   if(_field_per_mesh.empty())
196     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
197   return _field_per_mesh[0]->getMeshIteration();
198 }
199
200 /*!
201  * Returns the order number of iteration of the state of underlying mesh.
202  *  \return int - the order number.
203  *  \throw If \c _field_per_mesh.empty()
204  */
205 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
206 {
207   if(_field_per_mesh.empty())
208     throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
209   return _field_per_mesh[0]->getMeshOrder();
210 }
211
212 /*!
213  * Checks if \a this field is tagged by a given iteration number and a given
214  * iteration order number.
215  *  \param [in] iteration - the iteration number of interest.
216  *  \param [in] order - the iteration order number of interest.
217  *  \return bool - \c true if \a this->getIteration() == \a iteration && 
218  *          \a this->getOrder() == \a order.
219  */
220 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
221 {
222   return iteration==_iteration && order==_order;
223 }
224
225 /*!
226  * Returns number of iteration and order number of iteration when
227  * \a this field has been calculated.
228  *  \return std::pair<int,int> - a pair of the iteration number and the iteration
229  *          order number.
230  */
231 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
232 {
233   std::pair<int,int> p;
234   fillIteration(p);
235   return p;
236 }
237
238 /*!
239  * Returns number of iteration and order number of iteration when
240  * \a this field has been calculated.
241  *  \param [in,out] p - a pair returning the iteration number and the iteration
242  *          order number.
243  */
244 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
245 {
246   p.first=_iteration;
247   p.second=_order;
248 }
249
250 /*!
251  * Returns all types of spatial discretization of \a this field.
252  *  \param [in,out] types - a sequence of types of \a this field.
253  */
254 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
255 {
256   std::set<TypeOfField> types2;
257   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
258     {
259       (*it)->fillTypesOfFieldAvailable(types2);
260     }
261   std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
262   std::copy(types2.begin(),types2.end(),bi);
263 }
264
265 /*!
266  * Returns all types of spatial discretization of \a this field.
267  *  \return std::vector<TypeOfField> - a sequence of types of spatial discretization
268  *          of \a this field.
269  */
270 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
271 {
272   std::vector<TypeOfField> ret;
273   fillTypesOfFieldAvailable(ret);
274   return ret;
275 }
276
277 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
278 {
279   std::vector<std::string> ret;
280   std::set<std::string> ret2;
281   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
282     {
283       std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
284       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
285         if(ret2.find(*it2)==ret2.end())
286           {
287             ret.push_back(*it2);
288             ret2.insert(*it2);
289           }
290     }
291   return ret;
292 }
293
294 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
295 {
296   std::vector<std::string> ret;
297   std::set<std::string> ret2;
298   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
299     {
300       std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
301       for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
302         if(ret2.find(*it2)==ret2.end())
303           {
304             ret.push_back(*it2);
305             ret2.insert(*it2);
306           }
307     }
308   return ret;
309 }
310
311 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
312 {
313   std::vector<std::string> ret;
314   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
315     {
316       std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
317       ret.insert(ret.end(),tmp.begin(),tmp.end());
318     }
319   return ret;
320 }
321
322 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
323 {
324   std::vector<std::string> ret;
325   std::set<std::string> ret2;
326   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
327     {
328       std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
329       ret.insert(ret.end(),tmp.begin(),tmp.end());
330     }
331   return ret;
332 }
333
334 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
335 {
336   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
337     (*it)->changePflsRefsNamesGen(mapOfModif);
338 }
339
340 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
341 {
342   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
343     (*it)->changeLocsRefsNamesGen(mapOfModif);
344 }
345
346 /*!
347  * Returns all attributes of parts of \a this field lying on a given mesh.
348  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
349  * item of every of returned sequences refers to the _i_-th part of \a this field.
350  * Thus all sequences returned by this method are of the same length equal to number
351  * of different types of supporting entities.<br>
352  * A field part can include sub-parts with several different spatial discretizations,
353  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
354  * for example. Hence, some of the returned sequences contains nested sequences, and an item
355  * of a nested sequence corresponds to a type of spatial discretization.<br>
356  * This method allows for iteration over MEDFile DataStructure without any overhead.
357  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
358  *          for the case with only one underlying mesh. (Actually, the number of meshes is
359  *          not checked if \a mname == \c NULL).
360  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
361  *          a field part is returned. 
362  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
363  *          This sequence is of the same length as \a types. 
364  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
365  *          discretization. A profile name can be empty.
366  *          Length of this and of nested sequences is the same as that of \a typesF.
367  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
368  *          discretization. A localization name can be empty.
369  *          Length of this and of nested sequences is the same as that of \a typesF.
370  *  \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
371  *          of ids of tuples within the data array, per each type of spatial
372  *          discretization within one mesh entity type. 
373  *          Length of this and of nested sequences is the same as that of \a typesF.
374  *  \throw If no field is lying on \a mname.
375  */
376 std::vector< std::vector< std::pair<mcIdType,mcIdType> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
377 {
378   if(_field_per_mesh.empty())
379     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
380   return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
381 }
382
383 /*!
384  * Returns dimensions of mesh elements \a this field lies on. The returned value is a
385  * maximal absolute dimension and values returned via the out parameter \a levs are 
386  * dimensions relative to the maximal absolute dimension. <br>
387  * This method is designed for MEDFileField1TS instances that have a discretization
388  * \ref MEDCoupling::ON_CELLS "ON_CELLS", 
389  * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT", 
390  * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
391  * Only these 3 discretizations will be taken into account here. If \a this is
392  * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
393  * This method is useful to make the link between the dimension of the underlying mesh
394  * and the levels of \a this, because it is possible that the highest dimension of \a this
395  * field is not equal to the dimension of the underlying mesh.
396  * 
397  * Let's consider the following case:
398  * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
399  * TETRA4, HEXA8, TRI3 and SEG2.
400  * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
401  * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
402  *
403  * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
404  * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
405  * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
406  * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
407  * parameter of getFieldAtLevel() is computed basing on the returned values as this:
408  * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
409  * For example<br>
410  * to retrieve the highest level of
411  * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br> 
412  * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
413  * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
414  * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
415  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
416  *          for the case with only one underlying mesh. (Actually, the number of meshes is
417  *          not checked if \a mname == \c NULL).
418  *  \param [in,out] levs - a sequence returning the dimensions relative to the maximal
419  *          absolute one. They are in decreasing order. This sequence is cleared before
420  *          filling it in.
421  *  \return int - the maximal absolute dimension of elements \a this fields lies on.
422  *  \throw If no field is lying on \a mname.
423  */
424 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
425 {
426   levs.clear();
427   std::vector<INTERP_KERNEL::NormalizedCellType> types;
428   std::vector< std::vector<TypeOfField> > typesF;
429   std::vector< std::vector<std::string> > pfls, locs;
430   if(_field_per_mesh.empty())
431     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
432   _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
433   if(types.empty())
434     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
435   std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
436   if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
437     return -1;
438   st.erase(INTERP_KERNEL::NORM_ERROR);
439   std::set<int> ret1;
440   for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
441     {
442       const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
443       ret1.insert((int)cm.getDimension());
444     }
445   int ret=*std::max_element(ret1.begin(),ret1.end());
446   std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
447   std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
448   return ret;
449 }
450
451 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
452 {
453   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
454     if((*it).isNotNull())
455       (*it)->convertMedBallIntoClassic();
456 }
457
458 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayIdType *pfl)
459 {
460   if(!pfl)
461     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
462   std::string name(pfl->getName());
463   pfl->checkAllocated();
464   if(pfl->getNumberOfComponents()!=1)
465     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
466   if(name.empty())
467     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
468   if(_field_per_mesh.size()!=1)
469     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
470   MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
471   if(fpm.isNull())
472     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
473   MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
474   if(disc->getType()!=tof)
475     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
476   mcIdType s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
477   DataArray *arr(getUndergroundDataArray());
478   mcIdType nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
479   if(delta<0)
480     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
481   MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
482   MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
483   MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
484   arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
485   arrOut->copyStringInfoFrom(*arr);
486   arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
487   arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
488   arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
489   setArray(arrOut);
490   disc->setEnd(e-delta);
491   disc->setProfile(name);
492 }
493
494 /*!
495  * \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.
496  * \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.
497  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
498  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
499  */
500 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
501 {
502   if(_field_per_mesh.empty())
503     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
504   return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
505 }
506
507 /*!
508  * \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.
509  * \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.
510  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
511  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
512  */
513 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
514 {
515   if(_field_per_mesh.empty())
516     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
517   return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
518 }
519
520 /*!
521  * \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.
522  */
523 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
524 {
525   if(_field_per_mesh.empty())
526     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
527   if(mName.empty())
528     return 0;
529   std::string mName2(mName);
530   int ret=0;
531   std::vector<std::string> msg;
532   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
533     if(mName2==(*it)->getMeshName())
534       return ret;
535     else
536       msg.push_back((*it)->getMeshName());
537   std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
538   oss << "Possible meshes are : ";
539   for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
540     oss << "\"" << (*it2) << "\" ";
541   throw INTERP_KERNEL::Exception(oss.str());
542 }
543
544 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
545 {
546   if(!mesh)
547     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
548   std::string tmp(mesh->getName());
549   if(tmp.empty())
550     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
551   setMeshName(tmp);
552   std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
553   int i=0;
554   for(;it!=_field_per_mesh.end();it++,i++)
555     {
556       if((*it)->getMeshName()==tmp)
557         return i;
558     }
559   std::size_t sz=_field_per_mesh.size();
560   _field_per_mesh.resize(sz+1);
561   _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
562   return (int)sz;
563 }
564
565 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N,
566                                                                    MEDFileFieldGlobsReal& glob)
567 {
568   bool ret=false;
569   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
570     {
571       MEDFileFieldPerMesh *fpm(*it);
572       if(fpm)
573         ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
574     }
575   return ret;
576 }
577
578 /*!
579  * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
580  * splitting that leads to single spatial discretization of this.
581  *
582  * \sa splitMultiDiscrPerGeoTypes
583  */
584 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
585 {
586   std::vector<INTERP_KERNEL::NormalizedCellType> types;
587   std::vector< std::vector<TypeOfField> > typesF;
588   std::vector< std::vector<std::string> > pfls,locs;
589   std::vector< std::vector<std::pair<mcIdType,mcIdType> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
590   std::set<TypeOfField> allEnt;
591   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
592     for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
593       allEnt.insert(*it2);
594   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
595   std::set<TypeOfField>::const_iterator it3(allEnt.begin());
596   for(std::size_t i=0;i<allEnt.size();i++,it3++)
597     {
598       std::vector< std::pair<mcIdType,mcIdType> > its;
599       ret[i]=shallowCpy();
600       mcIdType newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
601       ret[i]->updateData(newLgth,its);
602     }
603   return ret;
604 }
605
606 /*!
607  * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest splitting level that can be done.
608  * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
609  *
610  * \sa splitDiscretizations
611  */
612 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
613 {
614   std::vector<INTERP_KERNEL::NormalizedCellType> types;
615   std::vector< std::vector<TypeOfField> > typesF;
616   std::vector< std::vector<std::string> > pfls,locs;
617   std::vector< std::vector<std::pair<mcIdType,mcIdType> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
618   std::set<TypeOfField> allEnt;
619   std::size_t nbOfMDPGT(0),ii(0);
620   for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
621     {
622       nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
623       for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
624         allEnt.insert(*it2);
625     }
626   if(allEnt.size()!=1)
627     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
628   if(nbOfMDPGT==0)
629     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
630   if(nbOfMDPGT==1)
631     {
632       std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
633       ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
634       return ret0;
635     }
636   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
637   for(std::size_t i=0;i<nbOfMDPGT;i++)
638     {
639       std::vector< std::pair<mcIdType,mcIdType> > its;
640       ret[i]=shallowCpy();
641       mcIdType newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
642       ret[i]->updateData(newLgth,its);
643     }
644   return ret;
645 }
646
647 mcIdType MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<mcIdType,mcIdType> >& its)
648 {
649   mcIdType globalCounter(0);
650   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
651     (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
652   return globalCounter;
653 }
654
655 mcIdType MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<mcIdType,mcIdType> >& its)
656 {
657   mcIdType globalCounter(0);
658   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
659     (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
660   return globalCounter;
661 }
662
663 void MEDFileAnyTypeField1TSWithoutSDA::updateData(mcIdType newLgth, const std::vector< std::pair<mcIdType,mcIdType> >& oldStartStops)
664 {
665   if(_nb_of_tuples_to_be_allocated>=0)
666     {
667       _nb_of_tuples_to_be_allocated=newLgth;
668       const DataArray *oldArr(getUndergroundDataArray());
669       if(oldArr)
670         {
671           MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
672           newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
673           setArray(newArr);
674           _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
675         }
676       return ;
677     }
678   if(_nb_of_tuples_to_be_allocated==-1)
679     return ;
680   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
681     {
682       const DataArray *oldArr(getUndergroundDataArray());
683       if(!oldArr || !oldArr->isAllocated())
684         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
685       MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
686       newArr->alloc(newLgth,getNumberOfComponents());
687       if(oldArr)
688         newArr->copyStringInfoFrom(*oldArr);
689       mcIdType pos=0;
690       for(std::vector< std::pair<mcIdType,mcIdType> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
691         {
692           if((*it).second<(*it).first)
693             throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
694           newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
695           pos+=(*it).second-(*it).first;
696         }
697       setArray(newArr);
698       return ;
699     }
700   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
701 }
702
703 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
704 {
705   if(_field_per_mesh.empty())
706     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
707   if(_field_per_mesh.size()>1)
708     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writing mode only ONE underlying mesh supported !");
709   _field_per_mesh[0]->copyOptionsFrom(opts);
710   _field_per_mesh[0]->writeLL(fid,nasc);
711 }
712
713 /*!
714  * MED file does not support ' ' at the end of the field name. This method corrects the possibly invalid input \a nonCorrectFieldName to a correct one by right stripping input.
715  */
716 std::string MEDFileAnyTypeField1TSWithoutSDA::FieldNameToMEDFileConvention(const std::string& nonCorrectFieldName)
717 {
718   std::string::size_type pos0(nonCorrectFieldName.find_last_not_of(' '));
719   if(pos0==std::string::npos)
720     return nonCorrectFieldName;
721   if(pos0+1==nonCorrectFieldName.length())
722     return nonCorrectFieldName;
723   return nonCorrectFieldName.substr(0,pos0+1);
724 }
725
726 /*!
727  * 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.
728  * If false is returned the memory allocation is not required.
729  */
730 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
731 {
732   if(_nb_of_tuples_to_be_allocated>=0)
733     {
734       getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
735       _nb_of_tuples_to_be_allocated=-2;
736       return true;
737     }
738   if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
739     return false;
740   if(_nb_of_tuples_to_be_allocated==-1)
741     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
742   if(_nb_of_tuples_to_be_allocated<-3)
743     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
744   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
745 }
746
747 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities, const MEDFileCapability *capability)
748 {
749   med_int numdt,numit;
750   med_float dt;
751   med_int meshnumdt(-1),meshnumit(-1);
752   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
753   if(!capability || !capability->isFastReader())
754   {
755     med_bool localMesh;
756     med_int nmesh;
757     INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
758     MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
759   }
760   if(_iteration!=numdt || _order!=numit)
761     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
762   _field_per_mesh.resize(1);
763   //
764   MEDFileMesh *mm(0);
765   if(ms)
766     {
767       mm=ms->getMeshWithName(getMeshName());
768     }
769   //
770   _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,FromMedInt<int>(meshnumdt),FromMedInt<int>(meshnumit),nasc,mm,entities);
771   _nb_of_tuples_to_be_allocated=0;
772   _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
773 }
774
775 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
776 {
777   allocIfNecessaryTheArrayToReceiveDataFromFile();
778   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
779     (*it)->loadBigArraysRecursively(fid,nasc);
780 }
781
782 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
783 {
784   if(allocIfNecessaryTheArrayToReceiveDataFromFile())
785     for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
786       (*it)->loadBigArraysRecursively(fid,nasc);
787 }
788
789 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
790 {
791   loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
792   loadBigArraysRecursively(fid,nasc);
793 }
794
795 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
796 {
797   DataArray *thisArr(getUndergroundDataArray());
798   if(thisArr && thisArr->isAllocated())
799     {
800       _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
801       thisArr->desallocate();
802     }
803 }
804
805 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
806 {
807   return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
808 }
809
810 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
811 {
812   std::vector<const BigMemoryObject *> ret;
813   if(getUndergroundDataArray())
814     ret.push_back(getUndergroundDataArray());
815   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
816     ret.push_back((const MEDFileFieldPerMesh *)*it);
817   return ret;
818 }
819
820 /*!
821  * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
822  * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
823  * "Sort By Type"), if not, an exception is thrown. 
824  *  \param [in] field - the field to add to \a this. The array of field \a field is ignored
825  *  \param [in] arr - the array of values.
826  *  \param [in,out] glob - the global data where profiles and localization present in
827  *          \a field, if any, are added.
828  *  \throw If the name of \a field is empty.
829  *  \throw If the data array of \a field is not set.
830  *  \throw If \a this->_arr is already allocated but has different number of components
831  *         than \a field.
832  *  \throw If the underlying mesh of \a field has no name.
833  *  \throw If elements in the mesh are not in the order suitable for writing to the MED file.
834  */
835 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
836 {
837   const MEDCouplingMesh *mesh(field->getMesh());
838   //
839   TypeOfField type(field->getTypeOfField());
840   std::vector<DataArrayIdType *> dummy;
841   if(mesh)
842     setMeshName(mesh->getName());
843   mcIdType start(copyTinyInfoFrom(th,field,arr));
844   int pos(addNewEntryIfNecessary(mesh));
845   if(type!=ON_NODES)
846     {
847       std::vector<mcIdType> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
848       _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
849     }
850   else
851     _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
852 }
853
854 /*!
855  * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
856  * of a given mesh are used as the support of the given field (a real support is not used). 
857  * Elements of the given mesh must be sorted suitable for writing to MED file. 
858  * Order of underlying mesh entities of the given field specified by \a profile parameter
859  * is not prescribed; this method permutes field values to have them sorted by element
860  * type as required for writing to MED file. A new profile is added only if no equal
861  * profile is missing. 
862  *  \param [in] field - the field to add to \a this. The field double values are ignored.
863  *  \param [in] arrOfVals - the values of the field \a field used.
864  *  \param [in] mesh - the supporting mesh of \a field.
865  *  \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
866  *  \param [in] profile - ids of mesh entities on which corresponding field values lie.
867  *  \param [in,out] glob - the global data where profiles and localization present in
868  *          \a field, if any, are added.
869  *  \param [in] nasc - the name scope used to assign names. Depends on the caller on the top call stack
870  *  \param [in] smartPflKiller - specifies if this method tries at most to avoid profiles
871  *  \throw If either \a field or \a mesh or \a profile has an empty name.
872  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
873  *  \throw If the data array of \a field is not set.
874  *  \throw If \a this->_arr is already allocated but has different number of components
875  *         than \a field.
876  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
877  *  \sa setFieldNoProfileSBT()
878  */
879 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayIdType *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc, bool smartPflKiller)
880 {
881   if(!field)
882     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
883   if(!arrOfVals || !arrOfVals->isAllocated())
884     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
885   TypeOfField type=field->getTypeOfField();
886   std::vector<DataArrayIdType *> idsInPflPerType;
887   std::vector<DataArrayIdType *> idsPerType;
888   std::vector<mcIdType> code,code2;
889   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
890   if(type!=ON_NODES)
891     {
892       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType,smartPflKiller);
893       std::vector< MCAuto<DataArrayIdType> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
894       std::vector< MCAuto<DataArrayIdType> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
895       std::vector<const DataArrayIdType *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
896       // start of check
897       MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
898       mcIdType nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
899       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
900         {
901           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
902           throw INTERP_KERNEL::Exception(oss.str());
903         }
904       // end of check
905       mcIdType start(copyTinyInfoFrom(th,field,arrOfVals));
906       code2=m->getDistributionOfTypes();
907       //
908       mcIdType pos=addNewEntryIfNecessary(m);
909       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
910     }
911   else
912     {
913       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
914         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
915       std::vector<mcIdType> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
916       std::vector<const DataArrayIdType *> idsPerType3(1); idsPerType3[0]=profile;
917       mcIdType nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
918       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
919         {
920           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
921           throw INTERP_KERNEL::Exception(oss.str());
922         }
923       mcIdType start(copyTinyInfoFrom(th,field,arrOfVals));
924       mcIdType pos(addNewEntryIfNecessary(m));
925       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
926     }
927 }
928
929 /*!
930  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
931  */
932 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(mcIdType newNbOfTuples)
933 {
934   if(_nb_of_tuples_to_be_allocated>=0)
935     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 !");
936   DataArray *arr(getOrCreateAndGetArray());
937   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
938   _nb_of_tuples_to_be_allocated=-3;
939 }
940
941 /*!
942  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
943  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
944  * larger by the size of \a field. Returns an id of the first not filled
945  * tuple of \a this->_arr.
946  *  \param [in] field - the field to copy the info on components and the name from.
947  *  \return int - the id of first not initialized tuple of \a this->_arr.
948  *  \throw If the name of \a field is empty.
949  *  \throw If the data array of \a field is not set.
950  *  \throw If \a this->_arr is already allocated but has different number of components
951  *         than \a field.
952  */
953 mcIdType MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
954 {
955   if(!field)
956     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
957   std::string name(field->getName());
958   setName(name.c_str());
959   if(field->getMesh())
960     setMeshName(field->getMesh()->getName());
961   setDtUnit(th->getTimeUnit());
962   if(name.empty())
963     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
964   if(!arr)
965     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
966   if(!arr->isAllocated())
967     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
968   _dt=th->getTime(_iteration,_order);
969   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
970   if(!getOrCreateAndGetArray()->isAllocated())
971     {
972       allocNotFromFile(arr->getNumberOfTuples());
973       return 0;
974     }
975   else
976     {
977       mcIdType oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
978       mcIdType newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
979       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
980       _nb_of_tuples_to_be_allocated=-3;
981       return oldNbOfTuples;
982     }
983 }
984
985 /*!
986  * Returns number of components in \a this field
987  *  \return int - the number of components.
988  */
989 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
990 {
991   return getOrCreateAndGetArray()->getNumberOfComponents();
992 }
993
994 /*!
995  * Change info on components in \a this.
996  * \throw If size of \a infos is not equal to the number of components already in \a this.
997  */
998 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
999 {
1000   DataArray *arr=getOrCreateAndGetArray();
1001   arr->setInfoOnComponents(infos);//will throw an exception if number of components mismatches
1002 }
1003
1004 /*!
1005  * Returns info on components of \a this field.
1006  *  \return const std::vector<std::string>& - a sequence of strings each being an
1007  *          information on _i_-th component.
1008  */
1009 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
1010 {
1011   const DataArray *arr=getOrCreateAndGetArray();
1012   return arr->getInfoOnComponents();
1013 }
1014
1015 /*!
1016  * Returns a mutable info on components of \a this field.
1017  *  \return std::vector<std::string>& - a sequence of strings each being an
1018  *          information on _i_-th component.
1019  */
1020 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
1021 {
1022   DataArray *arr=getOrCreateAndGetArray();
1023   return arr->getInfoOnComponents();
1024 }
1025
1026 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
1027 {
1028   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1029     {
1030       const MEDFileFieldPerMesh *fpm(*it);
1031       if(!fpm)
1032         continue;
1033       if(fpm->presenceOfMultiDiscPerGeoType())
1034         return true;
1035     }
1036   return false;
1037 }
1038
1039 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
1040 {
1041   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1042     if((*it).isNotNull())
1043       if((*it)->presenceOfStructureElements())
1044         return true;
1045   return false;
1046 }
1047
1048 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
1049 {
1050   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1051     if((*it).isNotNull())
1052       if(!(*it)->onlyStructureElements())
1053         return false;
1054   return true;
1055 }
1056
1057 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
1058 {
1059   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1060     if((*it).isNotNull())
1061       (*it)->killStructureElements();
1062 }
1063
1064 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
1065 {
1066   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1067     if((*it).isNotNull())
1068       (*it)->keepOnlyStructureElements();
1069 }
1070
1071 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
1072 {
1073   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1074     if((*it).isNotNull())
1075       (*it)->keepOnlyOnSE(seName);
1076 }
1077
1078 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
1079 {
1080   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1081     if((*it).isNotNull())
1082       (*it)->getMeshSENames(ps);
1083 }
1084
1085 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1086 {
1087   static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with  \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
1088   if(_field_per_mesh.empty())
1089     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
1090   if(_field_per_mesh.size()>1)
1091     throw INTERP_KERNEL::Exception(MSG0);
1092   if(_field_per_mesh[0].isNull())
1093     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
1094   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
1095   std::set<TypeOfField> types;
1096   pm->fillTypesOfFieldAvailable(types);
1097   if(types.size()!=1)
1098     throw INTERP_KERNEL::Exception(MSG0);
1099   TypeOfField type(*types.begin());
1100   int meshDimRelToMax(0);
1101   if(type==ON_NODES)
1102     meshDimRelToMax=0;
1103   else
1104     {
1105       int myDim(std::numeric_limits<int>::max());
1106       bool isUnique(pm->isUniqueLevel(myDim));
1107       if(!isUnique)
1108         throw INTERP_KERNEL::Exception(MSG0);
1109       meshDimRelToMax=myDim-mesh->getMeshDimension();
1110       if(meshDimRelToMax>0)
1111         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
1112     }
1113   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
1114 }
1115
1116 /*!
1117  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1118  *  \param [in] type - a spatial discretization of the new field.
1119  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1120  *  \param [in] mName - a name of the supporting mesh.
1121  *  \param [in] renumPol - specifies how to permute values of the result field according to
1122  *          the optional numbers of cells and nodes, if any. The valid values are
1123  *          - 0 - do not permute.
1124  *          - 1 - permute cells.
1125  *          - 2 - permute nodes.
1126  *          - 3 - permute cells and nodes.
1127  *
1128  *  \param [in] glob - the global data storing profiles and localization.
1129  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1130  *          caller is to delete this field using decrRef() as it is no more needed. 
1131  *  \throw If the MED file is not readable.
1132  *  \throw If there is no mesh named \a mName in the MED file.
1133  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1134  *  \throw If no field of \a this is lying on the mesh \a mName.
1135  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1136  */
1137 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1138 {
1139   MCAuto<MEDFileMesh> mm;
1140   if(mName.empty())
1141     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1142   else
1143     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1144   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1145 }
1146
1147 /*!
1148  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1149  *  \param [in] type - a spatial discretization of the new field.
1150  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1151  *  \param [in] renumPol - specifies how to permute values of the result field according to
1152  *          the optional numbers of cells and nodes, if any. The valid values are
1153  *          - 0 - do not permute.
1154  *          - 1 - permute cells.
1155  *          - 2 - permute nodes.
1156  *          - 3 - permute cells and nodes.
1157  *
1158  *  \param [in] glob - the global data storing profiles and localization.
1159  *  \param [in] mesh - the supporting mesh.
1160  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1161  *          caller is to delete this field using decrRef() as it is no more needed. 
1162  *  \throw If the MED file is not readable.
1163  *  \throw If no field of \a this is lying on \a mesh.
1164  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1165  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1166  */
1167 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1168 {
1169   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
1170   const DataArrayIdType *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
1171   if(meshDimRelToMax==1)
1172     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
1173   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
1174 }
1175
1176 /*!
1177  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
1178  * given mesh. 
1179  *  \param [in] type - a spatial discretization of the new field.
1180  *  \param [in] mName - a name of the supporting mesh.
1181  *  \param [in] renumPol - specifies how to permute values of the result field according to
1182  *          the optional numbers of cells and nodes, if any. The valid values are
1183  *          - 0 - do not permute.
1184  *          - 1 - permute cells.
1185  *          - 2 - permute nodes.
1186  *          - 3 - permute cells and nodes.
1187  *
1188  *  \param [in] glob - the global data storing profiles and localization.
1189  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1190  *          caller is to delete this field using decrRef() as it is no more needed. 
1191  *  \throw If the MED file is not readable.
1192  *  \throw If there is no mesh named \a mName in the MED file.
1193  *  \throw If there are no mesh entities in the mesh.
1194  *  \throw If no field values of the given \a type are available.
1195  */
1196 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1197 {
1198   MCAuto<MEDFileMesh> mm;
1199   if(mName.empty())
1200     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1201   else
1202     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1203   int absDim=getDimension();
1204   int meshDimRelToMax=absDim-mm->getMeshDimension();
1205   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1206 }
1207
1208 /*!
1209  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1210  *  \param [in] type - a spatial discretization of the new field.
1211  *  \param [in] renumPol - specifies how to permute values of the result field according to
1212  *          the optional numbers of cells and nodes, if any. The valid values are
1213  *          - 0 - do not permute.
1214  *          - 1 - permute cells.
1215  *          - 2 - permute nodes.
1216  *          - 3 - permute cells and nodes.
1217  *
1218  *  \param [in] glob - the global data storing profiles and localization.
1219  *  \param [in] mesh - the supporting mesh.
1220  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
1221  *         field according to \a renumPol.
1222  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
1223  *         field according to \a renumPol.
1224  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1225  *          caller is to delete this field using decrRef() as it is no more needed. 
1226  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1227  *  \throw If no field of \a this is lying on \a mesh.
1228  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1229  */
1230 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayIdType *cellRenum, const DataArrayIdType *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1231 {
1232   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
1233   bool isPfl=false;
1234   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
1235   switch(renumPol)
1236   {
1237     case 0:
1238       {
1239         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1240         return ret.retn();
1241       }
1242     case 3:
1243     case 1:
1244       {
1245         if(isPfl)
1246           throw INTERP_KERNEL::Exception(msg1);
1247         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1248         if(cellRenum)
1249           {
1250             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
1251               {
1252                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1253                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
1254                 throw INTERP_KERNEL::Exception(oss.str());
1255               }
1256             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
1257             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
1258             std::vector<DataArray *> arrOut2(1,arrOut);
1259             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
1260             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
1261             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
1262           }
1263         if(renumPol==1)
1264           return ret.retn();
1265       }
1266     case 2:
1267       {
1268         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1269         if(isPfl)
1270           throw INTERP_KERNEL::Exception(msg1);
1271         if(nodeRenum)
1272           {
1273             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
1274               {
1275                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1276                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
1277                 throw INTERP_KERNEL::Exception(oss.str());
1278               }
1279             MCAuto<DataArrayIdType> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
1280             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
1281               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
1282             ret->renumberNodes(nodeRenumSafe->getConstPointer());
1283           }
1284         return ret.retn();
1285       }
1286     default:
1287       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
1288   }
1289 }
1290
1291 /*!
1292  * Returns values and a profile of the field of a given type lying on a given support.
1293  *  \param [in] type - a spatial discretization of the field.
1294  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1295  *  \param [in] mesh - the supporting mesh.
1296  *  \param [out] pfl - a new instance of DataArrayIdType holding ids of mesh entities the
1297  *          field of interest lies on. If the field lies on all entities of the given
1298  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
1299  *          using decrRef() as it is no more needed.  
1300  *  \param [in] glob - the global data storing profiles and localization.
1301  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
1302  *          field. The caller is to delete this array using decrRef() as it is no more needed.
1303  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
1304  *  \throw If no field of \a this is lying on \a mesh.
1305  *  \throw If no field values of the given \a type are available.
1306  */
1307 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayIdType *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
1308 {
1309   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
1310   MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
1311   ret->setName(nasc.getName().c_str());
1312   return ret.retn();
1313 }
1314
1315 //= MEDFileField1TSWithoutSDA
1316
1317 /*!
1318  * Throws if a given value is not a valid (non-extended) relative dimension.
1319  *  \param [in] meshDimRelToMax - the relative dimension value.
1320  *  \throw If \a meshDimRelToMax > 0.
1321  */
1322 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
1323 {
1324   if(meshDimRelToMax>0)
1325     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
1326 }
1327
1328 /*!
1329  * Checks if elements of a given mesh are in the order suitable for writing 
1330  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
1331  * vector describing types of elements and their number.
1332  *  \param [in] mesh - the mesh to check.
1333  *  \return std::vector<int> - a vector holding for each element type (1) item of
1334  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
1335  *          These values are in full-interlace mode.
1336  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
1337  */
1338 std::vector<mcIdType> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
1339 {
1340   if(!mesh)
1341     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
1342   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
1343   std::size_t nbOfTypes=geoTypes.size();
1344   std::vector<mcIdType> code(3*nbOfTypes);
1345   MCAuto<DataArrayIdType> arr1=DataArrayIdType::New();
1346   arr1->alloc(nbOfTypes,1);
1347   mcIdType *arrPtr=arr1->getPointer();
1348   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
1349   for(std::size_t i=0;i<nbOfTypes;i++,it++)
1350     arrPtr[i]=ToIdType(std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it)));
1351   MCAuto<DataArrayIdType> arr2=arr1->checkAndPreparePermutation();
1352   const mcIdType *arrPtr2=arr2->getConstPointer();
1353   int i=0;
1354   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
1355     {
1356       mcIdType pos=arrPtr2[i];
1357       mcIdType nbCells=mesh->getNumberOfCellsWithType(*it);
1358       code[3*pos]=(mcIdType)(*it);
1359       code[3*pos+1]=nbCells;
1360       code[3*pos+2]=-1;//no profiles
1361     }
1362   std::vector<const DataArrayIdType *> idsPerType;//no profiles
1363   DataArrayIdType *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
1364   if(da)
1365     {
1366       da->decrRef();
1367       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
1368     }
1369   return code;
1370 }
1371
1372 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1373 {
1374   return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1375 }
1376
1377 /*!
1378  * Returns all attributes and values of parts of \a this field lying on a given mesh.
1379  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
1380  * item of every of returned sequences refers to the _i_-th part of \a this field.
1381  * Thus all sequences returned by this method are of the same length equal to number
1382  * of different types of supporting entities.<br>
1383  * A field part can include sub-parts with several different spatial discretizations,
1384  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
1385  * for example. Hence, some of the returned sequences contains nested sequences, and an item
1386  * of a nested sequence corresponds to a type of spatial discretization.<br>
1387  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
1388  * The overhead is due to selecting values into new instances of DataArrayDouble.
1389  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
1390  *          for the case with only one underlying mesh. (Actually, the number of meshes is
1391  *          not checked if \a mname == \c NULL).
1392  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
1393  *          a field part is returned. 
1394  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
1395  *          A field part can include sub-parts with several different spatial discretizations,
1396  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
1397  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
1398  *          This sequence is of the same length as \a types. 
1399  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
1400  *          discretization. A profile name can be empty.
1401  *          Length of this and of nested sequences is the same as that of \a typesF.
1402  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
1403  *          discretization. A localization name can be empty.
1404  *          Length of this and of nested sequences is the same as that of \a typesF.
1405  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
1406  *          per each type of spatial discretization within one mesh entity type.
1407  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
1408  *          Length of this and of nested sequences is the same as that of \a typesF.
1409  *  \throw If no field is lying on \a mname.
1410  */
1411 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
1412 {
1413   if(mname.empty())
1414     if(_field_per_mesh.empty())
1415       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
1416   std::vector< std::vector< std::pair<mcIdType,mcIdType> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
1417   std::size_t nbOfRet=ret0.size();
1418   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
1419   for(std::size_t i=0;i<nbOfRet;i++)
1420     {
1421       const std::vector< std::pair<mcIdType,mcIdType> >& p=ret0[i];
1422       std::size_t nbOfRet1=p.size();
1423       ret[i].resize(nbOfRet1);
1424       for(std::size_t j=0;j<nbOfRet1;j++)
1425         {
1426           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
1427           ret[i][j]=tmp;
1428         }
1429     }
1430   return ret;
1431 }
1432
1433 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
1434 {
1435   return TYPE_STR;
1436 }
1437
1438 MEDFileInt32Field1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
1439 {
1440   MCAuto<MEDFileInt32Field1TSWithoutSDA> ret(new MEDFileInt32Field1TSWithoutSDA);
1441   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
1442   ret->deepCpyLeavesFrom(*this);
1443   const DataArrayDouble *arr(_arr);
1444   if(arr)
1445     {
1446       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
1447       ret->setArray(arr2);
1448     }
1449   return ret.retn();
1450 }
1451
1452 /*!
1453  * Returns a pointer to the underground DataArrayDouble instance and a
1454  * sequence describing parameters of a support of each part of \a this field. The
1455  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
1456  * direct access to the field values. This method is intended for the field lying on one
1457  * mesh only.
1458  *  \param [in,out] entries - the sequence describing parameters of a support of each
1459  *         part of \a this field. Each item of this sequence consists of two parts. The
1460  *         first part describes a type of mesh entity and an id of discretization of a
1461  *         current field part. The second part describes a range of values [begin,end)
1462  *         within the returned array relating to the current field part.
1463  *  \return DataArrayDouble * - the pointer to the field values array.
1464  *  \throw If the number of underlying meshes is not equal to 1.
1465  *  \throw If no field values are available.
1466  *  \sa getUndergroundDataArray()
1467  */
1468 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1469 {
1470   return getUndergroundDataArrayTemplateExt(entries);
1471 }
1472
1473 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,meshName,csit,iteration,order)
1474 {
1475   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
1476   arr->setInfoAndChangeNbOfCompo(infos);
1477 }
1478
1479 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
1480 {
1481 }
1482
1483 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
1484 {
1485   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
1486   ret->deepCpyLeavesFrom(*this);
1487   return ret.retn();
1488 }
1489
1490 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
1491 {
1492   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
1493   if(_arr.isNotNull())
1494     ret->_arr=_arr->deepCopy();
1495   return ret.retn();
1496 }
1497
1498 //= MEDFileInt32Field1TSWithoutSDA
1499
1500 MEDFileInt32Field1TSWithoutSDA *MEDFileInt32Field1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1501 {
1502   return new MEDFileInt32Field1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1503 }
1504
1505 MEDFileInt32Field1TSWithoutSDA::MEDFileInt32Field1TSWithoutSDA()
1506 {
1507 }
1508
1509 MEDFileInt32Field1TSWithoutSDA::MEDFileInt32Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1510                                                            const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
1511 {
1512   DataArrayInt32 *arr(getOrCreateAndGetArrayTemplate());
1513   arr->setInfoAndChangeNbOfCompo(infos);
1514 }
1515
1516 const char *MEDFileInt32Field1TSWithoutSDA::getTypeStr() const
1517 {
1518   return TYPE_STR;
1519 }
1520
1521 /*!
1522  * Returns a pointer to the underground DataArrayIdType instance and a
1523  * sequence describing parameters of a support of each part of \a this field. The
1524  * caller should not decrRef() the returned DataArrayIdType. This method allows for a
1525  * direct access to the field values. This method is intended for the field lying on one
1526  * mesh only.
1527  *  \param [in,out] entries - the sequence describing parameters of a support of each
1528  *         part of \a this field. Each item of this sequence consists of two parts. The
1529  *         first part describes a type of mesh entity and an id of discretization of a
1530  *         current field part. The second part describes a range of values [begin,end)
1531  *         within the returned array relating to the current field part.
1532  *  \return DataArrayIdType * - the pointer to the field values array.
1533  *  \throw If the number of underlying meshes is not equal to 1.
1534  *  \throw If no field values are available.
1535  *  \sa getUndergroundDataArray()
1536  */
1537 DataArray *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1538 {
1539   return getUndergroundDataArrayIntExt(entries);
1540 }
1541
1542 /*!
1543  * Returns a pointer to the underground DataArrayInt instance and a
1544  * sequence describing parameters of a support of each part of \a this field. The
1545  * caller should not decrRef() the returned DataArrayIdType. This method allows for a
1546  * direct access to the field values. This method is intended for the field lying on one
1547  * mesh only.
1548  *  \param [in,out] entries - the sequence describing parameters of a support of each
1549  *         part of \a this field. Each item of this sequence consists of two parts. The
1550  *         first part describes a type of mesh entity and an id of discretization of a
1551  *         current field part. The second part describes a range of values [begin,end)
1552  *         within the returned array relating to the current field part.
1553  *  \return DataArrayInt * - the pointer to the field values array.
1554  *  \throw If the number of underlying meshes is not equal to 1.
1555  *  \throw If no field values are available.
1556  *  \sa getUndergroundDataArray()
1557  */
1558 DataArrayInt32 *MEDFileInt32Field1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1559 {
1560   if(_field_per_mesh.size()!=1)
1561     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1562   if(_field_per_mesh[0]==0)
1563     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1564   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1565   return getUndergroundDataArrayTemplate();
1566 }
1567
1568 MEDFileInt32Field1TSWithoutSDA *MEDFileInt32Field1TSWithoutSDA::shallowCpy() const
1569 {
1570   MCAuto<MEDFileInt32Field1TSWithoutSDA> ret(new MEDFileInt32Field1TSWithoutSDA(*this));
1571   ret->deepCpyLeavesFrom(*this);
1572   return ret.retn();
1573 }
1574
1575 MEDFileInt32Field1TSWithoutSDA *MEDFileInt32Field1TSWithoutSDA::deepCopy() const
1576 {
1577   MCAuto<MEDFileInt32Field1TSWithoutSDA> ret(shallowCpy());
1578   if(_arr.isNotNull())
1579     ret->_arr=_arr->deepCopy();
1580   return ret.retn();
1581 }
1582
1583 //= MEDFileInt64Field1TSWithoutSDA
1584
1585 MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1586 {
1587   return new MEDFileInt64Field1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1588 }
1589
1590 MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA()
1591 {
1592 }
1593
1594 MEDFileInt64Field1TSWithoutSDA::MEDFileInt64Field1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1595                                                            const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<Int64>(fieldName,meshName,csit,iteration,order,infos)
1596 {
1597   DataArrayInt64 *arr(getOrCreateAndGetArrayTemplate());
1598   arr->setInfoAndChangeNbOfCompo(infos);
1599 }
1600
1601 const char *MEDFileInt64Field1TSWithoutSDA::getTypeStr() const
1602 {
1603   return TYPE_STR;
1604 }
1605
1606 /*!
1607  * Returns a pointer to the underground DataArrayIdType instance and a
1608  * sequence describing parameters of a support of each part of \a this field. The
1609  * caller should not decrRef() the returned DataArrayIdType. This method allows for a
1610  * direct access to the field values. This method is intended for the field lying on one
1611  * mesh only.
1612  *  \param [in,out] entries - the sequence describing parameters of a support of each
1613  *         part of \a this field. Each item of this sequence consists of two parts. The
1614  *         first part describes a type of mesh entity and an id of discretization of a
1615  *         current field part. The second part describes a range of values [begin,end)
1616  *         within the returned array relating to the current field part.
1617  *  \return DataArrayIdType * - the pointer to the field values array.
1618  *  \throw If the number of underlying meshes is not equal to 1.
1619  *  \throw If no field values are available.
1620  *  \sa getUndergroundDataArray()
1621  */
1622 DataArray *MEDFileInt64Field1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1623 {
1624   return getUndergroundDataArrayIntExt(entries);
1625 }
1626
1627 /*!
1628  * Returns a pointer to the underground DataArrayInt instance and a
1629  * sequence describing parameters of a support of each part of \a this field. The
1630  * caller should not decrRef() the returned DataArrayIdType. This method allows for a
1631  * direct access to the field values. This method is intended for the field lying on one
1632  * mesh only.
1633  *  \param [in,out] entries - the sequence describing parameters of a support of each
1634  *         part of \a this field. Each item of this sequence consists of two parts. The
1635  *         first part describes a type of mesh entity and an id of discretization of a
1636  *         current field part. The second part describes a range of values [begin,end)
1637  *         within the returned array relating to the current field part.
1638  *  \return DataArrayInt * - the pointer to the field values array.
1639  *  \throw If the number of underlying meshes is not equal to 1.
1640  *  \throw If no field values are available.
1641  *  \sa getUndergroundDataArray()
1642  */
1643 DataArrayInt64 *MEDFileInt64Field1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1644 {
1645   if(_field_per_mesh.size()!=1)
1646     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1647   if(_field_per_mesh[0]==0)
1648     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1649   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1650   return getUndergroundDataArrayTemplate();
1651 }
1652
1653 MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::shallowCpy() const
1654 {
1655   MCAuto<MEDFileInt64Field1TSWithoutSDA> ret(new MEDFileInt64Field1TSWithoutSDA(*this));
1656   ret->deepCpyLeavesFrom(*this);
1657   return ret.retn();
1658 }
1659
1660 MEDFileInt64Field1TSWithoutSDA *MEDFileInt64Field1TSWithoutSDA::deepCopy() const
1661 {
1662   MCAuto<MEDFileInt64Field1TSWithoutSDA> ret(shallowCpy());
1663   if(_arr.isNotNull())
1664     ret->_arr=_arr->deepCopy();
1665   return ret.retn();
1666 }
1667
1668 //= MEDFileFloatField1TSWithoutSDA
1669
1670 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1671 {
1672   return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1673 }
1674
1675 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
1676 {
1677 }
1678
1679 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1680                                                                const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
1681 {
1682   DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
1683   arr->setInfoAndChangeNbOfCompo(infos);
1684 }
1685
1686 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
1687 {
1688   return TYPE_STR;
1689 }
1690
1691 /*!
1692  * Returns a pointer to the underground DataArrayFloat instance and a
1693  * sequence describing parameters of a support of each part of \a this field. The
1694  * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1695  * direct access to the field values. This method is intended for the field lying on one
1696  * mesh only.
1697  *  \param [in,out] entries - the sequence describing parameters of a support of each
1698  *         part of \a this field. Each item of this sequence consists of two parts. The
1699  *         first part describes a type of mesh entity and an id of discretization of a
1700  *         current field part. The second part describes a range of values [begin,end)
1701  *         within the returned array relating to the current field part.
1702  *  \return DataArrayFloat * - the pointer to the field values array.
1703  *  \throw If the number of underlying meshes is not equal to 1.
1704  *  \throw If no field values are available.
1705  *  \sa getUndergroundDataArray()
1706  */
1707 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1708 {
1709   return getUndergroundDataArrayFloatExt(entries);
1710 }
1711
1712 /*!
1713  * Returns a pointer to the underground DataArrayFloat instance and a
1714  * sequence describing parameters of a support of each part of \a this field. The
1715  * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1716  * direct access to the field values. This method is intended for the field lying on one
1717  * mesh only.
1718  *  \param [in,out] entries - the sequence describing parameters of a support of each
1719  *         part of \a this field. Each item of this sequence consists of two parts. The
1720  *         first part describes a type of mesh entity and an id of discretization of a
1721  *         current field part. The second part describes a range of values [begin,end)
1722  *         within the returned array relating to the current field part.
1723  *  \return DataArrayFloat * - the pointer to the field values array.
1724  *  \throw If the number of underlying meshes is not equal to 1.
1725  *  \throw If no field values are available.
1726  *  \sa getUndergroundDataArray()
1727  */
1728 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const
1729 {
1730   if(_field_per_mesh.size()!=1)
1731     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1732   if(_field_per_mesh[0]==0)
1733     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1734   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1735   return getUndergroundDataArrayTemplate();
1736 }
1737
1738 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
1739 {
1740   MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
1741   ret->deepCpyLeavesFrom(*this);
1742   return ret.retn();
1743 }
1744
1745 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
1746 {
1747   MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
1748   if(_arr.isNotNull())
1749     ret->_arr=_arr->deepCopy();
1750   return ret.retn();
1751 }
1752
1753 //= MEDFileAnyTypeField1TS
1754
1755 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
1756 {
1757 }
1758
1759 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1760 {
1761   med_field_type typcha;
1762   //
1763   std::vector<std::string> infos;
1764   std::string dtunit,fieldName,meshName;
1765   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1766   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1767   switch(typcha)
1768   {
1769     case MED_FLOAT64:
1770       {
1771         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1772         break;
1773       }
1774     case MED_INT32:
1775       {
1776         ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1777         break;
1778       }
1779     case MED_INT64:
1780       {
1781         ret=MEDFileInt64Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1782         break;
1783       }
1784     case MED_FLOAT32:
1785       {
1786         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1787         break;
1788       }
1789     case MED_INT:
1790       {
1791         if(sizeof(med_int)==sizeof(int))
1792           {
1793             ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1794             break;
1795           }
1796       }
1797     default:
1798       {
1799         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_FLOAT32, MED_INT32, MED_INT64] !";
1800         throw INTERP_KERNEL::Exception(oss.str());
1801       }
1802   }
1803   ret->setDtUnit(dtunit.c_str());
1804   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1805   //
1806   med_int numdt,numit;
1807   med_float dt;
1808   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1809   ret->setTime(FromMedInt<int>(numdt),FromMedInt<int>(numit),dt);
1810   ret->_csit=1;
1811   if(loadAll)
1812     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1813   else
1814     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1815   return ret.retn();
1816 }
1817
1818 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1819 try:MEDFileFieldGlobsReal(fid)
1820 {
1821   _content=BuildContentFrom(fid,loadAll,ms,entities);
1822   loadGlobals(fid);
1823 }
1824 catch(INTERP_KERNEL::Exception& e)
1825 {
1826     throw e;
1827 }
1828
1829 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1830 {
1831   med_field_type typcha;
1832   std::vector<std::string> infos;
1833   std::string dtunit,meshName;
1834   int nbSteps(0);
1835   {
1836     int iii=-1;
1837     nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
1838   }
1839   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1840   switch(typcha)
1841   {
1842     case MED_FLOAT64:
1843       {
1844         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1845         break;
1846       }
1847     case MED_INT32:
1848       {
1849         ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1850         break;
1851       }
1852     case MED_INT64:
1853       {
1854         ret=MEDFileInt64Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1855         break;
1856       }
1857     case MED_FLOAT32:
1858       {
1859         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1860         break;
1861       }
1862     case MED_INT:
1863       {
1864         if(sizeof(med_int)==sizeof(int))
1865           {
1866             ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1867             break;
1868           }
1869       }
1870     default:
1871       {
1872         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32, MED_INT64] !";
1873         throw INTERP_KERNEL::Exception(oss.str());
1874       }
1875   }
1876   ret->setMeshName(meshName);
1877   ret->setDtUnit(dtunit.c_str());
1878   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1879   //
1880   if(nbSteps<1)
1881     {
1882       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
1883       throw INTERP_KERNEL::Exception(oss.str());
1884     }
1885   //
1886   med_int numdt,numit;
1887   med_float dt;
1888   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1889   ret->setTime(FromMedInt<int>(numdt),FromMedInt<int>(numit),dt);
1890   ret->_csit=1;
1891   if(loadAll)
1892     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1893   else
1894     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1895   return ret.retn();
1896 }
1897
1898 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1899 try:MEDFileFieldGlobsReal(fid)
1900 {
1901   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1902   loadGlobals(fid);
1903 }
1904 catch(INTERP_KERNEL::Exception& e)
1905 {
1906     throw e;
1907 }
1908
1909 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
1910 {
1911   if(!c)
1912     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1913   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
1914     {
1915       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
1916       ret->_content=c; c->incrRef();
1917       return ret.retn();
1918     }
1919   if(dynamic_cast<const MEDFileInt32Field1TSWithoutSDA *>(c))
1920     {
1921       MCAuto<MEDFileInt32Field1TS> ret(MEDFileInt32Field1TS::New());
1922       ret->_content=c; c->incrRef();
1923       return ret.retn();
1924     }
1925   if(dynamic_cast<const MEDFileInt64Field1TSWithoutSDA *>(c))
1926     {
1927       MCAuto<MEDFileInt64Field1TS> ret(MEDFileInt64Field1TS::New());
1928       ret->_content=c; c->incrRef();
1929       return ret.retn();
1930     }
1931   if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
1932     {
1933       MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
1934       ret->_content=c; c->incrRef();
1935       return ret.retn();
1936     }
1937   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1938 }
1939
1940 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
1941 {
1942   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
1943   ret->setFileName(FileNameFromFID(fid));
1944   return ret;
1945 }
1946
1947 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
1948 {
1949   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1950   return New(fid,loadAll);
1951 }
1952
1953 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
1954 {
1955   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
1956   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1957   ret->loadGlobals(fid);
1958   return ret.retn();
1959 }
1960
1961 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1962 {
1963   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1964   return New(fid,fieldName,loadAll);
1965 }
1966
1967 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1968 {
1969   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1970   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1971   ret->loadGlobals(fid);
1972   return ret.retn();
1973 }
1974
1975 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
1976 {
1977   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1978   return New(fid,fieldName,iteration,order,loadAll);
1979 }
1980
1981 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
1982 {
1983   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
1984   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1985   ret->loadGlobals(fid);
1986   return ret.retn();
1987 }
1988
1989 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1990 {
1991   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1992   return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
1993 }
1994
1995 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1996 {
1997   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
1998   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1999   ret->loadGlobals(fid);
2000   return ret.retn();
2001 }
2002
2003 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2004 {
2005   med_field_type typcha;
2006   std::vector<std::string> infos;
2007   std::string dtunit,meshName;
2008   int iii(-1);
2009   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
2010   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
2011   switch(typcha)
2012   {
2013     case MED_FLOAT64:
2014       {
2015         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
2016         break;
2017       }
2018     case MED_INT32:
2019       {
2020         ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
2021         break;
2022       }
2023     case MED_INT64:
2024       {
2025         ret=MEDFileInt64Field1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
2026         break;
2027       }
2028     case MED_FLOAT32:
2029       {
2030         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
2031         break;
2032       }
2033     case MED_INT:
2034       {
2035         if(sizeof(med_int)==sizeof(int))
2036           {
2037             ret=MEDFileInt32Field1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
2038             break;
2039           }
2040       }
2041     default:
2042       {
2043         std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32, MED_FLOAT32, MED_INT64] !";
2044         throw INTERP_KERNEL::Exception(oss.str());
2045       }
2046   }
2047   ret->setDtUnit(dtunit.c_str());
2048   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
2049   //
2050   bool found=false;
2051   std::vector< std::pair<int,int> > dtits(nbOfStep2);
2052   for(int i=0;i<nbOfStep2 && !found;i++)
2053     {
2054       med_int numdt,numit;
2055       med_float dt;
2056       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
2057       if(numdt==iteration && numit==order)
2058         {
2059           found=true;
2060           ret->_csit=i+1;
2061         }
2062       else
2063         dtits[i]=std::pair<int,int>(numdt,numit);
2064     }
2065   if(!found)
2066     {
2067       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
2068       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
2069         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
2070       throw INTERP_KERNEL::Exception(oss.str());
2071     }
2072   if(loadAll)
2073     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
2074   else
2075     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
2076   return ret.retn();
2077 }
2078
2079 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
2080 try:MEDFileFieldGlobsReal(fid)
2081 {
2082   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
2083   loadGlobals(fid);
2084 }
2085 catch(INTERP_KERNEL::Exception& e)
2086 {
2087     throw e;
2088 }
2089
2090 /*!
2091  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
2092  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
2093  *
2094  * \warning this is a shallow copy constructor
2095  */
2096 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
2097 {
2098   if(!shallowCopyOfContent)
2099     {
2100       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
2101       otherPtr->incrRef();
2102       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
2103     }
2104   else
2105     {
2106       _content=other.shallowCpy();
2107     }
2108 }
2109
2110 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
2111 {
2112   if(checkFieldId)
2113     {
2114       med_int nbFields=MEDnField(fid);
2115       if(fieldIdCFormat>=nbFields)
2116         {
2117           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
2118           throw INTERP_KERNEL::Exception(oss.str());
2119         }
2120     }
2121   med_int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
2122   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2123   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2124   INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
2125   INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2126   INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2127   med_bool localMesh;
2128   med_int nbOfStep;
2129   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
2130   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
2131   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
2132   meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
2133   infos.clear(); infos.resize(ncomp);
2134   for(int j=0;j<ncomp;j++)
2135     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
2136   return FromMedInt<int>(nbOfStep);
2137 }
2138
2139 /*!
2140  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
2141  * 
2142  * \param [out]
2143  * \return in case of success the number of time steps available for the field with name \a fieldName.
2144  */
2145 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
2146 {
2147   med_int nbFields=MEDnField(fid);
2148   bool found=false;
2149   std::vector<std::string> fns(nbFields);
2150   int nbOfStep2(-1);
2151   for(int i=0;i<nbFields && !found;i++)
2152     {
2153       std::string tmp,tmp2;
2154       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
2155       fns[i]=tmp;
2156       found=(tmp==fieldName);
2157       if(found)
2158         {
2159           posCFormat=i;
2160           meshName=tmp2;
2161         }
2162     }
2163   if(!found)
2164     {
2165       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
2166       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
2167         oss << "\"" << *it << "\" ";
2168       throw INTERP_KERNEL::Exception(oss.str());
2169     }
2170   return nbOfStep2;
2171 }
2172
2173 /*!
2174  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2175  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2176  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2177  * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2178  * to keep a valid instance.
2179  * 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.
2180  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
2181  * 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.
2182  *
2183  * \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.
2184  * \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.
2185  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
2186  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2187  * \param [in] newLocName is the new localization name.
2188  * \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.
2189  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
2190  */
2191 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
2192 {
2193   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2194   std::string oldPflName=disc->getProfile();
2195   std::vector<std::string> vv=getPflsReallyUsedMulti();
2196   std::size_t nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
2197   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
2198     {
2199       disc->setProfile(newPflName);
2200       DataArrayIdType *pfl=getProfile(oldPflName.c_str());
2201       pfl->setName(newPflName);
2202     }
2203   else
2204     {
2205       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
2206       throw INTERP_KERNEL::Exception(oss.str());
2207     }
2208 }
2209
2210 /*!
2211  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2212  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2213  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2214  * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2215  * to keep a valid instance.
2216  * 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.
2217  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
2218  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
2219  * 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.
2220  *
2221  * \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.
2222  * \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.
2223  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
2224  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2225  * \param [in] newLocName is the new localization name.
2226  * \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.
2227  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
2228  */
2229 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
2230 {
2231   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2232   std::string oldLocName=disc->getLocalization();
2233   std::vector<std::string> vv=getLocsReallyUsedMulti();
2234   std::size_t nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
2235   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
2236     {
2237       disc->setLocalization(newLocName);
2238       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
2239       loc.setName(newLocName);
2240     }
2241   else
2242     {
2243       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
2244       throw INTERP_KERNEL::Exception(oss.str());
2245     }
2246 }
2247
2248 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
2249 {
2250   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2251   if(!ret)
2252     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
2253   return ret;
2254 }
2255
2256 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
2257 {
2258   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2259   if(!ret)
2260     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
2261   return ret;
2262 }
2263
2264 /*!
2265  * This method alloc the arrays and load potentially huge arrays contained in this field.
2266  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
2267  * This method can be also called to refresh or reinit values from a file.
2268  * 
2269  * \throw If the fileName is not set or points to a non readable MED file.
2270  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2271  */
2272 void MEDFileAnyTypeField1TS::loadArrays()
2273 {
2274   if(getFileName().empty())
2275     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
2276   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2277   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
2278 }
2279
2280 /*!
2281  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
2282  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
2283  * this method does not throw if \a this does not come from file read.
2284  * 
2285  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
2286  */
2287 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
2288 {
2289   if(!getFileName().empty())
2290     {
2291       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2292       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
2293     }
2294 }
2295
2296 /*!
2297  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
2298  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
2299  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
2300  * 
2301  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
2302  */
2303 void MEDFileAnyTypeField1TS::unloadArrays()
2304 {
2305   contentNotNullBase()->unloadArrays();
2306 }
2307
2308 /*!
2309  * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
2310  * This method is the symmetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
2311  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
2312  * 
2313  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2314  */
2315 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
2316 {
2317   if(!getFileName().empty())
2318     contentNotNullBase()->unloadArrays();
2319 }
2320
2321 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
2322 {
2323   std::size_t nbComp(getNumberOfComponents());
2324   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2325   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2326   for(std::size_t i=0;i<nbComp;i++)
2327     {
2328       std::string info=getInfo()[i];
2329       std::string c,u;
2330       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
2331       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
2332       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
2333     }
2334   if(getName().empty())
2335     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
2336   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),ToMedInt(nbComp),comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
2337   writeGlobals(fid,*this);
2338   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
2339 }
2340
2341 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
2342 {
2343   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
2344 }
2345
2346 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
2347 {
2348   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
2349   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
2350   return ret;
2351 }
2352
2353 /*!
2354  * Returns a string describing \a this field. This string is outputted 
2355  * by \c print Python command.
2356  */
2357 std::string MEDFileAnyTypeField1TS::simpleRepr() const
2358 {
2359   std::ostringstream oss;
2360   contentNotNullBase()->simpleRepr(0,oss,-1);
2361   simpleReprGlobs(oss);
2362   return oss.str();
2363 }
2364
2365 /*!
2366  * This method returns all profiles whose name is non empty used.
2367  * \b WARNING If profile is used several times it will be reported \b only \b once.
2368  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
2369  */
2370 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
2371 {
2372   return contentNotNullBase()->getPflsReallyUsed2();
2373 }
2374
2375 /*!
2376  * This method returns all localizations whose name is non empty used.
2377  * \b WARNING If localization is used several times it will be reported \b only \b once.
2378  */
2379 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
2380 {
2381   return contentNotNullBase()->getLocsReallyUsed2();
2382 }
2383
2384 /*!
2385  * This method returns all profiles whose name is non empty used.
2386  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
2387  */
2388 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
2389 {
2390   return contentNotNullBase()->getPflsReallyUsedMulti2();
2391 }
2392
2393 /*!
2394  * This method returns all localizations whose name is non empty used.
2395  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
2396  */
2397 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
2398 {
2399   return contentNotNullBase()->getLocsReallyUsedMulti2();
2400 }
2401
2402 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2403 {
2404   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
2405 }
2406
2407 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2408 {
2409   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
2410 }
2411
2412 int MEDFileAnyTypeField1TS::getDimension() const
2413 {
2414   return contentNotNullBase()->getDimension();
2415 }
2416
2417 int MEDFileAnyTypeField1TS::getIteration() const
2418 {
2419   return contentNotNullBase()->getIteration();
2420 }
2421
2422 int MEDFileAnyTypeField1TS::getOrder() const
2423 {
2424   return contentNotNullBase()->getOrder();
2425 }
2426
2427 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
2428 {
2429   return contentNotNullBase()->getTime(iteration,order);
2430 }
2431
2432 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
2433 {
2434   contentNotNullBase()->setTime(iteration,order,val);
2435 }
2436
2437 std::string MEDFileAnyTypeField1TS::getName() const
2438 {
2439   return contentNotNullBase()->getName();
2440 }
2441
2442 void MEDFileAnyTypeField1TS::setName(const std::string& name)
2443 {
2444   contentNotNullBase()->setName(name);
2445 }
2446
2447 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
2448 {
2449   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
2450 }
2451
2452 std::string MEDFileAnyTypeField1TS::getDtUnit() const
2453 {
2454   return contentNotNullBase()->getDtUnit();
2455 }
2456
2457 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
2458 {
2459   contentNotNullBase()->setDtUnit(dtUnit);
2460 }
2461
2462 std::string MEDFileAnyTypeField1TS::getMeshName() const
2463 {
2464   return contentNotNullBase()->getMeshName();
2465 }
2466
2467 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
2468 {
2469   contentNotNullBase()->setMeshName(newMeshName);
2470 }
2471
2472 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2473 {
2474   return contentNotNullBase()->changeMeshNames(modifTab);
2475 }
2476
2477 int MEDFileAnyTypeField1TS::getMeshIteration() const
2478 {
2479   return contentNotNullBase()->getMeshIteration();
2480 }
2481
2482 int MEDFileAnyTypeField1TS::getMeshOrder() const
2483 {
2484   return contentNotNullBase()->getMeshOrder();
2485 }
2486
2487 std::size_t MEDFileAnyTypeField1TS::getNumberOfComponents() const
2488 {
2489   return contentNotNullBase()->getNumberOfComponents();
2490 }
2491
2492 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
2493 {
2494   return contentNotNullBase()->isDealingTS(iteration,order);
2495 }
2496
2497 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
2498 {
2499   return contentNotNullBase()->getDtIt();
2500 }
2501
2502 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
2503 {
2504   contentNotNullBase()->fillIteration(p);
2505 }
2506
2507 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
2508 {
2509   contentNotNullBase()->fillTypesOfFieldAvailable(types);
2510 }
2511
2512 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
2513 {
2514   contentNotNullBase()->setInfo(infos);
2515 }
2516
2517 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
2518 {
2519   return contentNotNullBase()->getInfo();
2520 }
2521 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
2522 {
2523   return contentNotNullBase()->getInfo();
2524 }
2525
2526 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
2527 {
2528   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
2529 }
2530
2531 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
2532 {
2533   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2534 }
2535
2536 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
2537 {
2538   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2539 }
2540
2541 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
2542 {
2543   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
2544 }
2545
2546 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
2547 {
2548   return contentNotNullBase()->convertMedBallIntoClassic();
2549 }
2550
2551 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayIdType *pfl)
2552 {
2553   return contentNotNullBase()->makeReduction(ct,tof,pfl);
2554 }
2555
2556 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
2557 {
2558   return contentNotNullBase()->getTypesOfFieldAvailable();
2559 }
2560
2561 std::vector< std::vector<std::pair<mcIdType,mcIdType> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
2562                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2563 {
2564   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
2565 }
2566
2567 /*!
2568  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
2569  * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
2570  * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
2571  */
2572 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
2573 {
2574   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2575   if(!content)
2576     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
2577   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
2578   std::size_t sz(contentsSplit.size());
2579   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2580   for(std::size_t i=0;i<sz;i++)
2581     {
2582       ret[i]=shallowCpy();
2583       ret[i]->_content=contentsSplit[i];
2584     }
2585   return ret;
2586 }
2587
2588 /*!
2589  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
2590  * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2591  */
2592 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
2593 {
2594   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2595   if(!content)
2596     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
2597   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
2598   std::size_t sz(contentsSplit.size());
2599   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2600   for(std::size_t i=0;i<sz;i++)
2601     {
2602       ret[i]=shallowCpy();
2603       ret[i]->_content=contentsSplit[i];
2604     }
2605   return ret;
2606 }
2607
2608 /*!
2609  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
2610  * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2611  */
2612 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
2613 {
2614   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2615   if(!content)
2616     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
2617   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
2618   std::size_t sz(contentsSplit.size());
2619   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2620   for(std::size_t i=0;i<sz;i++)
2621     {
2622       ret[i]=shallowCpy();
2623       ret[i]->_content=contentsSplit[i];
2624     }
2625   return ret;
2626 }
2627
2628 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
2629 {
2630   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
2631   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
2632     ret->_content=_content->deepCopy();
2633   ret->deepCpyGlobs(*this);
2634   return ret.retn();
2635 }
2636
2637 mcIdType MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
2638 {
2639   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
2640   return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
2641 }
2642
2643 mcIdType MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
2644 {
2645   return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
2646 }
2647
2648 //= MEDFileField1TS
2649
2650 /*!
2651  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2652  * following the given input policy.
2653  *
2654  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2655  *                            By default (true) the globals are deeply copied.
2656  * \return MEDFileInt32Field1TS * - a new object that is the result of the conversion of \a this to int32 field.
2657  */
2658 MEDFileInt32Field1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
2659 {
2660   MCAuto<MEDFileInt32Field1TS> ret;
2661   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2662   if(content)
2663     {
2664       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
2665       if(!contc)
2666         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2667       MCAuto<MEDFileInt32Field1TSWithoutSDA> newc(contc->convertToInt());
2668       ret=static_cast<MEDFileInt32Field1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileInt32Field1TSWithoutSDA *)newc));
2669     }
2670   else
2671     ret=MEDFileInt32Field1TS::New();
2672   if(isDeepCpyGlobs)
2673     ret->deepCpyGlobs(*this);
2674   else
2675     ret->shallowCpyGlobs(*this);
2676   return ret.retn();
2677 }
2678
2679 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2680 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
2681 {
2682 }
2683 catch(INTERP_KERNEL::Exception& e)
2684 { throw e; }
2685
2686 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
2687 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
2688 {
2689 }
2690 catch(INTERP_KERNEL::Exception& e)
2691 { throw e; }
2692
2693 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
2694 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
2695 {
2696 }
2697 catch(INTERP_KERNEL::Exception& e)
2698 { throw e; }
2699
2700 /*!
2701  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
2702  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
2703  *
2704  * \warning this is a shallow copy constructor
2705  */
2706 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
2707 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
2708 {
2709 }
2710 catch(INTERP_KERNEL::Exception& e)
2711 { throw e; }
2712
2713 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
2714 {
2715   return new MEDFileField1TS(*this);
2716 }
2717
2718 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
2719                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2720 {
2721   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
2722 }
2723
2724 //= MEDFileInt32Field1TS
2725
2726 MCAuto<MEDCouplingFieldDouble> MEDFileInt32Field1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt32 *f)
2727 {
2728   if(!f)
2729     throw INTERP_KERNEL::Exception("MEDFileInt32Field1TS::ConvertFieldIntToFieldDouble : null input field !");
2730   int t1,t2;
2731   double t0(f->getTime(t1,t2));
2732   std::string tu(f->getTimeUnit());
2733   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
2734   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
2735   ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
2736   return ret;
2737 }
2738
2739 //= MEDFileInt64Field1TS
2740
2741 MCAuto<MEDCouplingFieldDouble> MEDFileInt64Field1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt64 *f)
2742 {
2743   if(!f)
2744     throw INTERP_KERNEL::Exception("MEDFileInt64Field1TS::ConvertFieldIntToFieldDouble : null input field !");
2745   int t1,t2;
2746   double t0(f->getTime(t1,t2));
2747   std::string tu(f->getTimeUnit());
2748   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
2749   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
2750   ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
2751   return ret;
2752 }
2753