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