Salome HOME
merge conflict
[modules/med.git] / src / medtool / src / MEDCoupling / MEDCouplingTimeDiscretization.cxx
1 // Copyright (C) 2007-2015  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 (CEA/DEN)
20
21 #include "MEDCouplingTimeDiscretization.hxx"
22 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDCouplingMesh.hxx"
25
26 #include <cmath>
27 #include <sstream>
28 #include <iterator>
29 #include <algorithm>
30 #include <functional>
31
32 using namespace ParaMEDMEM;
33
34 const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12;
35
36 const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
37
38 const char MEDCouplingNoTimeLabel::REPR[]="No time label defined.";
39
40 const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
41
42 const char MEDCouplingWithTimeStep::REPR[]="One time label.";
43
44 const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time.";
45
46 const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval.";
47
48 const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time.";
49
50 const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
51
52 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
53 {
54   switch(type)
55   {
56     case MEDCouplingNoTimeLabel::DISCRETIZATION:
57       return new MEDCouplingNoTimeLabel;
58     case MEDCouplingWithTimeStep::DISCRETIZATION:
59       return new MEDCouplingWithTimeStep;
60     case MEDCouplingConstOnTimeInterval::DISCRETIZATION:
61       return new MEDCouplingConstOnTimeInterval;
62     case MEDCouplingLinearTime::DISCRETIZATION:
63       return new MEDCouplingLinearTime;
64     default:
65       throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
66   }
67 }
68
69 void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
70 {
71   _time_tolerance=other._time_tolerance;
72   _time_unit=other._time_unit;
73 }
74
75 void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
76 {
77   _time_unit=other._time_unit;
78   if(_array && other._array)
79     _array->copyStringInfoFrom(*other._array);
80 }
81
82 void MEDCouplingTimeDiscretization::checkCoherency() const
83 {
84   if(!_array)
85     throw INTERP_KERNEL::Exception("Field invalid because no values set !");
86   if(_time_tolerance<0.)
87     throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
88 }
89
90 void MEDCouplingTimeDiscretization::updateTime() const
91 {
92   if(_array)
93     updateTimeWith(*_array);
94 }
95
96 std::size_t MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren() const
97 {
98   std::size_t ret(_time_unit.capacity());
99   return ret;
100 }
101
102 std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretization::getDirectChildrenWithNull() const
103 {
104   std::vector<const BigMemoryObject *> ret;
105   ret.push_back(_array);
106   return ret;
107 }
108
109 bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
110 {
111   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
112     return false;
113   if(_array==0 && other->_array==0)
114     return true;
115   if(_array==0 || other->_array==0)
116     return false;
117   if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
118     return false;
119   return true;
120 }
121
122 bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
123 {
124   std::ostringstream oss; oss.precision(15);
125   if(_time_unit!=other->_time_unit)
126     {
127       oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
128       reason=oss.str();
129       return false;
130     }
131   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
132     {
133       oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
134       reason=oss.str();
135       return false;
136     }
137   if(_array==0 && other->_array==0)
138     return true;
139   if(_array==0 || other->_array==0)
140     {
141       reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
142       return false;
143     }
144   if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
145     return false;
146   if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
147     return false;
148   return true;
149 }
150
151 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
152 {
153   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
154     return false;
155   if(_array==0 && other->_array==0)
156     return true;
157   if(_array==0 || other->_array==0)
158     return false;
159   if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
160     return false;
161   return true;
162 }
163
164 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
165 {
166   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
167     return false;
168   if(_array==0 && other->_array==0)
169     return true;
170   if(_array==0 || other->_array==0)
171     return false;
172   int nbC1=_array->getNumberOfComponents();
173   int nbC2=other->_array->getNumberOfComponents();
174   int nbMin=std::min(nbC1,nbC2);
175   if(nbC1!=nbC2 && nbMin!=1)
176     return false;
177   return true;
178 }
179
180 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
181 {
182   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
183     return false;
184   if(_array==0 && other->_array==0)
185     return true;
186   if(_array==0 || other->_array==0)
187     return false;
188   int nbC1=_array->getNumberOfComponents();
189   int nbC2=other->_array->getNumberOfComponents();
190   if(nbC1!=nbC2 && nbC2!=1)
191     return false;
192   return true;
193 }
194
195 bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
196 {
197   if(!areStrictlyCompatible(other,reason))
198     return false;
199   if(_array==other->_array)
200     return true;
201   return _array->isEqualIfNotWhy(*other->_array,prec,reason);
202 }
203
204 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
205 {
206   std::string reason;
207   return isEqualIfNotWhy(other,prec,reason);
208 }
209
210 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
211 {
212   std::string tmp;
213   if(!areStrictlyCompatible(other,tmp))
214     return false;
215   if(_array==other->_array)
216     return true;
217   return _array->isEqualWithoutConsideringStr(*other->_array,prec);
218 }
219
220 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
221 {
222   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
223   ret->setTimeUnit(getTimeUnit());
224   const DataArrayDouble *arrSrc=getArray();
225   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr;
226   if(arrSrc)
227     arr=arrSrc->performCpy(deepCpy);
228   ret->setArray(arr,0);
229   return ret;
230 }
231
232 void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
233 {
234   if(_array)
235     {
236       tinyInfo.push_back(_array->getNumberOfTuples());
237       tinyInfo.push_back(_array->getNumberOfComponents());
238     }
239   else
240     {
241       tinyInfo.push_back(-1);
242       tinyInfo.push_back(-1);
243     }
244 }
245
246 void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
247 {
248   arrays.resize(1);
249   if(_array!=0)
250     _array->decrRef();
251   DataArrayDouble *arr=0;
252   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
253     {
254       arr=DataArrayDouble::New();
255       arr->alloc(tinyInfoI[0],tinyInfoI[1]);
256     }
257   _array=arr;
258   arrays[0]=arr;
259 }
260
261 void MEDCouplingTimeDiscretization::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
262 {
263   static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !";
264   if(arrays.size()!=1)
265     throw INTERP_KERNEL::Exception(MSG);
266   if(_array!=0)
267     _array->decrRef();
268   _array=0;
269   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
270     {
271       if(!arrays[0])
272         throw INTERP_KERNEL::Exception(MSG);
273       arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
274       _array=arrays[0];
275       _array->incrRef();
276     }
277 }
278
279 void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
280 {
281   _time_tolerance=tinyInfoD[0];
282   int nbOfCompo=_array->getNumberOfComponents();
283   for(int i=0;i<nbOfCompo;i++)
284     _array->setInfoOnComponent(i,tinyInfoS[i]);
285 }
286
287 void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
288 {
289   tinyInfo.push_back(_time_tolerance);
290 }
291
292 void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
293 {
294   int nbOfCompo=_array->getNumberOfComponents();
295   for(int i=0;i<nbOfCompo;i++)
296     tinyInfo.push_back(_array->getInfoOnComponent(i));
297 }
298
299 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
300 {
301 }
302
303 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
304 {
305   if(other._array)
306     _array=other._array->performCpy(deepCpy);
307   else
308     _array=0;
309 }
310
311 MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
312 {
313   if(_array)
314     _array->decrRef();
315 }
316
317 void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
318 {
319   if(array!=_array)
320     {
321       if(_array)
322         _array->decrRef();
323       _array=array;
324       if(_array)
325         _array->incrRef();
326       if(owner)
327         owner->declareAsNew();
328     }
329 }
330
331 const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
332 {
333   throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
334 }
335
336 DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
337 {
338   throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
339 }
340
341 void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
342 {
343   throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
344 }
345
346 void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
347 {
348   if(arrays.size()!=1)
349     throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
350   setArray(arrays.back(),owner);
351 }
352
353 void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
354 {
355   arrays.resize(1);
356   arrays[0]=_array;
357 }
358
359 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
360 {
361   int iteration,order;
362   double time1=getEndTime(iteration,order)-_time_tolerance;
363   double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
364   return time1<=time2;
365 }
366
367 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
368 {
369   int iteration,order;
370   double time1=getEndTime(iteration,order)+_time_tolerance;
371   double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
372   return time1<time2;
373 }
374
375 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const
376 {
377   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
378   ret->setTimeUnit(getTimeUnit());
379   std::vector<DataArrayDouble *> arrays;
380   getArrays(arrays);
381   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
382   for(std::size_t j=0;j<arrays.size();j++)
383     {
384       if(arrays[j])
385         arrays2[j]=arrays[j]->doublyContractedProduct();
386       else
387         arrays2[j]=0;
388     }
389   std::vector<DataArrayDouble *> arrays3(arrays.size());
390   for(std::size_t j=0;j<arrays.size();j++)
391     arrays3[j]=arrays2[j];
392   ret->setArrays(arrays3,0);
393   return ret;
394 }
395
396 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const
397 {
398   std::vector<DataArrayDouble *> arrays;
399   getArrays(arrays);
400   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
401   for(std::size_t j=0;j<arrays.size();j++)
402     {
403       if(arrays[j])
404         arrays2[j]=arrays[j]->determinant();
405       else
406         arrays2[j]=0;
407     }
408   std::vector<DataArrayDouble *> arrays3(arrays.size());
409   for(std::size_t j=0;j<arrays.size();j++)
410     arrays3[j]=arrays2[j];
411   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
412   ret->setTimeUnit(getTimeUnit());
413   ret->setArrays(arrays3,0);
414   return ret;
415 }
416
417 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const
418 {
419   std::vector<DataArrayDouble *> arrays;
420   getArrays(arrays);
421   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
422   for(std::size_t j=0;j<arrays.size();j++)
423     {
424       if(arrays[j])
425         arrays2[j]=arrays[j]->eigenValues();
426       else
427         arrays2[j]=0;
428     }
429   std::vector<DataArrayDouble *> arrays3(arrays.size());
430   for(std::size_t j=0;j<arrays.size();j++)
431     arrays3[j]=arrays2[j];
432   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
433   ret->setTimeUnit(getTimeUnit());
434   ret->setArrays(arrays3,0);
435   return ret;
436 }
437
438 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const
439 {
440   std::vector<DataArrayDouble *> arrays;
441   getArrays(arrays);
442   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
443   for(std::size_t j=0;j<arrays.size();j++)
444     {
445       if(arrays[j])
446         arrays2[j]=arrays[j]->eigenVectors();
447       else
448         arrays2[j]=0;
449     }
450   std::vector<DataArrayDouble *> arrays3(arrays.size());
451   for(std::size_t j=0;j<arrays.size();j++)
452     arrays3[j]=arrays2[j];
453   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
454   ret->setTimeUnit(getTimeUnit());
455   ret->setArrays(arrays3,0);
456   return ret;
457 }
458
459 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const
460 {
461   std::vector<DataArrayDouble *> arrays;
462   getArrays(arrays);
463   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
464   for(std::size_t j=0;j<arrays.size();j++)
465     {
466       if(arrays[j])
467         arrays2[j]=arrays[j]->inverse();
468       else
469         arrays2[j]=0;
470     }
471   std::vector<DataArrayDouble *> arrays3(arrays.size());
472   for(std::size_t j=0;j<arrays.size();j++)
473     arrays3[j]=arrays2[j];
474   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
475   ret->setTimeUnit(getTimeUnit());
476   ret->setArrays(arrays3,0);
477   return ret;
478 }
479
480 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const
481 {
482   std::vector<DataArrayDouble *> arrays;
483   getArrays(arrays);
484   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
485   for(std::size_t j=0;j<arrays.size();j++)
486     {
487       if(arrays[j])
488         arrays2[j]=arrays[j]->trace();
489       else
490         arrays2[j]=0;
491     }
492   std::vector<DataArrayDouble *> arrays3(arrays.size());
493   for(std::size_t j=0;j<arrays.size();j++)
494     arrays3[j]=arrays2[j];
495   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
496   ret->setTimeUnit(getTimeUnit());
497   ret->setArrays(arrays3,0);
498   return ret;
499 }
500
501 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const
502 {
503   std::vector<DataArrayDouble *> arrays;
504   getArrays(arrays);
505   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
506   for(std::size_t j=0;j<arrays.size();j++)
507     {
508       if(arrays[j])
509         arrays2[j]=arrays[j]->deviator();
510       else
511         arrays2[j]=0;
512     }
513   std::vector<DataArrayDouble *> arrays3(arrays.size());
514   for(std::size_t j=0;j<arrays.size();j++)
515     arrays3[j]=arrays2[j];
516   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
517   ret->setTimeUnit(getTimeUnit());
518   ret->setArrays(arrays3,0);
519   return ret;
520 }
521
522 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const
523 {
524   std::vector<DataArrayDouble *> arrays;
525   getArrays(arrays);
526   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
527   for(std::size_t j=0;j<arrays.size();j++)
528     {
529       if(arrays[j])
530         arrays2[j]=arrays[j]->magnitude();
531       else
532         arrays2[j]=0;
533     }
534   std::vector<DataArrayDouble *> arrays3(arrays.size());
535   for(std::size_t j=0;j<arrays.size();j++)
536     arrays3[j]=arrays2[j];
537   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
538   ret->setTimeUnit(getTimeUnit());
539   ret->setArrays(arrays3,0);
540   return ret;
541 }
542
543 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const
544 {
545   std::vector<DataArrayDouble *> arrays;
546   getArrays(arrays);
547   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
548   for(std::size_t j=0;j<arrays.size();j++)
549     {
550       if(arrays[j])
551         arrays2[j]=arrays[j]->negate();
552       else
553         arrays2[j]=0;
554     }
555   std::vector<DataArrayDouble *> arrays3(arrays.size());
556   for(std::size_t j=0;j<arrays.size();j++)
557     arrays3[j]=arrays2[j];
558   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
559   ret->setTimeUnit(getTimeUnit());
560   ret->setArrays(arrays3,0);
561   return ret;
562 }
563
564 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const
565 {
566   std::vector<DataArrayDouble *> arrays;
567   getArrays(arrays);
568   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
569   for(std::size_t j=0;j<arrays.size();j++)
570     {
571       if(arrays[j])
572         arrays2[j]=arrays[j]->maxPerTuple();
573       else
574         arrays2[j]=0;
575     }
576   std::vector<DataArrayDouble *> arrays3(arrays.size());
577   for(std::size_t j=0;j<arrays.size();j++)
578     arrays3[j]=arrays2[j];
579   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
580   ret->setTimeUnit(getTimeUnit());
581   ret->setArrays(arrays3,0);
582   return ret;
583 }
584
585 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const
586 {
587   std::vector<DataArrayDouble *> arrays;
588   getArrays(arrays);
589   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
590   for(std::size_t j=0;j<arrays.size();j++)
591     {
592       if(arrays[j])
593         arrays2[j]=static_cast<DataArrayDouble *>(arrays[j]->keepSelectedComponents(compoIds));
594       else
595         arrays2[j]=0;
596     }
597   std::vector<DataArrayDouble *> arrays3(arrays.size());
598   for(std::size_t j=0;j<arrays.size();j++)
599     arrays3[j]=arrays2[j];
600   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
601   ret->setTimeUnit(getTimeUnit());
602   ret->setArrays(arrays3,0);
603   return ret;
604 }
605
606 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds)
607 {
608   std::vector<DataArrayDouble *> arrays1,arrays2;
609   getArrays(arrays1);
610   other->getArrays(arrays2);
611   if(arrays1.size()!=arrays2.size())
612     throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
613   for(std::size_t i=0;i<arrays1.size();i++)
614     {
615       if(arrays1[i]!=0 && arrays2[i]!=0)
616         arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
617       else if(arrays1[i]!=0 || arrays2[i]!=0)
618         throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
619     }
620 }
621
622 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue)
623 {
624   std::vector<DataArrayDouble *> arrays;
625   getArrays(arrays);
626   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
627   for(std::size_t j=0;j<arrays.size();j++)
628     {
629       if(arrays[j])
630         arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
631       else
632         arrays2[j]=0;
633     }
634   std::vector<DataArrayDouble *> arrays3(arrays.size());
635   for(std::size_t j=0;j<arrays.size();j++)
636     arrays3[j]=arrays2[j];
637   setArrays(arrays3,0);
638 }
639
640 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc)
641 {
642   std::vector<DataArrayDouble *> arrays;
643   getArrays(arrays);
644   for(std::size_t j=0;j<arrays.size();j++)
645     {
646       if(arrays[j])
647         arrays[j]->sortPerTuple(asc);
648     }
649 }
650
651 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
652 {
653   std::vector<DataArrayDouble *> arrays;
654   getArrays(arrays);
655   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
656   for(std::size_t j=0;j<arrays.size();j++)
657     {
658       if(arrays[j])
659         {
660           arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
661           arrays2[j]->fillWithValue(value);
662         }
663       else
664         {
665           arrays2[j]=DataArrayDouble::New();
666           arrays2[j]->alloc(nbOfTuple,nbOfCompo);
667           arrays2[j]->fillWithValue(value);
668         }
669     }
670   std::vector<DataArrayDouble *> arrays3(arrays.size());
671   for(std::size_t j=0;j<arrays.size();j++)
672     arrays3[j]=arrays2[j];
673   setArrays(arrays3,0);
674 }
675
676 void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
677 {
678   std::vector<DataArrayDouble *> arrays;
679   getArrays(arrays);
680   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
681   bool newArr=false;
682   for(std::size_t j=0;j<arrays.size();j++)
683     {
684       if(arrays[j])
685         {
686           arrays2[j]=arrays[j]; arrays2[j]->incrRef();
687           arrays2[j]->fillWithValue(value);
688         }
689       else
690         {
691           newArr=true;
692           arrays2[j]=DataArrayDouble::New();
693           arrays2[j]->alloc(nbOfTuple,1);
694           arrays2[j]->fillWithValue(value);
695         }
696     }
697   if(newArr)
698     {
699       std::vector<DataArrayDouble *> arrays3(arrays.size());
700       for(std::size_t j=0;j<arrays.size();j++)
701         arrays3[j]=arrays2[j];
702       setArrays(arrays3,0);
703     }
704 }
705
706 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
707 {
708   std::vector<DataArrayDouble *> arrays;
709   getArrays(arrays);
710   for(std::size_t j=0;j<arrays.size();j++)
711     {
712       if(arrays[j])
713         arrays[j]->applyLin(a,b,compoId);
714     }
715 }
716
717 void MEDCouplingTimeDiscretization::applyLin(double a, double b)
718 {
719   std::vector<DataArrayDouble *> arrays;
720   getArrays(arrays);
721   for(std::size_t j=0;j<arrays.size();j++)
722     {
723       if(arrays[j])
724         arrays[j]->applyLin(a,b);
725     }
726 }
727
728 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
729 {
730   std::vector<DataArrayDouble *> arrays;
731   getArrays(arrays);
732   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
733   for(std::size_t j=0;j<arrays.size();j++)
734     {
735       if(arrays[j])
736         arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
737       else
738         arrays2[j]=0;
739     }
740   std::vector<DataArrayDouble *> arrays3(arrays.size());
741   for(std::size_t j=0;j<arrays.size();j++)
742     arrays3[j]=arrays2[j];
743   setArrays(arrays3,0);
744 }
745
746 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const std::string& func)
747 {
748   std::vector<DataArrayDouble *> arrays;
749   getArrays(arrays);
750   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
751   for(std::size_t j=0;j<arrays.size();j++)
752     {
753       if(arrays[j])
754         arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
755       else
756         arrays2[j]=0;
757     }
758   std::vector<DataArrayDouble *> arrays3(arrays.size());
759   for(std::size_t j=0;j<arrays.size();j++)
760     arrays3[j]=arrays2[j];
761   setArrays(arrays3,0);
762 }
763
764 void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const std::string& func)
765 {
766   std::vector<DataArrayDouble *> arrays;
767   getArrays(arrays);
768   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
769   for(std::size_t j=0;j<arrays.size();j++)
770     {
771       if(arrays[j])
772         arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
773       else
774         arrays2[j]=0;
775     }
776   std::vector<DataArrayDouble *> arrays3(arrays.size());
777   for(std::size_t j=0;j<arrays.size();j++)
778     arrays3[j]=arrays2[j];
779   setArrays(arrays3,0);
780 }
781
782 void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
783 {
784   std::vector<DataArrayDouble *> arrays;
785   getArrays(arrays);
786   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
787   for(std::size_t j=0;j<arrays.size();j++)
788     {
789       if(arrays[j])
790         arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
791       else
792         arrays2[j]=0;
793     }
794   std::vector<DataArrayDouble *> arrays3(arrays.size());
795   for(std::size_t j=0;j<arrays.size();j++)
796     arrays3[j]=arrays2[j];
797   setArrays(arrays3,0);
798 }
799
800 void MEDCouplingTimeDiscretization::applyFunc(const std::string& func)
801 {
802   std::vector<DataArrayDouble *> arrays;
803   getArrays(arrays);
804   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
805   for(std::size_t j=0;j<arrays.size();j++)
806     {
807       if(arrays[j])
808         arrays2[j]=arrays[j]->applyFunc(func);
809       else
810         arrays2[j]=0;
811     }
812   std::vector<DataArrayDouble *> arrays3(arrays.size());
813   for(std::size_t j=0;j<arrays.size();j++)
814     arrays3[j]=arrays2[j];
815   setArrays(arrays3,0);
816 }
817
818 void MEDCouplingTimeDiscretization::applyFuncFast32(const std::string& func)
819 {
820   std::vector<DataArrayDouble *> arrays;
821   getArrays(arrays);
822   for(std::size_t j=0;j<arrays.size();j++)
823     {
824       if(arrays[j])
825         arrays[j]->applyFuncFast32(func);
826     }
827 }
828
829 void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func)
830 {
831   std::vector<DataArrayDouble *> arrays;
832   getArrays(arrays);
833   for(std::size_t j=0;j<arrays.size();j++)
834     {
835       if(arrays[j])
836         arrays[j]->applyFuncFast64(func);
837     }
838 }
839
840 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func)
841 {
842   std::vector<DataArrayDouble *> arrays;
843   getArrays(arrays);
844   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
845   for(std::size_t j=0;j<arrays.size();j++)
846     arrays2[j]=loc->applyFunc(nbOfComp,func);
847   std::vector<DataArrayDouble *> arrays3(arrays.size());
848   for(std::size_t j=0;j<arrays.size();j++)
849     arrays3[j]=arrays2[j];
850   setArrays(arrays3,0);
851 }
852
853 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
854 {
855   std::vector<DataArrayDouble *> arrays;
856   getArrays(arrays);
857   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
858   for(std::size_t j=0;j<arrays.size();j++)
859     arrays2[j]=loc->applyFunc(nbOfComp,func);
860   std::vector<DataArrayDouble *> arrays3(arrays.size());
861   for(std::size_t j=0;j<arrays.size();j++)
862     arrays3[j]=arrays2[j];
863   setArrays(arrays3,0);
864 }
865
866 void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
867 {
868   std::vector<DataArrayDouble *> arrays;
869   getArrays(arrays);
870   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
871   for(std::size_t j=0;j<arrays.size();j++)
872     arrays2[j]=loc->applyFunc2(nbOfComp,func);
873   std::vector<DataArrayDouble *> arrays3(arrays.size());
874   for(std::size_t j=0;j<arrays.size();j++)
875     arrays3[j]=arrays2[j];
876   setArrays(arrays3,0);
877 }
878
879 void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
880 {
881   std::vector<DataArrayDouble *> arrays;
882   getArrays(arrays);
883   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
884   for(std::size_t j=0;j<arrays.size();j++)
885     arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
886   std::vector<DataArrayDouble *> arrays3(arrays.size());
887   for(std::size_t j=0;j<arrays.size();j++)
888     arrays3[j]=arrays2[j];
889   setArrays(arrays3,0);
890 }
891
892 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
893 {
894 }
895
896 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
897 {
898 }
899
900 std::string MEDCouplingNoTimeLabel::getStringRepr() const
901 {
902   std::ostringstream stream;
903   stream << REPR;
904   stream << "\nTime unit is : \"" << _time_unit << "\"";
905   return stream.str();
906 }
907
908 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh)
909 {
910   throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
911 }
912
913 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
914 {
915   if(!MEDCouplingTimeDiscretization::areCompatible(other))
916     return false;
917   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
918   return otherC!=0;
919 }
920
921 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
922 {
923   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
924     return false;
925   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
926   bool ret=otherC!=0;
927   if(!ret)
928     reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
929   return ret;
930 }
931
932 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
933 {
934   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
935     return false;
936   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
937   return otherC!=0;
938 }
939
940 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
941 {
942   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
943     return false;
944   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
945   return otherC!=0;
946 }
947
948 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
949 {
950   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
951     return false;
952   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
953   return otherC!=0;
954 }
955
956 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
957 {
958   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
959   if(!otherC)
960     {
961       reason="This has time discretization NO_TIME, other not.";
962       return false;
963     }
964   return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
965 }
966
967 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
968 {
969   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
970   if(!otherC)
971     return false;
972   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
973 }
974
975 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
976 {
977   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
978   if(!otherC)
979     throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
980   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
981   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
982   ret->setArray(arr,0);
983   return ret;
984 }
985
986 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
987 {
988   std::vector<const DataArrayDouble *> a(other.size());
989   int i=0;
990   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
991     {
992       const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
993       if(!itC)
994         throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
995       a[i]=itC->getArray();
996     }
997   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
998   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
999   ret->setArray(arr,0);
1000   return ret;
1001 }
1002
1003 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
1004 {
1005   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1006   if(!otherC)
1007     throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
1008   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1009   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1010   ret->setTimeTolerance(getTimeTolerance());
1011   ret->setArray(arr,0);
1012   return ret;
1013 }
1014
1015 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
1016 {
1017   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1018   if(!otherC)
1019     throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
1020   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1021   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1022   ret->setArray(arr,0);
1023   return ret;
1024 }
1025
1026 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
1027 {
1028   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1029   if(!otherC)
1030     throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
1031   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1032   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1033   ret->setArray(arr,0);
1034   return ret;
1035 }
1036
1037 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
1038 {
1039   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1040   if(!otherC)
1041     throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1042   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1043   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1044   ret->setArray(arr,0);
1045   return ret;
1046 }
1047
1048 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
1049 {
1050   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1051   if(!otherC)
1052     throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1053   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1054   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1055   ret->setArray(arr,0);
1056   return ret;
1057 }
1058
1059 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
1060 {
1061   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1062   if(!otherC)
1063     throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
1064   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1065   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1066   ret->setArray(arr,0);
1067   return ret;
1068 }
1069
1070 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
1071 {
1072   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1073   if(!otherC)
1074     throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1075   if(!getArray())
1076     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1077   getArray()->addEqual(other->getArray());
1078 }
1079
1080 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1081 {
1082   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1083   if(!otherC)
1084     throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1085   if(!getArray())
1086     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1087   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1088   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1089   ret->setArray(arr,0);
1090   return ret;
1091 }
1092
1093 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1094 {
1095   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1096   if(!otherC)
1097     throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1098   if(!getArray())
1099     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1100   getArray()->substractEqual(other->getArray());
1101 }
1102
1103 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1104 {
1105   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1106   if(!otherC)
1107     throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1108   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1109   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1110   ret->setArray(arr,0);
1111   return ret;
1112 }
1113
1114 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1115 {
1116   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1117   if(!otherC)
1118     throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1119   if(!getArray())
1120     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1121   getArray()->multiplyEqual(other->getArray());
1122 }
1123
1124 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1125 {
1126   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1127   if(!otherC)
1128     throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1129   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1130   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1131   ret->setArray(arr,0);
1132   return ret;
1133 }
1134
1135 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1136 {
1137   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1138   if(!otherC)
1139     throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1140   if(!getArray())
1141     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1142   getArray()->divideEqual(other->getArray());
1143 }
1144
1145 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1146 {
1147   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1148   if(!otherC)
1149     throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1150   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1151   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1152   ret->setArray(arr,0);
1153   return ret;
1154 }
1155
1156 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1157 {
1158   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1159   if(!otherC)
1160     throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1161   if(!getArray())
1162     throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1163   getArray()->powEqual(other->getArray());
1164 }
1165
1166 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
1167 {
1168   return new MEDCouplingNoTimeLabel(*this,deepCpy);
1169 }
1170
1171 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const
1172 {
1173   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1174 }
1175
1176 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const
1177 {
1178   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1179 }
1180
1181 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1182 {
1183   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1184 }
1185
1186 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const
1187 {
1188   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1189 }
1190
1191 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
1192 {
1193   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1194 }
1195
1196 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const
1197 {
1198   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1199 }
1200
1201 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const
1202 {
1203   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1204 }
1205
1206 void MEDCouplingNoTimeLabel::setStartIteration(int it)
1207 {
1208   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1209 }
1210
1211 void MEDCouplingNoTimeLabel::setEndIteration(int it)
1212 {
1213   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1214 }
1215
1216 void MEDCouplingNoTimeLabel::setStartOrder(int order)
1217 {
1218   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1219 }
1220
1221 void MEDCouplingNoTimeLabel::setEndOrder(int order)
1222 {
1223   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1224 }
1225
1226 void MEDCouplingNoTimeLabel::setStartTimeValue(double time)
1227 {
1228   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1229 }
1230
1231 void MEDCouplingNoTimeLabel::setEndTimeValue(double time)
1232 {
1233   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1234 }
1235
1236 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order)
1237 {
1238   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1239 }
1240
1241 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order)
1242 {
1243   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1244 }
1245
1246 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const
1247 {
1248   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1249 }
1250
1251 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1252 {
1253   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1254 }
1255
1256 /*!
1257  * idem getTinySerializationIntInformation except that it is for multi field fetch
1258  */
1259 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1260 {
1261   tinyInfo.clear();
1262 }
1263
1264 /*!
1265  * idem getTinySerializationDbleInformation except that it is for multi field fetch
1266  */
1267 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1268 {
1269   tinyInfo.resize(1);
1270   tinyInfo[0]=_time_tolerance;
1271 }
1272
1273 /*!
1274  * idem finishUnserialization except that it is for multi field fetch
1275  */
1276 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1277 {
1278   _time_tolerance=tinyInfoD[0];
1279 }
1280
1281 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
1282     _time(other._time),_iteration(other._iteration),_order(other._order)
1283 {
1284 }
1285
1286 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
1287 {
1288 }
1289
1290 std::string MEDCouplingWithTimeStep::getStringRepr() const
1291 {
1292   std::ostringstream stream;
1293   stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
1294   stream << "\nTime unit is : \"" << _time_unit << "\"";
1295   return stream.str();
1296 }
1297
1298 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1299 {
1300   if(!mesh)
1301     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1302   int it=-1,order=-1;
1303   double val=mesh->getTime(it,order);
1304   _time=val; _iteration=it; _order=order;
1305   std::string tUnit=mesh->getTimeUnit();
1306   _time_unit=tUnit;
1307 }
1308
1309 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1310 {
1311   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1312   tinyInfo.push_back(_iteration);
1313   tinyInfo.push_back(_order);
1314 }
1315
1316 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1317 {
1318   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1319   tinyInfo.push_back(_time);
1320 }
1321
1322 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1323 {
1324   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1325   _time=tinyInfoD[1];
1326   _iteration=tinyInfoI[2];
1327   _order=tinyInfoI[3];
1328 }
1329
1330 /*!
1331  * idem getTinySerializationIntInformation except that it is for multi field fetch
1332  */
1333 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1334 {
1335   tinyInfo.resize(2);
1336   tinyInfo[0]=_iteration;
1337   tinyInfo[1]=_order;
1338 }
1339
1340 /*!
1341  * idem getTinySerializationDbleInformation except that it is for multi field fetch
1342  */
1343 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1344 {
1345   tinyInfo.resize(2);
1346   tinyInfo[0]=_time_tolerance;
1347   tinyInfo[1]=_time;
1348 }
1349
1350 /*!
1351  * idem finishUnserialization except that it is for multi field fetch
1352  */
1353 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1354 {
1355   _iteration=tinyInfoI[0];
1356   _order=tinyInfoI[1];
1357   _time_tolerance=tinyInfoD[0];
1358   _time=tinyInfoD[1];
1359 }
1360
1361 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
1362 {
1363   if(!MEDCouplingTimeDiscretization::areCompatible(other))
1364     return false;
1365   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1366   return otherC!=0;
1367 }
1368
1369 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1370 {
1371   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1372     return false;
1373   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1374   bool ret=otherC!=0;
1375   if(!ret)
1376     reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1377   return ret;
1378 }
1379
1380 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1381 {
1382   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1383     return false;
1384   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1385   return otherC!=0;
1386 }
1387
1388 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1389 {
1390   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1391     return false;
1392   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1393   return otherC!=0;
1394 }
1395
1396 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1397 {
1398   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1399     return false;
1400   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1401   return otherC!=0;
1402 }
1403
1404 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1405 {
1406   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1407   std::ostringstream oss; oss.precision(15);
1408   if(!otherC)
1409     {
1410       reason="This has time discretization ONE_TIME, other not.";
1411       return false;
1412     }
1413   if(_iteration!=otherC->_iteration)
1414     {
1415       oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
1416       reason=oss.str();
1417       return false;
1418     }
1419   if(_order!=otherC->_order)
1420     {
1421       oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
1422       reason=oss.str();
1423       return false;
1424     }
1425   if(std::fabs(_time-otherC->_time)>_time_tolerance)
1426     {
1427       oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
1428       reason=oss.str();
1429       return false;
1430     }
1431   return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1432 }
1433
1434 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1435 {
1436   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1437   if(!otherC)
1438     return false;
1439   if(_iteration!=otherC->_iteration)
1440     return false;
1441   if(_order!=otherC->_order)
1442     return false;
1443   if(std::fabs(_time-otherC->_time)>_time_tolerance)
1444     return false;
1445   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1446 }
1447
1448 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
1449 {
1450   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1451   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1452   if(!otherC)
1453     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1454   _time=otherC->_time;
1455   _iteration=otherC->_iteration;
1456   _order=otherC->_order;
1457 }
1458
1459 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1460 {
1461   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1462   if(!otherC)
1463     throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1464   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1465   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1466   ret->setArray(arr,0);
1467   return ret;
1468 }
1469
1470 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1471 {
1472   std::vector<const DataArrayDouble *> a(other.size());
1473   int i=0;
1474   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1475     {
1476       const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1477       if(!itC)
1478         throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1479       a[i]=itC->getArray();
1480     }
1481   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1482   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1483   ret->setArray(arr,0);
1484   return ret;
1485 }
1486
1487 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1488 {
1489   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1490   if(!otherC)
1491     throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1492   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1493   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1494   ret->setArray(arr,0);
1495   return ret;
1496 }
1497
1498 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1499 {
1500   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1501   if(!otherC)
1502     throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1503   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1504   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1505   ret->setArray(arr,0);
1506   return ret;
1507 }
1508
1509 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1510 {
1511   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1512   if(!otherC)
1513     throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1514   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1515   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1516   ret->setArray(arr,0);
1517   return ret;
1518 }
1519
1520 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1521 {
1522   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1523   if(!otherC)
1524     throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1525   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1526   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1527   ret->setArray(arr,0);
1528   return ret;
1529 }
1530
1531 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1532 {
1533   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1534   if(!otherC)
1535     throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1536   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1537   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1538   ret->setArray(arr,0);
1539   return ret;
1540 }
1541
1542 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1543 {
1544   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1545   if(!otherC)
1546     throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1547   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1548   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1549   ret->setArray(arr,0);
1550   int tmp1,tmp2;
1551   double tmp3=getStartTime(tmp1,tmp2);
1552   ret->setStartTime(tmp3,tmp1,tmp2);
1553   return ret;
1554 }
1555
1556 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1557 {
1558   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1559   if(!otherC)
1560     throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1561   if(!getArray())
1562     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1563   getArray()->addEqual(other->getArray());
1564 }
1565
1566 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1567 {
1568   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1569   if(!otherC)
1570     throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1571   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1572   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1573   ret->setArray(arr,0);
1574   int tmp1,tmp2;
1575   double tmp3=getStartTime(tmp1,tmp2);
1576   ret->setStartTime(tmp3,tmp1,tmp2);
1577   return ret;
1578 }
1579
1580 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1581 {
1582   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1583   if(!otherC)
1584     throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1585   if(!getArray())
1586     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1587   getArray()->substractEqual(other->getArray());
1588 }
1589
1590 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1591 {
1592   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1593   if(!otherC)
1594     throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1595   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1596   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1597   ret->setArray(arr,0);
1598   int tmp1,tmp2;
1599   double tmp3=getStartTime(tmp1,tmp2);
1600   ret->setStartTime(tmp3,tmp1,tmp2);
1601   return ret;
1602 }
1603
1604 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1605 {
1606   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1607   if(!otherC)
1608     throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1609   if(!getArray())
1610     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1611   getArray()->multiplyEqual(other->getArray());
1612 }
1613
1614 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1615 {
1616   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1617   if(!otherC)
1618     throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1619   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1620   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1621   ret->setArray(arr,0);
1622   int tmp1,tmp2;
1623   double tmp3=getStartTime(tmp1,tmp2);
1624   ret->setStartTime(tmp3,tmp1,tmp2);
1625   return ret;
1626 }
1627
1628 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1629 {
1630   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1631   if(!otherC)
1632     throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1633   if(!getArray())
1634     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1635   getArray()->divideEqual(other->getArray());
1636 }
1637
1638 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1639 {
1640   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1641   if(!otherC)
1642     throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1643   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1644   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1645   ret->setArray(arr,0);
1646   int tmp1,tmp2;
1647   double tmp3=getStartTime(tmp1,tmp2);
1648   ret->setStartTime(tmp3,tmp1,tmp2);
1649   return ret;
1650 }
1651
1652 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1653 {
1654   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1655   if(!otherC)
1656     throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1657   if(!getArray())
1658     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1659   getArray()->powEqual(other->getArray());
1660 }
1661
1662 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
1663 {
1664   return new MEDCouplingWithTimeStep(*this,deepCpy);
1665 }
1666
1667 void MEDCouplingWithTimeStep::checkNoTimePresence() const
1668 {
1669   throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1670 }
1671
1672 void MEDCouplingWithTimeStep::checkTimePresence(double time) const
1673 {
1674   if(std::fabs(time-_time)>_time_tolerance)
1675     {
1676       std::ostringstream stream;
1677       stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
1678       throw INTERP_KERNEL::Exception(stream.str().c_str());
1679     }
1680 }
1681
1682 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
1683 {
1684   if(std::fabs(time-_time)<=_time_tolerance)
1685     {
1686       std::vector< const DataArrayDouble *> ret(1);
1687       ret[0]=_array;
1688       return ret;
1689     }
1690   else
1691     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1692 }
1693
1694 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1695 {
1696   std::copy(vals.begin(),vals.end(),res);
1697 }
1698
1699 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const
1700 {
1701   if(std::fabs(time-_time)<=_time_tolerance)
1702     if(_array)
1703       _array->getTuple(eltId,value);
1704     else
1705       throw INTERP_KERNEL::Exception("No array existing.");
1706   else
1707     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1708 }
1709
1710 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1711 {
1712   if(_iteration==iteration && _order==order)
1713     if(_array)
1714       _array->getTuple(eltId,value);
1715     else
1716       throw INTERP_KERNEL::Exception("No array existing.");
1717   else
1718     throw INTERP_KERNEL::Exception("No data on this discrete time.");
1719 }
1720
1721 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
1722 {
1723 }
1724
1725 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
1726 {
1727   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1728   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1729   if(!otherC)
1730     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1731   _start_time=otherC->_start_time;
1732   _end_time=otherC->_end_time;
1733   _start_iteration=otherC->_start_iteration;
1734   _end_iteration=otherC->_end_iteration;
1735   _start_order=otherC->_start_order;
1736   _end_order=otherC->_end_order;
1737 }
1738
1739 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1740 {
1741   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1742   tinyInfo.push_back(_start_iteration);
1743   tinyInfo.push_back(_start_order);
1744   tinyInfo.push_back(_end_iteration);
1745   tinyInfo.push_back(_end_order);
1746 }
1747
1748 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1749 {
1750   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1751   tinyInfo.push_back(_start_time);
1752   tinyInfo.push_back(_end_time);
1753 }
1754
1755 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1756 {
1757   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1758   _start_time=tinyInfoD[1];
1759   _end_time=tinyInfoD[2];
1760   _start_iteration=tinyInfoI[2];
1761   _start_order=tinyInfoI[3];
1762   _end_iteration=tinyInfoI[4];
1763   _end_order=tinyInfoI[5];
1764 }
1765
1766 /*!
1767  * idem getTinySerializationIntInformation except that it is for multi field fetch
1768  */
1769 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1770 {
1771   tinyInfo.resize(4);
1772   tinyInfo[0]=_start_iteration;
1773   tinyInfo[1]=_start_order;
1774   tinyInfo[2]=_end_iteration;
1775   tinyInfo[3]=_end_order;
1776 }
1777
1778 /*!
1779  * idem getTinySerializationDbleInformation except that it is for multi field fetch
1780  */
1781 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1782 {
1783   tinyInfo.resize(3);
1784   tinyInfo[0]=_time_tolerance;
1785   tinyInfo[1]=_start_time;
1786   tinyInfo[2]=_end_time;
1787 }
1788
1789 /*!
1790  * idem finishUnserialization except that it is for multi field fetch
1791  */
1792 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1793 {
1794   _start_iteration=tinyInfoI[0];
1795   _start_order=tinyInfoI[1];
1796   _end_iteration=tinyInfoI[2];
1797   _end_order=tinyInfoI[3];
1798   _time_tolerance=tinyInfoD[0];
1799   _start_time=tinyInfoD[1];
1800   _end_time=tinyInfoD[2];
1801 }
1802
1803 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
1804       MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
1805       _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
1806 {
1807 }
1808
1809 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1810 {
1811   std::ostringstream stream;
1812   stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
1813   stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
1814   stream << "\nTime unit is : \"" << _time_unit << "\"";
1815   return stream.str();
1816 }
1817
1818 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1819 {
1820   if(!mesh)
1821     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1822   int it=-1,order=-1;
1823   double val=mesh->getTime(it,order);
1824   _start_time=val; _start_iteration=it; _start_order=order;
1825   _end_time=val; _end_iteration=it; _end_order=order;
1826   std::string tUnit=mesh->getTimeUnit();
1827   _time_unit=tUnit;
1828 }
1829
1830 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
1831 {
1832   return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
1833 }
1834
1835 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const
1836 {
1837   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1838     {
1839       std::vector< const DataArrayDouble *> ret(1);
1840       ret[0]=_array;
1841       return ret;
1842     }
1843   else
1844     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1845 }
1846
1847 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1848 {
1849   std::copy(vals.begin(),vals.end(),res);
1850 }
1851
1852 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
1853 {
1854   if(!MEDCouplingTimeDiscretization::areCompatible(other))
1855     return false;
1856   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1857   return otherC!=0;
1858 }
1859
1860 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1861 {
1862   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1863     return false;
1864   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1865   bool ret=otherC!=0;
1866   if(!ret)
1867     reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1868   return ret;
1869 }
1870
1871 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1872 {
1873   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1874     return false;
1875   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1876   return otherC!=0;
1877 }
1878
1879 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1880 {
1881   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1882     return false;
1883   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1884   return otherC!=0;
1885 }
1886
1887 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1888 {
1889   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1890     return false;
1891   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1892   return otherC!=0;
1893 }
1894
1895 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1896 {
1897   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1898   std::ostringstream oss; oss.precision(15);
1899   if(!otherC)
1900     {
1901       reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1902       return false;
1903     }
1904   if(_start_iteration!=otherC->_start_iteration)
1905     {
1906       oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
1907       reason=oss.str();
1908       return false;
1909     }
1910   if(_start_order!=otherC->_start_order)
1911     {
1912       oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
1913       reason=oss.str();
1914       return false;
1915     }
1916   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1917     {
1918       oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
1919       reason=oss.str();
1920       return false;
1921     }
1922   if(_end_iteration!=otherC->_end_iteration)
1923     {
1924       oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
1925       reason=oss.str();
1926       return false;
1927     }
1928   if(_end_order!=otherC->_end_order)
1929     {
1930       oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
1931       reason=oss.str();
1932       return false;
1933     }
1934   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1935     {
1936       oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
1937       reason=oss.str();
1938       return false;
1939     }
1940   return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1941 }
1942
1943 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1944 {
1945   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1946   if(!otherC)
1947     return false;
1948   if(_start_iteration!=otherC->_start_iteration)
1949     return false;
1950   if(_start_order!=otherC->_start_order)
1951     return false;
1952   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1953     return false;
1954   if(_end_iteration!=otherC->_end_iteration)
1955     return false;
1956   if(_end_order!=otherC->_end_order)
1957     return false;
1958   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1959     return false;
1960   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1961 }
1962
1963 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const
1964 {
1965   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1966     if(_array)
1967       _array->getTuple(eltId,value);
1968     else
1969       throw INTERP_KERNEL::Exception("No array existing.");
1970   else
1971     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1972 }
1973
1974 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1975 {
1976   if(iteration>=_start_iteration && iteration<=_end_iteration)
1977     if(_array)
1978       _array->getTuple(eltId,value);
1979     else
1980       throw INTERP_KERNEL::Exception("No array existing.");
1981   else
1982     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1983 }
1984
1985 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const
1986 {
1987   throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1988 }
1989
1990 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const
1991 {
1992   if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
1993     {
1994       std::ostringstream stream;
1995       stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
1996       stream << _time_tolerance << " and trying to access on time = " << time;
1997       throw INTERP_KERNEL::Exception(stream.str().c_str());
1998     }
1999 }
2000
2001 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
2002 {
2003   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2004   if(!otherC)
2005     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
2006   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
2007   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2008   ret->setArray(arr,0);
2009   return ret;
2010 }
2011
2012 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2013 {
2014   std::vector<const DataArrayDouble *> a(other.size());
2015   int i=0;
2016   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2017     {
2018       const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
2019       if(!itC)
2020         throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
2021       a[i]=itC->getArray();
2022     }
2023   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2024   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2025   ret->setArray(arr,0);
2026   return ret;
2027 }
2028
2029 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
2030 {
2031   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2032   if(!otherC)
2033     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
2034   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
2035   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2036   ret->setTimeTolerance(getTimeTolerance());
2037   ret->setArray(arr,0);
2038   return ret;
2039 }
2040
2041 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
2042 {
2043   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2044   if(!otherC)
2045     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
2046   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
2047   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2048   ret->setArray(arr,0);
2049   return ret;
2050 }
2051
2052 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
2053 {
2054   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2055   if(!otherC)
2056     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
2057   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2058   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2059   ret->setArray(arr,0);
2060   return ret;
2061 }
2062
2063 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
2064 {
2065   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2066   if(!otherC)
2067     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
2068   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
2069   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2070   ret->setArray(arr,0);
2071   return ret;
2072 }
2073
2074 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
2075 {
2076   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2077   if(!otherC)
2078     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
2079   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
2080   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2081   ret->setArray(arr,0);
2082   return ret;
2083 }
2084
2085 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
2086 {
2087   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2088   if(!otherC)
2089     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
2090   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
2091   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2092   ret->setArray(arr,0);
2093   int tmp1,tmp2;
2094   double tmp3=getStartTime(tmp1,tmp2);
2095   ret->setStartTime(tmp3,tmp1,tmp2);
2096   tmp3=getEndTime(tmp1,tmp2);
2097   ret->setEndTime(tmp3,tmp1,tmp2);
2098   return ret;
2099 }
2100
2101 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
2102 {
2103   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2104   if(!otherC)
2105     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
2106   if(!getArray())
2107     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
2108   getArray()->addEqual(other->getArray());
2109 }
2110
2111 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
2112 {
2113   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2114   if(!otherC)
2115     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
2116   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
2117   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2118   ret->setArray(arr,0);
2119   int tmp1,tmp2;
2120   double tmp3=getStartTime(tmp1,tmp2);
2121   ret->setStartTime(tmp3,tmp1,tmp2);
2122   tmp3=getEndTime(tmp1,tmp2);
2123   ret->setEndTime(tmp3,tmp1,tmp2);
2124   return ret;
2125 }
2126
2127 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2128 {
2129   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2130   if(!otherC)
2131     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2132   if(!getArray())
2133     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2134   getArray()->substractEqual(other->getArray());
2135 }
2136
2137 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2138 {
2139   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2140   if(!otherC)
2141     throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2142   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2143   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2144   ret->setArray(arr,0);
2145   int tmp1,tmp2;
2146   double tmp3=getStartTime(tmp1,tmp2);
2147   ret->setStartTime(tmp3,tmp1,tmp2);
2148   tmp3=getEndTime(tmp1,tmp2);
2149   ret->setEndTime(tmp3,tmp1,tmp2);
2150   return ret;
2151 }
2152
2153 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2154 {
2155   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2156   if(!otherC)
2157     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2158   if(!getArray())
2159     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2160   getArray()->multiplyEqual(other->getArray());
2161 }
2162
2163 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2164 {
2165   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2166   if(!otherC)
2167     throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2168   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2169   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2170   ret->setArray(arr,0);
2171   int tmp1,tmp2;
2172   double tmp3=getStartTime(tmp1,tmp2);
2173   ret->setStartTime(tmp3,tmp1,tmp2);
2174   tmp3=getEndTime(tmp1,tmp2);
2175   ret->setEndTime(tmp3,tmp1,tmp2);
2176   return ret;
2177 }
2178
2179 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2180 {
2181   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2182   if(!otherC)
2183     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2184   if(!getArray())
2185     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2186   getArray()->divideEqual(other->getArray());
2187 }
2188
2189 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2190 {
2191   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2192   if(!otherC)
2193     throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2194   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2195   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2196   ret->setArray(arr,0);
2197   int tmp1,tmp2;
2198   double tmp3=getStartTime(tmp1,tmp2);
2199   ret->setStartTime(tmp3,tmp1,tmp2);
2200   tmp3=getEndTime(tmp1,tmp2);
2201   ret->setEndTime(tmp3,tmp1,tmp2);
2202   return ret;
2203 }
2204
2205 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2206 {
2207   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2208   if(!otherC)
2209     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2210   if(!getArray())
2211     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2212   getArray()->powEqual(other->getArray());
2213 }
2214
2215 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
2216     _start_time(other._start_time),_end_time(other._end_time),
2217     _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
2218     _start_order(other._start_order),_end_order(other._end_order)
2219 {
2220   if(other._end_array)
2221     _end_array=other._end_array->performCpy(deepCpy);
2222   else
2223     _end_array=0;
2224 }
2225
2226 void MEDCouplingTwoTimeSteps::updateTime() const
2227 {
2228   MEDCouplingTimeDiscretization::updateTime();
2229   if(_end_array)
2230     updateTimeWith(*_end_array);
2231 }
2232
2233 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
2234 {
2235   if(!mesh)
2236     throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2237   int it=-1,order=-1;
2238   double val=mesh->getTime(it,order);
2239   _start_time=val; _start_iteration=it; _start_order=order;
2240   _end_time=val; _end_iteration=it; _end_order=order;
2241   std::string tUnit=mesh->getTimeUnit();
2242   _time_unit=tUnit;
2243 }
2244
2245 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
2246 {
2247   return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
2248 }
2249
2250 std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildrenWithNull() const
2251 {
2252   std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildrenWithNull());
2253   ret.push_back(_end_array);
2254   return ret;
2255 }
2256
2257 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
2258 {
2259   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2260   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2261   if(!otherC)
2262     throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2263   _start_time=otherC->_start_time;
2264   _end_time=otherC->_end_time;
2265   _start_iteration=otherC->_start_iteration;
2266   _end_iteration=otherC->_end_iteration;
2267   _start_order=otherC->_start_order;
2268   _end_order=otherC->_end_order;
2269 }
2270
2271 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
2272 {
2273   MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2274   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2275   if(!otherC)
2276     throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2277   if(_end_array && otherC->_end_array)
2278     _end_array->copyStringInfoFrom(*otherC->_end_array);
2279 }
2280
2281 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2282 {
2283   return _end_array;
2284 }
2285
2286 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2287 {
2288   return _end_array;
2289 }
2290
2291 void MEDCouplingTwoTimeSteps::checkCoherency() const
2292 {
2293   MEDCouplingTimeDiscretization::checkCoherency();
2294   if(!_end_array)
2295     throw INTERP_KERNEL::Exception("No end array specified !");
2296   if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2297     throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2298   if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2299     throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2300 }
2301
2302 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
2303 {
2304   std::ostringstream oss;
2305   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2306   if(!otherC)
2307     {
2308       reason="This has time discretization LINEAR_TIME, other not.";
2309       return false;
2310     }
2311   if(_start_iteration!=otherC->_start_iteration)
2312     {
2313       oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
2314       reason=oss.str();
2315       return false;
2316     }
2317   if(_start_order!=otherC->_start_order)
2318     {
2319       oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
2320       reason=oss.str();
2321       return false;
2322     }
2323   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2324     {
2325       oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
2326       reason=oss.str();
2327       return false;
2328     }
2329   if(_end_iteration!=otherC->_end_iteration)
2330     {
2331       oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
2332       reason=oss.str();
2333       return false;
2334     }
2335   if(_end_order!=otherC->_end_order)
2336     {
2337       oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
2338       reason=oss.str();
2339       return false;
2340     }
2341   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2342     {
2343       oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
2344       reason=oss.str();
2345       return false;
2346     }
2347   if(_end_array!=otherC->_end_array)
2348     if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2349       {
2350         reason.insert(0,"end arrays differ for linear time.");
2351         return false;
2352       }
2353   return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2354 }
2355
2356 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
2357 {
2358   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2359   if(!otherC)
2360     return false;
2361   if(_start_iteration!=otherC->_start_iteration)
2362     return false;
2363   if(_end_iteration!=otherC->_end_iteration)
2364     return false;
2365   if(_start_order!=otherC->_start_order)
2366     return false;
2367   if(_end_order!=otherC->_end_order)
2368     return false;
2369   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2370     return false;
2371   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2372     return false;
2373   if(_end_array!=otherC->_end_array)
2374     if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2375       return false;
2376   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2377 }
2378
2379 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
2380 {
2381 }
2382
2383 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2384 {
2385   if(_end_array)
2386     _end_array->decrRef();
2387 }
2388
2389 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const
2390 {
2391   throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2392 }
2393
2394 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
2395 {
2396   if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
2397     {
2398       std::ostringstream stream;
2399       stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
2400       stream << _time_tolerance << " and trying to access on time = " << time;
2401       throw INTERP_KERNEL::Exception(stream.str().c_str());
2402     }
2403 }
2404
2405 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2406 {
2407   arrays.resize(2);
2408   arrays[0]=_array;
2409   arrays[1]=_end_array;
2410 }
2411
2412 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2413 {
2414   if(array!=_end_array)
2415     {
2416       if(_end_array)
2417         _end_array->decrRef();
2418       _end_array=array;
2419       if(_end_array)
2420         _end_array->incrRef();
2421       if(owner)
2422         owner->declareAsNew();
2423     }
2424 }
2425
2426 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2427 {
2428   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2429   tinyInfo.push_back(_start_iteration);
2430   tinyInfo.push_back(_start_order);
2431   tinyInfo.push_back(_end_iteration);
2432   tinyInfo.push_back(_end_order);
2433   if(_end_array)
2434     {
2435       tinyInfo.push_back(_end_array->getNumberOfTuples());
2436       tinyInfo.push_back(_end_array->getNumberOfComponents());
2437     }
2438   else
2439     {
2440       tinyInfo.push_back(-1);
2441       tinyInfo.push_back(-1);
2442     }
2443 }
2444
2445 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2446 {
2447   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2448   tinyInfo.push_back(_start_time);
2449   tinyInfo.push_back(_end_time);
2450 }
2451
2452 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2453 {
2454   int nbOfCompo=_array->getNumberOfComponents();
2455   for(int i=0;i<nbOfCompo;i++)
2456     tinyInfo.push_back(_array->getInfoOnComponent(i));
2457   for(int i=0;i<nbOfCompo;i++)
2458     tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2459 }
2460
2461 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2462 {
2463   arrays.resize(2);
2464   if(_array!=0)
2465     _array->decrRef();
2466   if(_end_array!=0)
2467     _end_array->decrRef();
2468   DataArrayDouble *arr=0;
2469   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2470     {
2471       arr=DataArrayDouble::New();
2472       arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2473     }
2474   _array=arr;
2475   arrays[0]=arr;
2476   arr=0;
2477   if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2478     {
2479       arr=DataArrayDouble::New();
2480       arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2481     }
2482   _end_array=arr;
2483   arrays[1]=arr;
2484 }
2485
2486 void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
2487 {
2488   static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !";
2489   if(arrays.size()!=2)
2490     throw INTERP_KERNEL::Exception(MSG);
2491   if(_array!=0)
2492     _array->decrRef();
2493   if(_end_array!=0)
2494     _end_array->decrRef();
2495   _array=0; _end_array=0;
2496   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2497     {
2498       if(!arrays[0])
2499         throw INTERP_KERNEL::Exception(MSG);
2500       arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2501       _array=arrays[0]; _array->incrRef();
2502     }
2503   if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2504     {
2505       if(!arrays[1])
2506         throw INTERP_KERNEL::Exception(MSG);
2507       arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2508       _end_array=arrays[1]; _end_array->incrRef();
2509     }
2510 }
2511
2512 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2513 {
2514   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2515   _start_time=tinyInfoD[1];
2516   _end_time=tinyInfoD[2];
2517   _start_iteration=tinyInfoI[2];
2518   _start_order=tinyInfoI[3];
2519   _end_iteration=tinyInfoI[4];
2520   _end_order=tinyInfoI[5];
2521 }
2522
2523 /*!
2524  * idem getTinySerializationIntInformation except that it is for multi field fetch
2525  */
2526 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2527 {
2528   tinyInfo.resize(4);
2529   tinyInfo[0]=_start_iteration;
2530   tinyInfo[1]=_start_order;
2531   tinyInfo[2]=_end_iteration;
2532   tinyInfo[3]=_end_order;
2533 }
2534
2535 /*!
2536  * idem getTinySerializationDbleInformation except that it is for multi field fetch
2537  */
2538 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2539 {
2540   tinyInfo.resize(3);
2541   tinyInfo[0]=_time_tolerance;
2542   tinyInfo[1]=_start_time;
2543   tinyInfo[2]=_end_time;
2544 }
2545
2546 /*!
2547  * idem finishUnserialization except that it is for multi field fetch
2548  */
2549 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2550 {
2551   _start_iteration=tinyInfoI[0];
2552   _start_order=tinyInfoI[1];
2553   _end_iteration=tinyInfoI[2];
2554   _end_order=tinyInfoI[3];
2555   _time_tolerance=tinyInfoD[0];
2556   _start_time=tinyInfoD[1];
2557   _end_time=tinyInfoD[2];
2558 }
2559
2560 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
2561 {
2562   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
2563     {
2564       std::vector< const DataArrayDouble *> ret(2);
2565       ret[0]=_array;
2566       ret[1]=_end_array;
2567       return ret;
2568     }
2569   else
2570     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2571 }
2572
2573 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
2574 {
2575   if(arrays.size()!=2)
2576     throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2577   setArray(arrays.front(),owner);
2578   setEndArray(arrays.back(),owner);
2579 }
2580
2581 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy)
2582 {
2583 }
2584
2585 MEDCouplingLinearTime::MEDCouplingLinearTime()
2586 {
2587 }
2588
2589 std::string MEDCouplingLinearTime::getStringRepr() const
2590 {
2591   std::ostringstream stream;
2592   stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
2593   stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
2594   stream << "Time unit is : \"" << _time_unit << "\"";
2595   return stream.str();
2596 }
2597
2598 void MEDCouplingLinearTime::checkCoherency() const
2599 {
2600   MEDCouplingTwoTimeSteps::checkCoherency();
2601   if(std::fabs(_start_time-_end_time)<_time_tolerance)
2602     throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2603 }
2604
2605 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
2606 {
2607   return new MEDCouplingLinearTime(*this,deepCpy);
2608 }
2609
2610 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
2611 {
2612   if(!MEDCouplingTimeDiscretization::areCompatible(other))
2613     return false;
2614   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2615   if(otherC==0)
2616     return false;
2617   if(_end_array==0 && otherC->_end_array==0)
2618     return true;
2619   if(_end_array==0 || otherC->_end_array==0)
2620     return false;
2621   if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2622     return false;
2623   return true;
2624 }
2625
2626 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
2627 {
2628   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2629     return false;
2630   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2631   bool ret=otherC!=0;
2632   if(!ret)
2633     reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2634   return ret;
2635 }
2636
2637 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
2638 {
2639   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2640     return false;
2641   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2642   return otherC!=0;
2643 }
2644
2645 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
2646 {
2647   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2648     return false;
2649   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2650   if(otherC==0)
2651     return false;
2652   if(_end_array==0 && otherC->_end_array==0)
2653     return true;
2654   if(_end_array==0 || otherC->_end_array==0)
2655     return false;
2656   int nbC1=_end_array->getNumberOfComponents();
2657   int nbC2=otherC->_end_array->getNumberOfComponents();
2658   if(nbC1!=nbC2 && nbC2!=1)
2659     return false;
2660   return true;
2661 }
2662
2663 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2664 {
2665   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2666     return false;
2667   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2668   return otherC!=0;
2669 }
2670
2671 /*!
2672  * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2673  */
2674 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2675 {
2676   double alpha=(_end_time-time)/(_end_time-_start_time);
2677   std::size_t nbComp=vals.size()/2;
2678   std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2679   std::vector<double> tmp(nbComp);
2680   std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2681   std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2682 }
2683
2684 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
2685 {
2686   double alpha=(_end_time-time)/(_end_time-_start_time);
2687   int nbComp;
2688   if(_array)
2689     _array->getTuple(eltId,value);
2690   else
2691     throw INTERP_KERNEL::Exception("No start array existing.");
2692   nbComp=_array->getNumberOfComponents();
2693   std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2694   std::vector<double> tmp(nbComp);
2695   if(_end_array)
2696     _end_array->getTuple(eltId,&tmp[0]);
2697   else
2698     throw INTERP_KERNEL::Exception("No end array existing.");
2699   std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2700   std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2701 }
2702
2703 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
2704 {
2705   if(iteration==_start_iteration && order==_start_order)
2706     {
2707       if(_array)
2708         _array->getTuple(eltId,value);
2709       else
2710         throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2711     }
2712   if(iteration==_end_iteration && order==_end_order)
2713     {
2714       if(_end_array)
2715         _end_array->getTuple(eltId,value);
2716       else
2717         throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2718     }
2719   else
2720     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2721 }
2722
2723 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2724 {
2725   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2726   if(!otherC)
2727     throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2728   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2729   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2730   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2731   ret->setArray(arr1,0);
2732   ret->setEndArray(arr2,0);
2733   return ret;
2734 }
2735
2736 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2737 {
2738   std::vector<const DataArrayDouble *> a(other.size());
2739   std::vector<const DataArrayDouble *> b(other.size());
2740   int i=0;
2741   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2742     {
2743       const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2744       if(!itC)
2745         throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2746       a[i]=itC->getArray();
2747       b[i]=itC->getEndArray();
2748     }
2749   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2750   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
2751   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2752   ret->setArray(arr,0);
2753   ret->setEndArray(arr2,0);
2754   return ret;
2755 }
2756
2757 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2758 {
2759   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2760   if(!otherC)
2761     throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2762   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
2763   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
2764   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2765   ret->setTimeTolerance(getTimeTolerance());
2766   ret->setArray(arr1,0);
2767   ret->setEndArray(arr2,0);
2768   return ret;
2769 }
2770
2771 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2772 {
2773   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2774   if(!otherC)
2775     throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2776   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
2777   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
2778   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2779   ret->setArray(arr1,0);
2780   ret->setEndArray(arr2,0);
2781   return ret;
2782 }
2783
2784 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2785 {
2786   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2787   if(!otherC)
2788     throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2789   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2790   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
2791   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2792   ret->setArray(arr1,0);
2793   ret->setEndArray(arr2,0);
2794   return ret;
2795 }
2796
2797 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2798 {
2799   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2800   if(!otherC)
2801     throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2802   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2803   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
2804   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
2805   ret->setArray(arr1,0);
2806   ret->setEndArray(arr2,0);
2807   return ret;
2808 }
2809
2810 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2811 {
2812   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2813   if(!otherC)
2814     throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2815   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
2816   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
2817   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2818   ret->setArray(arr1,0);
2819   ret->setEndArray(arr2,0);
2820   return ret;
2821 }
2822
2823 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2824 {
2825   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2826   if(!otherC)
2827     throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2828   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
2829   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
2830   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2831   ret->setArray(arr1,0);
2832   ret->setEndArray(arr2,0);
2833   return ret;
2834 }
2835
2836 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2837 {
2838   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2839   if(!otherC)
2840     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2841   if(!getArray())
2842     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2843   if(!getEndArray())
2844     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2845   getArray()->addEqual(other->getArray());
2846   getEndArray()->addEqual(other->getEndArray());
2847 }
2848
2849 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2850 {
2851   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2852   if(!otherC)
2853     throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2854   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2855   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2856   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2857   ret->setArray(arr1,0);
2858   ret->setEndArray(arr2,0);
2859   return ret;
2860 }
2861
2862 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2863 {
2864   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2865   if(!otherC)
2866     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2867   if(!getArray())
2868     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2869   if(!getEndArray())
2870     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2871   getArray()->substractEqual(other->getArray());
2872   getEndArray()->substractEqual(other->getEndArray());
2873 }
2874
2875 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2876 {
2877   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2878   if(!otherC)
2879     throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2880   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2881   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2882   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2883   ret->setArray(arr1,0);
2884   ret->setEndArray(arr2,0);
2885   return ret;
2886 }
2887
2888 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2889 {
2890   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2891   if(!otherC)
2892     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2893   if(!getArray())
2894     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2895   if(!getEndArray())
2896     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2897   getArray()->multiplyEqual(other->getArray());
2898   getEndArray()->multiplyEqual(other->getEndArray());
2899 }
2900
2901 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2902 {
2903   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2904   if(!otherC)
2905     throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2906   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2907   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2908   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2909   ret->setArray(arr1,0);
2910   ret->setEndArray(arr2,0);
2911   return ret;
2912 }
2913
2914 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2915 {
2916   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2917   if(!otherC)
2918     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2919   if(!getArray())
2920     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2921   if(!getEndArray())
2922     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2923   getArray()->divideEqual(other->getArray());
2924   getEndArray()->divideEqual(other->getEndArray());
2925 }
2926
2927 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2928 {
2929   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2930   if(!otherC)
2931     throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2932   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2933   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2934   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2935   ret->setArray(arr1,0);
2936   ret->setEndArray(arr2,0);
2937   return ret;
2938 }
2939
2940 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2941 {
2942   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2943   if(!otherC)
2944     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2945   if(!getArray())
2946     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2947   if(!getEndArray())
2948     throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2949   getArray()->powEqual(other->getArray());
2950   getEndArray()->powEqual(other->getEndArray());
2951 }