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