1 // Copyright (C) 2007-2016 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.txx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDCouplingMesh.hxx"
30 using namespace MEDCoupling;
32 template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<double>;
33 template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<int>;
35 const char MEDCouplingTimeDiscretizationInt::REPR[]="One time label.";
37 const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
39 const char MEDCouplingNoTimeLabel::REPR[]="No time label defined.";
41 const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
43 const char MEDCouplingWithTimeStep::REPR[]="One time label.";
45 const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time.";
47 const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval.";
49 const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time.";
51 const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
53 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
57 case MEDCouplingNoTimeLabel::DISCRETIZATION:
58 return new MEDCouplingNoTimeLabel;
59 case MEDCouplingWithTimeStep::DISCRETIZATION:
60 return new MEDCouplingWithTimeStep;
61 case MEDCouplingConstOnTimeInterval::DISCRETIZATION:
62 return new MEDCouplingConstOnTimeInterval;
63 case MEDCouplingLinearTime::DISCRETIZATION:
64 return new MEDCouplingLinearTime;
66 throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
70 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
72 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
74 if(_array==0 && other->_array==0)
76 if(_array==0 || other->_array==0)
78 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
83 bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
85 if(!areStrictlyCompatible(other,reason))
87 if(_array==other->getArray())
89 return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
92 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
95 return isEqualIfNotWhy(other,prec,reason);
98 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
101 if(!areStrictlyCompatible(other,tmp))
103 if(_array==other->getArray())
105 return _array->isEqualWithoutConsideringStr(*other->getArray(),prec);
108 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const
110 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
111 ret->setTimeUnit(getTimeUnit());
112 const DataArrayDouble *arrSrc=getArray();
113 MCAuto<DataArrayDouble> arr;
115 arr=arrSrc->performCopyOrIncrRef(deepCopy);
116 ret->setArray(arr,0);
120 void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
124 tinyInfo.push_back(_array->getNumberOfTuples());
125 tinyInfo.push_back(_array->getNumberOfComponents());
129 tinyInfo.push_back(-1);
130 tinyInfo.push_back(-1);
134 void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
139 DataArrayDouble *arr=0;
140 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
142 arr=DataArrayDouble::New();
143 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
149 void MEDCouplingTimeDiscretization::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
151 static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !";
153 throw INTERP_KERNEL::Exception(MSG);
157 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
160 throw INTERP_KERNEL::Exception(MSG);
161 arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
167 void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
169 _time_tolerance=tinyInfoD[0];
170 int nbOfCompo=_array->getNumberOfComponents();
171 for(int i=0;i<nbOfCompo;i++)
172 _array->setInfoOnComponent(i,tinyInfoS[i]);
175 void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
177 tinyInfo.push_back(_time_tolerance);
180 void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
182 int nbOfCompo=_array->getNumberOfComponents();
183 for(int i=0;i<nbOfCompo;i++)
184 tinyInfo.push_back(_array->getInfoOnComponent(i));
187 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
190 double time1=getEndTime(iteration,order)-_time_tolerance;
191 double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
195 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
198 double time1=getEndTime(iteration,order)+_time_tolerance;
199 double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
203 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::computeVectorFieldCyl(const DataArrayDouble *coords, const double center[3], const double vect[3]) const
205 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
206 ret->setTimeUnit(getTimeUnit());
207 std::vector<DataArrayDouble *> arrays;
209 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
210 for(std::size_t j=0;j<arrays.size();j++)
213 arrays2[j]=arrays[j]->fromCartToCylGiven(coords,center,vect);
215 std::vector<DataArrayDouble *> arrays3(arrays.size());
216 for(std::size_t j=0;j<arrays.size();j++)
217 arrays3[j]=arrays2[j];
218 ret->setArrays(arrays3,0);
222 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const
224 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
225 ret->setTimeUnit(getTimeUnit());
226 std::vector<DataArrayDouble *> arrays;
228 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
229 for(std::size_t j=0;j<arrays.size();j++)
232 arrays2[j]=arrays[j]->doublyContractedProduct();
234 std::vector<DataArrayDouble *> arrays3(arrays.size());
235 for(std::size_t j=0;j<arrays.size();j++)
236 arrays3[j]=arrays2[j];
237 ret->setArrays(arrays3,0);
241 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const
243 std::vector<DataArrayDouble *> arrays;
245 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
246 for(std::size_t j=0;j<arrays.size();j++)
249 arrays2[j]=arrays[j]->determinant();
251 std::vector<DataArrayDouble *> arrays3(arrays.size());
252 for(std::size_t j=0;j<arrays.size();j++)
253 arrays3[j]=arrays2[j];
254 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
255 ret->setTimeUnit(getTimeUnit());
256 ret->setArrays(arrays3,0);
260 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const
262 std::vector<DataArrayDouble *> arrays;
264 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
265 for(std::size_t j=0;j<arrays.size();j++)
268 arrays2[j]=arrays[j]->eigenValues();
270 std::vector<DataArrayDouble *> arrays3(arrays.size());
271 for(std::size_t j=0;j<arrays.size();j++)
272 arrays3[j]=arrays2[j];
273 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
274 ret->setTimeUnit(getTimeUnit());
275 ret->setArrays(arrays3,0);
279 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const
281 std::vector<DataArrayDouble *> arrays;
283 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
284 for(std::size_t j=0;j<arrays.size();j++)
287 arrays2[j]=arrays[j]->eigenVectors();
289 std::vector<DataArrayDouble *> arrays3(arrays.size());
290 for(std::size_t j=0;j<arrays.size();j++)
291 arrays3[j]=arrays2[j];
292 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
293 ret->setTimeUnit(getTimeUnit());
294 ret->setArrays(arrays3,0);
298 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const
300 std::vector<DataArrayDouble *> arrays;
302 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
303 for(std::size_t j=0;j<arrays.size();j++)
306 arrays2[j]=arrays[j]->inverse();
308 std::vector<DataArrayDouble *> arrays3(arrays.size());
309 for(std::size_t j=0;j<arrays.size();j++)
310 arrays3[j]=arrays2[j];
311 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
312 ret->setTimeUnit(getTimeUnit());
313 ret->setArrays(arrays3,0);
317 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const
319 std::vector<DataArrayDouble *> arrays;
321 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
322 for(std::size_t j=0;j<arrays.size();j++)
325 arrays2[j]=arrays[j]->trace();
327 std::vector<DataArrayDouble *> arrays3(arrays.size());
328 for(std::size_t j=0;j<arrays.size();j++)
329 arrays3[j]=arrays2[j];
330 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
331 ret->setTimeUnit(getTimeUnit());
332 ret->setArrays(arrays3,0);
336 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const
338 std::vector<DataArrayDouble *> arrays;
340 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
341 for(std::size_t j=0;j<arrays.size();j++)
344 arrays2[j]=arrays[j]->deviator();
346 std::vector<DataArrayDouble *> arrays3(arrays.size());
347 for(std::size_t j=0;j<arrays.size();j++)
348 arrays3[j]=arrays2[j];
349 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
350 ret->setTimeUnit(getTimeUnit());
351 ret->setArrays(arrays3,0);
355 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const
357 std::vector<DataArrayDouble *> arrays;
359 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
360 for(std::size_t j=0;j<arrays.size();j++)
363 arrays2[j]=arrays[j]->magnitude();
365 std::vector<DataArrayDouble *> arrays3(arrays.size());
366 for(std::size_t j=0;j<arrays.size();j++)
367 arrays3[j]=arrays2[j];
368 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
369 ret->setTimeUnit(getTimeUnit());
370 ret->setArrays(arrays3,0);
374 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const
376 std::vector<DataArrayDouble *> arrays;
378 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
379 for(std::size_t j=0;j<arrays.size();j++)
382 arrays2[j]=arrays[j]->negate();
384 std::vector<DataArrayDouble *> arrays3(arrays.size());
385 for(std::size_t j=0;j<arrays.size();j++)
386 arrays3[j]=arrays2[j];
387 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
388 ret->setTimeUnit(getTimeUnit());
389 ret->setArrays(arrays3,0);
393 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const
395 std::vector<DataArrayDouble *> arrays;
397 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
398 for(std::size_t j=0;j<arrays.size();j++)
401 arrays2[j]=arrays[j]->maxPerTuple();
403 std::vector<DataArrayDouble *> arrays3(arrays.size());
404 for(std::size_t j=0;j<arrays.size();j++)
405 arrays3[j]=arrays2[j];
406 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
407 ret->setTimeUnit(getTimeUnit());
408 ret->setArrays(arrays3,0);
412 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const
414 std::vector<DataArrayDouble *> arrays;
416 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
417 for(std::size_t j=0;j<arrays.size();j++)
420 arrays2[j]=static_cast<DataArrayDouble *>(arrays[j]->keepSelectedComponents(compoIds));
422 std::vector<DataArrayDouble *> arrays3(arrays.size());
423 for(std::size_t j=0;j<arrays.size();j++)
424 arrays3[j]=arrays2[j];
425 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
426 ret->setTimeUnit(getTimeUnit());
427 ret->setArrays(arrays3,0);
431 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds)
433 std::vector<DataArrayDouble *> arrays1,arrays2;
435 other->getArrays(arrays2);
436 if(arrays1.size()!=arrays2.size())
437 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
438 for(std::size_t i=0;i<arrays1.size();i++)
440 if(arrays1[i]!=0 && arrays2[i]!=0)
441 arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
442 else if(arrays1[i]!=0 || arrays2[i]!=0)
443 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
447 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue)
449 std::vector<DataArrayDouble *> arrays;
451 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
452 for(std::size_t j=0;j<arrays.size();j++)
455 arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
457 std::vector<DataArrayDouble *> arrays3(arrays.size());
458 for(std::size_t j=0;j<arrays.size();j++)
459 arrays3[j]=arrays2[j];
460 setArrays(arrays3,0);
463 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc)
465 std::vector<DataArrayDouble *> arrays;
467 for(std::size_t j=0;j<arrays.size();j++)
470 arrays[j]->sortPerTuple(asc);
474 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
476 std::vector<DataArrayDouble *> arrays;
478 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
479 for(std::size_t j=0;j<arrays.size();j++)
483 arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
484 arrays2[j]->fillWithValue(value);
488 arrays2[j]=DataArrayDouble::New();
489 arrays2[j]->alloc(nbOfTuple,nbOfCompo);
490 arrays2[j]->fillWithValue(value);
493 std::vector<DataArrayDouble *> arrays3(arrays.size());
494 for(std::size_t j=0;j<arrays.size();j++)
495 arrays3[j]=arrays2[j];
496 setArrays(arrays3,0);
499 void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
501 std::vector<DataArrayDouble *> arrays;
503 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
505 for(std::size_t j=0;j<arrays.size();j++)
509 arrays2[j]=arrays[j]; arrays2[j]->incrRef();
510 arrays2[j]->fillWithValue(value);
515 arrays2[j]=DataArrayDouble::New();
516 arrays2[j]->alloc(nbOfTuple,1);
517 arrays2[j]->fillWithValue(value);
522 std::vector<DataArrayDouble *> arrays3(arrays.size());
523 for(std::size_t j=0;j<arrays.size();j++)
524 arrays3[j]=arrays2[j];
525 setArrays(arrays3,0);
529 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
531 std::vector<DataArrayDouble *> arrays;
533 for(std::size_t j=0;j<arrays.size();j++)
536 arrays[j]->applyLin(a,b,compoId);
540 void MEDCouplingTimeDiscretization::applyLin(double a, double b)
542 std::vector<DataArrayDouble *> arrays;
544 for(std::size_t j=0;j<arrays.size();j++)
547 arrays[j]->applyLin(a,b);
551 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
553 std::vector<DataArrayDouble *> arrays;
555 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
556 for(std::size_t j=0;j<arrays.size();j++)
559 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
561 std::vector<DataArrayDouble *> arrays3(arrays.size());
562 for(std::size_t j=0;j<arrays.size();j++)
563 arrays3[j]=arrays2[j];
564 setArrays(arrays3,0);
567 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const std::string& func)
569 std::vector<DataArrayDouble *> arrays;
571 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
572 for(std::size_t j=0;j<arrays.size();j++)
575 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
579 std::vector<DataArrayDouble *> arrays3(arrays.size());
580 for(std::size_t j=0;j<arrays.size();j++)
581 arrays3[j]=arrays2[j];
582 setArrays(arrays3,0);
585 void MEDCouplingTimeDiscretization::applyFuncCompo(int nbOfComp, const std::string& func)
587 std::vector<DataArrayDouble *> arrays;
589 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
590 for(std::size_t j=0;j<arrays.size();j++)
593 arrays2[j]=arrays[j]->applyFuncCompo(nbOfComp,func);
595 std::vector<DataArrayDouble *> arrays3(arrays.size());
596 for(std::size_t j=0;j<arrays.size();j++)
597 arrays3[j]=arrays2[j];
598 setArrays(arrays3,0);
601 void MEDCouplingTimeDiscretization::applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
603 std::vector<DataArrayDouble *> arrays;
605 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
606 for(std::size_t j=0;j<arrays.size();j++)
609 arrays2[j]=arrays[j]->applyFuncNamedCompo(nbOfComp,varsOrder,func);
611 std::vector<DataArrayDouble *> arrays3(arrays.size());
612 for(std::size_t j=0;j<arrays.size();j++)
613 arrays3[j]=arrays2[j];
614 setArrays(arrays3,0);
617 void MEDCouplingTimeDiscretization::applyFunc(const std::string& func)
619 std::vector<DataArrayDouble *> arrays;
621 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
622 for(std::size_t j=0;j<arrays.size();j++)
625 arrays2[j]=arrays[j]->applyFunc(func);
627 std::vector<DataArrayDouble *> arrays3(arrays.size());
628 for(std::size_t j=0;j<arrays.size();j++)
629 arrays3[j]=arrays2[j];
630 setArrays(arrays3,0);
633 void MEDCouplingTimeDiscretization::applyFuncFast32(const std::string& func)
635 std::vector<DataArrayDouble *> arrays;
637 for(std::size_t j=0;j<arrays.size();j++)
640 arrays[j]->applyFuncFast32(func);
644 void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func)
646 std::vector<DataArrayDouble *> arrays;
648 for(std::size_t j=0;j<arrays.size();j++)
651 arrays[j]->applyFuncFast64(func);
655 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func)
657 std::vector<DataArrayDouble *> arrays;
659 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
660 for(std::size_t j=0;j<arrays.size();j++)
661 arrays2[j]=loc->applyFunc(nbOfComp,func);
662 std::vector<DataArrayDouble *> arrays3(arrays.size());
663 for(std::size_t j=0;j<arrays.size();j++)
664 arrays3[j]=arrays2[j];
665 setArrays(arrays3,0);
668 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
670 std::vector<DataArrayDouble *> arrays;
672 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
673 for(std::size_t j=0;j<arrays.size();j++)
674 arrays2[j]=loc->applyFunc(nbOfComp,func);
675 std::vector<DataArrayDouble *> arrays3(arrays.size());
676 for(std::size_t j=0;j<arrays.size();j++)
677 arrays3[j]=arrays2[j];
678 setArrays(arrays3,0);
681 void MEDCouplingTimeDiscretization::fillFromAnalyticCompo(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
683 std::vector<DataArrayDouble *> arrays;
685 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
686 for(std::size_t j=0;j<arrays.size();j++)
687 arrays2[j]=loc->applyFuncCompo(nbOfComp,func);
688 std::vector<DataArrayDouble *> arrays3(arrays.size());
689 for(std::size_t j=0;j<arrays.size();j++)
690 arrays3[j]=arrays2[j];
691 setArrays(arrays3,0);
694 void MEDCouplingTimeDiscretization::fillFromAnalyticNamedCompo(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
696 std::vector<DataArrayDouble *> arrays;
698 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
699 for(std::size_t j=0;j<arrays.size();j++)
700 arrays2[j]=loc->applyFuncNamedCompo(nbOfComp,varsOrder,func);
701 std::vector<DataArrayDouble *> arrays3(arrays.size());
702 for(std::size_t j=0;j<arrays.size();j++)
703 arrays3[j]=arrays2[j];
704 setArrays(arrays3,0);
707 ////////////////////////
709 bool MEDCouplingTimeKeeper::isEqualIfNotWhy(const MEDCouplingTimeKeeper& other, double prec, std::string& reason) const
711 std::ostringstream oss;
712 if(_iteration!=other._iteration)
714 oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << other._iteration;
718 if(_order!=other._order)
720 oss << "orders differ. this order=" << _order << " other order=" << other._order;
724 if(std::fabs(_time-other._time)>prec)
726 oss << "times differ. this time=" << _time << " other time=" << other._time;
733 bool MEDCouplingTimeKeeper::isEqual(const MEDCouplingTimeKeeper& other, double prec) const
735 if(_iteration!=other._iteration)
737 if(_order!=other._order)
739 if(std::fabs(_time-other._time)>prec)
744 void MEDCouplingTimeKeeper::copyFrom(const MEDCouplingTimeKeeper& other)
747 _iteration=other._iteration;
751 void MEDCouplingTimeKeeper::checkTimePresence(double time, double eps) const
753 if(std::fabs(time-_time)>eps)
755 std::ostringstream stream;
756 stream << "The field is defined on time " << _time << " with eps=" << eps << " and asking time = " << time << " !";
757 throw INTERP_KERNEL::Exception(stream.str().c_str());
761 ////////////////////////
763 MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt()
767 MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<int>(other,deepCopy),_tk(other._tk)
771 std::string MEDCouplingTimeDiscretizationInt::getStringRepr() const
773 std::ostringstream stream;
774 stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
775 stream << "\nTime unit is : \"" << _time_unit << "\"";
779 MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::performCopyOrIncrRef(bool deepCopy) const
781 return new MEDCouplingTimeDiscretizationInt(*this,deepCopy);
784 MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::New(TypeOfTimeDiscretization type)
788 case MEDCouplingTimeDiscretizationInt::DISCRETIZATION:
789 return new MEDCouplingTimeDiscretizationInt;
791 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for intergers !");
795 bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec, std::string& reason) const
798 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
801 reason="Time discretization is NULL.";
804 const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(other));
806 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt !");
807 if(!MEDCouplingTimeDiscretizationTemplate<int>::areStrictlyCompatible(other,reason))
809 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
811 if(_array==other->getArray())
813 return _array->isEqualIfNotWhy(*other->getArray(),reason);
816 bool MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec) const
819 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr : only precision 0 is supported !");
820 const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(other));
822 throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !");
824 if(!areStrictlyCompatible(other,tmp))
827 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
829 if(_array==other->getArray())
831 return _array->isEqualWithoutConsideringStr(*(other->getArray()));
834 double MEDCouplingTimeDiscretizationInt::getEndTime(int& iteration, int& order) const
836 throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !");
839 void MEDCouplingTimeDiscretizationInt::setEndIteration(int it)
841 throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !");
844 void MEDCouplingTimeDiscretizationInt::setEndOrder(int order)
846 throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !");
849 void MEDCouplingTimeDiscretizationInt::setEndTimeValue(double time)
851 throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !");
854 void MEDCouplingTimeDiscretizationInt::setEndTime(double time, int iteration, int order)
856 throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !");
859 ////////////////////////
861 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
865 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy)
869 std::string MEDCouplingNoTimeLabel::getStringRepr() const
871 std::ostringstream stream;
873 stream << "\nTime unit is : \"" << _time_unit << "\"";
877 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh)
879 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
882 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
884 if(!MEDCouplingTimeDiscretization::areCompatible(other))
886 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
890 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
892 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
894 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
897 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
901 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
903 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
905 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
909 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
911 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
913 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
917 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
919 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
921 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
925 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
927 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
930 reason="This has time discretization NO_TIME, other not.";
933 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
936 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
938 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
941 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
944 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
946 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
948 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
949 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(getArray(),other->getArray()));
950 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
951 ret->setArray(arr,0);
955 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
957 std::vector<const DataArrayDouble *> a(other.size());
959 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
961 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
963 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
964 a[i]=itC->getArray();
966 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a));
967 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
968 ret->setArray(arr,0);
972 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
974 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
976 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
977 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
978 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
979 ret->setTimeTolerance(getTimeTolerance());
980 ret->setArray(arr,0);
984 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
986 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
988 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
989 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
990 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
991 ret->setArray(arr,0);
995 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
997 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
999 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
1000 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1001 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1002 ret->setArray(arr,0);
1006 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
1008 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1010 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1011 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1012 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1013 ret->setArray(arr,0);
1017 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
1019 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1021 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1022 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1023 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1024 ret->setArray(arr,0);
1028 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
1030 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1032 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
1033 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1034 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1035 ret->setArray(arr,0);
1039 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
1041 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1043 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1045 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1046 getArray()->addEqual(other->getArray());
1049 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1051 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1053 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1055 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1056 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1057 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1058 ret->setArray(arr,0);
1062 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1064 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1066 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1068 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1069 getArray()->substractEqual(other->getArray());
1072 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1074 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1076 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1077 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1078 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1079 ret->setArray(arr,0);
1083 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1085 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1087 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1089 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1090 getArray()->multiplyEqual(other->getArray());
1093 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1095 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1097 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1098 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1099 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1100 ret->setArray(arr,0);
1104 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1106 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1108 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1110 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1111 getArray()->divideEqual(other->getArray());
1114 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1116 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1118 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1119 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1120 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1121 ret->setArray(arr,0);
1125 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1127 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1129 throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1131 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1132 getArray()->powEqual(other->getArray());
1135 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCopyOrIncrRef(bool deepCopy) const
1137 return new MEDCouplingNoTimeLabel(*this,deepCopy);
1140 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const
1142 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1145 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const
1147 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1150 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1152 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1155 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const
1157 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1160 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
1162 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1165 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const
1167 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1170 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const
1172 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1175 void MEDCouplingNoTimeLabel::setStartIteration(int it)
1177 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1180 void MEDCouplingNoTimeLabel::setEndIteration(int it)
1182 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1185 void MEDCouplingNoTimeLabel::setStartOrder(int order)
1187 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1190 void MEDCouplingNoTimeLabel::setEndOrder(int order)
1192 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1195 void MEDCouplingNoTimeLabel::setStartTimeValue(double time)
1197 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1200 void MEDCouplingNoTimeLabel::setEndTimeValue(double time)
1202 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1205 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order)
1207 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1210 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order)
1212 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1215 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const
1217 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1220 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1222 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1226 * idem getTinySerializationIntInformation except that it is for multi field fetch
1228 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1234 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1236 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1239 tinyInfo[0]=_time_tolerance;
1243 * idem finishUnserialization except that it is for multi field fetch
1245 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1247 _time_tolerance=tinyInfoD[0];
1250 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),_tk(other._tk)
1254 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep()
1258 std::string MEDCouplingWithTimeStep::getStringRepr() const
1260 std::ostringstream stream;
1261 stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
1262 stream << "\nTime unit is : \"" << _time_unit << "\"";
1263 return stream.str();
1266 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1269 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1271 double val=mesh->getTime(it,order);
1272 _tk.setAllInfo(val,it,order);
1273 std::string tUnit=mesh->getTimeUnit();
1277 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1279 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1280 tinyInfo.push_back(_tk.getIteration());
1281 tinyInfo.push_back(_tk.getOrder());
1284 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1286 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1287 tinyInfo.push_back(_tk.getTimeValue());
1290 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1292 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1293 _tk.setTimeValue(tinyInfoD[1]);
1294 _tk.setIteration(tinyInfoI[2]);
1295 _tk.setOrder(tinyInfoI[3]);
1299 * idem getTinySerializationIntInformation except that it is for multi field fetch
1301 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1304 tinyInfo[0]=_tk.getIteration();
1305 tinyInfo[1]=_tk.getOrder();
1309 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1311 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1314 tinyInfo[0]=_time_tolerance;
1315 tinyInfo[1]=_tk.getTimeValue();
1319 * idem finishUnserialization except that it is for multi field fetch
1321 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1323 _tk.setIteration(tinyInfoI[0]);
1324 _tk.setOrder(tinyInfoI[1]);
1325 _time_tolerance=tinyInfoD[0];
1326 _tk.setTimeValue(tinyInfoD[1]);
1329 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1331 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1333 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1337 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1339 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1341 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1344 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1348 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1350 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1352 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1356 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1358 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1360 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1364 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1366 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1368 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1372 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1374 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1375 std::ostringstream oss; oss.precision(15);
1378 reason="This has time discretization ONE_TIME, other not.";
1381 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
1383 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1386 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1388 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1391 if(!_tk.isEqual(otherC->_tk,_time_tolerance))
1393 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1396 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1398 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1399 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1401 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1402 _tk.copyFrom(otherC->_tk);
1405 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1407 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1409 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1410 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1411 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1412 ret->setArray(arr,0);
1416 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1418 std::vector<const DataArrayDouble *> a(other.size());
1420 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1422 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1424 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1425 a[i]=itC->getArray();
1427 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1428 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1429 ret->setArray(arr,0);
1433 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1435 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1437 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1438 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1439 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1440 ret->setArray(arr,0);
1444 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1446 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1448 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1449 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1450 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1451 ret->setArray(arr,0);
1455 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1457 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1459 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1460 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1461 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1462 ret->setArray(arr,0);
1466 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1468 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1470 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1471 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1472 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1473 ret->setArray(arr,0);
1477 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1479 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1481 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1482 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1483 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1484 ret->setArray(arr,0);
1488 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1490 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1492 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1493 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1494 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1495 ret->setArray(arr,0);
1497 double tmp3=getStartTime(tmp1,tmp2);
1498 ret->setStartTime(tmp3,tmp1,tmp2);
1502 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1504 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1506 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1508 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1509 getArray()->addEqual(other->getArray());
1512 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1514 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1516 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1517 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1518 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1519 ret->setArray(arr,0);
1521 double tmp3=getStartTime(tmp1,tmp2);
1522 ret->setStartTime(tmp3,tmp1,tmp2);
1526 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1528 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1530 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1532 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1533 getArray()->substractEqual(other->getArray());
1536 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1538 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1540 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1541 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1542 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1543 ret->setArray(arr,0);
1545 double tmp3=getStartTime(tmp1,tmp2);
1546 ret->setStartTime(tmp3,tmp1,tmp2);
1550 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1552 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1554 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1556 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1557 getArray()->multiplyEqual(other->getArray());
1560 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1562 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1564 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1565 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1566 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1567 ret->setArray(arr,0);
1569 double tmp3=getStartTime(tmp1,tmp2);
1570 ret->setStartTime(tmp3,tmp1,tmp2);
1574 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1576 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1578 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1580 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1581 getArray()->divideEqual(other->getArray());
1584 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1586 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1588 throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1589 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1590 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1591 ret->setArray(arr,0);
1593 double tmp3=getStartTime(tmp1,tmp2);
1594 ret->setStartTime(tmp3,tmp1,tmp2);
1598 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1600 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1602 throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1604 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1605 getArray()->powEqual(other->getArray());
1608 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCopyOrIncrRef(bool deepCopy) const
1610 return new MEDCouplingWithTimeStep(*this,deepCopy);
1613 void MEDCouplingWithTimeStep::checkNoTimePresence() const
1615 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1618 void MEDCouplingWithTimeStep::checkTimePresence(double time) const
1620 _tk.checkTimePresence(time,_time_tolerance);
1623 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
1625 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1627 std::vector< const DataArrayDouble *> ret(1);
1632 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1635 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1637 std::copy(vals.begin(),vals.end(),res);
1640 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const
1642 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1644 _array->getTuple(eltId,value);
1646 throw INTERP_KERNEL::Exception("No array existing.");
1648 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1651 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1653 if(_tk.getIteration()==iteration && _tk.getOrder()==order)
1655 _array->getTuple(eltId,value);
1657 throw INTERP_KERNEL::Exception("No array existing.");
1659 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1662 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval()
1666 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1668 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1669 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1671 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1672 _start.copyFrom(otherC->_start);
1673 _end.copyFrom(otherC->_end);
1676 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1678 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1679 tinyInfo.push_back(_start.getIteration());
1680 tinyInfo.push_back(_start.getOrder());
1681 tinyInfo.push_back(_end.getIteration());
1682 tinyInfo.push_back(_end.getOrder());
1685 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1687 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1688 tinyInfo.push_back(_start.getTimeValue());
1689 tinyInfo.push_back(_end.getTimeValue());
1692 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1694 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1695 _start.setTimeValue(tinyInfoD[1]);
1696 _end.setTimeValue(tinyInfoD[2]);
1697 _start.setIteration(tinyInfoI[2]);
1698 _start.setOrder(tinyInfoI[3]);
1699 _end.setIteration(tinyInfoI[4]);
1700 _end.setOrder(tinyInfoI[5]);
1704 * idem getTinySerializationIntInformation except that it is for multi field fetch
1706 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1709 tinyInfo[0]=_start.getIteration();
1710 tinyInfo[1]=_start.getOrder();
1711 tinyInfo[2]=_end.getIteration();
1712 tinyInfo[3]=_end.getOrder();
1716 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1718 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1721 tinyInfo[0]=_time_tolerance;
1722 tinyInfo[1]=_start.getTimeValue();
1723 tinyInfo[2]=_end.getTimeValue();
1727 * idem finishUnserialization except that it is for multi field fetch
1729 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1731 _start.setIteration(tinyInfoI[0]);
1732 _start.setOrder(tinyInfoI[1]);
1733 _end.setIteration(tinyInfoI[2]);
1734 _end.setOrder(tinyInfoI[3]);
1735 _time_tolerance=tinyInfoD[0];
1736 _start.setTimeValue(tinyInfoD[1]);
1737 _end.setTimeValue(tinyInfoD[2]);
1740 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCopy):
1741 MEDCouplingTimeDiscretization(other,deepCopy),_start(other._start),_end(other._end)
1745 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1747 std::ostringstream stream;
1748 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
1749 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
1750 stream << "\nTime unit is : \"" << _time_unit << "\"";
1751 return stream.str();
1754 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1757 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1759 double val=mesh->getTime(it,order);
1760 _start.setAllInfo(val,it,order);
1761 _end.setAllInfo(val,it,order);
1762 std::string tUnit(mesh->getTimeUnit());
1766 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCopyOrIncrRef(bool deepCopy) const
1768 return new MEDCouplingConstOnTimeInterval(*this,deepCopy);
1771 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const
1773 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1775 std::vector< const DataArrayDouble *> ret(1);
1780 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1783 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1785 std::copy(vals.begin(),vals.end(),res);
1788 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1790 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1792 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1796 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1798 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1800 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1803 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1807 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1809 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1811 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1815 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1817 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1819 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1823 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1825 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1827 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1831 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1833 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1834 std::ostringstream oss; oss.precision(15);
1837 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1840 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
1842 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
1844 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1847 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1849 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1852 if(!_start.isEqual(otherC->_start,_time_tolerance))
1854 if(!_end.isEqual(otherC->_end,_time_tolerance))
1856 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1859 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const
1861 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1863 _array->getTuple(eltId,value);
1865 throw INTERP_KERNEL::Exception("No array existing.");
1867 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1870 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1872 if(iteration>=_start.getIteration() && iteration<=_end.getIteration())
1874 _array->getTuple(eltId,value);
1876 throw INTERP_KERNEL::Exception("No array existing.");
1878 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1881 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const
1883 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1886 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const
1888 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
1890 std::ostringstream stream;
1891 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
1892 stream << _time_tolerance << " and trying to access on time = " << time;
1893 throw INTERP_KERNEL::Exception(stream.str().c_str());
1897 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1899 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1901 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1902 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1903 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1904 ret->setArray(arr,0);
1908 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1910 std::vector<const DataArrayDouble *> a(other.size());
1912 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1914 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
1916 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
1917 a[i]=itC->getArray();
1919 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1920 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1921 ret->setArray(arr,0);
1925 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
1927 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1929 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
1930 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1931 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1932 ret->setTimeTolerance(getTimeTolerance());
1933 ret->setArray(arr,0);
1937 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
1939 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1941 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
1942 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1943 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1944 ret->setArray(arr,0);
1948 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
1950 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1952 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
1953 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1954 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1955 ret->setArray(arr,0);
1959 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
1961 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1963 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
1964 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1965 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1966 ret->setArray(arr,0);
1970 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
1972 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1974 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
1975 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1976 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1977 ret->setArray(arr,0);
1981 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
1983 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1985 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
1986 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1987 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1988 ret->setArray(arr,0);
1990 double tmp3=getStartTime(tmp1,tmp2);
1991 ret->setStartTime(tmp3,tmp1,tmp2);
1992 tmp3=getEndTime(tmp1,tmp2);
1993 ret->setEndTime(tmp3,tmp1,tmp2);
1997 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
1999 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2001 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
2003 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
2004 getArray()->addEqual(other->getArray());
2007 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
2009 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2011 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
2012 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
2013 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2014 ret->setArray(arr,0);
2016 double tmp3=getStartTime(tmp1,tmp2);
2017 ret->setStartTime(tmp3,tmp1,tmp2);
2018 tmp3=getEndTime(tmp1,tmp2);
2019 ret->setEndTime(tmp3,tmp1,tmp2);
2023 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2025 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2027 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2029 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2030 getArray()->substractEqual(other->getArray());
2033 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2035 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2037 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2038 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2039 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2040 ret->setArray(arr,0);
2042 double tmp3=getStartTime(tmp1,tmp2);
2043 ret->setStartTime(tmp3,tmp1,tmp2);
2044 tmp3=getEndTime(tmp1,tmp2);
2045 ret->setEndTime(tmp3,tmp1,tmp2);
2049 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2051 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2053 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2055 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2056 getArray()->multiplyEqual(other->getArray());
2059 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2061 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2063 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2064 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2065 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2066 ret->setArray(arr,0);
2068 double tmp3=getStartTime(tmp1,tmp2);
2069 ret->setStartTime(tmp3,tmp1,tmp2);
2070 tmp3=getEndTime(tmp1,tmp2);
2071 ret->setEndTime(tmp3,tmp1,tmp2);
2075 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2077 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2079 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2081 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2082 getArray()->divideEqual(other->getArray());
2085 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2087 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2089 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2090 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2091 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2092 ret->setArray(arr,0);
2094 double tmp3=getStartTime(tmp1,tmp2);
2095 ret->setStartTime(tmp3,tmp1,tmp2);
2096 tmp3=getEndTime(tmp1,tmp2);
2097 ret->setEndTime(tmp3,tmp1,tmp2);
2101 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2103 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2105 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2107 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2108 getArray()->powEqual(other->getArray());
2111 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
2112 _start(other._start),_end(other._end)
2114 if(other._end_array)
2115 _end_array=other._end_array->performCopyOrIncrRef(deepCopy);
2120 void MEDCouplingTwoTimeSteps::updateTime() const
2122 MEDCouplingTimeDiscretization::updateTime();
2124 updateTimeWith(*_end_array);
2127 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
2130 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2132 double val=mesh->getTime(it,order);
2133 _start.setAllInfo(val,it,order);
2134 _end.setAllInfo(val,it,order);
2135 std::string tUnit=mesh->getTimeUnit();
2139 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
2141 return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
2144 std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildrenWithNull() const
2146 std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildrenWithNull());
2147 ret.push_back(_end_array);
2151 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2153 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2154 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2156 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2157 _start.copyFrom(otherC->_start);
2158 _end.copyFrom(otherC->_end);
2161 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2163 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2164 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2166 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2167 if(_end_array && otherC->_end_array)
2168 _end_array->copyStringInfoFrom(*otherC->_end_array);
2171 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2176 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2181 void MEDCouplingTwoTimeSteps::checkConsistencyLight() const
2183 MEDCouplingTimeDiscretization::checkConsistencyLight();
2185 throw INTERP_KERNEL::Exception("No end array specified !");
2186 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2187 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2188 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2189 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2192 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
2194 std::ostringstream oss;
2195 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2198 reason="This has time discretization LINEAR_TIME, other not.";
2201 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
2203 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
2205 if(_end_array!=otherC->_end_array)
2206 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2208 reason.insert(0,"end arrays differ for linear time.");
2211 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2214 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
2216 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2219 if(!_start.isEqual(otherC->_start,_time_tolerance))
2221 if(!_end.isEqual(otherC->_end,_time_tolerance))
2223 if(_end_array!=otherC->_end_array)
2224 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2226 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2229 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0)
2233 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2236 _end_array->decrRef();
2239 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const
2241 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2244 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
2246 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
2248 std::ostringstream stream;
2249 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
2250 stream << _time_tolerance << " and trying to access on time = " << time;
2251 throw INTERP_KERNEL::Exception(stream.str().c_str());
2255 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2259 arrays[1]=_end_array;
2262 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2264 if(array!=_end_array)
2267 _end_array->decrRef();
2270 _end_array->incrRef();
2272 owner->declareAsNew();
2276 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2278 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2279 tinyInfo.push_back(_start.getIteration());
2280 tinyInfo.push_back(_start.getOrder());
2281 tinyInfo.push_back(_end.getIteration());
2282 tinyInfo.push_back(_end.getOrder());
2285 tinyInfo.push_back(_end_array->getNumberOfTuples());
2286 tinyInfo.push_back(_end_array->getNumberOfComponents());
2290 tinyInfo.push_back(-1);
2291 tinyInfo.push_back(-1);
2295 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2297 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2298 tinyInfo.push_back(_start.getTimeValue());
2299 tinyInfo.push_back(_end.getTimeValue());
2302 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2304 int nbOfCompo=_array->getNumberOfComponents();
2305 for(int i=0;i<nbOfCompo;i++)
2306 tinyInfo.push_back(_array->getInfoOnComponent(i));
2307 for(int i=0;i<nbOfCompo;i++)
2308 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2311 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2317 _end_array->decrRef();
2318 DataArrayDouble *arr=0;
2319 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2321 arr=DataArrayDouble::New();
2322 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2327 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2329 arr=DataArrayDouble::New();
2330 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2336 void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
2338 static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !";
2339 if(arrays.size()!=2)
2340 throw INTERP_KERNEL::Exception(MSG);
2344 _end_array->decrRef();
2345 _array=0; _end_array=0;
2346 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2349 throw INTERP_KERNEL::Exception(MSG);
2350 arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2351 _array=arrays[0]; _array->incrRef();
2353 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2356 throw INTERP_KERNEL::Exception(MSG);
2357 arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2358 _end_array=arrays[1]; _end_array->incrRef();
2362 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2364 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2365 _start.setTimeValue(tinyInfoD[1]);
2366 _end.setTimeValue(tinyInfoD[2]);
2367 _start.setIteration(tinyInfoI[2]);
2368 _start.setOrder(tinyInfoI[3]);
2369 _end.setIteration(tinyInfoI[4]);
2370 _end.setOrder(tinyInfoI[5]);
2374 * idem getTinySerializationIntInformation except that it is for multi field fetch
2376 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2379 tinyInfo[0]=_start.getIteration();
2380 tinyInfo[1]=_start.getOrder();
2381 tinyInfo[2]=_end.getIteration();
2382 tinyInfo[3]=_end.getOrder();
2386 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2388 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2391 tinyInfo[0]=_time_tolerance;
2392 tinyInfo[1]=_start.getTimeValue();
2393 tinyInfo[2]=_end.getTimeValue();
2397 * idem finishUnserialization except that it is for multi field fetch
2399 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2401 _start.setIteration(tinyInfoI[0]);
2402 _start.setOrder(tinyInfoI[1]);
2403 _end.setIteration(tinyInfoI[2]);
2404 _end.setOrder(tinyInfoI[3]);
2405 _time_tolerance=tinyInfoD[0];
2406 _start.setTimeValue(tinyInfoD[1]);
2407 _end.setTimeValue(tinyInfoD[2]);
2410 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
2412 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
2414 std::vector< const DataArrayDouble *> ret(2);
2420 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2423 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
2425 if(arrays.size()!=2)
2426 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2427 setArray(arrays.front(),owner);
2428 setEndArray(arrays.back(),owner);
2431 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCopy):MEDCouplingTwoTimeSteps(other,deepCopy)
2435 MEDCouplingLinearTime::MEDCouplingLinearTime()
2439 std::string MEDCouplingLinearTime::getStringRepr() const
2441 std::ostringstream stream;
2442 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
2443 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
2444 stream << "Time unit is : \"" << _time_unit << "\"";
2445 return stream.str();
2448 void MEDCouplingLinearTime::checkConsistencyLight() const
2450 MEDCouplingTwoTimeSteps::checkConsistencyLight();
2451 if(std::fabs(_start.getTimeValue()-_end.getTimeValue())<_time_tolerance)
2452 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2455 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCopyOrIncrRef(bool deepCopy) const
2457 return new MEDCouplingLinearTime(*this,deepCopy);
2460 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2462 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2464 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2467 if(_end_array==0 && otherC->_end_array==0)
2469 if(_end_array==0 || otherC->_end_array==0)
2471 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2476 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
2478 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2480 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2483 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2487 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2489 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2491 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2495 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2497 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2499 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2502 if(_end_array==0 && otherC->_end_array==0)
2504 if(_end_array==0 || otherC->_end_array==0)
2506 int nbC1=_end_array->getNumberOfComponents();
2507 int nbC2=otherC->_end_array->getNumberOfComponents();
2508 if(nbC1!=nbC2 && nbC2!=1)
2513 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2515 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2517 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2522 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2524 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2526 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2527 std::size_t nbComp=vals.size()/2;
2528 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2529 std::vector<double> tmp(nbComp);
2530 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2531 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2534 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
2536 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2539 _array->getTuple(eltId,value);
2541 throw INTERP_KERNEL::Exception("No start array existing.");
2542 nbComp=_array->getNumberOfComponents();
2543 std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2544 std::vector<double> tmp(nbComp);
2546 _end_array->getTuple(eltId,&tmp[0]);
2548 throw INTERP_KERNEL::Exception("No end array existing.");
2549 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2550 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2553 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
2555 if(iteration==_start.getIteration() && order==_start.getOrder())
2558 _array->getTuple(eltId,value);
2560 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2562 if(iteration==_end.getIteration() && order==_end.getOrder())
2565 _end_array->getTuple(eltId,value);
2567 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2570 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2573 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2575 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2577 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2578 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2579 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2580 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2581 ret->setArray(arr1,0);
2582 ret->setEndArray(arr2,0);
2586 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2588 std::vector<const DataArrayDouble *> a(other.size());
2589 std::vector<const DataArrayDouble *> b(other.size());
2591 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2593 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2595 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2596 a[i]=itC->getArray();
2597 b[i]=itC->getEndArray();
2599 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b));
2600 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2601 ret->setArray(arr,0);
2602 ret->setEndArray(arr2,0);
2606 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2608 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2610 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2611 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray()));
2612 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2613 ret->setTimeTolerance(getTimeTolerance());
2614 ret->setArray(arr1,0);
2615 ret->setEndArray(arr2,0);
2619 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2621 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2623 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2624 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray()));
2625 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2626 ret->setArray(arr1,0);
2627 ret->setEndArray(arr2,0);
2631 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2633 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2635 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2636 MCAuto<DataArrayDouble> arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()));
2637 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2638 ret->setArray(arr1,0);
2639 ret->setEndArray(arr2,0);
2643 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2645 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2647 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2648 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2649 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray()));
2650 ret->setArray(arr1,0);
2651 ret->setEndArray(arr2,0);
2655 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2657 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2659 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2660 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray()));
2661 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2662 ret->setArray(arr1,0);
2663 ret->setEndArray(arr2,0);
2667 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2669 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2671 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2672 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray()));
2673 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2674 ret->setArray(arr1,0);
2675 ret->setEndArray(arr2,0);
2679 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2681 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2683 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2685 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2687 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2688 getArray()->addEqual(other->getArray());
2689 getEndArray()->addEqual(other->getEndArray());
2692 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2694 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2696 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2697 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2698 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2699 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2700 ret->setArray(arr1,0);
2701 ret->setEndArray(arr2,0);
2705 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2707 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2709 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2711 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2713 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2714 getArray()->substractEqual(other->getArray());
2715 getEndArray()->substractEqual(other->getEndArray());
2718 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2720 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2722 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2723 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2724 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2725 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2726 ret->setArray(arr1,0);
2727 ret->setEndArray(arr2,0);
2731 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2733 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2735 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2737 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2739 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2740 getArray()->multiplyEqual(other->getArray());
2741 getEndArray()->multiplyEqual(other->getEndArray());
2744 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2746 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2748 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2749 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2750 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2751 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2752 ret->setArray(arr1,0);
2753 ret->setEndArray(arr2,0);
2757 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2759 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2761 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2763 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2765 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2766 getArray()->divideEqual(other->getArray());
2767 getEndArray()->divideEqual(other->getEndArray());
2770 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2772 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2774 throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2775 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2776 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2777 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2778 ret->setArray(arr1,0);
2779 ret->setEndArray(arr2,0);
2783 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2785 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2787 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2789 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2791 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2792 getArray()->powEqual(other->getArray());
2793 getEndArray()->powEqual(other->getEndArray());