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