Salome HOME
Typo-fix by Kunda
[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 splitting 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  *  \param [in] nasc - the name scope used to assign names. Depends on the caller on the top call stack
865  *  \param [in] smartPflKiller - specifies if this method tries at most to avoid profiles
866  *  \throw If either \a field or \a mesh or \a profile has an empty name.
867  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
868  *  \throw If the data array of \a field is not set.
869  *  \throw If \a this->_arr is already allocated but has different number of components
870  *         than \a field.
871  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
872  *  \sa setFieldNoProfileSBT()
873  */
874 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, bool smartPflKiller)
875 {
876   if(!field)
877     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
878   if(!arrOfVals || !arrOfVals->isAllocated())
879     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
880   TypeOfField type=field->getTypeOfField();
881   std::vector<DataArrayInt *> idsInPflPerType;
882   std::vector<DataArrayInt *> idsPerType;
883   std::vector<int> code,code2;
884   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
885   if(type!=ON_NODES)
886     {
887       m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType,smartPflKiller);
888       std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
889       std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin()); 
890       std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
891       // start of check
892       MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
893       int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
894       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
895         {
896           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
897           throw INTERP_KERNEL::Exception(oss.str());
898         }
899       // end of check
900       int start(copyTinyInfoFrom(th,field,arrOfVals));
901       code2=m->getDistributionOfTypes();
902       //
903       int pos=addNewEntryIfNecessary(m);
904       _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
905     }
906   else
907     {
908       if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
909         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
910       std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
911       std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
912       int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
913       if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
914         {
915           std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
916           throw INTERP_KERNEL::Exception(oss.str());
917         }
918       int start(copyTinyInfoFrom(th,field,arrOfVals));
919       int pos(addNewEntryIfNecessary(m));
920       _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
921     }
922 }
923
924 /*!
925  * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
926  */
927 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
928 {
929   if(_nb_of_tuples_to_be_allocated>=0)
930     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 !");
931   DataArray *arr(getOrCreateAndGetArray());
932   arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
933   _nb_of_tuples_to_be_allocated=-3;
934 }
935
936 /*!
937  * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
938  * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
939  * larger by the size of \a field. Returns an id of the first not filled
940  * tuple of \a this->_arr.
941  *  \param [in] field - the field to copy the info on components and the name from.
942  *  \return int - the id of first not initialized tuple of \a this->_arr.
943  *  \throw If the name of \a field is empty.
944  *  \throw If the data array of \a field is not set.
945  *  \throw If \a this->_arr is already allocated but has different number of components
946  *         than \a field.
947  */
948 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
949 {
950   if(!field)
951     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
952   std::string name(field->getName());
953   setName(name.c_str());
954   if(field->getMesh())
955     setMeshName(field->getMesh()->getName());
956   setDtUnit(th->getTimeUnit());
957   if(name.empty())
958     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
959   if(!arr)
960     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
961   if(!arr->isAllocated())
962     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
963   _dt=th->getTime(_iteration,_order);
964   getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
965   if(!getOrCreateAndGetArray()->isAllocated())
966     {
967       allocNotFromFile(arr->getNumberOfTuples());
968       return 0;
969     }
970   else
971     {
972       int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
973       int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
974       getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
975       _nb_of_tuples_to_be_allocated=-3;
976       return oldNbOfTuples;
977     }
978 }
979
980 /*!
981  * Returns number of components in \a this field
982  *  \return int - the number of components.
983  */
984 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
985 {
986   return getOrCreateAndGetArray()->getNumberOfComponents();
987 }
988
989 /*!
990  * Change info on components in \a this.
991  * \throw If size of \a infos is not equal to the number of components already in \a this.
992  */
993 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
994 {
995   DataArray *arr=getOrCreateAndGetArray();
996   arr->setInfoOnComponents(infos);//will throw an exception if number of components mismatches
997 }
998
999 /*!
1000  * Returns info on components of \a this field.
1001  *  \return const std::vector<std::string>& - a sequence of strings each being an
1002  *          information on _i_-th component.
1003  */
1004 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
1005 {
1006   const DataArray *arr=getOrCreateAndGetArray();
1007   return arr->getInfoOnComponents();
1008 }
1009
1010 /*!
1011  * Returns a mutable info on components of \a this field.
1012  *  \return std::vector<std::string>& - a sequence of strings each being an
1013  *          information on _i_-th component.
1014  */
1015 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
1016 {
1017   DataArray *arr=getOrCreateAndGetArray();
1018   return arr->getInfoOnComponents();
1019 }
1020
1021 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
1022 {
1023   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1024     {
1025       const MEDFileFieldPerMesh *fpm(*it);
1026       if(!fpm)
1027         continue;
1028       if(fpm->presenceOfMultiDiscPerGeoType())
1029         return true;
1030     }
1031   return false;
1032 }
1033
1034 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
1035 {
1036   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1037     if((*it).isNotNull())
1038       if((*it)->presenceOfStructureElements())
1039         return true;
1040   return false;
1041 }
1042
1043 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
1044 {
1045   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1046     if((*it).isNotNull())
1047       if(!(*it)->onlyStructureElements())
1048         return false;
1049   return true;
1050 }
1051
1052 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
1053 {
1054   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1055     if((*it).isNotNull())
1056       (*it)->killStructureElements();
1057 }
1058
1059 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
1060 {
1061   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1062     if((*it).isNotNull())
1063       (*it)->keepOnlyStructureElements();
1064 }
1065
1066 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
1067 {
1068   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1069     if((*it).isNotNull())
1070       (*it)->keepOnlyOnSE(seName);
1071 }
1072
1073 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
1074 {
1075   for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1076     if((*it).isNotNull())
1077       (*it)->getMeshSENames(ps);
1078 }
1079
1080 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1081 {
1082   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 !";
1083   if(_field_per_mesh.empty())
1084     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
1085   if(_field_per_mesh.size()>1)
1086     throw INTERP_KERNEL::Exception(MSG0);
1087   if(_field_per_mesh[0].isNull())
1088     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
1089   const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
1090   std::set<TypeOfField> types;
1091   pm->fillTypesOfFieldAvailable(types);
1092   if(types.size()!=1)
1093     throw INTERP_KERNEL::Exception(MSG0);
1094   TypeOfField type(*types.begin());
1095   int meshDimRelToMax(0);
1096   if(type==ON_NODES)
1097     meshDimRelToMax=0;
1098   else
1099     {
1100       int myDim(std::numeric_limits<int>::max());
1101       bool isUnique(pm->isUniqueLevel(myDim));
1102       if(!isUnique)
1103         throw INTERP_KERNEL::Exception(MSG0);
1104       meshDimRelToMax=myDim-mesh->getMeshDimension();
1105       if(meshDimRelToMax>0)
1106         throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
1107     }
1108   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
1109 }
1110
1111 /*!
1112  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1113  *  \param [in] type - a spatial discretization of the new field.
1114  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1115  *  \param [in] mName - a name of the supporting mesh.
1116  *  \param [in] renumPol - specifies how to permute values of the result field according to
1117  *          the optional numbers of cells and nodes, if any. The valid values are
1118  *          - 0 - do not permute.
1119  *          - 1 - permute cells.
1120  *          - 2 - permute nodes.
1121  *          - 3 - permute cells and nodes.
1122  *
1123  *  \param [in] glob - the global data storing profiles and localization.
1124  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1125  *          caller is to delete this field using decrRef() as it is no more needed. 
1126  *  \throw If the MED file is not readable.
1127  *  \throw If there is no mesh named \a mName in the MED file.
1128  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1129  *  \throw If no field of \a this is lying on the mesh \a mName.
1130  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1131  */
1132 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1133 {
1134   MCAuto<MEDFileMesh> mm;
1135   if(mName.empty())
1136     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1137   else
1138     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1139   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1140 }
1141
1142 /*!
1143  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1144  *  \param [in] type - a spatial discretization of the new field.
1145  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1146  *  \param [in] renumPol - specifies how to permute values of the result field according to
1147  *          the optional numbers of cells and nodes, if any. The valid values are
1148  *          - 0 - do not permute.
1149  *          - 1 - permute cells.
1150  *          - 2 - permute nodes.
1151  *          - 3 - permute cells and nodes.
1152  *
1153  *  \param [in] glob - the global data storing profiles and localization.
1154  *  \param [in] mesh - the supporting mesh.
1155  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1156  *          caller is to delete this field using decrRef() as it is no more needed. 
1157  *  \throw If the MED file is not readable.
1158  *  \throw If no field of \a this is lying on \a mesh.
1159  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1160  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1161  */
1162 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1163 {
1164   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
1165   const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
1166   if(meshDimRelToMax==1)
1167     (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
1168   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
1169 }
1170
1171 /*!
1172  * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
1173  * given mesh. 
1174  *  \param [in] type - a spatial discretization of the new field.
1175  *  \param [in] mName - a name of the supporting mesh.
1176  *  \param [in] renumPol - specifies how to permute values of the result field according to
1177  *          the optional numbers of cells and nodes, if any. The valid values are
1178  *          - 0 - do not permute.
1179  *          - 1 - permute cells.
1180  *          - 2 - permute nodes.
1181  *          - 3 - permute cells and nodes.
1182  *
1183  *  \param [in] glob - the global data storing profiles and localization.
1184  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1185  *          caller is to delete this field using decrRef() as it is no more needed. 
1186  *  \throw If the MED file is not readable.
1187  *  \throw If there is no mesh named \a mName in the MED file.
1188  *  \throw If there are no mesh entities in the mesh.
1189  *  \throw If no field values of the given \a type are available.
1190  */
1191 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1192 {
1193   MCAuto<MEDFileMesh> mm;
1194   if(mName.empty())
1195     mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1196   else
1197     mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1198   int absDim=getDimension();
1199   int meshDimRelToMax=absDim-mm->getMeshDimension();
1200   return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1201 }
1202
1203 /*!
1204  * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1205  *  \param [in] type - a spatial discretization of the new field.
1206  *  \param [in] renumPol - specifies how to permute values of the result field according to
1207  *          the optional numbers of cells and nodes, if any. The valid values are
1208  *          - 0 - do not permute.
1209  *          - 1 - permute cells.
1210  *          - 2 - permute nodes.
1211  *          - 3 - permute cells and nodes.
1212  *
1213  *  \param [in] glob - the global data storing profiles and localization.
1214  *  \param [in] mesh - the supporting mesh.
1215  *  \param [in] cellRenum - the cell numbers array used for permutation of the result
1216  *         field according to \a renumPol.
1217  *  \param [in] nodeRenum - the node numbers array used for permutation of the result
1218  *         field according to \a renumPol.
1219  *  \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1220  *          caller is to delete this field using decrRef() as it is no more needed. 
1221  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1222  *  \throw If no field of \a this is lying on \a mesh.
1223  *  \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1224  */
1225 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
1226 {
1227   static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
1228   bool isPfl=false;
1229   MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
1230   switch(renumPol)
1231   {
1232     case 0:
1233       {
1234         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1235         return ret.retn();
1236       }
1237     case 3:
1238     case 1:
1239       {
1240         if(isPfl)
1241           throw INTERP_KERNEL::Exception(msg1);
1242         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1243         if(cellRenum)
1244           {
1245             if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
1246               {
1247                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1248                 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
1249                 throw INTERP_KERNEL::Exception(oss.str());
1250               }
1251             MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
1252             if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
1253             std::vector<DataArray *> arrOut2(1,arrOut);
1254             // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
1255             disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
1256             (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
1257           }
1258         if(renumPol==1)
1259           return ret.retn();
1260       }
1261     case 2:
1262       {
1263         //no need to test _field_per_mesh.empty() because geMeshName has already done it
1264         if(isPfl)
1265           throw INTERP_KERNEL::Exception(msg1);
1266         if(nodeRenum)
1267           {
1268             if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
1269               {
1270                 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1271                 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
1272                 throw INTERP_KERNEL::Exception(oss.str());
1273               }
1274             MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
1275             if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
1276               throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
1277             ret->renumberNodes(nodeRenumSafe->getConstPointer());
1278           }
1279         return ret.retn();
1280       }
1281     default:
1282       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
1283   }
1284 }
1285
1286 /*!
1287  * Returns values and a profile of the field of a given type lying on a given support.
1288  *  \param [in] type - a spatial discretization of the field.
1289  *  \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1290  *  \param [in] mesh - the supporting mesh.
1291  *  \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
1292  *          field of interest lies on. If the field lies on all entities of the given
1293  *          dimension, all ids in \a pfl are zero. The caller is to delete this array
1294  *          using decrRef() as it is no more needed.  
1295  *  \param [in] glob - the global data storing profiles and localization.
1296  *  \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
1297  *          field. The caller is to delete this array using decrRef() as it is no more needed.
1298  *  \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
1299  *  \throw If no field of \a this is lying on \a mesh.
1300  *  \throw If no field values of the given \a type are available.
1301  */
1302 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
1303 {
1304   MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
1305   MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
1306   ret->setName(nasc.getName().c_str());
1307   return ret.retn();
1308 }
1309
1310 //= MEDFileField1TSWithoutSDA
1311
1312 /*!
1313  * Throws if a given value is not a valid (non-extended) relative dimension.
1314  *  \param [in] meshDimRelToMax - the relative dimension value.
1315  *  \throw If \a meshDimRelToMax > 0.
1316  */
1317 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
1318 {
1319   if(meshDimRelToMax>0)
1320     throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
1321 }
1322
1323 /*!
1324  * Checks if elements of a given mesh are in the order suitable for writing 
1325  * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
1326  * vector describing types of elements and their number.
1327  *  \param [in] mesh - the mesh to check.
1328  *  \return std::vector<int> - a vector holding for each element type (1) item of
1329  *          INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1. 
1330  *          These values are in full-interlace mode.
1331  *  \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
1332  */
1333 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
1334 {
1335   if(!mesh)
1336     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
1337   std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
1338   int nbOfTypes=geoTypes.size();
1339   std::vector<int> code(3*nbOfTypes);
1340   MCAuto<DataArrayInt> arr1=DataArrayInt::New();
1341   arr1->alloc(nbOfTypes,1);
1342   int *arrPtr=arr1->getPointer();
1343   std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
1344   for(int i=0;i<nbOfTypes;i++,it++)
1345     arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
1346   MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
1347   const int *arrPtr2=arr2->getConstPointer();
1348   int i=0;
1349   for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
1350     {
1351       int pos=arrPtr2[i];
1352       int nbCells=mesh->getNumberOfCellsWithType(*it);
1353       code[3*pos]=(int)(*it);
1354       code[3*pos+1]=nbCells;
1355       code[3*pos+2]=-1;//no profiles
1356     }
1357   std::vector<const DataArrayInt *> idsPerType;//no profiles
1358   DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
1359   if(da)
1360     {
1361       da->decrRef();
1362       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
1363     }
1364   return code;
1365 }
1366
1367 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1368 {
1369   return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1370 }
1371
1372 /*!
1373  * Returns all attributes and values of parts of \a this field lying on a given mesh.
1374  * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
1375  * item of every of returned sequences refers to the _i_-th part of \a this field.
1376  * Thus all sequences returned by this method are of the same length equal to number
1377  * of different types of supporting entities.<br>
1378  * A field part can include sub-parts with several different spatial discretizations,
1379  * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
1380  * for example. Hence, some of the returned sequences contains nested sequences, and an item
1381  * of a nested sequence corresponds to a type of spatial discretization.<br>
1382  * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
1383  * The overhead is due to selecting values into new instances of DataArrayDouble.
1384  *  \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
1385  *          for the case with only one underlying mesh. (Actually, the number of meshes is
1386  *          not checked if \a mname == \c NULL).
1387  *  \param [in,out] types - a sequence of types of underlying mesh entities. A type per
1388  *          a field part is returned. 
1389  *  \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
1390  *          A field part can include sub-parts with several different spatial discretizations,
1391  *          \ref MEDCoupling::ON_CELLS "ON_CELLS" and 
1392  *          \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
1393  *          This sequence is of the same length as \a types. 
1394  *  \param [in,out] pfls - a sequence returning a profile name per each type of spatial
1395  *          discretization. A profile name can be empty.
1396  *          Length of this and of nested sequences is the same as that of \a typesF.
1397  *  \param [in,out] locs - a sequence returning a localization name per each type of spatial
1398  *          discretization. A localization name can be empty.
1399  *          Length of this and of nested sequences is the same as that of \a typesF.
1400  *  \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
1401  *          per each type of spatial discretization within one mesh entity type.
1402  *          The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
1403  *          Length of this and of nested sequences is the same as that of \a typesF.
1404  *  \throw If no field is lying on \a mname.
1405  */
1406 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
1407 {
1408   if(mname.empty())
1409     if(_field_per_mesh.empty())
1410       throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
1411   std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
1412   int nbOfRet=ret0.size();
1413   std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
1414   for(int i=0;i<nbOfRet;i++)
1415     {
1416       const std::vector< std::pair<int,int> >& p=ret0[i];
1417       int nbOfRet1=p.size();
1418       ret[i].resize(nbOfRet1);
1419       for(int j=0;j<nbOfRet1;j++)
1420         {
1421           DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
1422           ret[i][j]=tmp;
1423         }
1424     }
1425   return ret;
1426 }
1427
1428 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
1429 {
1430   return TYPE_STR;
1431 }
1432
1433 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
1434 {
1435   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
1436   ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
1437   ret->deepCpyLeavesFrom(*this);
1438   const DataArrayDouble *arr(_arr);
1439   if(arr)
1440     {
1441       MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
1442       ret->setArray(arr2);
1443     }
1444   return ret.retn();
1445 }
1446
1447 /*!
1448  * Returns a pointer to the underground DataArrayDouble instance and a
1449  * sequence describing parameters of a support of each part of \a this field. The
1450  * caller should not decrRef() the returned DataArrayDouble. This method allows for a
1451  * direct access to the field values. This method is intended for the field lying on one
1452  * mesh only.
1453  *  \param [in,out] entries - the sequence describing parameters of a support of each
1454  *         part of \a this field. Each item of this sequence consists of two parts. The
1455  *         first part describes a type of mesh entity and an id of discretization of a
1456  *         current field part. The second part describes a range of values [begin,end)
1457  *         within the returned array relating to the current field part.
1458  *  \return DataArrayDouble * - the pointer to the field values array.
1459  *  \throw If the number of underlying meshes is not equal to 1.
1460  *  \throw If no field values are available.
1461  *  \sa getUndergroundDataArray()
1462  */
1463 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1464 {
1465   return getUndergroundDataArrayTemplateExt(entries);
1466 }
1467
1468 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)
1469 {
1470   DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
1471   arr->setInfoAndChangeNbOfCompo(infos);
1472 }
1473
1474 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
1475 {
1476 }
1477
1478 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
1479 {
1480   MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
1481   ret->deepCpyLeavesFrom(*this);
1482   return ret.retn();
1483 }
1484
1485 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
1486 {
1487   MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
1488   if(_arr.isNotNull())
1489     ret->_arr=_arr->deepCopy();
1490   return ret.retn();
1491 }
1492
1493 //= MEDFileIntField1TSWithoutSDA
1494
1495 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1496 {
1497   return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1498 }
1499
1500 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
1501 {
1502 }
1503
1504 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1505                                                            const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
1506 {
1507   DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
1508   arr->setInfoAndChangeNbOfCompo(infos);
1509 }
1510
1511 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
1512 {
1513   return TYPE_STR;
1514 }
1515
1516 /*!
1517  * Returns a pointer to the underground DataArrayInt instance and a
1518  * sequence describing parameters of a support of each part of \a this field. The
1519  * caller should not decrRef() the returned DataArrayInt. This method allows for a
1520  * direct access to the field values. This method is intended for the field lying on one
1521  * mesh only.
1522  *  \param [in,out] entries - the sequence describing parameters of a support of each
1523  *         part of \a this field. Each item of this sequence consists of two parts. The
1524  *         first part describes a type of mesh entity and an id of discretization of a
1525  *         current field part. The second part describes a range of values [begin,end)
1526  *         within the returned array relating to the current field part.
1527  *  \return DataArrayInt * - the pointer to the field values array.
1528  *  \throw If the number of underlying meshes is not equal to 1.
1529  *  \throw If no field values are available.
1530  *  \sa getUndergroundDataArray()
1531  */
1532 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1533 {
1534   return getUndergroundDataArrayIntExt(entries);
1535 }
1536
1537 /*!
1538  * Returns a pointer to the underground DataArrayInt instance and a
1539  * sequence describing parameters of a support of each part of \a this field. The
1540  * caller should not decrRef() the returned DataArrayInt. This method allows for a
1541  * direct access to the field values. This method is intended for the field lying on one
1542  * mesh only.
1543  *  \param [in,out] entries - the sequence describing parameters of a support of each
1544  *         part of \a this field. Each item of this sequence consists of two parts. The
1545  *         first part describes a type of mesh entity and an id of discretization of a
1546  *         current field part. The second part describes a range of values [begin,end)
1547  *         within the returned array relating to the current field part.
1548  *  \return DataArrayInt * - the pointer to the field values array.
1549  *  \throw If the number of underlying meshes is not equal to 1.
1550  *  \throw If no field values are available.
1551  *  \sa getUndergroundDataArray()
1552  */
1553 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1554 {
1555   if(_field_per_mesh.size()!=1)
1556     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1557   if(_field_per_mesh[0]==0)
1558     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1559   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1560   return getUndergroundDataArrayTemplate();
1561 }
1562
1563 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
1564 {
1565   MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
1566   ret->deepCpyLeavesFrom(*this);
1567   return ret.retn();
1568 }
1569
1570 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
1571 {
1572   MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
1573   if(_arr.isNotNull())
1574     ret->_arr=_arr->deepCopy();
1575   return ret.retn();
1576 }
1577
1578 //= MEDFileFloatField1TSWithoutSDA
1579
1580 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1581 {
1582   return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1583 }
1584
1585 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
1586 {
1587 }
1588
1589 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1590                                                                const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
1591 {
1592   DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
1593   arr->setInfoAndChangeNbOfCompo(infos);
1594 }
1595
1596 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
1597 {
1598   return TYPE_STR;
1599 }
1600
1601 /*!
1602  * Returns a pointer to the underground DataArrayFloat instance and a
1603  * sequence describing parameters of a support of each part of \a this field. The
1604  * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1605  * direct access to the field values. This method is intended for the field lying on one
1606  * mesh only.
1607  *  \param [in,out] entries - the sequence describing parameters of a support of each
1608  *         part of \a this field. Each item of this sequence consists of two parts. The
1609  *         first part describes a type of mesh entity and an id of discretization of a
1610  *         current field part. The second part describes a range of values [begin,end)
1611  *         within the returned array relating to the current field part.
1612  *  \return DataArrayFloat * - the pointer to the field values array.
1613  *  \throw If the number of underlying meshes is not equal to 1.
1614  *  \throw If no field values are available.
1615  *  \sa getUndergroundDataArray()
1616  */
1617 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1618 {
1619   return getUndergroundDataArrayFloatExt(entries);
1620 }
1621
1622 /*!
1623  * Returns a pointer to the underground DataArrayFloat instance and a
1624  * sequence describing parameters of a support of each part of \a this field. The
1625  * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1626  * direct access to the field values. This method is intended for the field lying on one
1627  * mesh only.
1628  *  \param [in,out] entries - the sequence describing parameters of a support of each
1629  *         part of \a this field. Each item of this sequence consists of two parts. The
1630  *         first part describes a type of mesh entity and an id of discretization of a
1631  *         current field part. The second part describes a range of values [begin,end)
1632  *         within the returned array relating to the current field part.
1633  *  \return DataArrayFloat * - the pointer to the field values array.
1634  *  \throw If the number of underlying meshes is not equal to 1.
1635  *  \throw If no field values are available.
1636  *  \sa getUndergroundDataArray()
1637  */
1638 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1639 {
1640   if(_field_per_mesh.size()!=1)
1641     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1642   if(_field_per_mesh[0]==0)
1643     throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1644   _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1645   return getUndergroundDataArrayTemplate();
1646 }
1647
1648 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
1649 {
1650   MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
1651   ret->deepCpyLeavesFrom(*this);
1652   return ret.retn();
1653 }
1654
1655 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
1656 {
1657   MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
1658   if(_arr.isNotNull())
1659     ret->_arr=_arr->deepCopy();
1660   return ret.retn();
1661 }
1662
1663 //= MEDFileAnyTypeField1TS
1664
1665 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
1666 {
1667 }
1668
1669 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1670 {
1671   med_field_type typcha;
1672   //
1673   std::vector<std::string> infos;
1674   std::string dtunit,fieldName,meshName;
1675   LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1676   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1677   switch(typcha)
1678   {
1679     case MED_FLOAT64:
1680       {
1681         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1682         break;
1683       }
1684     case MED_INT32:
1685       {
1686         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1687         break;
1688       }
1689     case MED_FLOAT32:
1690       {
1691         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1692         break;
1693       }
1694     case MED_INT:
1695       {
1696         if(sizeof(med_int)==sizeof(int))
1697           {
1698             ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1699             break;
1700           }
1701       }
1702     default:
1703       {
1704         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] !";
1705         throw INTERP_KERNEL::Exception(oss.str());
1706       }
1707   }
1708   ret->setDtUnit(dtunit.c_str());
1709   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1710   //
1711   med_int numdt,numit;
1712   med_float dt;
1713   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1714   ret->setTime(numdt,numit,dt);
1715   ret->_csit=1;
1716   if(loadAll)
1717     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1718   else
1719     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1720   return ret.retn();
1721 }
1722
1723 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1724 try:MEDFileFieldGlobsReal(fid)
1725 {
1726   _content=BuildContentFrom(fid,loadAll,ms,entities);
1727   loadGlobals(fid);
1728 }
1729 catch(INTERP_KERNEL::Exception& e)
1730 {
1731     throw e;
1732 }
1733
1734 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1735 {
1736   med_field_type typcha;
1737   std::vector<std::string> infos;
1738   std::string dtunit,meshName;
1739   int nbSteps(0);
1740   {
1741     int iii=-1;
1742     nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
1743   }
1744   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1745   switch(typcha)
1746   {
1747     case MED_FLOAT64:
1748       {
1749         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1750         break;
1751       }
1752     case MED_INT32:
1753       {
1754         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1755         break;
1756       }
1757     case MED_FLOAT32:
1758       {
1759         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1760         break;
1761       }
1762     case MED_INT:
1763       {
1764         if(sizeof(med_int)==sizeof(int))
1765           {
1766             ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1767             break;
1768           }
1769       }
1770     default:
1771       {
1772         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] !";
1773         throw INTERP_KERNEL::Exception(oss.str());
1774       }
1775   }
1776   ret->setMeshName(meshName);
1777   ret->setDtUnit(dtunit.c_str());
1778   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1779   //
1780   if(nbSteps<1)
1781     {
1782       std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
1783       throw INTERP_KERNEL::Exception(oss.str());
1784     }
1785   //
1786   med_int numdt,numit;
1787   med_float dt;
1788   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1789   ret->setTime(numdt,numit,dt);
1790   ret->_csit=1;
1791   if(loadAll)
1792     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1793   else
1794     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1795   return ret.retn();
1796 }
1797
1798 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1799 try:MEDFileFieldGlobsReal(fid)
1800 {
1801   _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1802   loadGlobals(fid);
1803 }
1804 catch(INTERP_KERNEL::Exception& e)
1805 {
1806     throw e;
1807 }
1808
1809 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
1810 {
1811   if(!c)
1812     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1813   if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
1814     {
1815       MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
1816       ret->_content=c; c->incrRef();
1817       return ret.retn();
1818     }
1819   if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
1820     {
1821       MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
1822       ret->_content=c; c->incrRef();
1823       return ret.retn();
1824     }
1825   if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
1826     {
1827       MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
1828       ret->_content=c; c->incrRef();
1829       return ret.retn();
1830     }
1831   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1832 }
1833
1834 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
1835 {
1836   MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
1837   ret->setFileName(FileNameFromFID(fid));
1838   return ret;
1839 }
1840
1841 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
1842 {
1843   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1844   return New(fid,loadAll);
1845 }
1846
1847 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
1848 {
1849   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
1850   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1851   ret->loadGlobals(fid);
1852   return ret.retn();
1853 }
1854
1855 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1856 {
1857   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1858   return New(fid,fieldName,loadAll);
1859 }
1860
1861 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1862 {
1863   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1864   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1865   ret->loadGlobals(fid);
1866   return ret.retn();
1867 }
1868
1869 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
1870 {
1871   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1872   return New(fid,fieldName,iteration,order,loadAll);
1873 }
1874
1875 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
1876 {
1877   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
1878   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1879   ret->loadGlobals(fid);
1880   return ret.retn();
1881 }
1882
1883 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1884 {
1885   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1886   return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
1887 }
1888
1889 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1890 {
1891   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
1892   MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1893   ret->loadGlobals(fid);
1894   return ret.retn();
1895 }
1896
1897 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1898 {
1899   med_field_type typcha;
1900   std::vector<std::string> infos;
1901   std::string dtunit,meshName;
1902   int iii(-1);
1903   int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
1904   MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1905   switch(typcha)
1906   {
1907     case MED_FLOAT64:
1908       {
1909         ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1910         break;
1911       }
1912     case MED_INT32:
1913       {
1914         ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1915         break;
1916       }
1917     case MED_FLOAT32:
1918       {
1919         ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1920         break;
1921       }
1922     case MED_INT:
1923       {
1924         if(sizeof(med_int)==sizeof(int))
1925           {
1926             ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1927             break;
1928           }
1929       }
1930     default:
1931       {
1932         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] !";
1933         throw INTERP_KERNEL::Exception(oss.str());
1934       }
1935   }
1936   ret->setDtUnit(dtunit.c_str());
1937   ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1938   //
1939   bool found=false;
1940   std::vector< std::pair<int,int> > dtits(nbOfStep2);
1941   for(int i=0;i<nbOfStep2 && !found;i++)
1942     {
1943       med_int numdt,numit;
1944       med_float dt;
1945       MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
1946       if(numdt==iteration && numit==order)
1947         {
1948           found=true;
1949           ret->_csit=i+1;
1950         }
1951       else
1952         dtits[i]=std::pair<int,int>(numdt,numit);
1953     }
1954   if(!found)
1955     {
1956       std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
1957       for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
1958         oss << "(" << (*iter).first << "," << (*iter).second << "), ";
1959       throw INTERP_KERNEL::Exception(oss.str());
1960     }
1961   if(loadAll)
1962     ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1963   else
1964     ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1965   return ret.retn();
1966 }
1967
1968 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1969 try:MEDFileFieldGlobsReal(fid)
1970 {
1971   _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
1972   loadGlobals(fid);
1973 }
1974 catch(INTERP_KERNEL::Exception& e)
1975 {
1976     throw e;
1977 }
1978
1979 /*!
1980  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1981  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1982  *
1983  * \warning this is a shallow copy constructor
1984  */
1985 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
1986 {
1987   if(!shallowCopyOfContent)
1988     {
1989       const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
1990       otherPtr->incrRef();
1991       _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
1992     }
1993   else
1994     {
1995       _content=other.shallowCpy();
1996     }
1997 }
1998
1999 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)
2000 {
2001   if(checkFieldId)
2002     {
2003       int nbFields=MEDnField(fid);
2004       if(fieldIdCFormat>=nbFields)
2005         {
2006           std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
2007           throw INTERP_KERNEL::Exception(oss.str());
2008         }
2009     }
2010   int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
2011   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2012   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2013   INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
2014   INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2015   INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2016   med_bool localMesh;
2017   int nbOfStep;
2018   MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
2019   fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
2020   dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
2021   meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
2022   infos.clear(); infos.resize(ncomp);
2023   for(int j=0;j<ncomp;j++)
2024     infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
2025   return nbOfStep;
2026 }
2027
2028 /*!
2029  * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
2030  * 
2031  * \param [out]
2032  * \return in case of success the number of time steps available for the field with name \a fieldName.
2033  */
2034 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)
2035 {
2036   int nbFields=MEDnField(fid);
2037   bool found=false;
2038   std::vector<std::string> fns(nbFields);
2039   int nbOfStep2(-1);
2040   for(int i=0;i<nbFields && !found;i++)
2041     {
2042       std::string tmp,tmp2;
2043       nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
2044       fns[i]=tmp;
2045       found=(tmp==fieldName);
2046       if(found)
2047         {
2048           posCFormat=i;
2049           meshName=tmp2;
2050         }
2051     }
2052   if(!found)
2053     {
2054       std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
2055       for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
2056         oss << "\"" << *it << "\" ";
2057       throw INTERP_KERNEL::Exception(oss.str());
2058     }
2059   return nbOfStep2;
2060 }
2061
2062 /*!
2063  * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2064  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2065  * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2066  * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2067  * to keep a valid instance.
2068  * 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.
2069  * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
2070  * 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.
2071  *
2072  * \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.
2073  * \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.
2074  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
2075  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2076  * \param [in] newLocName is the new localization name.
2077  * \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.
2078  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
2079  */
2080 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
2081 {
2082   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2083   std::string oldPflName=disc->getProfile();
2084   std::vector<std::string> vv=getPflsReallyUsedMulti();
2085   int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
2086   if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
2087     {
2088       disc->setProfile(newPflName);
2089       DataArrayInt *pfl=getProfile(oldPflName.c_str());
2090       pfl->setName(newPflName);
2091     }
2092   else
2093     {
2094       std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
2095       throw INTERP_KERNEL::Exception(oss.str());
2096     }
2097 }
2098
2099 /*!
2100  * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2101  * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2102  * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2103  * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2104  * to keep a valid instance.
2105  * 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.
2106  * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
2107  * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
2108  * 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.
2109  *
2110  * \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.
2111  * \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.
2112  * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of 
2113  *             \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2114  * \param [in] newLocName is the new localization name.
2115  * \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.
2116  *             If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
2117  */
2118 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
2119 {
2120   MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2121   std::string oldLocName=disc->getLocalization();
2122   std::vector<std::string> vv=getLocsReallyUsedMulti();
2123   int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
2124   if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
2125     {
2126       disc->setLocalization(newLocName);
2127       MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
2128       loc.setName(newLocName);
2129     }
2130   else
2131     {
2132       std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
2133       throw INTERP_KERNEL::Exception(oss.str());
2134     }
2135 }
2136
2137 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
2138 {
2139   MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2140   if(!ret)
2141     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
2142   return ret;
2143 }
2144
2145 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
2146 {
2147   const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2148   if(!ret)
2149     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
2150   return ret;
2151 }
2152
2153 /*!
2154  * This method alloc the arrays and load potentially huge arrays contained in this field.
2155  * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
2156  * This method can be also called to refresh or reinit values from a file.
2157  * 
2158  * \throw If the fileName is not set or points to a non readable MED file.
2159  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2160  */
2161 void MEDFileAnyTypeField1TS::loadArrays()
2162 {
2163   if(getFileName().empty())
2164     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
2165   MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2166   contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
2167 }
2168
2169 /*!
2170  * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
2171  * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
2172  * this method does not throw if \a this does not come from file read.
2173  * 
2174  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
2175  */
2176 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
2177 {
2178   if(!getFileName().empty())
2179     {
2180       MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2181       contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
2182     }
2183 }
2184
2185 /*!
2186  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
2187  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
2188  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
2189  * 
2190  * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
2191  */
2192 void MEDFileAnyTypeField1TS::unloadArrays()
2193 {
2194   contentNotNullBase()->unloadArrays();
2195 }
2196
2197 /*!
2198  * 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.
2199  * This method is the symmetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
2200  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
2201  * 
2202  * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2203  */
2204 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
2205 {
2206   if(!getFileName().empty())
2207     contentNotNullBase()->unloadArrays();
2208 }
2209
2210 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
2211 {
2212   int nbComp(getNumberOfComponents());
2213   INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2214   INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2215   for(int i=0;i<nbComp;i++)
2216     {
2217       std::string info=getInfo()[i];
2218       std::string c,u;
2219       MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
2220       MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
2221       MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
2222     }
2223   if(getName().empty())
2224     throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
2225   MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
2226   writeGlobals(fid,*this);
2227   contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
2228 }
2229
2230 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
2231 {
2232   return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
2233 }
2234
2235 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
2236 {
2237   std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
2238   ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
2239   return ret;
2240 }
2241
2242 /*!
2243  * Returns a string describing \a this field. This string is outputted 
2244  * by \c print Python command.
2245  */
2246 std::string MEDFileAnyTypeField1TS::simpleRepr() const
2247 {
2248   std::ostringstream oss;
2249   contentNotNullBase()->simpleRepr(0,oss,-1);
2250   simpleReprGlobs(oss);
2251   return oss.str();
2252 }
2253
2254 /*!
2255  * This method returns all profiles whose name is non empty used.
2256  * \b WARNING If profile is used several times it will be reported \b only \b once.
2257  * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
2258  */
2259 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
2260 {
2261   return contentNotNullBase()->getPflsReallyUsed2();
2262 }
2263
2264 /*!
2265  * This method returns all localizations whose name is non empty used.
2266  * \b WARNING If localization is used several times it will be reported \b only \b once.
2267  */
2268 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
2269 {
2270   return contentNotNullBase()->getLocsReallyUsed2();
2271 }
2272
2273 /*!
2274  * This method returns all profiles whose name is non empty used.
2275  * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
2276  */
2277 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
2278 {
2279   return contentNotNullBase()->getPflsReallyUsedMulti2();
2280 }
2281
2282 /*!
2283  * This method returns all localizations whose name is non empty used.
2284  * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
2285  */
2286 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
2287 {
2288   return contentNotNullBase()->getLocsReallyUsedMulti2();
2289 }
2290
2291 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2292 {
2293   contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
2294 }
2295
2296 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2297 {
2298   contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
2299 }
2300
2301 int MEDFileAnyTypeField1TS::getDimension() const
2302 {
2303   return contentNotNullBase()->getDimension();
2304 }
2305
2306 int MEDFileAnyTypeField1TS::getIteration() const
2307 {
2308   return contentNotNullBase()->getIteration();
2309 }
2310
2311 int MEDFileAnyTypeField1TS::getOrder() const
2312 {
2313   return contentNotNullBase()->getOrder();
2314 }
2315
2316 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
2317 {
2318   return contentNotNullBase()->getTime(iteration,order);
2319 }
2320
2321 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
2322 {
2323   contentNotNullBase()->setTime(iteration,order,val);
2324 }
2325
2326 std::string MEDFileAnyTypeField1TS::getName() const
2327 {
2328   return contentNotNullBase()->getName();
2329 }
2330
2331 void MEDFileAnyTypeField1TS::setName(const std::string& name)
2332 {
2333   contentNotNullBase()->setName(name);
2334 }
2335
2336 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
2337 {
2338   contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
2339 }
2340
2341 std::string MEDFileAnyTypeField1TS::getDtUnit() const
2342 {
2343   return contentNotNullBase()->getDtUnit();
2344 }
2345
2346 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
2347 {
2348   contentNotNullBase()->setDtUnit(dtUnit);
2349 }
2350
2351 std::string MEDFileAnyTypeField1TS::getMeshName() const
2352 {
2353   return contentNotNullBase()->getMeshName();
2354 }
2355
2356 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
2357 {
2358   contentNotNullBase()->setMeshName(newMeshName);
2359 }
2360
2361 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2362 {
2363   return contentNotNullBase()->changeMeshNames(modifTab);
2364 }
2365
2366 int MEDFileAnyTypeField1TS::getMeshIteration() const
2367 {
2368   return contentNotNullBase()->getMeshIteration();
2369 }
2370
2371 int MEDFileAnyTypeField1TS::getMeshOrder() const
2372 {
2373   return contentNotNullBase()->getMeshOrder();
2374 }
2375
2376 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
2377 {
2378   return contentNotNullBase()->getNumberOfComponents();
2379 }
2380
2381 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
2382 {
2383   return contentNotNullBase()->isDealingTS(iteration,order);
2384 }
2385
2386 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
2387 {
2388   return contentNotNullBase()->getDtIt();
2389 }
2390
2391 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
2392 {
2393   contentNotNullBase()->fillIteration(p);
2394 }
2395
2396 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
2397 {
2398   contentNotNullBase()->fillTypesOfFieldAvailable(types);
2399 }
2400
2401 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
2402 {
2403   contentNotNullBase()->setInfo(infos);
2404 }
2405
2406 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
2407 {
2408   return contentNotNullBase()->getInfo();
2409 }
2410 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
2411 {
2412   return contentNotNullBase()->getInfo();
2413 }
2414
2415 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
2416 {
2417   return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
2418 }
2419
2420 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
2421 {
2422   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2423 }
2424
2425 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
2426 {
2427   return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2428 }
2429
2430 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
2431 {
2432   return contentNotNullBase()->getNonEmptyLevels(mname,levs);
2433 }
2434
2435 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
2436 {
2437   return contentNotNullBase()->convertMedBallIntoClassic();
2438 }
2439
2440 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
2441 {
2442   return contentNotNullBase()->makeReduction(ct,tof,pfl);
2443 }
2444
2445 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
2446 {
2447   return contentNotNullBase()->getTypesOfFieldAvailable();
2448 }
2449
2450 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,
2451                                                                                               std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2452 {
2453   return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
2454 }
2455
2456 /*!
2457  * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
2458  * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
2459  * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
2460  */
2461 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
2462 {
2463   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2464   if(!content)
2465     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
2466   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
2467   std::size_t sz(contentsSplit.size());
2468   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2469   for(std::size_t i=0;i<sz;i++)
2470     {
2471       ret[i]=shallowCpy();
2472       ret[i]->_content=contentsSplit[i];
2473     }
2474   return ret;
2475 }
2476
2477 /*!
2478  * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
2479  * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2480  */
2481 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
2482 {
2483   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2484   if(!content)
2485     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
2486   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
2487   std::size_t sz(contentsSplit.size());
2488   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2489   for(std::size_t i=0;i<sz;i++)
2490     {
2491       ret[i]=shallowCpy();
2492       ret[i]->_content=contentsSplit[i];
2493     }
2494   return ret;
2495 }
2496
2497 /*!
2498  * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
2499  * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2500  */
2501 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
2502 {
2503   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2504   if(!content)
2505     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
2506   std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
2507   std::size_t sz(contentsSplit.size());
2508   std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2509   for(std::size_t i=0;i<sz;i++)
2510     {
2511       ret[i]=shallowCpy();
2512       ret[i]->_content=contentsSplit[i];
2513     }
2514   return ret;
2515 }
2516
2517 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
2518 {
2519   MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
2520   if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
2521     ret->_content=_content->deepCopy();
2522   ret->deepCpyGlobs(*this);
2523   return ret.retn();
2524 }
2525
2526 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
2527 {
2528   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
2529   return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
2530 }
2531
2532 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
2533 {
2534   return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
2535 }
2536
2537 //= MEDFileField1TS
2538
2539 /*!
2540  * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2541  * following the given input policy.
2542  *
2543  * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2544  *                            By default (true) the globals are deeply copied.
2545  * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
2546  */
2547 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
2548 {
2549   MCAuto<MEDFileIntField1TS> ret;
2550   const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2551   if(content)
2552     {
2553       const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
2554       if(!contc)
2555         throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2556       MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
2557       ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
2558     }
2559   else
2560     ret=MEDFileIntField1TS::New();
2561   if(isDeepCpyGlobs)
2562     ret->deepCpyGlobs(*this);
2563   else
2564     ret->shallowCpyGlobs(*this);
2565   return ret.retn();
2566 }
2567
2568 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2569 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
2570 {
2571 }
2572 catch(INTERP_KERNEL::Exception& e)
2573 { throw e; }
2574
2575 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
2576 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
2577 {
2578 }
2579 catch(INTERP_KERNEL::Exception& e)
2580 { throw e; }
2581
2582 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
2583 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
2584 {
2585 }
2586 catch(INTERP_KERNEL::Exception& e)
2587 { throw e; }
2588
2589 /*!
2590  * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
2591  * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
2592  *
2593  * \warning this is a shallow copy constructor
2594  */
2595 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
2596 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
2597 {
2598 }
2599 catch(INTERP_KERNEL::Exception& e)
2600 { throw e; }
2601
2602 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
2603 {
2604   return new MEDFileField1TS(*this);
2605 }
2606
2607 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
2608                                                                                       std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2609 {
2610   return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
2611 }
2612
2613 //= MEDFileIntField1TS
2614
2615 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
2616 {
2617   if(!f)
2618     throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
2619   int t1,t2;
2620   double t0(f->getTime(t1,t2));
2621   std::string tu(f->getTimeUnit());
2622   MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
2623   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
2624   ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
2625   return ret;
2626 }
2627
2628 //= MEDFileFloatField1TS
2629
2630 //= MEDFileFloatField1TS