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