1 // Copyright (C) 2007-2013 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(std::size_t j=0;j<arrays.size();j++)
362 arrays2[j]=arrays[j]->doublyContractedProduct();
366 std::vector<DataArrayDouble *> arrays3(arrays.size());
367 for(std::size_t j=0;j<arrays.size();j++)
368 arrays3[j]=arrays2[j];
369 ret->setArrays(arrays3,0);
373 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const throw(INTERP_KERNEL::Exception)
375 std::vector<DataArrayDouble *> arrays;
377 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
378 for(std::size_t j=0;j<arrays.size();j++)
381 arrays2[j]=arrays[j]->determinant();
385 std::vector<DataArrayDouble *> arrays3(arrays.size());
386 for(std::size_t j=0;j<arrays.size();j++)
387 arrays3[j]=arrays2[j];
388 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
389 ret->setTimeUnit(getTimeUnit());
390 ret->setArrays(arrays3,0);
394 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const throw(INTERP_KERNEL::Exception)
396 std::vector<DataArrayDouble *> arrays;
398 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
399 for(std::size_t j=0;j<arrays.size();j++)
402 arrays2[j]=arrays[j]->eigenValues();
406 std::vector<DataArrayDouble *> arrays3(arrays.size());
407 for(std::size_t j=0;j<arrays.size();j++)
408 arrays3[j]=arrays2[j];
409 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
410 ret->setTimeUnit(getTimeUnit());
411 ret->setArrays(arrays3,0);
415 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const throw(INTERP_KERNEL::Exception)
417 std::vector<DataArrayDouble *> arrays;
419 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
420 for(std::size_t j=0;j<arrays.size();j++)
423 arrays2[j]=arrays[j]->eigenVectors();
427 std::vector<DataArrayDouble *> arrays3(arrays.size());
428 for(std::size_t j=0;j<arrays.size();j++)
429 arrays3[j]=arrays2[j];
430 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
431 ret->setTimeUnit(getTimeUnit());
432 ret->setArrays(arrays3,0);
436 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const throw(INTERP_KERNEL::Exception)
438 std::vector<DataArrayDouble *> arrays;
440 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
441 for(std::size_t j=0;j<arrays.size();j++)
444 arrays2[j]=arrays[j]->inverse();
448 std::vector<DataArrayDouble *> arrays3(arrays.size());
449 for(std::size_t j=0;j<arrays.size();j++)
450 arrays3[j]=arrays2[j];
451 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
452 ret->setTimeUnit(getTimeUnit());
453 ret->setArrays(arrays3,0);
457 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const throw(INTERP_KERNEL::Exception)
459 std::vector<DataArrayDouble *> arrays;
461 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
462 for(std::size_t j=0;j<arrays.size();j++)
465 arrays2[j]=arrays[j]->trace();
469 std::vector<DataArrayDouble *> arrays3(arrays.size());
470 for(std::size_t j=0;j<arrays.size();j++)
471 arrays3[j]=arrays2[j];
472 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
473 ret->setTimeUnit(getTimeUnit());
474 ret->setArrays(arrays3,0);
478 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const throw(INTERP_KERNEL::Exception)
480 std::vector<DataArrayDouble *> arrays;
482 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
483 for(std::size_t j=0;j<arrays.size();j++)
486 arrays2[j]=arrays[j]->deviator();
490 std::vector<DataArrayDouble *> arrays3(arrays.size());
491 for(std::size_t j=0;j<arrays.size();j++)
492 arrays3[j]=arrays2[j];
493 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
494 ret->setTimeUnit(getTimeUnit());
495 ret->setArrays(arrays3,0);
499 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const throw(INTERP_KERNEL::Exception)
501 std::vector<DataArrayDouble *> arrays;
503 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
504 for(std::size_t j=0;j<arrays.size();j++)
507 arrays2[j]=arrays[j]->magnitude();
511 std::vector<DataArrayDouble *> arrays3(arrays.size());
512 for(std::size_t j=0;j<arrays.size();j++)
513 arrays3[j]=arrays2[j];
514 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
515 ret->setTimeUnit(getTimeUnit());
516 ret->setArrays(arrays3,0);
520 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const throw(INTERP_KERNEL::Exception)
522 std::vector<DataArrayDouble *> arrays;
524 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
525 for(std::size_t j=0;j<arrays.size();j++)
528 arrays2[j]=arrays[j]->negate();
532 std::vector<DataArrayDouble *> arrays3(arrays.size());
533 for(std::size_t j=0;j<arrays.size();j++)
534 arrays3[j]=arrays2[j];
535 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
536 ret->setTimeUnit(getTimeUnit());
537 ret->setArrays(arrays3,0);
541 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const throw(INTERP_KERNEL::Exception)
543 std::vector<DataArrayDouble *> arrays;
545 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
546 for(std::size_t j=0;j<arrays.size();j++)
549 arrays2[j]=arrays[j]->maxPerTuple();
553 std::vector<DataArrayDouble *> arrays3(arrays.size());
554 for(std::size_t j=0;j<arrays.size();j++)
555 arrays3[j]=arrays2[j];
556 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
557 ret->setTimeUnit(getTimeUnit());
558 ret->setArrays(arrays3,0);
562 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
564 std::vector<DataArrayDouble *> arrays;
566 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
567 for(std::size_t j=0;j<arrays.size();j++)
570 arrays2[j]=arrays[j]->keepSelectedComponents(compoIds);
574 std::vector<DataArrayDouble *> arrays3(arrays.size());
575 for(std::size_t j=0;j<arrays.size();j++)
576 arrays3[j]=arrays2[j];
577 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
578 ret->setTimeUnit(getTimeUnit());
579 ret->setArrays(arrays3,0);
583 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
585 std::vector<DataArrayDouble *> arrays1,arrays2;
587 other->getArrays(arrays2);
588 if(arrays1.size()!=arrays2.size())
589 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
590 for(std::size_t i=0;i<arrays1.size();i++)
592 if(arrays1[i]!=0 && arrays2[i]!=0)
593 arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
594 else if(arrays1[i]!=0 || arrays2[i]!=0)
595 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
599 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception)
601 std::vector<DataArrayDouble *> arrays;
603 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
604 for(std::size_t j=0;j<arrays.size();j++)
607 arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
611 std::vector<DataArrayDouble *> arrays3(arrays.size());
612 for(std::size_t j=0;j<arrays.size();j++)
613 arrays3[j]=arrays2[j];
614 setArrays(arrays3,0);
617 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
619 std::vector<DataArrayDouble *> arrays;
621 for(std::size_t j=0;j<arrays.size();j++)
624 arrays[j]->sortPerTuple(asc);
628 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
630 std::vector<DataArrayDouble *> arrays;
632 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
633 for(std::size_t j=0;j<arrays.size();j++)
637 arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
638 arrays2[j]->fillWithValue(value);
642 arrays2[j]=DataArrayDouble::New();
643 arrays2[j]->alloc(nbOfTuple,nbOfCompo);
644 arrays2[j]->fillWithValue(value);
647 std::vector<DataArrayDouble *> arrays3(arrays.size());
648 for(std::size_t j=0;j<arrays.size();j++)
649 arrays3[j]=arrays2[j];
650 setArrays(arrays3,0);
653 void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
655 std::vector<DataArrayDouble *> arrays;
657 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
659 for(std::size_t j=0;j<arrays.size();j++)
663 arrays2[j]=arrays[j]; arrays2[j]->incrRef();
664 arrays2[j]->fillWithValue(value);
669 arrays2[j]=DataArrayDouble::New();
670 arrays2[j]->alloc(nbOfTuple,1);
671 arrays2[j]->fillWithValue(value);
676 std::vector<DataArrayDouble *> arrays3(arrays.size());
677 for(std::size_t j=0;j<arrays.size();j++)
678 arrays3[j]=arrays2[j];
679 setArrays(arrays3,0);
683 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
685 std::vector<DataArrayDouble *> arrays;
687 for(std::size_t j=0;j<arrays.size();j++)
690 arrays[j]->applyLin(a,b,compoId);
694 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
696 std::vector<DataArrayDouble *> arrays;
698 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
699 for(std::size_t j=0;j<arrays.size();j++)
702 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
706 std::vector<DataArrayDouble *> arrays3(arrays.size());
707 for(std::size_t j=0;j<arrays.size();j++)
708 arrays3[j]=arrays2[j];
709 setArrays(arrays3,0);
712 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
714 std::vector<DataArrayDouble *> arrays;
716 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
717 for(std::size_t j=0;j<arrays.size();j++)
720 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
724 std::vector<DataArrayDouble *> arrays3(arrays.size());
725 for(std::size_t j=0;j<arrays.size();j++)
726 arrays3[j]=arrays2[j];
727 setArrays(arrays3,0);
730 void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
732 std::vector<DataArrayDouble *> arrays;
734 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
735 for(std::size_t j=0;j<arrays.size();j++)
738 arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
742 std::vector<DataArrayDouble *> arrays3(arrays.size());
743 for(std::size_t j=0;j<arrays.size();j++)
744 arrays3[j]=arrays2[j];
745 setArrays(arrays3,0);
748 void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
750 std::vector<DataArrayDouble *> arrays;
752 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
753 for(std::size_t j=0;j<arrays.size();j++)
756 arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
760 std::vector<DataArrayDouble *> arrays3(arrays.size());
761 for(std::size_t j=0;j<arrays.size();j++)
762 arrays3[j]=arrays2[j];
763 setArrays(arrays3,0);
766 void MEDCouplingTimeDiscretization::applyFunc(const char *func)
768 std::vector<DataArrayDouble *> arrays;
770 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
771 for(std::size_t j=0;j<arrays.size();j++)
774 arrays2[j]=arrays[j]->applyFunc(func);
778 std::vector<DataArrayDouble *> arrays3(arrays.size());
779 for(std::size_t j=0;j<arrays.size();j++)
780 arrays3[j]=arrays2[j];
781 setArrays(arrays3,0);
784 void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
786 std::vector<DataArrayDouble *> arrays;
788 for(std::size_t j=0;j<arrays.size();j++)
791 arrays[j]->applyFuncFast32(func);
795 void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func)
797 std::vector<DataArrayDouble *> arrays;
799 for(std::size_t j=0;j<arrays.size();j++)
802 arrays[j]->applyFuncFast64(func);
806 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception)
808 std::vector<DataArrayDouble *> arrays;
810 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
811 for(std::size_t j=0;j<arrays.size();j++)
812 arrays2[j]=loc->applyFunc(nbOfComp,func);
813 std::vector<DataArrayDouble *> arrays3(arrays.size());
814 for(std::size_t j=0;j<arrays.size();j++)
815 arrays3[j]=arrays2[j];
816 setArrays(arrays3,0);
819 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
821 std::vector<DataArrayDouble *> arrays;
823 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
824 for(std::size_t j=0;j<arrays.size();j++)
825 arrays2[j]=loc->applyFunc(nbOfComp,func);
826 std::vector<DataArrayDouble *> arrays3(arrays.size());
827 for(std::size_t j=0;j<arrays.size();j++)
828 arrays3[j]=arrays2[j];
829 setArrays(arrays3,0);
832 void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
834 std::vector<DataArrayDouble *> arrays;
836 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
837 for(std::size_t j=0;j<arrays.size();j++)
838 arrays2[j]=loc->applyFunc2(nbOfComp,func);
839 std::vector<DataArrayDouble *> arrays3(arrays.size());
840 for(std::size_t j=0;j<arrays.size();j++)
841 arrays3[j]=arrays2[j];
842 setArrays(arrays3,0);
845 void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
847 std::vector<DataArrayDouble *> arrays;
849 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
850 for(std::size_t j=0;j<arrays.size();j++)
851 arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
852 std::vector<DataArrayDouble *> arrays3(arrays.size());
853 for(std::size_t j=0;j<arrays.size();j++)
854 arrays3[j]=arrays2[j];
855 setArrays(arrays3,0);
858 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
862 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
866 std::string MEDCouplingNoTimeLabel::getStringRepr() const
868 std::ostringstream stream;
870 stream << "\nTime unit is : \"" << _time_unit << "\"";
874 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
876 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
879 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
881 if(!MEDCouplingTimeDiscretization::areCompatible(other))
883 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
887 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
889 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
891 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
894 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
898 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
900 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
902 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
906 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
908 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
910 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
914 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
916 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
918 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
922 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
924 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
927 reason="This has time discretization NO_TIME, other not.";
930 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
933 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
935 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
938 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
941 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
943 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
945 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
946 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
947 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
948 ret->setArray(arr,0);
952 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
954 std::vector<const DataArrayDouble *> a(other.size());
956 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
958 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
960 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
961 a[i]=itC->getArray();
963 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
964 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
965 ret->setArray(arr,0);
969 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
971 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
973 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
974 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
975 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
976 ret->setTimeTolerance(getTimeTolerance());
977 ret->setArray(arr,0);
981 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
983 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
985 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
986 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
987 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
988 ret->setArray(arr,0);
992 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
994 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
996 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
997 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
998 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
999 ret->setArray(arr,0);
1003 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
1005 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1007 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1008 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1009 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1010 ret->setArray(arr,0);
1014 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
1016 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1018 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1019 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1020 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1021 ret->setArray(arr,0);
1025 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
1027 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1029 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
1030 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1031 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1032 ret->setArray(arr,0);
1036 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
1038 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1040 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1042 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1043 getArray()->addEqual(other->getArray());
1046 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1048 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1050 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1052 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1053 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1054 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1055 ret->setArray(arr,0);
1059 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1061 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1063 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1065 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1066 getArray()->substractEqual(other->getArray());
1069 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1071 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1073 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1074 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1075 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1076 ret->setArray(arr,0);
1080 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1082 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1084 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1086 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1087 getArray()->multiplyEqual(other->getArray());
1090 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1092 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1094 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1095 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1096 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1097 ret->setArray(arr,0);
1101 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1103 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1105 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1107 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1108 getArray()->divideEqual(other->getArray());
1111 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1113 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1115 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1116 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1117 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1118 ret->setArray(arr,0);
1122 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1124 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1126 throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1128 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1129 getArray()->powEqual(other->getArray());
1132 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
1134 return new MEDCouplingNoTimeLabel(*this,deepCpy);
1137 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1139 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1142 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1144 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1147 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1149 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1152 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
1154 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1157 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
1159 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1162 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
1164 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1167 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
1169 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1172 void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception)
1174 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1177 void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception)
1179 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1182 void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception)
1184 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1187 void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception)
1189 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1192 void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception)
1194 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1197 void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception)
1199 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1202 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
1204 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1207 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
1209 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1212 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1214 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1217 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1219 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1223 * idem getTinySerializationIntInformation except that it is for multi field fetch
1225 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1231 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1233 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1236 tinyInfo[0]=_time_tolerance;
1240 * idem finishUnserialization except that it is for multi field fetch
1242 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1244 _time_tolerance=tinyInfoD[0];
1247 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
1248 _time(other._time),_iteration(other._iteration),_order(other._order)
1252 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
1256 std::string MEDCouplingWithTimeStep::getStringRepr() const
1258 std::ostringstream stream;
1259 stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
1260 stream << "\nTime unit is : \"" << _time_unit << "\"";
1261 return stream.str();
1264 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1267 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1269 double val=mesh->getTime(it,order);
1270 _time=val; _iteration=it; _order=order;
1271 std::string tUnit=mesh->getTimeUnit();
1275 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1277 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1278 tinyInfo.push_back(_iteration);
1279 tinyInfo.push_back(_order);
1282 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1284 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1285 tinyInfo.push_back(_time);
1288 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1290 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1292 _iteration=tinyInfoI[2];
1293 _order=tinyInfoI[3];
1297 * idem getTinySerializationIntInformation except that it is for multi field fetch
1299 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1302 tinyInfo[0]=_iteration;
1307 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1309 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1312 tinyInfo[0]=_time_tolerance;
1317 * idem finishUnserialization except that it is for multi field fetch
1319 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1321 _iteration=tinyInfoI[0];
1322 _order=tinyInfoI[1];
1323 _time_tolerance=tinyInfoD[0];
1327 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
1329 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1331 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1335 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1337 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1339 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1342 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1346 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1348 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1350 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1354 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1356 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1358 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1362 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1364 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1366 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1370 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1372 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1373 std::ostringstream oss; oss.precision(15);
1376 reason="This has time discretization ONE_TIME, other not.";
1379 if(_iteration!=otherC->_iteration)
1381 oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
1385 if(_order!=otherC->_order)
1387 oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
1391 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1393 oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
1397 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1400 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1402 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1405 if(_iteration!=otherC->_iteration)
1407 if(_order!=otherC->_order)
1409 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1411 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1414 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
1416 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1417 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1419 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1420 _time=otherC->_time;
1421 _iteration=otherC->_iteration;
1422 _order=otherC->_order;
1425 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1427 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1429 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1430 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1431 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1432 ret->setArray(arr,0);
1436 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1438 std::vector<const DataArrayDouble *> a(other.size());
1440 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1442 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1444 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1445 a[i]=itC->getArray();
1447 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1448 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1449 ret->setArray(arr,0);
1453 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1455 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1457 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1458 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1459 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1460 ret->setArray(arr,0);
1464 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1466 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1468 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1469 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1470 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1471 ret->setArray(arr,0);
1475 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1477 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1479 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1480 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1481 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1482 ret->setArray(arr,0);
1486 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1488 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1490 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1491 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1492 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1493 ret->setArray(arr,0);
1497 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1499 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1501 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1502 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1503 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1504 ret->setArray(arr,0);
1508 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1510 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1512 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1513 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1514 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1515 ret->setArray(arr,0);
1517 double tmp3=getStartTime(tmp1,tmp2);
1518 ret->setStartTime(tmp3,tmp1,tmp2);
1522 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1524 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1526 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1528 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1529 getArray()->addEqual(other->getArray());
1532 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1534 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1536 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1537 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1538 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1539 ret->setArray(arr,0);
1541 double tmp3=getStartTime(tmp1,tmp2);
1542 ret->setStartTime(tmp3,tmp1,tmp2);
1546 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1548 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1550 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1552 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1553 getArray()->substractEqual(other->getArray());
1556 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1558 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1560 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1561 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1562 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1563 ret->setArray(arr,0);
1565 double tmp3=getStartTime(tmp1,tmp2);
1566 ret->setStartTime(tmp3,tmp1,tmp2);
1570 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1572 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1574 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1576 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1577 getArray()->multiplyEqual(other->getArray());
1580 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1582 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1584 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1585 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1586 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1587 ret->setArray(arr,0);
1589 double tmp3=getStartTime(tmp1,tmp2);
1590 ret->setStartTime(tmp3,tmp1,tmp2);
1594 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1596 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1598 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1600 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1601 getArray()->divideEqual(other->getArray());
1604 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1606 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1608 throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1609 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1610 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1611 ret->setArray(arr,0);
1613 double tmp3=getStartTime(tmp1,tmp2);
1614 ret->setStartTime(tmp3,tmp1,tmp2);
1618 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1620 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1622 throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1624 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1625 getArray()->powEqual(other->getArray());
1628 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
1630 return new MEDCouplingWithTimeStep(*this,deepCpy);
1633 void MEDCouplingWithTimeStep::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
1635 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1638 void MEDCouplingWithTimeStep::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1640 if(std::fabs(time-_time)>_time_tolerance)
1642 std::ostringstream stream;
1643 stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
1644 throw INTERP_KERNEL::Exception(stream.str().c_str());
1648 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1650 if(std::fabs(time-_time)<=_time_tolerance)
1652 std::vector< const DataArrayDouble *> ret(1);
1657 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1660 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1662 std::copy(vals.begin(),vals.end(),res);
1665 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1667 if(std::fabs(time-_time)<=_time_tolerance)
1669 _array->getTuple(eltId,value);
1671 throw INTERP_KERNEL::Exception("No array existing.");
1673 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1676 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1678 if(_iteration==iteration && _order==order)
1680 _array->getTuple(eltId,value);
1682 throw INTERP_KERNEL::Exception("No array existing.");
1684 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1687 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
1691 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
1693 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1694 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1696 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1697 _start_time=otherC->_start_time;
1698 _end_time=otherC->_end_time;
1699 _start_iteration=otherC->_start_iteration;
1700 _end_iteration=otherC->_end_iteration;
1701 _start_order=otherC->_start_order;
1702 _end_order=otherC->_end_order;
1705 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1707 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1708 tinyInfo.push_back(_start_iteration);
1709 tinyInfo.push_back(_start_order);
1710 tinyInfo.push_back(_end_iteration);
1711 tinyInfo.push_back(_end_order);
1714 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1716 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1717 tinyInfo.push_back(_start_time);
1718 tinyInfo.push_back(_end_time);
1721 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1723 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1724 _start_time=tinyInfoD[1];
1725 _end_time=tinyInfoD[2];
1726 _start_iteration=tinyInfoI[2];
1727 _start_order=tinyInfoI[3];
1728 _end_iteration=tinyInfoI[4];
1729 _end_order=tinyInfoI[5];
1733 * idem getTinySerializationIntInformation except that it is for multi field fetch
1735 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1738 tinyInfo[0]=_start_iteration;
1739 tinyInfo[1]=_start_order;
1740 tinyInfo[2]=_end_iteration;
1741 tinyInfo[3]=_end_order;
1745 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1747 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1750 tinyInfo[0]=_time_tolerance;
1751 tinyInfo[1]=_start_time;
1752 tinyInfo[2]=_end_time;
1756 * idem finishUnserialization except that it is for multi field fetch
1758 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1760 _start_iteration=tinyInfoI[0];
1761 _start_order=tinyInfoI[1];
1762 _end_iteration=tinyInfoI[2];
1763 _end_order=tinyInfoI[3];
1764 _time_tolerance=tinyInfoD[0];
1765 _start_time=tinyInfoD[1];
1766 _end_time=tinyInfoD[2];
1769 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
1770 MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
1771 _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
1775 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1777 std::ostringstream stream;
1778 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
1779 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
1780 stream << "\nTime unit is : \"" << _time_unit << "\"";
1781 return stream.str();
1784 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
1787 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1789 double val=mesh->getTime(it,order);
1790 _start_time=val; _start_iteration=it; _start_order=order;
1791 _end_time=val; _end_iteration=it; _end_order=order;
1792 std::string tUnit=mesh->getTimeUnit();
1796 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
1798 return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
1801 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
1803 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1805 std::vector< const DataArrayDouble *> ret(1);
1810 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1813 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1815 std::copy(vals.begin(),vals.end(),res);
1818 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
1820 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1822 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1826 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1828 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1830 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1833 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1837 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1839 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1841 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1845 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1847 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1849 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1853 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1855 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1857 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1861 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1863 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1864 std::ostringstream oss; oss.precision(15);
1867 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1870 if(_start_iteration!=otherC->_start_iteration)
1872 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
1876 if(_start_order!=otherC->_start_order)
1878 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
1882 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1884 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
1888 if(_end_iteration!=otherC->_end_iteration)
1890 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
1894 if(_end_order!=otherC->_end_order)
1896 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
1900 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1902 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
1906 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1909 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1911 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1914 if(_start_iteration!=otherC->_start_iteration)
1916 if(_start_order!=otherC->_start_order)
1918 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1920 if(_end_iteration!=otherC->_end_iteration)
1922 if(_end_order!=otherC->_end_order)
1924 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1926 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1929 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
1931 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1933 _array->getTuple(eltId,value);
1935 throw INTERP_KERNEL::Exception("No array existing.");
1937 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1940 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
1942 if(iteration>=_start_iteration && iteration<=_end_iteration)
1944 _array->getTuple(eltId,value);
1946 throw INTERP_KERNEL::Exception("No array existing.");
1948 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1951 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
1953 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1956 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
1958 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
1960 std::ostringstream stream;
1961 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
1962 stream << _time_tolerance << " and trying to access on time = " << time;
1963 throw INTERP_KERNEL::Exception(stream.str().c_str());
1967 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1969 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1971 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1972 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1973 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1974 ret->setArray(arr,0);
1978 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1980 std::vector<const DataArrayDouble *> a(other.size());
1982 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1984 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
1986 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
1987 a[i]=itC->getArray();
1989 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1990 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1991 ret->setArray(arr,0);
1995 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
1997 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1999 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
2000 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
2001 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2002 ret->setTimeTolerance(getTimeTolerance());
2003 ret->setArray(arr,0);
2007 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
2009 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2011 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
2012 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
2013 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2014 ret->setArray(arr,0);
2018 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
2020 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2022 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
2023 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2024 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2025 ret->setArray(arr,0);
2029 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
2031 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2033 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
2034 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
2035 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2036 ret->setArray(arr,0);
2040 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
2042 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2044 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
2045 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
2046 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2047 ret->setArray(arr,0);
2051 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
2053 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2055 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
2056 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
2057 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2058 ret->setArray(arr,0);
2060 double tmp3=getStartTime(tmp1,tmp2);
2061 ret->setStartTime(tmp3,tmp1,tmp2);
2062 tmp3=getEndTime(tmp1,tmp2);
2063 ret->setEndTime(tmp3,tmp1,tmp2);
2067 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
2069 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2071 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
2073 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
2074 getArray()->addEqual(other->getArray());
2077 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
2079 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2081 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
2082 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
2083 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2084 ret->setArray(arr,0);
2086 double tmp3=getStartTime(tmp1,tmp2);
2087 ret->setStartTime(tmp3,tmp1,tmp2);
2088 tmp3=getEndTime(tmp1,tmp2);
2089 ret->setEndTime(tmp3,tmp1,tmp2);
2093 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2095 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2097 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2099 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2100 getArray()->substractEqual(other->getArray());
2103 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2105 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2107 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2108 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2109 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2110 ret->setArray(arr,0);
2112 double tmp3=getStartTime(tmp1,tmp2);
2113 ret->setStartTime(tmp3,tmp1,tmp2);
2114 tmp3=getEndTime(tmp1,tmp2);
2115 ret->setEndTime(tmp3,tmp1,tmp2);
2119 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2121 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2123 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2125 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2126 getArray()->multiplyEqual(other->getArray());
2129 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2131 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2133 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2134 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2135 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2136 ret->setArray(arr,0);
2138 double tmp3=getStartTime(tmp1,tmp2);
2139 ret->setStartTime(tmp3,tmp1,tmp2);
2140 tmp3=getEndTime(tmp1,tmp2);
2141 ret->setEndTime(tmp3,tmp1,tmp2);
2145 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2147 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2149 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2151 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2152 getArray()->divideEqual(other->getArray());
2155 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2157 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2159 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2160 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2161 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2162 ret->setArray(arr,0);
2164 double tmp3=getStartTime(tmp1,tmp2);
2165 ret->setStartTime(tmp3,tmp1,tmp2);
2166 tmp3=getEndTime(tmp1,tmp2);
2167 ret->setEndTime(tmp3,tmp1,tmp2);
2171 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2173 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2175 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2177 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2178 getArray()->powEqual(other->getArray());
2181 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
2182 _start_time(other._start_time),_end_time(other._end_time),
2183 _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
2184 _start_order(other._start_order),_end_order(other._end_order)
2186 if(other._end_array)
2187 _end_array=other._end_array->performCpy(deepCpy);
2192 void MEDCouplingTwoTimeSteps::updateTime() const
2194 MEDCouplingTimeDiscretization::updateTime();
2196 updateTimeWith(*_end_array);
2199 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
2202 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2204 double val=mesh->getTime(it,order);
2205 _start_time=val; _start_iteration=it; _start_order=order;
2206 _end_time=val; _end_iteration=it; _end_order=order;
2207 std::string tUnit=mesh->getTimeUnit();
2211 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySize() const
2215 ret+=_end_array->getHeapMemorySize();
2216 return MEDCouplingTimeDiscretization::getHeapMemorySize()+ret;
2219 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
2221 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2222 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2224 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2225 _start_time=otherC->_start_time;
2226 _end_time=otherC->_end_time;
2227 _start_iteration=otherC->_start_iteration;
2228 _end_iteration=otherC->_end_iteration;
2229 _start_order=otherC->_start_order;
2230 _end_order=otherC->_end_order;
2233 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
2235 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2236 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2238 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2239 if(_end_array && otherC->_end_array)
2240 _end_array->copyStringInfoFrom(*otherC->_end_array);
2243 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2248 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2253 void MEDCouplingTwoTimeSteps::checkCoherency() const throw(INTERP_KERNEL::Exception)
2255 MEDCouplingTimeDiscretization::checkCoherency();
2257 throw INTERP_KERNEL::Exception("No end array specified !");
2258 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2259 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2260 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2261 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2264 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
2266 std::ostringstream oss;
2267 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2270 reason="This has time discretization LINEAR_TIME, other not.";
2273 if(_start_iteration!=otherC->_start_iteration)
2275 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
2279 if(_start_order!=otherC->_start_order)
2281 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
2285 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2287 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
2291 if(_end_iteration!=otherC->_end_iteration)
2293 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
2297 if(_end_order!=otherC->_end_order)
2299 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
2303 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2305 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
2309 if(_end_array!=otherC->_end_array)
2310 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2312 reason.insert(0,"end arrays differ for linear time.");
2315 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2318 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
2320 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2323 if(_start_iteration!=otherC->_start_iteration)
2325 if(_end_iteration!=otherC->_end_iteration)
2327 if(_start_order!=otherC->_start_order)
2329 if(_end_order!=otherC->_end_order)
2331 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2333 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2335 if(_end_array!=otherC->_end_array)
2336 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2338 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2341 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
2345 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2348 _end_array->decrRef();
2351 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
2353 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2356 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
2358 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
2360 std::ostringstream stream;
2361 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
2362 stream << _time_tolerance << " and trying to access on time = " << time;
2363 throw INTERP_KERNEL::Exception(stream.str().c_str());
2367 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2371 arrays[1]=_end_array;
2374 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2376 if(array!=_end_array)
2379 _end_array->decrRef();
2382 _end_array->incrRef();
2384 owner->declareAsNew();
2388 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2390 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2391 tinyInfo.push_back(_start_iteration);
2392 tinyInfo.push_back(_start_order);
2393 tinyInfo.push_back(_end_iteration);
2394 tinyInfo.push_back(_end_order);
2397 tinyInfo.push_back(_end_array->getNumberOfTuples());
2398 tinyInfo.push_back(_end_array->getNumberOfComponents());
2402 tinyInfo.push_back(-1);
2403 tinyInfo.push_back(-1);
2407 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2409 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2410 tinyInfo.push_back(_start_time);
2411 tinyInfo.push_back(_end_time);
2414 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2416 int nbOfCompo=_array->getNumberOfComponents();
2417 for(int i=0;i<nbOfCompo;i++)
2418 tinyInfo.push_back(_array->getInfoOnComponent(i));
2419 for(int i=0;i<nbOfCompo;i++)
2420 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2423 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2429 _end_array->decrRef();
2430 DataArrayDouble *arr=0;
2431 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2433 arr=DataArrayDouble::New();
2434 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2439 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2441 arr=DataArrayDouble::New();
2442 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2448 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2450 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2451 _start_time=tinyInfoD[1];
2452 _end_time=tinyInfoD[2];
2453 _start_iteration=tinyInfoI[2];
2454 _start_order=tinyInfoI[3];
2455 _end_iteration=tinyInfoI[4];
2456 _end_order=tinyInfoI[5];
2460 * idem getTinySerializationIntInformation except that it is for multi field fetch
2462 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2465 tinyInfo[0]=_start_iteration;
2466 tinyInfo[1]=_start_order;
2467 tinyInfo[2]=_end_iteration;
2468 tinyInfo[3]=_end_order;
2472 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2474 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2477 tinyInfo[0]=_time_tolerance;
2478 tinyInfo[1]=_start_time;
2479 tinyInfo[2]=_end_time;
2483 * idem finishUnserialization except that it is for multi field fetch
2485 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2487 _start_iteration=tinyInfoI[0];
2488 _start_order=tinyInfoI[1];
2489 _end_iteration=tinyInfoI[2];
2490 _end_order=tinyInfoI[3];
2491 _time_tolerance=tinyInfoD[0];
2492 _start_time=tinyInfoD[1];
2493 _end_time=tinyInfoD[2];
2496 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
2498 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
2500 std::vector< const DataArrayDouble *> ret(2);
2506 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2509 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
2511 if(arrays.size()!=2)
2512 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2513 setArray(arrays.front(),owner);
2514 setEndArray(arrays.back(),owner);
2517 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy)
2521 MEDCouplingLinearTime::MEDCouplingLinearTime()
2525 std::string MEDCouplingLinearTime::getStringRepr() const
2527 std::ostringstream stream;
2528 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
2529 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
2530 stream << "Time unit is : \"" << _time_unit << "\"";
2531 return stream.str();
2534 void MEDCouplingLinearTime::checkCoherency() const throw(INTERP_KERNEL::Exception)
2536 MEDCouplingTwoTimeSteps::checkCoherency();
2537 if(std::fabs(_start_time-_end_time)<_time_tolerance)
2538 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2541 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
2543 return new MEDCouplingLinearTime(*this,deepCpy);
2546 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
2548 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2550 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2553 if(_end_array==0 && otherC->_end_array==0)
2555 if(_end_array==0 || otherC->_end_array==0)
2557 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2562 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
2564 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2566 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2569 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2573 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
2575 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2577 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2581 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
2583 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2585 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2588 if(_end_array==0 && otherC->_end_array==0)
2590 if(_end_array==0 || otherC->_end_array==0)
2592 int nbC1=_end_array->getNumberOfComponents();
2593 int nbC2=otherC->_end_array->getNumberOfComponents();
2594 if(nbC1!=nbC2 && nbC2!=1)
2599 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2601 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2603 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2608 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2610 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2612 double alpha=(_end_time-time)/(_end_time-_start_time);
2613 std::size_t nbComp=vals.size()/2;
2614 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2615 std::vector<double> tmp(nbComp);
2616 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2617 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2620 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
2622 double alpha=(_end_time-time)/(_end_time-_start_time);
2625 _array->getTuple(eltId,value);
2627 throw INTERP_KERNEL::Exception("No start array existing.");
2628 nbComp=_array->getNumberOfComponents();
2629 std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2630 std::vector<double> tmp(nbComp);
2632 _end_array->getTuple(eltId,&tmp[0]);
2634 throw INTERP_KERNEL::Exception("No end array existing.");
2635 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2636 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2639 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
2641 if(iteration==_start_iteration && order==_start_order)
2644 _array->getTuple(eltId,value);
2646 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2648 if(iteration==_end_iteration && order==_end_order)
2651 _end_array->getTuple(eltId,value);
2653 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2656 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2659 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2661 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2663 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2664 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2665 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2666 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2667 ret->setArray(arr1,0);
2668 ret->setEndArray(arr2,0);
2672 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2674 std::vector<const DataArrayDouble *> a(other.size());
2675 std::vector<const DataArrayDouble *> b(other.size());
2677 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2679 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2681 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2682 a[i]=itC->getArray();
2683 b[i]=itC->getEndArray();
2685 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2686 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
2687 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2688 ret->setArray(arr,0);
2689 ret->setEndArray(arr2,0);
2693 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2695 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2697 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2698 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
2699 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
2700 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2701 ret->setTimeTolerance(getTimeTolerance());
2702 ret->setArray(arr1,0);
2703 ret->setEndArray(arr2,0);
2707 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2709 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2711 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2712 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
2713 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
2714 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2715 ret->setArray(arr1,0);
2716 ret->setEndArray(arr2,0);
2720 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2722 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2724 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2725 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2726 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
2727 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2728 ret->setArray(arr1,0);
2729 ret->setEndArray(arr2,0);
2733 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2735 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2737 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2738 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2739 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
2740 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
2741 ret->setArray(arr1,0);
2742 ret->setEndArray(arr2,0);
2746 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2748 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2750 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2751 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
2752 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
2753 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2754 ret->setArray(arr1,0);
2755 ret->setEndArray(arr2,0);
2759 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2761 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2763 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2764 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
2765 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
2766 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2767 ret->setArray(arr1,0);
2768 ret->setEndArray(arr2,0);
2772 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2774 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2776 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2778 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2780 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2781 getArray()->addEqual(other->getArray());
2782 getEndArray()->addEqual(other->getEndArray());
2785 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2787 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2789 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2790 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2791 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2792 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2793 ret->setArray(arr1,0);
2794 ret->setEndArray(arr2,0);
2798 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2800 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2802 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2804 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2806 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2807 getArray()->substractEqual(other->getArray());
2808 getEndArray()->substractEqual(other->getEndArray());
2811 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2813 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2815 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2816 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2817 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2818 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2819 ret->setArray(arr1,0);
2820 ret->setEndArray(arr2,0);
2824 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2826 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2828 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2830 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2832 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2833 getArray()->multiplyEqual(other->getArray());
2834 getEndArray()->multiplyEqual(other->getEndArray());
2837 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2839 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2841 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2842 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2843 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2844 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2845 ret->setArray(arr1,0);
2846 ret->setEndArray(arr2,0);
2850 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2852 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2854 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2856 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2858 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2859 getArray()->divideEqual(other->getArray());
2860 getEndArray()->divideEqual(other->getEndArray());
2863 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2865 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2867 throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2868 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2869 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2870 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2871 ret->setArray(arr1,0);
2872 ret->setEndArray(arr2,0);
2876 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2878 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2880 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2882 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2884 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2885 getArray()->powEqual(other->getArray());
2886 getEndArray()->powEqual(other->getEndArray());