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