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