1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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)
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
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::getHeapMemorySizeWithoutChildren() const
98 std::size_t ret(_time_unit.capacity());
102 std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretization::getDirectChildren() const
104 std::vector<const BigMemoryObject *> ret;
106 ret.push_back(_array);
110 bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
112 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
114 if(_array==0 && other->_array==0)
116 if(_array==0 || other->_array==0)
118 if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
123 bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
125 std::ostringstream oss; oss.precision(15);
126 if(_time_unit!=other->_time_unit)
128 oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
132 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
134 oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
138 if(_array==0 && other->_array==0)
140 if(_array==0 || other->_array==0)
142 reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
145 if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
147 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
152 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
154 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
156 if(_array==0 && other->_array==0)
158 if(_array==0 || other->_array==0)
160 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
165 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
167 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
169 if(_array==0 && other->_array==0)
171 if(_array==0 || other->_array==0)
173 int nbC1=_array->getNumberOfComponents();
174 int nbC2=other->_array->getNumberOfComponents();
175 int nbMin=std::min(nbC1,nbC2);
176 if(nbC1!=nbC2 && nbMin!=1)
181 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
183 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
185 if(_array==0 && other->_array==0)
187 if(_array==0 || other->_array==0)
189 int nbC1=_array->getNumberOfComponents();
190 int nbC2=other->_array->getNumberOfComponents();
191 if(nbC1!=nbC2 && nbC2!=1)
196 bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
198 if(!areStrictlyCompatible(other,reason))
200 if(_array==other->_array)
202 return _array->isEqualIfNotWhy(*other->_array,prec,reason);
205 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
208 return isEqualIfNotWhy(other,prec,reason);
211 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
214 if(!areStrictlyCompatible(other,tmp))
216 if(_array==other->_array)
218 return _array->isEqualWithoutConsideringStr(*other->_array,prec);
221 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
223 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
224 ret->setTimeUnit(getTimeUnit());
225 const DataArrayDouble *arrSrc=getArray();
226 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr;
228 arr=arrSrc->performCpy(deepCpy);
229 ret->setArray(arr,0);
233 void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
237 tinyInfo.push_back(_array->getNumberOfTuples());
238 tinyInfo.push_back(_array->getNumberOfComponents());
242 tinyInfo.push_back(-1);
243 tinyInfo.push_back(-1);
247 void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
252 DataArrayDouble *arr=0;
253 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
255 arr=DataArrayDouble::New();
256 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
262 void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
264 _time_tolerance=tinyInfoD[0];
265 int nbOfCompo=_array->getNumberOfComponents();
266 for(int i=0;i<nbOfCompo;i++)
267 _array->setInfoOnComponent(i,tinyInfoS[i]);
270 void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
272 tinyInfo.push_back(_time_tolerance);
275 void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
277 int nbOfCompo=_array->getNumberOfComponents();
278 for(int i=0;i<nbOfCompo;i++)
279 tinyInfo.push_back(_array->getInfoOnComponent(i));
282 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
286 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
289 _array=other._array->performCpy(deepCpy);
294 MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
300 void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
310 owner->declareAsNew();
314 const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
316 throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
319 DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
321 throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
324 void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
326 throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
329 void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
332 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
333 setArray(arrays.back(),owner);
336 void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
342 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
345 double time1=getEndTime(iteration,order)-_time_tolerance;
346 double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
350 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
353 double time1=getEndTime(iteration,order)+_time_tolerance;
354 double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
358 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const
360 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
361 ret->setTimeUnit(getTimeUnit());
362 std::vector<DataArrayDouble *> arrays;
364 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
365 for(std::size_t j=0;j<arrays.size();j++)
368 arrays2[j]=arrays[j]->doublyContractedProduct();
372 std::vector<DataArrayDouble *> arrays3(arrays.size());
373 for(std::size_t j=0;j<arrays.size();j++)
374 arrays3[j]=arrays2[j];
375 ret->setArrays(arrays3,0);
379 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const
381 std::vector<DataArrayDouble *> arrays;
383 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
384 for(std::size_t j=0;j<arrays.size();j++)
387 arrays2[j]=arrays[j]->determinant();
391 std::vector<DataArrayDouble *> arrays3(arrays.size());
392 for(std::size_t j=0;j<arrays.size();j++)
393 arrays3[j]=arrays2[j];
394 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
395 ret->setTimeUnit(getTimeUnit());
396 ret->setArrays(arrays3,0);
400 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const
402 std::vector<DataArrayDouble *> arrays;
404 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
405 for(std::size_t j=0;j<arrays.size();j++)
408 arrays2[j]=arrays[j]->eigenValues();
412 std::vector<DataArrayDouble *> arrays3(arrays.size());
413 for(std::size_t j=0;j<arrays.size();j++)
414 arrays3[j]=arrays2[j];
415 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
416 ret->setTimeUnit(getTimeUnit());
417 ret->setArrays(arrays3,0);
421 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const
423 std::vector<DataArrayDouble *> arrays;
425 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
426 for(std::size_t j=0;j<arrays.size();j++)
429 arrays2[j]=arrays[j]->eigenVectors();
433 std::vector<DataArrayDouble *> arrays3(arrays.size());
434 for(std::size_t j=0;j<arrays.size();j++)
435 arrays3[j]=arrays2[j];
436 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
437 ret->setTimeUnit(getTimeUnit());
438 ret->setArrays(arrays3,0);
442 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const
444 std::vector<DataArrayDouble *> arrays;
446 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
447 for(std::size_t j=0;j<arrays.size();j++)
450 arrays2[j]=arrays[j]->inverse();
454 std::vector<DataArrayDouble *> arrays3(arrays.size());
455 for(std::size_t j=0;j<arrays.size();j++)
456 arrays3[j]=arrays2[j];
457 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
458 ret->setTimeUnit(getTimeUnit());
459 ret->setArrays(arrays3,0);
463 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const
465 std::vector<DataArrayDouble *> arrays;
467 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
468 for(std::size_t j=0;j<arrays.size();j++)
471 arrays2[j]=arrays[j]->trace();
475 std::vector<DataArrayDouble *> arrays3(arrays.size());
476 for(std::size_t j=0;j<arrays.size();j++)
477 arrays3[j]=arrays2[j];
478 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
479 ret->setTimeUnit(getTimeUnit());
480 ret->setArrays(arrays3,0);
484 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const
486 std::vector<DataArrayDouble *> arrays;
488 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
489 for(std::size_t j=0;j<arrays.size();j++)
492 arrays2[j]=arrays[j]->deviator();
496 std::vector<DataArrayDouble *> arrays3(arrays.size());
497 for(std::size_t j=0;j<arrays.size();j++)
498 arrays3[j]=arrays2[j];
499 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
500 ret->setTimeUnit(getTimeUnit());
501 ret->setArrays(arrays3,0);
505 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const
507 std::vector<DataArrayDouble *> arrays;
509 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
510 for(std::size_t j=0;j<arrays.size();j++)
513 arrays2[j]=arrays[j]->magnitude();
517 std::vector<DataArrayDouble *> arrays3(arrays.size());
518 for(std::size_t j=0;j<arrays.size();j++)
519 arrays3[j]=arrays2[j];
520 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
521 ret->setTimeUnit(getTimeUnit());
522 ret->setArrays(arrays3,0);
526 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const
528 std::vector<DataArrayDouble *> arrays;
530 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
531 for(std::size_t j=0;j<arrays.size();j++)
534 arrays2[j]=arrays[j]->negate();
538 std::vector<DataArrayDouble *> arrays3(arrays.size());
539 for(std::size_t j=0;j<arrays.size();j++)
540 arrays3[j]=arrays2[j];
541 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
542 ret->setTimeUnit(getTimeUnit());
543 ret->setArrays(arrays3,0);
547 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const
549 std::vector<DataArrayDouble *> arrays;
551 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
552 for(std::size_t j=0;j<arrays.size();j++)
555 arrays2[j]=arrays[j]->maxPerTuple();
559 std::vector<DataArrayDouble *> arrays3(arrays.size());
560 for(std::size_t j=0;j<arrays.size();j++)
561 arrays3[j]=arrays2[j];
562 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
563 ret->setTimeUnit(getTimeUnit());
564 ret->setArrays(arrays3,0);
568 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const
570 std::vector<DataArrayDouble *> arrays;
572 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
573 for(std::size_t j=0;j<arrays.size();j++)
576 arrays2[j]=static_cast<DataArrayDouble *>(arrays[j]->keepSelectedComponents(compoIds));
580 std::vector<DataArrayDouble *> arrays3(arrays.size());
581 for(std::size_t j=0;j<arrays.size();j++)
582 arrays3[j]=arrays2[j];
583 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
584 ret->setTimeUnit(getTimeUnit());
585 ret->setArrays(arrays3,0);
589 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds)
591 std::vector<DataArrayDouble *> arrays1,arrays2;
593 other->getArrays(arrays2);
594 if(arrays1.size()!=arrays2.size())
595 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
596 for(std::size_t i=0;i<arrays1.size();i++)
598 if(arrays1[i]!=0 && arrays2[i]!=0)
599 arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
600 else if(arrays1[i]!=0 || arrays2[i]!=0)
601 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
605 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue)
607 std::vector<DataArrayDouble *> arrays;
609 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
610 for(std::size_t j=0;j<arrays.size();j++)
613 arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
617 std::vector<DataArrayDouble *> arrays3(arrays.size());
618 for(std::size_t j=0;j<arrays.size();j++)
619 arrays3[j]=arrays2[j];
620 setArrays(arrays3,0);
623 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc)
625 std::vector<DataArrayDouble *> arrays;
627 for(std::size_t j=0;j<arrays.size();j++)
630 arrays[j]->sortPerTuple(asc);
634 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
636 std::vector<DataArrayDouble *> arrays;
638 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
639 for(std::size_t j=0;j<arrays.size();j++)
643 arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
644 arrays2[j]->fillWithValue(value);
648 arrays2[j]=DataArrayDouble::New();
649 arrays2[j]->alloc(nbOfTuple,nbOfCompo);
650 arrays2[j]->fillWithValue(value);
653 std::vector<DataArrayDouble *> arrays3(arrays.size());
654 for(std::size_t j=0;j<arrays.size();j++)
655 arrays3[j]=arrays2[j];
656 setArrays(arrays3,0);
659 void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
661 std::vector<DataArrayDouble *> arrays;
663 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
665 for(std::size_t j=0;j<arrays.size();j++)
669 arrays2[j]=arrays[j]; arrays2[j]->incrRef();
670 arrays2[j]->fillWithValue(value);
675 arrays2[j]=DataArrayDouble::New();
676 arrays2[j]->alloc(nbOfTuple,1);
677 arrays2[j]->fillWithValue(value);
682 std::vector<DataArrayDouble *> arrays3(arrays.size());
683 for(std::size_t j=0;j<arrays.size();j++)
684 arrays3[j]=arrays2[j];
685 setArrays(arrays3,0);
689 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
691 std::vector<DataArrayDouble *> arrays;
693 for(std::size_t j=0;j<arrays.size();j++)
696 arrays[j]->applyLin(a,b,compoId);
700 void MEDCouplingTimeDiscretization::applyLin(double a, double b)
702 std::vector<DataArrayDouble *> arrays;
704 for(std::size_t j=0;j<arrays.size();j++)
707 arrays[j]->applyLin(a,b);
711 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
713 std::vector<DataArrayDouble *> arrays;
715 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
716 for(std::size_t j=0;j<arrays.size();j++)
719 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
723 std::vector<DataArrayDouble *> arrays3(arrays.size());
724 for(std::size_t j=0;j<arrays.size();j++)
725 arrays3[j]=arrays2[j];
726 setArrays(arrays3,0);
729 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const std::string& func)
731 std::vector<DataArrayDouble *> arrays;
733 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
734 for(std::size_t j=0;j<arrays.size();j++)
737 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
741 std::vector<DataArrayDouble *> arrays3(arrays.size());
742 for(std::size_t j=0;j<arrays.size();j++)
743 arrays3[j]=arrays2[j];
744 setArrays(arrays3,0);
747 void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const std::string& func)
749 std::vector<DataArrayDouble *> arrays;
751 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
752 for(std::size_t j=0;j<arrays.size();j++)
755 arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
759 std::vector<DataArrayDouble *> arrays3(arrays.size());
760 for(std::size_t j=0;j<arrays.size();j++)
761 arrays3[j]=arrays2[j];
762 setArrays(arrays3,0);
765 void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
767 std::vector<DataArrayDouble *> arrays;
769 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
770 for(std::size_t j=0;j<arrays.size();j++)
773 arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
777 std::vector<DataArrayDouble *> arrays3(arrays.size());
778 for(std::size_t j=0;j<arrays.size();j++)
779 arrays3[j]=arrays2[j];
780 setArrays(arrays3,0);
783 void MEDCouplingTimeDiscretization::applyFunc(const std::string& func)
785 std::vector<DataArrayDouble *> arrays;
787 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
788 for(std::size_t j=0;j<arrays.size();j++)
791 arrays2[j]=arrays[j]->applyFunc(func);
795 std::vector<DataArrayDouble *> arrays3(arrays.size());
796 for(std::size_t j=0;j<arrays.size();j++)
797 arrays3[j]=arrays2[j];
798 setArrays(arrays3,0);
801 void MEDCouplingTimeDiscretization::applyFuncFast32(const std::string& func)
803 std::vector<DataArrayDouble *> arrays;
805 for(std::size_t j=0;j<arrays.size();j++)
808 arrays[j]->applyFuncFast32(func);
812 void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func)
814 std::vector<DataArrayDouble *> arrays;
816 for(std::size_t j=0;j<arrays.size();j++)
819 arrays[j]->applyFuncFast64(func);
823 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func)
825 std::vector<DataArrayDouble *> arrays;
827 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
828 for(std::size_t j=0;j<arrays.size();j++)
829 arrays2[j]=loc->applyFunc(nbOfComp,func);
830 std::vector<DataArrayDouble *> arrays3(arrays.size());
831 for(std::size_t j=0;j<arrays.size();j++)
832 arrays3[j]=arrays2[j];
833 setArrays(arrays3,0);
836 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
838 std::vector<DataArrayDouble *> arrays;
840 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
841 for(std::size_t j=0;j<arrays.size();j++)
842 arrays2[j]=loc->applyFunc(nbOfComp,func);
843 std::vector<DataArrayDouble *> arrays3(arrays.size());
844 for(std::size_t j=0;j<arrays.size();j++)
845 arrays3[j]=arrays2[j];
846 setArrays(arrays3,0);
849 void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
851 std::vector<DataArrayDouble *> arrays;
853 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
854 for(std::size_t j=0;j<arrays.size();j++)
855 arrays2[j]=loc->applyFunc2(nbOfComp,func);
856 std::vector<DataArrayDouble *> arrays3(arrays.size());
857 for(std::size_t j=0;j<arrays.size();j++)
858 arrays3[j]=arrays2[j];
859 setArrays(arrays3,0);
862 void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
864 std::vector<DataArrayDouble *> arrays;
866 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
867 for(std::size_t j=0;j<arrays.size();j++)
868 arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
869 std::vector<DataArrayDouble *> arrays3(arrays.size());
870 for(std::size_t j=0;j<arrays.size();j++)
871 arrays3[j]=arrays2[j];
872 setArrays(arrays3,0);
875 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
879 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
883 std::string MEDCouplingNoTimeLabel::getStringRepr() const
885 std::ostringstream stream;
887 stream << "\nTime unit is : \"" << _time_unit << "\"";
891 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh)
893 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
896 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
898 if(!MEDCouplingTimeDiscretization::areCompatible(other))
900 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
904 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
906 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
908 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
911 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
915 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
917 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
919 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
923 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
925 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
927 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
931 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
933 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
935 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
939 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
941 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
944 reason="This has time discretization NO_TIME, other not.";
947 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
950 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
952 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
955 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
958 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
960 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
962 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
963 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
964 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
965 ret->setArray(arr,0);
969 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
971 std::vector<const DataArrayDouble *> a(other.size());
973 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
975 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
977 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
978 a[i]=itC->getArray();
980 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
981 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
982 ret->setArray(arr,0);
986 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
988 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
990 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
991 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
992 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
993 ret->setTimeTolerance(getTimeTolerance());
994 ret->setArray(arr,0);
998 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
1000 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1002 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
1003 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1004 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1005 ret->setArray(arr,0);
1009 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
1011 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1013 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
1014 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1015 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1016 ret->setArray(arr,0);
1020 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
1022 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1024 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1025 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1026 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1027 ret->setArray(arr,0);
1031 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
1033 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1035 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1036 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1037 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1038 ret->setArray(arr,0);
1042 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
1044 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1046 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
1047 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1048 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1049 ret->setArray(arr,0);
1053 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
1055 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1057 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1059 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1060 getArray()->addEqual(other->getArray());
1063 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1065 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1067 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1069 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1070 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1071 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1072 ret->setArray(arr,0);
1076 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1078 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1080 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1082 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1083 getArray()->substractEqual(other->getArray());
1086 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1088 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1090 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1091 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1092 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1093 ret->setArray(arr,0);
1097 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1099 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1101 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1103 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1104 getArray()->multiplyEqual(other->getArray());
1107 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1109 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1111 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1112 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1113 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1114 ret->setArray(arr,0);
1118 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1120 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1122 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1124 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1125 getArray()->divideEqual(other->getArray());
1128 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1130 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1132 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1133 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1134 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1135 ret->setArray(arr,0);
1139 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1141 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1143 throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1145 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1146 getArray()->powEqual(other->getArray());
1149 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
1151 return new MEDCouplingNoTimeLabel(*this,deepCpy);
1154 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const
1156 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1159 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const
1161 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1164 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1166 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1169 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const
1171 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1174 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
1176 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1179 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const
1181 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1184 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const
1186 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1189 void MEDCouplingNoTimeLabel::setStartIteration(int it)
1191 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1194 void MEDCouplingNoTimeLabel::setEndIteration(int it)
1196 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1199 void MEDCouplingNoTimeLabel::setStartOrder(int order)
1201 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1204 void MEDCouplingNoTimeLabel::setEndOrder(int order)
1206 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1209 void MEDCouplingNoTimeLabel::setStartTimeValue(double time)
1211 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1214 void MEDCouplingNoTimeLabel::setEndTimeValue(double time)
1216 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1219 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order)
1221 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1224 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order)
1226 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1229 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const
1231 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1234 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1236 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1240 * idem getTinySerializationIntInformation except that it is for multi field fetch
1242 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1248 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1250 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1253 tinyInfo[0]=_time_tolerance;
1257 * idem finishUnserialization except that it is for multi field fetch
1259 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1261 _time_tolerance=tinyInfoD[0];
1264 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
1265 _time(other._time),_iteration(other._iteration),_order(other._order)
1269 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
1273 std::string MEDCouplingWithTimeStep::getStringRepr() const
1275 std::ostringstream stream;
1276 stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
1277 stream << "\nTime unit is : \"" << _time_unit << "\"";
1278 return stream.str();
1281 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1284 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1286 double val=mesh->getTime(it,order);
1287 _time=val; _iteration=it; _order=order;
1288 std::string tUnit=mesh->getTimeUnit();
1292 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1294 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1295 tinyInfo.push_back(_iteration);
1296 tinyInfo.push_back(_order);
1299 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1301 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1302 tinyInfo.push_back(_time);
1305 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1307 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1309 _iteration=tinyInfoI[2];
1310 _order=tinyInfoI[3];
1314 * idem getTinySerializationIntInformation except that it is for multi field fetch
1316 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1319 tinyInfo[0]=_iteration;
1324 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1326 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1329 tinyInfo[0]=_time_tolerance;
1334 * idem finishUnserialization except that it is for multi field fetch
1336 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1338 _iteration=tinyInfoI[0];
1339 _order=tinyInfoI[1];
1340 _time_tolerance=tinyInfoD[0];
1344 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
1346 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1348 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1352 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1354 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1356 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1359 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1363 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1365 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1367 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1371 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1373 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1375 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1379 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1381 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1383 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1387 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1389 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1390 std::ostringstream oss; oss.precision(15);
1393 reason="This has time discretization ONE_TIME, other not.";
1396 if(_iteration!=otherC->_iteration)
1398 oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
1402 if(_order!=otherC->_order)
1404 oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
1408 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1410 oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
1414 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1417 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1419 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1422 if(_iteration!=otherC->_iteration)
1424 if(_order!=otherC->_order)
1426 if(std::fabs(_time-otherC->_time)>_time_tolerance)
1428 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1431 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
1433 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1434 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1436 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1437 _time=otherC->_time;
1438 _iteration=otherC->_iteration;
1439 _order=otherC->_order;
1442 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1444 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1446 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1447 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1448 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1449 ret->setArray(arr,0);
1453 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1455 std::vector<const DataArrayDouble *> a(other.size());
1457 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1459 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1461 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1462 a[i]=itC->getArray();
1464 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1465 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1466 ret->setArray(arr,0);
1470 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1472 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1474 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1475 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1476 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1477 ret->setArray(arr,0);
1481 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1483 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1485 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1486 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1487 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1488 ret->setArray(arr,0);
1492 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1494 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1496 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1497 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1498 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1499 ret->setArray(arr,0);
1503 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1505 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1507 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1508 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1509 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1510 ret->setArray(arr,0);
1514 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1516 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1518 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1519 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1520 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1521 ret->setArray(arr,0);
1525 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1527 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1529 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1530 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1531 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1532 ret->setArray(arr,0);
1534 double tmp3=getStartTime(tmp1,tmp2);
1535 ret->setStartTime(tmp3,tmp1,tmp2);
1539 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1541 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1543 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1545 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1546 getArray()->addEqual(other->getArray());
1549 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1551 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1553 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1554 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1555 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1556 ret->setArray(arr,0);
1558 double tmp3=getStartTime(tmp1,tmp2);
1559 ret->setStartTime(tmp3,tmp1,tmp2);
1563 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1565 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1567 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1569 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1570 getArray()->substractEqual(other->getArray());
1573 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1575 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1577 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1578 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1579 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1580 ret->setArray(arr,0);
1582 double tmp3=getStartTime(tmp1,tmp2);
1583 ret->setStartTime(tmp3,tmp1,tmp2);
1587 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1589 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1591 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1593 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1594 getArray()->multiplyEqual(other->getArray());
1597 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1599 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1601 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1602 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1603 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1604 ret->setArray(arr,0);
1606 double tmp3=getStartTime(tmp1,tmp2);
1607 ret->setStartTime(tmp3,tmp1,tmp2);
1611 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1613 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1615 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1617 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1618 getArray()->divideEqual(other->getArray());
1621 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1623 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1625 throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1626 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1627 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1628 ret->setArray(arr,0);
1630 double tmp3=getStartTime(tmp1,tmp2);
1631 ret->setStartTime(tmp3,tmp1,tmp2);
1635 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1637 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1639 throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1641 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1642 getArray()->powEqual(other->getArray());
1645 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
1647 return new MEDCouplingWithTimeStep(*this,deepCpy);
1650 void MEDCouplingWithTimeStep::checkNoTimePresence() const
1652 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1655 void MEDCouplingWithTimeStep::checkTimePresence(double time) const
1657 if(std::fabs(time-_time)>_time_tolerance)
1659 std::ostringstream stream;
1660 stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
1661 throw INTERP_KERNEL::Exception(stream.str().c_str());
1665 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
1667 if(std::fabs(time-_time)<=_time_tolerance)
1669 std::vector< const DataArrayDouble *> ret(1);
1674 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1677 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1679 std::copy(vals.begin(),vals.end(),res);
1682 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const
1684 if(std::fabs(time-_time)<=_time_tolerance)
1686 _array->getTuple(eltId,value);
1688 throw INTERP_KERNEL::Exception("No array existing.");
1690 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1693 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1695 if(_iteration==iteration && _order==order)
1697 _array->getTuple(eltId,value);
1699 throw INTERP_KERNEL::Exception("No array existing.");
1701 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1704 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
1708 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
1710 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1711 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1713 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1714 _start_time=otherC->_start_time;
1715 _end_time=otherC->_end_time;
1716 _start_iteration=otherC->_start_iteration;
1717 _end_iteration=otherC->_end_iteration;
1718 _start_order=otherC->_start_order;
1719 _end_order=otherC->_end_order;
1722 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1724 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1725 tinyInfo.push_back(_start_iteration);
1726 tinyInfo.push_back(_start_order);
1727 tinyInfo.push_back(_end_iteration);
1728 tinyInfo.push_back(_end_order);
1731 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1733 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1734 tinyInfo.push_back(_start_time);
1735 tinyInfo.push_back(_end_time);
1738 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1740 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1741 _start_time=tinyInfoD[1];
1742 _end_time=tinyInfoD[2];
1743 _start_iteration=tinyInfoI[2];
1744 _start_order=tinyInfoI[3];
1745 _end_iteration=tinyInfoI[4];
1746 _end_order=tinyInfoI[5];
1750 * idem getTinySerializationIntInformation except that it is for multi field fetch
1752 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1755 tinyInfo[0]=_start_iteration;
1756 tinyInfo[1]=_start_order;
1757 tinyInfo[2]=_end_iteration;
1758 tinyInfo[3]=_end_order;
1762 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1764 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1767 tinyInfo[0]=_time_tolerance;
1768 tinyInfo[1]=_start_time;
1769 tinyInfo[2]=_end_time;
1773 * idem finishUnserialization except that it is for multi field fetch
1775 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1777 _start_iteration=tinyInfoI[0];
1778 _start_order=tinyInfoI[1];
1779 _end_iteration=tinyInfoI[2];
1780 _end_order=tinyInfoI[3];
1781 _time_tolerance=tinyInfoD[0];
1782 _start_time=tinyInfoD[1];
1783 _end_time=tinyInfoD[2];
1786 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
1787 MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
1788 _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
1792 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1794 std::ostringstream stream;
1795 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
1796 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
1797 stream << "\nTime unit is : \"" << _time_unit << "\"";
1798 return stream.str();
1801 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1804 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1806 double val=mesh->getTime(it,order);
1807 _start_time=val; _start_iteration=it; _start_order=order;
1808 _end_time=val; _end_iteration=it; _end_order=order;
1809 std::string tUnit=mesh->getTimeUnit();
1813 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
1815 return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
1818 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const
1820 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1822 std::vector< const DataArrayDouble *> ret(1);
1827 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1830 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1832 std::copy(vals.begin(),vals.end(),res);
1835 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
1837 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1839 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1843 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
1845 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1847 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1850 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1854 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
1856 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1858 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1862 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
1864 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1866 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1870 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1872 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1874 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1878 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
1880 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1881 std::ostringstream oss; oss.precision(15);
1884 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1887 if(_start_iteration!=otherC->_start_iteration)
1889 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
1893 if(_start_order!=otherC->_start_order)
1895 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
1899 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1901 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
1905 if(_end_iteration!=otherC->_end_iteration)
1907 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
1911 if(_end_order!=otherC->_end_order)
1913 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
1917 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1919 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
1923 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1926 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
1928 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1931 if(_start_iteration!=otherC->_start_iteration)
1933 if(_start_order!=otherC->_start_order)
1935 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
1937 if(_end_iteration!=otherC->_end_iteration)
1939 if(_end_order!=otherC->_end_order)
1941 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
1943 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1946 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const
1948 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
1950 _array->getTuple(eltId,value);
1952 throw INTERP_KERNEL::Exception("No array existing.");
1954 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1957 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1959 if(iteration>=_start_iteration && iteration<=_end_iteration)
1961 _array->getTuple(eltId,value);
1963 throw INTERP_KERNEL::Exception("No array existing.");
1965 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1968 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const
1970 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1973 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const
1975 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
1977 std::ostringstream stream;
1978 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
1979 stream << _time_tolerance << " and trying to access on time = " << time;
1980 throw INTERP_KERNEL::Exception(stream.str().c_str());
1984 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1986 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1988 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1989 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1990 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1991 ret->setArray(arr,0);
1995 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1997 std::vector<const DataArrayDouble *> a(other.size());
1999 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2001 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
2003 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
2004 a[i]=itC->getArray();
2006 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2007 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2008 ret->setArray(arr,0);
2012 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
2014 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2016 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
2017 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
2018 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2019 ret->setTimeTolerance(getTimeTolerance());
2020 ret->setArray(arr,0);
2024 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
2026 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2028 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
2029 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
2030 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2031 ret->setArray(arr,0);
2035 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
2037 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2039 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
2040 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2041 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2042 ret->setArray(arr,0);
2046 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
2048 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2050 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
2051 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
2052 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2053 ret->setArray(arr,0);
2057 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
2059 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2061 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
2062 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
2063 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2064 ret->setArray(arr,0);
2068 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
2070 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2072 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
2073 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
2074 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2075 ret->setArray(arr,0);
2077 double tmp3=getStartTime(tmp1,tmp2);
2078 ret->setStartTime(tmp3,tmp1,tmp2);
2079 tmp3=getEndTime(tmp1,tmp2);
2080 ret->setEndTime(tmp3,tmp1,tmp2);
2084 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
2086 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2088 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
2090 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
2091 getArray()->addEqual(other->getArray());
2094 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
2096 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2098 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
2099 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
2100 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2101 ret->setArray(arr,0);
2103 double tmp3=getStartTime(tmp1,tmp2);
2104 ret->setStartTime(tmp3,tmp1,tmp2);
2105 tmp3=getEndTime(tmp1,tmp2);
2106 ret->setEndTime(tmp3,tmp1,tmp2);
2110 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2112 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2114 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2116 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2117 getArray()->substractEqual(other->getArray());
2120 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2122 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2124 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2125 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2126 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2127 ret->setArray(arr,0);
2129 double tmp3=getStartTime(tmp1,tmp2);
2130 ret->setStartTime(tmp3,tmp1,tmp2);
2131 tmp3=getEndTime(tmp1,tmp2);
2132 ret->setEndTime(tmp3,tmp1,tmp2);
2136 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2138 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2140 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2142 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2143 getArray()->multiplyEqual(other->getArray());
2146 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2148 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2150 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2151 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2152 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2153 ret->setArray(arr,0);
2155 double tmp3=getStartTime(tmp1,tmp2);
2156 ret->setStartTime(tmp3,tmp1,tmp2);
2157 tmp3=getEndTime(tmp1,tmp2);
2158 ret->setEndTime(tmp3,tmp1,tmp2);
2162 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2164 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2166 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2168 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2169 getArray()->divideEqual(other->getArray());
2172 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2174 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2176 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2177 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2178 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2179 ret->setArray(arr,0);
2181 double tmp3=getStartTime(tmp1,tmp2);
2182 ret->setStartTime(tmp3,tmp1,tmp2);
2183 tmp3=getEndTime(tmp1,tmp2);
2184 ret->setEndTime(tmp3,tmp1,tmp2);
2188 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2190 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2192 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2194 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2195 getArray()->powEqual(other->getArray());
2198 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
2199 _start_time(other._start_time),_end_time(other._end_time),
2200 _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
2201 _start_order(other._start_order),_end_order(other._end_order)
2203 if(other._end_array)
2204 _end_array=other._end_array->performCpy(deepCpy);
2209 void MEDCouplingTwoTimeSteps::updateTime() const
2211 MEDCouplingTimeDiscretization::updateTime();
2213 updateTimeWith(*_end_array);
2216 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
2219 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2221 double val=mesh->getTime(it,order);
2222 _start_time=val; _start_iteration=it; _start_order=order;
2223 _end_time=val; _end_iteration=it; _end_order=order;
2224 std::string tUnit=mesh->getTimeUnit();
2228 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
2230 return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
2233 std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildren() const
2235 std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildren());
2237 ret.push_back(_end_array);
2241 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
2243 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2244 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2246 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2247 _start_time=otherC->_start_time;
2248 _end_time=otherC->_end_time;
2249 _start_iteration=otherC->_start_iteration;
2250 _end_iteration=otherC->_end_iteration;
2251 _start_order=otherC->_start_order;
2252 _end_order=otherC->_end_order;
2255 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
2257 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2258 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2260 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2261 if(_end_array && otherC->_end_array)
2262 _end_array->copyStringInfoFrom(*otherC->_end_array);
2265 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2270 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2275 void MEDCouplingTwoTimeSteps::checkCoherency() const
2277 MEDCouplingTimeDiscretization::checkCoherency();
2279 throw INTERP_KERNEL::Exception("No end array specified !");
2280 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2281 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2282 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2283 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2286 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
2288 std::ostringstream oss;
2289 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2292 reason="This has time discretization LINEAR_TIME, other not.";
2295 if(_start_iteration!=otherC->_start_iteration)
2297 oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
2301 if(_start_order!=otherC->_start_order)
2303 oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
2307 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2309 oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
2313 if(_end_iteration!=otherC->_end_iteration)
2315 oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
2319 if(_end_order!=otherC->_end_order)
2321 oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
2325 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2327 oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
2331 if(_end_array!=otherC->_end_array)
2332 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2334 reason.insert(0,"end arrays differ for linear time.");
2337 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2340 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
2342 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
2345 if(_start_iteration!=otherC->_start_iteration)
2347 if(_end_iteration!=otherC->_end_iteration)
2349 if(_start_order!=otherC->_start_order)
2351 if(_end_order!=otherC->_end_order)
2353 if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
2355 if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
2357 if(_end_array!=otherC->_end_array)
2358 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2360 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2363 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
2367 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2370 _end_array->decrRef();
2373 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const
2375 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2378 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
2380 if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
2382 std::ostringstream stream;
2383 stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
2384 stream << _time_tolerance << " and trying to access on time = " << time;
2385 throw INTERP_KERNEL::Exception(stream.str().c_str());
2389 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2393 arrays[1]=_end_array;
2396 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2398 if(array!=_end_array)
2401 _end_array->decrRef();
2404 _end_array->incrRef();
2406 owner->declareAsNew();
2410 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2412 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2413 tinyInfo.push_back(_start_iteration);
2414 tinyInfo.push_back(_start_order);
2415 tinyInfo.push_back(_end_iteration);
2416 tinyInfo.push_back(_end_order);
2419 tinyInfo.push_back(_end_array->getNumberOfTuples());
2420 tinyInfo.push_back(_end_array->getNumberOfComponents());
2424 tinyInfo.push_back(-1);
2425 tinyInfo.push_back(-1);
2429 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2431 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2432 tinyInfo.push_back(_start_time);
2433 tinyInfo.push_back(_end_time);
2436 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2438 int nbOfCompo=_array->getNumberOfComponents();
2439 for(int i=0;i<nbOfCompo;i++)
2440 tinyInfo.push_back(_array->getInfoOnComponent(i));
2441 for(int i=0;i<nbOfCompo;i++)
2442 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2445 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2451 _end_array->decrRef();
2452 DataArrayDouble *arr=0;
2453 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2455 arr=DataArrayDouble::New();
2456 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2461 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2463 arr=DataArrayDouble::New();
2464 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2470 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2472 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2473 _start_time=tinyInfoD[1];
2474 _end_time=tinyInfoD[2];
2475 _start_iteration=tinyInfoI[2];
2476 _start_order=tinyInfoI[3];
2477 _end_iteration=tinyInfoI[4];
2478 _end_order=tinyInfoI[5];
2482 * idem getTinySerializationIntInformation except that it is for multi field fetch
2484 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2487 tinyInfo[0]=_start_iteration;
2488 tinyInfo[1]=_start_order;
2489 tinyInfo[2]=_end_iteration;
2490 tinyInfo[3]=_end_order;
2494 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2496 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2499 tinyInfo[0]=_time_tolerance;
2500 tinyInfo[1]=_start_time;
2501 tinyInfo[2]=_end_time;
2505 * idem finishUnserialization except that it is for multi field fetch
2507 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2509 _start_iteration=tinyInfoI[0];
2510 _start_order=tinyInfoI[1];
2511 _end_iteration=tinyInfoI[2];
2512 _end_order=tinyInfoI[3];
2513 _time_tolerance=tinyInfoD[0];
2514 _start_time=tinyInfoD[1];
2515 _end_time=tinyInfoD[2];
2518 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
2520 if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
2522 std::vector< const DataArrayDouble *> ret(2);
2528 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2531 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
2533 if(arrays.size()!=2)
2534 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2535 setArray(arrays.front(),owner);
2536 setEndArray(arrays.back(),owner);
2539 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy)
2543 MEDCouplingLinearTime::MEDCouplingLinearTime()
2547 std::string MEDCouplingLinearTime::getStringRepr() const
2549 std::ostringstream stream;
2550 stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
2551 stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
2552 stream << "Time unit is : \"" << _time_unit << "\"";
2553 return stream.str();
2556 void MEDCouplingLinearTime::checkCoherency() const
2558 MEDCouplingTwoTimeSteps::checkCoherency();
2559 if(std::fabs(_start_time-_end_time)<_time_tolerance)
2560 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2563 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
2565 return new MEDCouplingLinearTime(*this,deepCpy);
2568 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
2570 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2572 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2575 if(_end_array==0 && otherC->_end_array==0)
2577 if(_end_array==0 || otherC->_end_array==0)
2579 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2584 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
2586 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2588 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2591 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2595 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
2597 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2599 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2603 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
2605 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2607 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2610 if(_end_array==0 && otherC->_end_array==0)
2612 if(_end_array==0 || otherC->_end_array==0)
2614 int nbC1=_end_array->getNumberOfComponents();
2615 int nbC2=otherC->_end_array->getNumberOfComponents();
2616 if(nbC1!=nbC2 && nbC2!=1)
2621 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2623 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2625 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2630 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2632 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2634 double alpha=(_end_time-time)/(_end_time-_start_time);
2635 std::size_t nbComp=vals.size()/2;
2636 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2637 std::vector<double> tmp(nbComp);
2638 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2639 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2642 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
2644 double alpha=(_end_time-time)/(_end_time-_start_time);
2647 _array->getTuple(eltId,value);
2649 throw INTERP_KERNEL::Exception("No start array existing.");
2650 nbComp=_array->getNumberOfComponents();
2651 std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2652 std::vector<double> tmp(nbComp);
2654 _end_array->getTuple(eltId,&tmp[0]);
2656 throw INTERP_KERNEL::Exception("No end array existing.");
2657 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2658 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2661 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
2663 if(iteration==_start_iteration && order==_start_order)
2666 _array->getTuple(eltId,value);
2668 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2670 if(iteration==_end_iteration && order==_end_order)
2673 _end_array->getTuple(eltId,value);
2675 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2678 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2681 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2683 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2685 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2686 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2687 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2688 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2689 ret->setArray(arr1,0);
2690 ret->setEndArray(arr2,0);
2694 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2696 std::vector<const DataArrayDouble *> a(other.size());
2697 std::vector<const DataArrayDouble *> b(other.size());
2699 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2701 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2703 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2704 a[i]=itC->getArray();
2705 b[i]=itC->getEndArray();
2707 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
2708 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
2709 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2710 ret->setArray(arr,0);
2711 ret->setEndArray(arr2,0);
2715 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2717 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2719 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2720 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
2721 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
2722 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2723 ret->setTimeTolerance(getTimeTolerance());
2724 ret->setArray(arr1,0);
2725 ret->setEndArray(arr2,0);
2729 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2731 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2733 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2734 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
2735 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
2736 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2737 ret->setArray(arr1,0);
2738 ret->setEndArray(arr2,0);
2742 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2744 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2746 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2747 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
2748 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
2749 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2750 ret->setArray(arr1,0);
2751 ret->setEndArray(arr2,0);
2755 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2757 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2759 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2760 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2761 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
2762 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
2763 ret->setArray(arr1,0);
2764 ret->setEndArray(arr2,0);
2768 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2770 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2772 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2773 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
2774 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
2775 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2776 ret->setArray(arr1,0);
2777 ret->setEndArray(arr2,0);
2781 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2783 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2785 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2786 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
2787 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
2788 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2789 ret->setArray(arr1,0);
2790 ret->setEndArray(arr2,0);
2794 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2796 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2798 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2800 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2802 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2803 getArray()->addEqual(other->getArray());
2804 getEndArray()->addEqual(other->getEndArray());
2807 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2809 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2811 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2812 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2813 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2814 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2815 ret->setArray(arr1,0);
2816 ret->setEndArray(arr2,0);
2820 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2822 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2824 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2826 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2828 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2829 getArray()->substractEqual(other->getArray());
2830 getEndArray()->substractEqual(other->getEndArray());
2833 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2835 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2837 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2838 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2839 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2840 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2841 ret->setArray(arr1,0);
2842 ret->setEndArray(arr2,0);
2846 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2848 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2850 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2852 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2854 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2855 getArray()->multiplyEqual(other->getArray());
2856 getEndArray()->multiplyEqual(other->getEndArray());
2859 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2861 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2863 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2864 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2865 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2866 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2867 ret->setArray(arr1,0);
2868 ret->setEndArray(arr2,0);
2872 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2874 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2876 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2878 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2880 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2881 getArray()->divideEqual(other->getArray());
2882 getEndArray()->divideEqual(other->getEndArray());
2885 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2887 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2889 throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2890 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2891 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2892 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2893 ret->setArray(arr1,0);
2894 ret->setEndArray(arr2,0);
2898 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2900 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2902 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2904 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2906 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2907 getArray()->powEqual(other->getArray());
2908 getEndArray()->powEqual(other->getEndArray());