1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingTimeDiscretization.hxx"
22 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDCouplingMesh.hxx"
32 using namespace ParaMEDMEM;
34 const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12;
36 const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
38 const char MEDCouplingNoTimeLabel::REPR[]="No time label defined.";
40 const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
42 const char MEDCouplingWithTimeStep::REPR[]="One time label.";
44 const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time.";
46 const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval.";
48 const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time.";
50 const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
52 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
56 case MEDCouplingNoTimeLabel::DISCRETIZATION:
57 return new MEDCouplingNoTimeLabel;
58 case MEDCouplingWithTimeStep::DISCRETIZATION:
59 return new MEDCouplingWithTimeStep;
60 case MEDCouplingConstOnTimeInterval::DISCRETIZATION:
61 return new MEDCouplingConstOnTimeInterval;
62 case MEDCouplingLinearTime::DISCRETIZATION:
63 return new MEDCouplingLinearTime;
65 throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
69 void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
71 _time_tolerance=other._time_tolerance;
72 _time_unit=other._time_unit;
75 void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
77 _time_unit=other._time_unit;
78 if(_array && other._array)
79 _array->copyStringInfoFrom(*other._array);
82 void MEDCouplingTimeDiscretization::checkCoherency() const throw(INTERP_KERNEL::Exception)
85 throw INTERP_KERNEL::Exception("Field invalid because no values set !");
86 if(_time_tolerance<0.)
87 throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
90 void MEDCouplingTimeDiscretization::updateTime() const
93 updateTimeWith(*_array);
96 std::size_t MEDCouplingTimeDiscretization::getHeapMemorySize() const
98 std::size_t ret=_time_unit.capacity();
100 ret+=_array->getHeapMemorySize();
104 bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
106 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
108 if(_array==0 && other->_array==0)
110 if(_array==0 || other->_array==0)
112 if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
117 bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
119 std::ostringstream oss; oss.precision(15);
120 if(_time_unit!=other->_time_unit)
122 oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
126 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
128 oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
132 if(_array==0 && other->_array==0)
134 if(_array==0 || other->_array==0)
136 reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
139 if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
141 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
146 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
148 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
150 if(_array==0 && other->_array==0)
152 if(_array==0 || other->_array==0)
154 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
159 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
161 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
163 if(_array==0 && other->_array==0)
165 if(_array==0 || other->_array==0)
167 int nbC1=_array->getNumberOfComponents();
168 int nbC2=other->_array->getNumberOfComponents();
169 int nbMin=std::min(nbC1,nbC2);
170 if(nbC1!=nbC2 && nbMin!=1)
175 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
177 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
179 if(_array==0 && other->_array==0)
181 if(_array==0 || other->_array==0)
183 int nbC1=_array->getNumberOfComponents();
184 int nbC2=other->_array->getNumberOfComponents();
185 if(nbC1!=nbC2 && nbC2!=1)
190 bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
192 if(!areStrictlyCompatible(other,reason))
194 if(_array==other->_array)
196 return _array->isEqualIfNotWhy(*other->_array,prec,reason);
199 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
202 return isEqualIfNotWhy(other,prec,reason);
205 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
208 if(!areStrictlyCompatible(other,tmp))
210 if(_array==other->_array)
212 return _array->isEqualWithoutConsideringStr(*other->_array,prec);
215 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
217 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
218 ret->setTimeUnit(getTimeUnit());
219 const DataArrayDouble *arrSrc=getArray();
220 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr;
222 arr=arrSrc->performCpy(deepCpy);
223 ret->setArray(arr,0);
227 void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
231 tinyInfo.push_back(_array->getNumberOfTuples());
232 tinyInfo.push_back(_array->getNumberOfComponents());
236 tinyInfo.push_back(-1);
237 tinyInfo.push_back(-1);
241 void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
246 DataArrayDouble *arr=0;
247 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
249 arr=DataArrayDouble::New();
250 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
256 void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
258 _time_tolerance=tinyInfoD[0];
259 int nbOfCompo=_array->getNumberOfComponents();
260 for(int i=0;i<nbOfCompo;i++)
261 _array->setInfoOnComponent(i,tinyInfoS[i].c_str());
264 void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
266 tinyInfo.push_back(_time_tolerance);
269 void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
271 int nbOfCompo=_array->getNumberOfComponents();
272 for(int i=0;i<nbOfCompo;i++)
273 tinyInfo.push_back(_array->getInfoOnComponent(i));
276 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
280 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
283 _array=other._array->performCpy(deepCpy);
288 MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
294 void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
304 owner->declareAsNew();
308 const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
310 throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
313 DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
315 throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
318 void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
320 throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
323 void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
326 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
327 setArray(arrays.back(),owner);
330 void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
336 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
339 double time1=getEndTime(iteration,order)-_time_tolerance;
340 double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
344 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
347 double time1=getEndTime(iteration,order)+_time_tolerance;
348 double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
352 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
354 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
355 ret->setTimeUnit(getTimeUnit());
356 std::vector<DataArrayDouble *> arrays;
358 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
359 for(int j=0;j<(int)arrays.size();j++)
362 arrays2[j]=arrays[j]->doublyContractedProduct();
366 std::vector<DataArrayDouble *> arrays3(arrays.size());
367 for(int j=0;j<(int)arrays.size();j++)
368 arrays3[j]=arrays2[j];
369 ret->setArrays(arrays3,0);
373 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const throw(INTERP_KERNEL::Exception)
375 std::vector<DataArrayDouble *> arrays;
377 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
378 for(int j=0;j<(int)arrays.size();j++)
381 arrays2[j]=arrays[j]->determinant();
385 std::vector<DataArrayDouble *> arrays3(arrays.size());
386 for(int j=0;j<(int)arrays.size();j++)
387 arrays3[j]=arrays2[j];
388 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
389 ret->setTimeUnit(getTimeUnit());
390 ret->setArrays(arrays3,0);
394 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const throw(INTERP_KERNEL::Exception)
396 std::vector<DataArrayDouble *> arrays;
398 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
399 for(int j=0;j<(int)arrays.size();j++)
402 arrays2[j]=arrays[j]->eigenValues();
406 std::vector<DataArrayDouble *> arrays3(arrays.size());
407 for(int j=0;j<(int)arrays.size();j++)
408 arrays3[j]=arrays2[j];
409 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
410 ret->setTimeUnit(getTimeUnit());
411 ret->setArrays(arrays3,0);
415 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const throw(INTERP_KERNEL::Exception)
417 std::vector<DataArrayDouble *> arrays;
419 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
420 for(int j=0;j<(int)arrays.size();j++)
423 arrays2[j]=arrays[j]->eigenVectors();
427 std::vector<DataArrayDouble *> arrays3(arrays.size());
428 for(int j=0;j<(int)arrays.size();j++)
429 arrays3[j]=arrays2[j];
430 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
431 ret->setTimeUnit(getTimeUnit());
432 ret->setArrays(arrays3,0);
436 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const throw(INTERP_KERNEL::Exception)
438 std::vector<DataArrayDouble *> arrays;
440 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
441 for(int j=0;j<(int)arrays.size();j++)
444 arrays2[j]=arrays[j]->inverse();
448 std::vector<DataArrayDouble *> arrays3(arrays.size());
449 for(int j=0;j<(int)arrays.size();j++)
450 arrays3[j]=arrays2[j];
451 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
452 ret->setTimeUnit(getTimeUnit());
453 ret->setArrays(arrays3,0);
457 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const throw(INTERP_KERNEL::Exception)
459 std::vector<DataArrayDouble *> arrays;
461 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
462 for(int j=0;j<(int)arrays.size();j++)
465 arrays2[j]=arrays[j]->trace();
469 std::vector<DataArrayDouble *> arrays3(arrays.size());
470 for(int j=0;j<(int)arrays.size();j++)
471 arrays3[j]=arrays2[j];
472 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
473 ret->setTimeUnit(getTimeUnit());
474 ret->setArrays(arrays3,0);
478 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const throw(INTERP_KERNEL::Exception)
480 std::vector<DataArrayDouble *> arrays;
482 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
483 for(int j=0;j<(int)arrays.size();j++)
486 arrays2[j]=arrays[j]->deviator();
490 std::vector<DataArrayDouble *> arrays3(arrays.size());
491 for(int j=0;j<(int)arrays.size();j++)
492 arrays3[j]=arrays2[j];
493 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
494 ret->setTimeUnit(getTimeUnit());
495 ret->setArrays(arrays3,0);
499 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const throw(INTERP_KERNEL::Exception)
501 std::vector<DataArrayDouble *> arrays;
503 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
504 for(int j=0;j<(int)arrays.size();j++)
507 arrays2[j]=arrays[j]->magnitude();
511 std::vector<DataArrayDouble *> arrays3(arrays.size());
512 for(int j=0;j<(int)arrays.size();j++)
513 arrays3[j]=arrays2[j];
514 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
515 ret->setTimeUnit(getTimeUnit());
516 ret->setArrays(arrays3,0);
520 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const throw(INTERP_KERNEL::Exception)
522 std::vector<DataArrayDouble *> arrays;
524 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
525 for(int j=0;j<(int)arrays.size();j++)
528 arrays2[j]=arrays[j]->maxPerTuple();
532 std::vector<DataArrayDouble *> arrays3(arrays.size());
533 for(int j=0;j<(int)arrays.size();j++)
534 arrays3[j]=arrays2[j];
535 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
536 ret->setTimeUnit(getTimeUnit());
537 ret->setArrays(arrays3,0);
541 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
543 std::vector<DataArrayDouble *> arrays;
545 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
546 for(int j=0;j<(int)arrays.size();j++)
549 arrays2[j]=arrays[j]->keepSelectedComponents(compoIds);
553 std::vector<DataArrayDouble *> arrays3(arrays.size());
554 for(int j=0;j<(int)arrays.size();j++)
555 arrays3[j]=arrays2[j];
556 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
557 ret->setTimeUnit(getTimeUnit());
558 ret->setArrays(arrays3,0);
562 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
564 std::vector<DataArrayDouble *> arrays1,arrays2;
566 other->getArrays(arrays2);
567 if(arrays1.size()!=arrays2.size())
568 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
569 for(unsigned int i=0;i<arrays1.size();i++)
571 if(arrays1[i]!=0 && arrays2[i]!=0)
572 arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
573 else if(arrays1[i]!=0 || arrays2[i]!=0)
574 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
578 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception)
580 std::vector<DataArrayDouble *> arrays;
582 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
583 for(int j=0;j<(int)arrays.size();j++)
586 arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
590 std::vector<DataArrayDouble *> arrays3(arrays.size());
591 for(int j=0;j<(int)arrays.size();j++)
592 arrays3[j]=arrays2[j];
593 setArrays(arrays3,0);
596 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
598 std::vector<DataArrayDouble *> arrays;
600 for(int j=0;j<(int)arrays.size();j++)
603 arrays[j]->sortPerTuple(asc);
607 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
609 std::vector<DataArrayDouble *> arrays;
611 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
612 for(int j=0;j<(int)arrays.size();j++)
616 arrays[j]->incrRef();
617 arrays[j]->fillWithValue(value);
618 arrays2[j]=arrays[j];
622 DataArrayDouble *tmp=DataArrayDouble::New();
623 tmp->alloc(nbOfTuple,nbOfCompo);
624 tmp->fillWithValue(value);
628 std::vector<DataArrayDouble *> arrays3(arrays.size());
629 for(int j=0;j<(int)arrays.size();j++)
630 arrays3[j]=arrays2[j];
631 setArrays(arrays3,0);
634 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
636 std::vector<DataArrayDouble *> arrays;
638 for(int j=0;j<(int)arrays.size();j++)
641 arrays[j]->applyLin(a,b,compoId);
645 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
647 std::vector<DataArrayDouble *> arrays;
649 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
650 for(int j=0;j<(int)arrays.size();j++)
653 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
657 std::vector<DataArrayDouble *> arrays3(arrays.size());
658 for(int j=0;j<(int)arrays.size();j++)
659 arrays3[j]=arrays2[j];
660 setArrays(arrays3,0);
663 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
665 std::vector<DataArrayDouble *> arrays;
667 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
668 for(int j=0;j<(int)arrays.size();j++)
671 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
675 std::vector<DataArrayDouble *> arrays3(arrays.size());
676 for(int j=0;j<(int)arrays.size();j++)
677 arrays3[j]=arrays2[j];
678 setArrays(arrays3,0);
681 void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
683 std::vector<DataArrayDouble *> arrays;
685 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
686 for(int j=0;j<(int)arrays.size();j++)
689 arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
693 std::vector<DataArrayDouble *> arrays3(arrays.size());
694 for(int j=0;j<(int)arrays.size();j++)
695 arrays3[j]=arrays2[j];
696 setArrays(arrays3,0);
699 void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
701 std::vector<DataArrayDouble *> arrays;
703 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
704 for(int j=0;j<(int)arrays.size();j++)
707 arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
711 std::vector<DataArrayDouble *> arrays3(arrays.size());
712 for(int j=0;j<(int)arrays.size();j++)
713 arrays3[j]=arrays2[j];
714 setArrays(arrays3,0);
717 void MEDCouplingTimeDiscretization::applyFunc(const char *func)
719 std::vector<DataArrayDouble *> arrays;
721 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
722 for(int j=0;j<(int)arrays.size();j++)
725 arrays2[j]=arrays[j]->applyFunc(func);
729 std::vector<DataArrayDouble *> arrays3(arrays.size());
730 for(int j=0;j<(int)arrays.size();j++)
731 arrays3[j]=arrays2[j];
732 setArrays(arrays3,0);
735 void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
737 std::vector<DataArrayDouble *> arrays;
739 for(int j=0;j<(int)arrays.size();j++)
742 arrays[j]->applyFuncFast32(func);
746 void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func)
748 std::vector<DataArrayDouble *> arrays;
750 for(int j=0;j<(int)arrays.size();j++)
753 arrays[j]->applyFuncFast64(func);
757 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception)
759 std::vector<DataArrayDouble *> arrays;
761 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
762 for(int j=0;j<(int)arrays.size();j++)
763 arrays2[j]=loc->applyFunc(nbOfComp,func);
764 std::vector<DataArrayDouble *> arrays3(arrays.size());
765 for(int j=0;j<(int)arrays.size();j++)
766 arrays3[j]=arrays2[j];
767 setArrays(arrays3,0);
770 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
772 std::vector<DataArrayDouble *> arrays;
774 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
775 for(int j=0;j<(int)arrays.size();j++)
776 arrays2[j]=loc->applyFunc(nbOfComp,func);
777 std::vector<DataArrayDouble *> arrays3(arrays.size());
778 for(int j=0;j<(int)arrays.size();j++)
779 arrays3[j]=arrays2[j];
780 setArrays(arrays3,0);
783 void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
785 std::vector<DataArrayDouble *> arrays;
787 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
788 for(int j=0;j<(int)arrays.size();j++)
789 arrays2[j]=loc->applyFunc2(nbOfComp,func);
790 std::vector<DataArrayDouble *> arrays3(arrays.size());
791 for(int j=0;j<(int)arrays.size();j++)
792 arrays3[j]=arrays2[j];
793 setArrays(arrays3,0);
796 void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
798 std::vector<DataArrayDouble *> arrays;
800 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
801 for(int j=0;j<(int)arrays.size();j++)
802 arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
803 std::vector<DataArrayDouble *> arrays3(arrays.size());
804 for(int j=0;j<(int)arrays.size();j++)
805 arrays3[j]=arrays2[j];
806 setArrays(arrays3,0);
809 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
813 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
817 std::string MEDCouplingNoTimeLabel::getStringRepr() const
819 std::ostringstream stream;
821 stream << "\nTime unit is : \"" << _time_unit << "\"";
825 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
827 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
830 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
832 if(!MEDCouplingTimeDiscretization::areCompatible(other))
834 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
838 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
840 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
842 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
845 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
849 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
851 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
853 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
857 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
859 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
861 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
865 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
867 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
869 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
873 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
875 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
878 reason="This has time discretization NO_TIME, other not.";
881 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
884 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
886 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
889 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
892 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
894 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
896 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
897 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
898 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
899 ret->setArray(arr,0);
903 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
905 std::vector<const DataArrayDouble *> a(other.size());
907 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
909 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
911 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
912 a[i]=itC->getArray();
914 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
915 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
916 ret->setArray(arr,0);
920 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
922 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
924 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
925 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
926 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
927 ret->setTimeTolerance(getTimeTolerance());
928 ret->setArray(arr,0);
932 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
934 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
936 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
937 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
938 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
939 ret->setArray(arr,0);
943 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
945 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
947 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
948 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
949 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
950 ret->setArray(arr,0);
954 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
956 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
958 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
959 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
960 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
961 ret->setArray(arr,0);
965 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
967 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
969 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
970 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
971 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
972 ret->setArray(arr,0);
976 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
978 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
980 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
981 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
982 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
983 ret->setArray(arr,0);
987 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
989 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
991 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
993 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
994 getArray()->addEqual(other->getArray());
997 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
999 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1001 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1003 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1004 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1005 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1006 ret->setArray(arr,0);
1010 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1012 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1014 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1016 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1017 getArray()->substractEqual(other->getArray());
1020 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1022 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1024 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1025 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1026 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1027 ret->setArray(arr,0);
1031 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1033 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1035 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1037 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1038 getArray()->multiplyEqual(other->getArray());
1041 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1043 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1045 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1046 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1047 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1048 ret->setArray(arr,0);
1052 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1054 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1056 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1058 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1059 getArray()->divideEqual(other->getArray());
1062 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
1064 return new MEDCouplingNoTimeLabel(*this,deepCpy);
1067 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1069 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1072 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1074 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1077 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1079 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1082 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
1084 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1087 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
1089 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1092 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
1094 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1097 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
1099 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1102 void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception)
1104 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1107 void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception)
1109 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1112 void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception)
1114 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1117 void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception)
1119 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1122 void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception)
1124 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1127 void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception)
1129 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1132 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
1134 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1137 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
1139 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1142 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1144 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1147 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1149 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1153 * idem getTinySerializationIntInformation except that it is for multi field fetch
1155 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1161 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1163 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1166 tinyInfo[0]=_time_tolerance;
1170 * idem finishUnserialization except that it is for multi field fetch
1172 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1174 _time_tolerance=tinyInfoD[0];
1177 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
1178 _time(other._time),_iteration(other._iteration),_order(other._order)
1182 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
1186 std::string MEDCouplingWithTimeStep::getStringRepr() const
1188 std::ostringstream stream;
1189 stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
1190 stream << "\nTime unit is : \"" << _time_unit << "\"";
1191 return stream.str();
1194 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1197 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1199 double val=mesh->getTime(it,order);
1200 _time=val; _iteration=it; _order=order;
1201 std::string tUnit=mesh->getTimeUnit();
1205 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1207 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1208 tinyInfo.push_back(_iteration);
1209 tinyInfo.push_back(_order);
1212 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1214 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1215 tinyInfo.push_back(_time);
1218 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1220 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1222 _iteration=tinyInfoI[2];
1223 _order=tinyInfoI[3];
1227 * idem getTinySerializationIntInformation except that it is for multi field fetch
1229 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1232 tinyInfo[0]=_iteration;
1237 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1239 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1242 tinyInfo[0]=_time_tolerance;
1247 * idem finishUnserialization except that it is for multi field fetch
1249 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1251 _iteration=tinyInfoI[0];
1252 _order=tinyInfoI[1];
1253 _time_tolerance=tinyInfoD[0];
1257 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
1259 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1261 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1265 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1267 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1269 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1272 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1276 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1278 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1280 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1284 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1286 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1288 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1292 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1294 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1296 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1300 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1302 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1303 std::ostringstream oss; oss.precision(15);
1306 reason="This has time discretization ONE_TIME, other not.";
1309 if(_iteration!=otherC->_iteration)
1311 oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
1315 if(_order!=otherC->_order)
1317 oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
1321 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1323 oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
1327 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1330 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1332 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1335 if(_iteration!=otherC->_iteration)
1337 if(_order!=otherC->_order)
1339 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1341 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1344 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
1346 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1347 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1349 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1350 _time=otherC->_time;
1351 _iteration=otherC->_iteration;
1352 _order=otherC->_order;
1355 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1357 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1359 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1360 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1361 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1362 ret->setArray(arr,0);
1366 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1368 std::vector<const DataArrayDouble *> a(other.size());
1370 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1372 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1374 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1375 a[i]=itC->getArray();
1377 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1378 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1379 ret->setArray(arr,0);
1383 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1385 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1387 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1388 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1389 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1390 ret->setArray(arr,0);
1394 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1396 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1398 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1399 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1400 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1401 ret->setArray(arr,0);
1405 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1407 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1409 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1410 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1411 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1412 ret->setArray(arr,0);
1416 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1418 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1420 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1421 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1422 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1423 ret->setArray(arr,0);
1427 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1429 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1431 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1432 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1433 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1434 ret->setArray(arr,0);
1438 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1440 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1442 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1443 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1444 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1445 ret->setArray(arr,0);
1447 double tmp3=getStartTime(tmp1,tmp2);
1448 ret->setStartTime(tmp3,tmp1,tmp2);
1452 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1454 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1456 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1458 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1459 getArray()->addEqual(other->getArray());
1462 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1464 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1466 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1467 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1468 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1469 ret->setArray(arr,0);
1471 double tmp3=getStartTime(tmp1,tmp2);
1472 ret->setStartTime(tmp3,tmp1,tmp2);
1476 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1478 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1480 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1482 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1483 getArray()->substractEqual(other->getArray());
1486 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1488 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1490 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1491 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1492 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1493 ret->setArray(arr,0);
1495 double tmp3=getStartTime(tmp1,tmp2);
1496 ret->setStartTime(tmp3,tmp1,tmp2);
1500 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1502 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1504 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1506 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1507 getArray()->multiplyEqual(other->getArray());
1510 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1512 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1514 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1515 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1516 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1517 ret->setArray(arr,0);
1519 double tmp3=getStartTime(tmp1,tmp2);
1520 ret->setStartTime(tmp3,tmp1,tmp2);
1524 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1526 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1528 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1530 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1531 getArray()->divideEqual(other->getArray());
1534 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
1536 return new MEDCouplingWithTimeStep(*this,deepCpy);
1539 void MEDCouplingWithTimeStep::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
1541 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1544 void MEDCouplingWithTimeStep::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1546 if(std::fabs(time-_time)>_time_tolerance)
1548 std::ostringstream stream;
1549 stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
1550 throw INTERP_KERNEL::Exception(stream.str().c_str());
1554 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1556 if(std::fabs(time-_time)<=_time_tolerance)
1558 std::vector< const DataArrayDouble *> ret(1);
1563 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1566 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1568 std::copy(vals.begin(),vals.end(),res);
1571 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1573 if(std::fabs(time-_time)<=_time_tolerance)
1575 _array->getTuple(eltId,value);
1577 throw INTERP_KERNEL::Exception("No array existing.");
1579 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1582 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1584 if(_iteration==iteration && _order==order)
1586 _array->getTuple(eltId,value);
1588 throw INTERP_KERNEL::Exception("No array existing.");
1590 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1593 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
1597 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
1599 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1600 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1602 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1603 _start_time=otherC->_start_time;
1604 _end_time=otherC->_end_time;
1605 _start_iteration=otherC->_start_iteration;
1606 _end_iteration=otherC->_end_iteration;
1607 _start_order=otherC->_start_order;
1608 _end_order=otherC->_end_order;
1611 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1613 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1614 tinyInfo.push_back(_start_iteration);
1615 tinyInfo.push_back(_start_order);
1616 tinyInfo.push_back(_end_iteration);
1617 tinyInfo.push_back(_end_order);
1620 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1622 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1623 tinyInfo.push_back(_start_time);
1624 tinyInfo.push_back(_end_time);
1627 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1629 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1630 _start_time=tinyInfoD[1];
1631 _end_time=tinyInfoD[2];
1632 _start_iteration=tinyInfoI[2];
1633 _start_order=tinyInfoI[3];
1634 _end_iteration=tinyInfoI[4];
1635 _end_order=tinyInfoI[5];
1639 * idem getTinySerializationIntInformation except that it is for multi field fetch
1641 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1644 tinyInfo[0]=_start_iteration;
1645 tinyInfo[1]=_start_order;
1646 tinyInfo[2]=_end_iteration;
1647 tinyInfo[3]=_end_order;
1651 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1653 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1656 tinyInfo[0]=_time_tolerance;
1657 tinyInfo[1]=_start_time;
1658 tinyInfo[2]=_end_time;
1662 * idem finishUnserialization except that it is for multi field fetch
1664 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1666 _start_iteration=tinyInfoI[0];
1667 _start_order=tinyInfoI[1];
1668 _end_iteration=tinyInfoI[2];
1669 _end_order=tinyInfoI[3];
1670 _time_tolerance=tinyInfoD[0];
1671 _start_time=tinyInfoD[1];
1672 _end_time=tinyInfoD[2];
1675 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
1676 MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
1677 _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
1681 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1683 std::ostringstream stream;
1684 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
1685 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
1686 stream << "\nTime unit is : \"" << _time_unit << "\"";
1687 return stream.str();
1690 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1693 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1695 double val=mesh->getTime(it,order);
1696 _start_time=val; _start_iteration=it; _start_order=order;
1697 _end_time=val; _end_iteration=it; _end_order=order;
1698 std::string tUnit=mesh->getTimeUnit();
1702 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
1704 return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
1707 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1709 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1711 std::vector< const DataArrayDouble *> ret(1);
1716 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1719 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1721 std::copy(vals.begin(),vals.end(),res);
1724 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
1726 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1728 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1732 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1734 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1736 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1739 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1743 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1745 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1747 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1751 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1753 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1755 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1759 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1761 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1763 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1767 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1769 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1770 std::ostringstream oss; oss.precision(15);
1773 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1776 if(_start_iteration!=otherC->_start_iteration)
1778 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
1782 if(_start_order!=otherC->_start_order)
1784 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
1788 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1790 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
1794 if(_end_iteration!=otherC->_end_iteration)
1796 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
1800 if(_end_order!=otherC->_end_order)
1802 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
1806 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1808 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
1812 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1815 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1817 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1820 if(_start_iteration!=otherC->_start_iteration)
1822 if(_start_order!=otherC->_start_order)
1824 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1826 if(_end_iteration!=otherC->_end_iteration)
1828 if(_end_order!=otherC->_end_order)
1830 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1832 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1835 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1837 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1839 _array->getTuple(eltId,value);
1841 throw INTERP_KERNEL::Exception("No array existing.");
1843 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1846 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1848 if(iteration>=_start_iteration && iteration<=_end_iteration)
1850 _array->getTuple(eltId,value);
1852 throw INTERP_KERNEL::Exception("No array existing.");
1854 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1857 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
1859 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1862 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1864 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
1866 std::ostringstream stream;
1867 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
1868 stream << _time_tolerance << " and trying to access on time = " << time;
1869 throw INTERP_KERNEL::Exception(stream.str().c_str());
1873 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1875 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1877 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1878 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1879 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1880 ret->setArray(arr,0);
1884 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1886 std::vector<const DataArrayDouble *> a(other.size());
1888 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1890 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
1892 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
1893 a[i]=itC->getArray();
1895 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1896 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1897 ret->setArray(arr,0);
1901 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
1903 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1905 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
1906 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1907 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1908 ret->setTimeTolerance(getTimeTolerance());
1909 ret->setArray(arr,0);
1913 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
1915 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1917 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
1918 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1919 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1920 ret->setArray(arr,0);
1924 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
1926 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1928 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
1929 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1930 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1931 ret->setArray(arr,0);
1935 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
1937 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1939 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
1940 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1941 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1942 ret->setArray(arr,0);
1946 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
1948 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1950 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
1951 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1952 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1953 ret->setArray(arr,0);
1957 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
1959 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1961 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
1962 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1963 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1964 ret->setArray(arr,0);
1966 double tmp3=getStartTime(tmp1,tmp2);
1967 ret->setStartTime(tmp3,tmp1,tmp2);
1968 tmp3=getEndTime(tmp1,tmp2);
1969 ret->setEndTime(tmp3,tmp1,tmp2);
1973 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
1975 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1977 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
1979 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
1980 getArray()->addEqual(other->getArray());
1983 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
1985 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1987 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
1988 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1989 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1990 ret->setArray(arr,0);
1992 double tmp3=getStartTime(tmp1,tmp2);
1993 ret->setStartTime(tmp3,tmp1,tmp2);
1994 tmp3=getEndTime(tmp1,tmp2);
1995 ret->setEndTime(tmp3,tmp1,tmp2);
1999 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2001 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2003 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2005 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2006 getArray()->substractEqual(other->getArray());
2009 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2011 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2013 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2014 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2015 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2016 ret->setArray(arr,0);
2018 double tmp3=getStartTime(tmp1,tmp2);
2019 ret->setStartTime(tmp3,tmp1,tmp2);
2020 tmp3=getEndTime(tmp1,tmp2);
2021 ret->setEndTime(tmp3,tmp1,tmp2);
2025 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2027 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2029 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2031 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2032 getArray()->multiplyEqual(other->getArray());
2035 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2037 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2039 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2040 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2041 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2042 ret->setArray(arr,0);
2044 double tmp3=getStartTime(tmp1,tmp2);
2045 ret->setStartTime(tmp3,tmp1,tmp2);
2046 tmp3=getEndTime(tmp1,tmp2);
2047 ret->setEndTime(tmp3,tmp1,tmp2);
2051 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2053 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2055 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2057 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2058 getArray()->divideEqual(other->getArray());
2061 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
2062 _start_time(other._start_time),_end_time(other._end_time),
2063 _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
2064 _start_order(other._start_order),_end_order(other._end_order)
2066 if(other._end_array)
2067 _end_array=other._end_array->performCpy(deepCpy);
2072 void MEDCouplingTwoTimeSteps::updateTime() const
2074 MEDCouplingTimeDiscretization::updateTime();
2076 updateTimeWith(*_end_array);
2079 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
2082 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2084 double val=mesh->getTime(it,order);
2085 _start_time=val; _start_iteration=it; _start_order=order;
2086 _end_time=val; _end_iteration=it; _end_order=order;
2087 std::string tUnit=mesh->getTimeUnit();
2091 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySize() const
2095 ret+=_end_array->getHeapMemorySize();
2096 return MEDCouplingTimeDiscretization::getHeapMemorySize()+ret;
2099 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
2101 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2102 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2104 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2105 _start_time=otherC->_start_time;
2106 _end_time=otherC->_end_time;
2107 _start_iteration=otherC->_start_iteration;
2108 _end_iteration=otherC->_end_iteration;
2109 _start_order=otherC->_start_order;
2110 _end_order=otherC->_end_order;
2113 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
2115 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2116 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2118 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2119 if(_end_array && otherC->_end_array)
2120 _end_array->copyStringInfoFrom(*otherC->_end_array);
2123 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2128 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2133 void MEDCouplingTwoTimeSteps::checkCoherency() const throw(INTERP_KERNEL::Exception)
2135 MEDCouplingTimeDiscretization::checkCoherency();
2137 throw INTERP_KERNEL::Exception("No end array specified !");
2138 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2139 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2140 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2141 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2144 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
2146 std::ostringstream oss;
2147 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2150 reason="This has time discretization LINEAR_TIME, other not.";
2153 if(_start_iteration!=otherC->_start_iteration)
2155 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
2159 if(_start_order!=otherC->_start_order)
2161 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
2165 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2167 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
2171 if(_end_iteration!=otherC->_end_iteration)
2173 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
2177 if(_end_order!=otherC->_end_order)
2179 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
2183 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2185 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
2189 if(_end_array!=otherC->_end_array)
2190 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2192 reason.insert(0,"end arrays differ for linear time.");
2195 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2198 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
2200 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2203 if(_start_iteration!=otherC->_start_iteration)
2205 if(_end_iteration!=otherC->_end_iteration)
2207 if(_start_order!=otherC->_start_order)
2209 if(_end_order!=otherC->_end_order)
2211 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2213 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2215 if(_end_array!=otherC->_end_array)
2216 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2218 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2221 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
2225 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2228 _end_array->decrRef();
2231 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
2233 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2236 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
2238 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
2240 std::ostringstream stream;
2241 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
2242 stream << _time_tolerance << " and trying to access on time = " << time;
2243 throw INTERP_KERNEL::Exception(stream.str().c_str());
2247 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2251 arrays[1]=_end_array;
2254 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2256 if(array!=_end_array)
2259 _end_array->decrRef();
2262 _end_array->incrRef();
2264 owner->declareAsNew();
2268 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2270 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2271 tinyInfo.push_back(_start_iteration);
2272 tinyInfo.push_back(_start_order);
2273 tinyInfo.push_back(_end_iteration);
2274 tinyInfo.push_back(_end_order);
2277 tinyInfo.push_back(_end_array->getNumberOfTuples());
2278 tinyInfo.push_back(_end_array->getNumberOfComponents());
2282 tinyInfo.push_back(-1);
2283 tinyInfo.push_back(-1);
2287 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2289 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2290 tinyInfo.push_back(_start_time);
2291 tinyInfo.push_back(_end_time);
2294 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2296 int nbOfCompo=_array->getNumberOfComponents();
2297 for(int i=0;i<nbOfCompo;i++)
2298 tinyInfo.push_back(_array->getInfoOnComponent(i));
2299 for(int i=0;i<nbOfCompo;i++)
2300 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2303 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2309 _end_array->decrRef();
2310 DataArrayDouble *arr=0;
2311 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2313 arr=DataArrayDouble::New();
2314 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2319 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2321 arr=DataArrayDouble::New();
2322 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2328 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2330 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2331 _start_time=tinyInfoD[1];
2332 _end_time=tinyInfoD[2];
2333 _start_iteration=tinyInfoI[2];
2334 _start_order=tinyInfoI[3];
2335 _end_iteration=tinyInfoI[4];
2336 _end_order=tinyInfoI[5];
2340 * idem getTinySerializationIntInformation except that it is for multi field fetch
2342 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2345 tinyInfo[0]=_start_iteration;
2346 tinyInfo[1]=_start_order;
2347 tinyInfo[2]=_end_iteration;
2348 tinyInfo[3]=_end_order;
2352 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2354 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2357 tinyInfo[0]=_time_tolerance;
2358 tinyInfo[1]=_start_time;
2359 tinyInfo[2]=_end_time;
2363 * idem finishUnserialization except that it is for multi field fetch
2365 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2367 _start_iteration=tinyInfoI[0];
2368 _start_order=tinyInfoI[1];
2369 _end_iteration=tinyInfoI[2];
2370 _end_order=tinyInfoI[3];
2371 _time_tolerance=tinyInfoD[0];
2372 _start_time=tinyInfoD[1];
2373 _end_time=tinyInfoD[2];
2376 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
2378 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
2380 std::vector< const DataArrayDouble *> ret(2);
2386 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2389 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
2391 if(arrays.size()!=2)
2392 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2393 setArray(arrays.front(),owner);
2394 setEndArray(arrays.back(),owner);
2397 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy)
2401 MEDCouplingLinearTime::MEDCouplingLinearTime()
2405 std::string MEDCouplingLinearTime::getStringRepr() const
2407 std::ostringstream stream;
2408 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
2409 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
2410 stream << "Time unit is : \"" << _time_unit << "\"";
2411 return stream.str();
2414 void MEDCouplingLinearTime::checkCoherency() const throw(INTERP_KERNEL::Exception)
2416 MEDCouplingTwoTimeSteps::checkCoherency();
2417 if(std::fabs(_start_time-_end_time)<_time_tolerance)
2418 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2421 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
2423 return new MEDCouplingLinearTime(*this,deepCpy);
2426 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
2428 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2430 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2433 if(_end_array==0 && otherC->_end_array==0)
2435 if(_end_array==0 || otherC->_end_array==0)
2437 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2442 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
2444 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2446 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2449 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2453 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
2455 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2457 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2461 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
2463 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2465 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2468 if(_end_array==0 && otherC->_end_array==0)
2470 if(_end_array==0 || otherC->_end_array==0)
2472 int nbC1=_end_array->getNumberOfComponents();
2473 int nbC2=otherC->_end_array->getNumberOfComponents();
2474 if(nbC1!=nbC2 && nbC2!=1)
2479 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2481 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2483 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2488 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2490 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2492 double alpha=(_end_time-time)/(_end_time-_start_time);
2493 std::size_t nbComp=vals.size()/2;
2494 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2495 std::vector<double> tmp(nbComp);
2496 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2497 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2500 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
2502 double alpha=(_end_time-time)/(_end_time-_start_time);
2505 _array->getTuple(eltId,value);
2507 throw INTERP_KERNEL::Exception("No start array existing.");
2508 nbComp=_array->getNumberOfComponents();
2509 std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2510 std::vector<double> tmp(nbComp);
2512 _end_array->getTuple(eltId,&tmp[0]);
2514 throw INTERP_KERNEL::Exception("No end array existing.");
2515 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2516 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2519 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
2521 if(iteration==_start_iteration && order==_start_order)
2524 _array->getTuple(eltId,value);
2526 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2528 if(iteration==_end_iteration && order==_end_order)
2531 _end_array->getTuple(eltId,value);
2533 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2536 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2539 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2541 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2543 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2544 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2545 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2546 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2547 ret->setArray(arr1,0);
2548 ret->setEndArray(arr2,0);
2552 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2554 std::vector<const DataArrayDouble *> a(other.size());
2555 std::vector<const DataArrayDouble *> b(other.size());
2557 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2559 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2561 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2562 a[i]=itC->getArray();
2563 b[i]=itC->getEndArray();
2565 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2566 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
2567 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2568 ret->setArray(arr,0);
2569 ret->setEndArray(arr2,0);
2573 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2575 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2577 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2578 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
2579 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
2580 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2581 ret->setTimeTolerance(getTimeTolerance());
2582 ret->setArray(arr1,0);
2583 ret->setEndArray(arr2,0);
2587 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2589 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2591 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2592 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
2593 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
2594 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2595 ret->setArray(arr1,0);
2596 ret->setEndArray(arr2,0);
2600 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2602 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2604 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2605 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2606 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
2607 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2608 ret->setArray(arr1,0);
2609 ret->setEndArray(arr2,0);
2613 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2615 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2617 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2618 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2619 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
2620 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
2621 ret->setArray(arr1,0);
2622 ret->setEndArray(arr2,0);
2626 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2628 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2630 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2631 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
2632 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
2633 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2634 ret->setArray(arr1,0);
2635 ret->setEndArray(arr2,0);
2639 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2641 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2643 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2644 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
2645 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
2646 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2647 ret->setArray(arr1,0);
2648 ret->setEndArray(arr2,0);
2652 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2654 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2656 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2658 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2660 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2661 getArray()->addEqual(other->getArray());
2662 getEndArray()->addEqual(other->getEndArray());
2665 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2667 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2669 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2670 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2671 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2672 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2673 ret->setArray(arr1,0);
2674 ret->setEndArray(arr2,0);
2678 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2680 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2682 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2684 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2686 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2687 getArray()->substractEqual(other->getArray());
2688 getEndArray()->substractEqual(other->getEndArray());
2691 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2693 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2695 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2696 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2697 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2698 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2699 ret->setArray(arr1,0);
2700 ret->setEndArray(arr2,0);
2704 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2706 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2708 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2710 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2712 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2713 getArray()->multiplyEqual(other->getArray());
2714 getEndArray()->multiplyEqual(other->getEndArray());
2717 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2719 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2721 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2722 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2723 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2724 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2725 ret->setArray(arr1,0);
2726 ret->setEndArray(arr2,0);
2730 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2732 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2734 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2736 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2738 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2739 getArray()->divideEqual(other->getArray());
2740 getEndArray()->divideEqual(other->getEndArray());