1 // Copyright (C) 2007-2023 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<float>;
34 template class MEDCoupling::MEDCouplingTimeDiscretizationSimple<float>;
35 template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<int>;
36 template class MEDCoupling::MEDCouplingTimeDiscretizationSimple<int>;
38 const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
40 const char MEDCouplingNoTimeLabel::REPR[]="No time label defined.";
42 const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
44 const char MEDCouplingWithTimeStep::REPR[]="One time label.";
46 const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time.";
48 const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval.";
50 const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time.";
52 const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
54 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
58 case MEDCouplingNoTimeLabel::DISCRETIZATION:
59 return new MEDCouplingNoTimeLabel;
60 case MEDCouplingWithTimeStep::DISCRETIZATION:
61 return new MEDCouplingWithTimeStep;
62 case MEDCouplingConstOnTimeInterval::DISCRETIZATION:
63 return new MEDCouplingConstOnTimeInterval;
64 case MEDCouplingLinearTime::DISCRETIZATION:
65 return new MEDCouplingLinearTime;
67 throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
71 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
73 if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
75 if(_array==0 && other->_array==0)
77 if(_array==0 || other->_array==0)
79 if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
84 bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
86 if(!areStrictlyCompatible(other,reason))
88 if(_array==other->getArray())
90 return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
93 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
96 return isEqualIfNotWhy(other,prec,reason);
99 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
102 if(!areStrictlyCompatible(other,tmp))
104 if(_array==other->getArray())
106 return _array->isEqualWithoutConsideringStr(*other->getArray(),prec);
109 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const
111 MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
112 ret->setTimeUnit(getTimeUnit());
113 const DataArrayDouble *arrSrc=getArray();
114 MCAuto<DataArrayDouble> arr;
116 arr=arrSrc->performCopyOrIncrRef(deepCopy);
117 ret->setArray(arr,0);
121 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
124 double time1=getEndTime(iteration,order)-_time_tolerance;
125 double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
129 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
132 double time1=getEndTime(iteration,order)+_time_tolerance;
133 double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
137 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::computeVectorFieldCyl(const DataArrayDouble *coords, const double center[3], const double vect[3]) const
139 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
140 ret->setTimeUnit(getTimeUnit());
141 std::vector<DataArrayDouble *> arrays;
143 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
144 for(std::size_t j=0;j<arrays.size();j++)
147 arrays2[j]=arrays[j]->fromCartToCylGiven(coords,center,vect);
149 std::vector<DataArrayDouble *> arrays3(arrays.size());
150 for(std::size_t j=0;j<arrays.size();j++)
151 arrays3[j]=arrays2[j];
152 ret->setArrays(arrays3,0);
156 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const
158 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
159 ret->setTimeUnit(getTimeUnit());
160 std::vector<DataArrayDouble *> arrays;
162 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
163 for(std::size_t j=0;j<arrays.size();j++)
166 arrays2[j]=arrays[j]->doublyContractedProduct();
168 std::vector<DataArrayDouble *> arrays3(arrays.size());
169 for(std::size_t j=0;j<arrays.size();j++)
170 arrays3[j]=arrays2[j];
171 ret->setArrays(arrays3,0);
175 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const
177 std::vector<DataArrayDouble *> arrays;
179 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
180 for(std::size_t j=0;j<arrays.size();j++)
183 arrays2[j]=arrays[j]->determinant();
185 std::vector<DataArrayDouble *> arrays3(arrays.size());
186 for(std::size_t j=0;j<arrays.size();j++)
187 arrays3[j]=arrays2[j];
188 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
189 ret->setTimeUnit(getTimeUnit());
190 ret->setArrays(arrays3,0);
194 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const
196 std::vector<DataArrayDouble *> arrays;
198 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
199 for(std::size_t j=0;j<arrays.size();j++)
202 arrays2[j]=arrays[j]->eigenValues();
204 std::vector<DataArrayDouble *> arrays3(arrays.size());
205 for(std::size_t j=0;j<arrays.size();j++)
206 arrays3[j]=arrays2[j];
207 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
208 ret->setTimeUnit(getTimeUnit());
209 ret->setArrays(arrays3,0);
213 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const
215 std::vector<DataArrayDouble *> arrays;
217 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
218 for(std::size_t j=0;j<arrays.size();j++)
221 arrays2[j]=arrays[j]->eigenVectors();
223 std::vector<DataArrayDouble *> arrays3(arrays.size());
224 for(std::size_t j=0;j<arrays.size();j++)
225 arrays3[j]=arrays2[j];
226 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
227 ret->setTimeUnit(getTimeUnit());
228 ret->setArrays(arrays3,0);
232 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const
234 std::vector<DataArrayDouble *> arrays;
236 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
237 for(std::size_t j=0;j<arrays.size();j++)
240 arrays2[j]=arrays[j]->inverse();
242 std::vector<DataArrayDouble *> arrays3(arrays.size());
243 for(std::size_t j=0;j<arrays.size();j++)
244 arrays3[j]=arrays2[j];
245 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
246 ret->setTimeUnit(getTimeUnit());
247 ret->setArrays(arrays3,0);
251 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const
253 std::vector<DataArrayDouble *> arrays;
255 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
256 for(std::size_t j=0;j<arrays.size();j++)
259 arrays2[j]=arrays[j]->trace();
261 std::vector<DataArrayDouble *> arrays3(arrays.size());
262 for(std::size_t j=0;j<arrays.size();j++)
263 arrays3[j]=arrays2[j];
264 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
265 ret->setTimeUnit(getTimeUnit());
266 ret->setArrays(arrays3,0);
270 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const
272 std::vector<DataArrayDouble *> arrays;
274 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
275 for(std::size_t j=0;j<arrays.size();j++)
278 arrays2[j]=arrays[j]->deviator();
280 std::vector<DataArrayDouble *> arrays3(arrays.size());
281 for(std::size_t j=0;j<arrays.size();j++)
282 arrays3[j]=arrays2[j];
283 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
284 ret->setTimeUnit(getTimeUnit());
285 ret->setArrays(arrays3,0);
289 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const
291 std::vector<DataArrayDouble *> arrays;
293 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
294 for(std::size_t j=0;j<arrays.size();j++)
297 arrays2[j]=arrays[j]->magnitude();
299 std::vector<DataArrayDouble *> arrays3(arrays.size());
300 for(std::size_t j=0;j<arrays.size();j++)
301 arrays3[j]=arrays2[j];
302 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
303 ret->setTimeUnit(getTimeUnit());
304 ret->setArrays(arrays3,0);
308 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const
310 std::vector<DataArrayDouble *> arrays;
312 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
313 for(std::size_t j=0;j<arrays.size();j++)
316 arrays2[j]=arrays[j]->negate();
318 std::vector<DataArrayDouble *> arrays3(arrays.size());
319 for(std::size_t j=0;j<arrays.size();j++)
320 arrays3[j]=arrays2[j];
321 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
322 ret->setTimeUnit(getTimeUnit());
323 ret->setArrays(arrays3,0);
327 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const
329 std::vector<DataArrayDouble *> arrays;
331 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
332 for(std::size_t j=0;j<arrays.size();j++)
335 arrays2[j]=arrays[j]->maxPerTuple();
337 std::vector<DataArrayDouble *> arrays3(arrays.size());
338 for(std::size_t j=0;j<arrays.size();j++)
339 arrays3[j]=arrays2[j];
340 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
341 ret->setTimeUnit(getTimeUnit());
342 ret->setArrays(arrays3,0);
346 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<std::size_t>& compoIds) const
348 std::vector<DataArrayDouble *> arrays;
350 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
351 for(std::size_t j=0;j<arrays.size();j++)
354 arrays2[j]=static_cast<DataArrayDouble *>(arrays[j]->keepSelectedComponents(compoIds));
356 std::vector<DataArrayDouble *> arrays3(arrays.size());
357 for(std::size_t j=0;j<arrays.size();j++)
358 arrays3[j]=arrays2[j];
359 MEDCouplingTimeDiscretization *ret(MEDCouplingTimeDiscretization::New(getEnum()));
360 ret->setTimeUnit(getTimeUnit());
361 ret->setArrays(arrays3,0);
365 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<std::size_t>& compoIds)
367 std::vector<DataArrayDouble *> arrays1,arrays2;
369 other->getArrays(arrays2);
370 if(arrays1.size()!=arrays2.size())
371 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
372 for(std::size_t i=0;i<arrays1.size();i++)
374 if(arrays1[i]!=0 && arrays2[i]!=0)
375 arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
376 else if(arrays1[i]!=0 || arrays2[i]!=0)
377 throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondence are not defined symmetrically !");
381 void MEDCouplingTimeDiscretization::changeNbOfComponents(std::size_t newNbOfComp, double dftValue)
383 std::vector<DataArrayDouble *> arrays;
385 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
386 for(std::size_t j=0;j<arrays.size();j++)
389 arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
391 std::vector<DataArrayDouble *> arrays3(arrays.size());
392 for(std::size_t j=0;j<arrays.size();j++)
393 arrays3[j]=arrays2[j];
394 setArrays(arrays3,0);
397 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc)
399 std::vector<DataArrayDouble *> arrays;
401 for(std::size_t j=0;j<arrays.size();j++)
404 arrays[j]->sortPerTuple(asc);
408 void MEDCouplingTimeDiscretization::setUniformValue(mcIdType nbOfTuple, int nbOfCompo, double value)
410 std::vector<DataArrayDouble *> arrays;
412 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
413 for(std::size_t j=0;j<arrays.size();j++)
417 arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
418 arrays2[j]->fillWithValue(value);
422 arrays2[j]=DataArrayDouble::New();
423 arrays2[j]->alloc(nbOfTuple,nbOfCompo);
424 arrays2[j]->fillWithValue(value);
427 std::vector<DataArrayDouble *> arrays3(arrays.size());
428 for(std::size_t j=0;j<arrays.size();j++)
429 arrays3[j]=arrays2[j];
430 setArrays(arrays3,0);
433 void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(mcIdType nbOfTuple, double value)
435 std::vector<DataArrayDouble *> arrays;
437 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
439 for(std::size_t j=0;j<arrays.size();j++)
443 arrays2[j]=arrays[j]; arrays2[j]->incrRef();
444 arrays2[j]->fillWithValue(value);
449 arrays2[j]=DataArrayDouble::New();
450 arrays2[j]->alloc(nbOfTuple,1);
451 arrays2[j]->fillWithValue(value);
456 std::vector<DataArrayDouble *> arrays3(arrays.size());
457 for(std::size_t j=0;j<arrays.size();j++)
458 arrays3[j]=arrays2[j];
459 setArrays(arrays3,0);
463 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
465 std::vector<DataArrayDouble *> arrays;
467 for(std::size_t j=0;j<arrays.size();j++)
470 arrays[j]->applyLin(a,b,compoId);
474 void MEDCouplingTimeDiscretization::applyLin(double a, double b)
476 std::vector<DataArrayDouble *> arrays;
478 for(std::size_t j=0;j<arrays.size();j++)
481 arrays[j]->applyLin(a,b);
485 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
487 std::vector<DataArrayDouble *> arrays;
489 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
490 for(std::size_t j=0;j<arrays.size();j++)
493 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
495 std::vector<DataArrayDouble *> arrays3(arrays.size());
496 for(std::size_t j=0;j<arrays.size();j++)
497 arrays3[j]=arrays2[j];
498 setArrays(arrays3,0);
501 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const std::string& func)
503 std::vector<DataArrayDouble *> arrays;
505 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
506 for(std::size_t j=0;j<arrays.size();j++)
509 arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
513 std::vector<DataArrayDouble *> arrays3(arrays.size());
514 for(std::size_t j=0;j<arrays.size();j++)
515 arrays3[j]=arrays2[j];
516 setArrays(arrays3,0);
519 void MEDCouplingTimeDiscretization::applyFuncCompo(int nbOfComp, const std::string& func)
521 std::vector<DataArrayDouble *> arrays;
523 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
524 for(std::size_t j=0;j<arrays.size();j++)
527 arrays2[j]=arrays[j]->applyFuncCompo(nbOfComp,func);
529 std::vector<DataArrayDouble *> arrays3(arrays.size());
530 for(std::size_t j=0;j<arrays.size();j++)
531 arrays3[j]=arrays2[j];
532 setArrays(arrays3,0);
535 void MEDCouplingTimeDiscretization::applyFuncNamedCompo(int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
537 std::vector<DataArrayDouble *> arrays;
539 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
540 for(std::size_t j=0;j<arrays.size();j++)
543 arrays2[j]=arrays[j]->applyFuncNamedCompo(nbOfComp,varsOrder,func);
545 std::vector<DataArrayDouble *> arrays3(arrays.size());
546 for(std::size_t j=0;j<arrays.size();j++)
547 arrays3[j]=arrays2[j];
548 setArrays(arrays3,0);
551 void MEDCouplingTimeDiscretization::applyFunc(const std::string& 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(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::applyFuncFast32(const std::string& func)
569 std::vector<DataArrayDouble *> arrays;
571 for(std::size_t j=0;j<arrays.size();j++)
574 arrays[j]->applyFuncFast32(func);
578 void MEDCouplingTimeDiscretization::applyFuncFast64(const std::string& func)
580 std::vector<DataArrayDouble *> arrays;
582 for(std::size_t j=0;j<arrays.size();j++)
585 arrays[j]->applyFuncFast64(func);
589 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func)
591 std::vector<DataArrayDouble *> arrays;
593 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
594 for(std::size_t j=0;j<arrays.size();j++)
595 arrays2[j]=loc->applyFunc(nbOfComp,func);
596 std::vector<DataArrayDouble *> arrays3(arrays.size());
597 for(std::size_t j=0;j<arrays.size();j++)
598 arrays3[j]=arrays2[j];
599 setArrays(arrays3,0);
602 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
604 std::vector<DataArrayDouble *> arrays;
606 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
607 for(std::size_t j=0;j<arrays.size();j++)
608 arrays2[j]=loc->applyFunc(nbOfComp,func);
609 std::vector<DataArrayDouble *> arrays3(arrays.size());
610 for(std::size_t j=0;j<arrays.size();j++)
611 arrays3[j]=arrays2[j];
612 setArrays(arrays3,0);
615 void MEDCouplingTimeDiscretization::fillFromAnalyticCompo(const DataArrayDouble *loc, int nbOfComp, const std::string& func)
617 std::vector<DataArrayDouble *> arrays;
619 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
620 for(std::size_t j=0;j<arrays.size();j++)
621 arrays2[j]=loc->applyFuncCompo(nbOfComp,func);
622 std::vector<DataArrayDouble *> arrays3(arrays.size());
623 for(std::size_t j=0;j<arrays.size();j++)
624 arrays3[j]=arrays2[j];
625 setArrays(arrays3,0);
628 void MEDCouplingTimeDiscretization::fillFromAnalyticNamedCompo(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func)
630 std::vector<DataArrayDouble *> arrays;
632 std::vector< MCAuto<DataArrayDouble> > arrays2(arrays.size());
633 for(std::size_t j=0;j<arrays.size();j++)
634 arrays2[j]=loc->applyFuncNamedCompo(nbOfComp,varsOrder,func);
635 std::vector<DataArrayDouble *> arrays3(arrays.size());
636 for(std::size_t j=0;j<arrays.size();j++)
637 arrays3[j]=arrays2[j];
638 setArrays(arrays3,0);
641 ////////////////////////
643 bool MEDCouplingTimeKeeper::isEqualIfNotWhy(const MEDCouplingTimeKeeper& other, double prec, std::string& reason) const
645 std::ostringstream oss;
646 if(_iteration!=other._iteration)
648 oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << other._iteration;
652 if(_order!=other._order)
654 oss << "orders differ. this order=" << _order << " other order=" << other._order;
658 if(std::fabs(_time-other._time)>prec)
660 oss << "times differ. this time=" << _time << " other time=" << other._time;
667 bool MEDCouplingTimeKeeper::isEqual(const MEDCouplingTimeKeeper& other, double prec) const
669 if(_iteration!=other._iteration)
671 if(_order!=other._order)
673 if(std::fabs(_time-other._time)>prec)
678 void MEDCouplingTimeKeeper::copyFrom(const MEDCouplingTimeKeeper& other)
681 _iteration=other._iteration;
685 void MEDCouplingTimeKeeper::checkTimePresence(double time, double eps) const
687 if(std::fabs(time-_time)>eps)
689 std::ostringstream stream;
690 stream << "The field is defined on time " << _time << " with eps=" << eps << " and asking time = " << time << " !";
691 throw INTERP_KERNEL::Exception(stream.str().c_str());
695 ////////////////////////
697 MEDCouplingTimeDiscretizationInt32::MEDCouplingTimeDiscretizationInt32(const MEDCouplingTimeDiscretizationInt32& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<Int32>(other,deepCopy)
701 MEDCouplingTimeDiscretizationInt32 *MEDCouplingTimeDiscretizationInt32::performCopyOrIncrRef(bool deepCopy) const
703 return new MEDCouplingTimeDiscretizationInt32(*this,deepCopy);
706 MEDCouplingTimeDiscretizationInt32 *MEDCouplingTimeDiscretizationInt32::New(TypeOfTimeDiscretization type)
710 case MEDCouplingTimeDiscretizationInt32::DISCRETIZATION:
711 return new MEDCouplingTimeDiscretizationInt32;
713 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for integers !");
717 bool MEDCouplingTimeDiscretizationInt32::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<Int32> *other, Int32 prec, std::string& reason) const
720 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
723 reason="Time discretization is NULL.";
726 const MEDCouplingTimeDiscretizationInt32 *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt32 *>(other));
728 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt32 !");
729 if(!MEDCouplingTimeDiscretizationTemplate<Int32>::areStrictlyCompatible(other,reason))
731 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
733 if(_array==other->getArray())
735 return _array->isEqualIfNotWhy(*other->getArray(),reason);
738 bool MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<Int32> *other, Int32 prec) const
741 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt32::isEqualWithoutConsideringStr : only precision 0 is supported !");
742 const MEDCouplingTimeDiscretizationInt32 *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt32 *>(other));
744 throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !");
746 if(!areStrictlyCompatible(other,tmp))
749 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
751 if(_array==other->getArray())
753 return _array->isEqualWithoutConsideringStr(*(other->getArray()));
756 ////////////////////////
758 MEDCouplingTimeDiscretizationInt64::MEDCouplingTimeDiscretizationInt64(const MEDCouplingTimeDiscretizationInt64& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<Int64>(other,deepCopy)
762 MEDCouplingTimeDiscretizationInt64 *MEDCouplingTimeDiscretizationInt64::performCopyOrIncrRef(bool deepCopy) const
764 return new MEDCouplingTimeDiscretizationInt64(*this,deepCopy);
767 MEDCouplingTimeDiscretizationInt64 *MEDCouplingTimeDiscretizationInt64::New(TypeOfTimeDiscretization type)
771 case MEDCouplingTimeDiscretizationInt64::DISCRETIZATION:
772 return new MEDCouplingTimeDiscretizationInt64;
774 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for integers !");
778 bool MEDCouplingTimeDiscretizationInt64::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<Int64> *other, Int64 prec, std::string& reason) const
781 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
784 reason="Time discretization is NULL.";
787 const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt64 *>(other));
789 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt64 !");
790 if(!MEDCouplingTimeDiscretizationTemplate<Int64>::areStrictlyCompatible(other,reason))
792 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
794 if(_array==other->getArray())
796 return _array->isEqualIfNotWhy(*other->getArray(),reason);
799 bool MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<Int64> *other, Int64 prec) const
802 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt64::isEqualWithoutConsideringStr : only precision 0 is supported !");
803 const MEDCouplingTimeDiscretizationInt64 *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt64 *>(other));
805 throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationInt !");
807 if(!areStrictlyCompatible(other,tmp))
810 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
812 if(_array==other->getArray())
814 return _array->isEqualWithoutConsideringStr(*(other->getArray()));
817 ////////////////////////
819 MEDCouplingTimeDiscretizationFloat::MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<float>(other,deepCopy)
823 MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::performCopyOrIncrRef(bool deepCopy) const
825 return new MEDCouplingTimeDiscretizationFloat(*this,deepCopy);
828 MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::New(TypeOfTimeDiscretization type)
832 case MEDCouplingTimeDiscretizationFloat::DISCRETIZATION:
833 return new MEDCouplingTimeDiscretizationFloat;
835 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for integers !");
839 bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec, std::string& reason) const
843 reason="Time discretization is NULL.";
846 const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
848 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationFloat !");
849 if(!MEDCouplingTimeDiscretizationTemplate<float>::areStrictlyCompatible(other,reason))
851 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
853 if(_array==other->getArray())
855 return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
858 bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec) const
861 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr : only precision 0 is supported !");
862 const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
864 throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationFloat !");
866 if(!areStrictlyCompatible(other,tmp))
869 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
871 if(_array==other->getArray())
873 return _array->isEqualWithoutConsideringStr(*(other->getArray()),prec);
876 ////////////////////////
878 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
882 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy)
886 std::string MEDCouplingNoTimeLabel::getStringRepr() const
888 std::ostringstream stream;
890 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
894 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh)
896 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
899 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
901 if(!MEDCouplingTimeDiscretization::areCompatible(other))
903 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
907 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
909 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
911 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
914 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
918 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
920 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
922 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
926 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
928 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
930 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
934 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
936 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
938 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
942 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
944 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
947 reason="This has time discretization NO_TIME, other not.";
950 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
953 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
955 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
958 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
961 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
963 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
965 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
966 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(getArray(),other->getArray()));
967 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
968 ret->setArray(arr,0);
972 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
974 std::vector<const DataArrayDouble *> a(other.size());
976 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
978 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
980 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
981 a[i]=itC->getArray();
983 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a));
984 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
985 ret->setArray(arr,0);
989 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
991 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
993 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
994 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
995 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
996 ret->setTimeTolerance(getTimeTolerance());
997 ret->setArray(arr,0);
1001 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
1003 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1005 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
1006 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1007 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1008 ret->setArray(arr,0);
1012 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
1014 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1016 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
1017 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1018 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1019 ret->setArray(arr,0);
1023 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
1025 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1027 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1028 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1029 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1030 ret->setArray(arr,0);
1034 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
1036 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1038 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
1039 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1040 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1041 ret->setArray(arr,0);
1045 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
1047 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1049 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
1050 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1051 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1052 ret->setArray(arr,0);
1056 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
1058 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1060 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1062 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1063 getArray()->addEqual(other->getArray());
1066 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1068 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1070 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1072 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1073 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1074 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1075 ret->setArray(arr,0);
1079 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1081 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1083 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1085 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1086 getArray()->substractEqual(other->getArray());
1089 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1091 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1093 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1094 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1095 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1096 ret->setArray(arr,0);
1100 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1102 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1104 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1106 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1107 getArray()->multiplyEqual(other->getArray());
1110 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1112 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1114 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1115 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1116 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1117 ret->setArray(arr,0);
1121 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1123 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1125 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1127 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1128 getArray()->divideEqual(other->getArray());
1131 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1133 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1135 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1136 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1137 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1138 ret->setArray(arr,0);
1142 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1144 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1146 throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1148 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1149 getArray()->powEqual(other->getArray());
1152 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCopyOrIncrRef(bool deepCopy) const
1154 return new MEDCouplingNoTimeLabel(*this,deepCopy);
1157 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const
1159 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1162 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const
1164 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1167 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1169 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1172 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const
1174 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1177 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
1179 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1182 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const
1184 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1187 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const
1189 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1192 void MEDCouplingNoTimeLabel::setStartIteration(int it)
1194 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1197 void MEDCouplingNoTimeLabel::setEndIteration(int it)
1199 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1202 void MEDCouplingNoTimeLabel::setStartOrder(int order)
1204 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1207 void MEDCouplingNoTimeLabel::setEndOrder(int order)
1209 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1212 void MEDCouplingNoTimeLabel::setStartTimeValue(double time)
1214 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1217 void MEDCouplingNoTimeLabel::setEndTimeValue(double time)
1219 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1222 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order)
1224 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1227 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order)
1229 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1232 void MEDCouplingNoTimeLabel::getValueOnTime(mcIdType eltId, double time, double *value) const
1234 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1237 void MEDCouplingNoTimeLabel::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const
1239 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1243 * idem getTinySerializationIntInformation except that it is for multi field fetch
1245 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<mcIdType>& tinyInfo) const
1251 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1253 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1256 tinyInfo[0]=_time_tolerance;
1260 * idem finishUnserialization except that it is for multi field fetch
1262 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD)
1264 _time_tolerance=tinyInfoD[0];
1267 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),_tk(other._tk)
1271 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep()
1275 std::string MEDCouplingWithTimeStep::getStringRepr() const
1277 std::ostringstream stream;
1278 stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
1279 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
1280 return stream.str();
1283 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1286 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1288 double val=mesh->getTime(it,order);
1289 _tk.setAllInfo(val,it,order);
1290 std::string tUnit(mesh->getTimeUnit());
1294 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<mcIdType>& tinyInfo) const
1296 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1297 tinyInfo.push_back(_tk.getIteration());
1298 tinyInfo.push_back(_tk.getOrder());
1301 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1303 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1304 tinyInfo.push_back(_tk.getTimeValue());
1307 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1309 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1310 _tk.setTimeValue(tinyInfoD[1]);
1311 _tk.setIteration(FromIdType<int>(tinyInfoI[2]));
1312 _tk.setOrder(FromIdType<int>(tinyInfoI[3]));
1316 * idem getTinySerializationIntInformation except that it is for multi field fetch
1318 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<mcIdType>& tinyInfo) const
1321 tinyInfo[0]=_tk.getIteration();
1322 tinyInfo[1]=_tk.getOrder();
1326 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1328 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1331 tinyInfo[0]=_time_tolerance;
1332 tinyInfo[1]=_tk.getTimeValue();
1336 * idem finishUnserialization except that it is for multi field fetch
1338 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD)
1340 _tk.setIteration(FromIdType<int>(tinyInfoI[0]));
1341 _tk.setOrder(FromIdType<int>(tinyInfoI[1]));
1342 _time_tolerance=tinyInfoD[0];
1343 _tk.setTimeValue(tinyInfoD[1]);
1346 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1348 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1350 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1354 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1356 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1358 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1361 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1365 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1367 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1369 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1373 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1375 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1377 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1381 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1383 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1385 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1389 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1391 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1392 std::ostringstream oss; oss.precision(15);
1395 reason="This has time discretization ONE_TIME, other not.";
1398 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
1400 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1403 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1405 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1408 if(!_tk.isEqual(otherC->_tk,_time_tolerance))
1410 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1413 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1415 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1416 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1418 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1419 _tk.copyFrom(otherC->_tk);
1422 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1424 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1426 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1427 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1428 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1429 ret->setArray(arr,0);
1433 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1435 std::vector<const DataArrayDouble *> a(other.size());
1437 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1439 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1441 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1442 a[i]=itC->getArray();
1444 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1445 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1446 ret->setArray(arr,0);
1450 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1452 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1454 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1455 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1456 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1457 ret->setArray(arr,0);
1461 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1463 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1465 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1466 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1467 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1468 ret->setArray(arr,0);
1472 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1474 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1476 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1477 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1478 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1479 ret->setArray(arr,0);
1483 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1485 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1487 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1488 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1489 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1490 ret->setArray(arr,0);
1494 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1496 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1498 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1499 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1500 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1501 ret->setArray(arr,0);
1505 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1507 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1509 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1510 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1511 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1512 ret->setArray(arr,0);
1514 double tmp3=getStartTime(tmp1,tmp2);
1515 ret->setStartTime(tmp3,tmp1,tmp2);
1519 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1521 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1523 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1525 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1526 getArray()->addEqual(other->getArray());
1529 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1531 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1533 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1534 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1535 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1536 ret->setArray(arr,0);
1538 double tmp3=getStartTime(tmp1,tmp2);
1539 ret->setStartTime(tmp3,tmp1,tmp2);
1543 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1545 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1547 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1549 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1550 getArray()->substractEqual(other->getArray());
1553 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1555 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1557 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1558 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1559 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1560 ret->setArray(arr,0);
1562 double tmp3=getStartTime(tmp1,tmp2);
1563 ret->setStartTime(tmp3,tmp1,tmp2);
1567 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1569 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1571 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1573 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1574 getArray()->multiplyEqual(other->getArray());
1577 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1579 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1581 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1582 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1583 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1584 ret->setArray(arr,0);
1586 double tmp3=getStartTime(tmp1,tmp2);
1587 ret->setStartTime(tmp3,tmp1,tmp2);
1591 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1593 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1595 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1597 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1598 getArray()->divideEqual(other->getArray());
1601 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1603 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1605 throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1606 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1607 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1608 ret->setArray(arr,0);
1610 double tmp3=getStartTime(tmp1,tmp2);
1611 ret->setStartTime(tmp3,tmp1,tmp2);
1615 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1617 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1619 throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1621 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1622 getArray()->powEqual(other->getArray());
1625 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCopyOrIncrRef(bool deepCopy) const
1627 return new MEDCouplingWithTimeStep(*this,deepCopy);
1630 void MEDCouplingWithTimeStep::checkNoTimePresence() const
1632 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1635 void MEDCouplingWithTimeStep::checkTimePresence(double time) const
1637 _tk.checkTimePresence(time,_time_tolerance);
1640 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
1642 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1644 std::vector< const DataArrayDouble *> ret(1);
1649 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1652 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1654 std::copy(vals.begin(),vals.end(),res);
1657 void MEDCouplingWithTimeStep::getValueOnTime(mcIdType eltId, double time, double *value) const
1659 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1661 _array->getTuple(eltId,value);
1663 throw INTERP_KERNEL::Exception("No array existing.");
1665 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1668 void MEDCouplingWithTimeStep::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const
1670 if(_tk.getIteration()==iteration && _tk.getOrder()==order)
1672 _array->getTuple(eltId,value);
1674 throw INTERP_KERNEL::Exception("No array existing.");
1676 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1679 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval()
1683 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1685 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1686 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1688 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1689 _start.copyFrom(otherC->_start);
1690 _end.copyFrom(otherC->_end);
1693 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<mcIdType>& tinyInfo) const
1695 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1696 tinyInfo.push_back(_start.getIteration());
1697 tinyInfo.push_back(_start.getOrder());
1698 tinyInfo.push_back(_end.getIteration());
1699 tinyInfo.push_back(_end.getOrder());
1702 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1704 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1705 tinyInfo.push_back(_start.getTimeValue());
1706 tinyInfo.push_back(_end.getTimeValue());
1709 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1711 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1712 _start.setTimeValue(tinyInfoD[1]);
1713 _end.setTimeValue(tinyInfoD[2]);
1714 _start.setIteration(FromIdType<int>(tinyInfoI[2]));
1715 _start.setOrder(FromIdType<int>(tinyInfoI[3]));
1716 _end.setIteration(FromIdType<int>(tinyInfoI[4]));
1717 _end.setOrder(FromIdType<int>(tinyInfoI[5]));
1721 * idem getTinySerializationIntInformation except that it is for multi field fetch
1723 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<mcIdType>& tinyInfo) const
1726 tinyInfo[0]=_start.getIteration();
1727 tinyInfo[1]=_start.getOrder();
1728 tinyInfo[2]=_end.getIteration();
1729 tinyInfo[3]=_end.getOrder();
1733 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1735 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1738 tinyInfo[0]=_time_tolerance;
1739 tinyInfo[1]=_start.getTimeValue();
1740 tinyInfo[2]=_end.getTimeValue();
1744 * idem finishUnserialization except that it is for multi field fetch
1746 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD)
1748 _start.setIteration(FromIdType<int>(tinyInfoI[0]));
1749 _start.setOrder(FromIdType<int>(tinyInfoI[1]));
1750 _end.setIteration(FromIdType<int>(tinyInfoI[2]));
1751 _end.setOrder(FromIdType<int>(tinyInfoI[3]));
1752 _time_tolerance=tinyInfoD[0];
1753 _start.setTimeValue(tinyInfoD[1]);
1754 _end.setTimeValue(tinyInfoD[2]);
1757 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCopy):
1758 MEDCouplingTimeDiscretization(other,deepCopy),_start(other._start),_end(other._end)
1762 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1764 std::ostringstream stream;
1765 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
1766 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
1767 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
1768 return stream.str();
1771 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1774 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1776 double val=mesh->getTime(it,order);
1777 _start.setAllInfo(val,it,order);
1778 _end.setAllInfo(val,it,order);
1779 std::string tUnit(mesh->getTimeUnit());
1783 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCopyOrIncrRef(bool deepCopy) const
1785 return new MEDCouplingConstOnTimeInterval(*this,deepCopy);
1788 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const
1790 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1792 std::vector< const DataArrayDouble *> ret(1);
1797 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1800 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1802 std::copy(vals.begin(),vals.end(),res);
1805 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1807 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1809 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1813 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1815 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1817 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1820 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1824 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1826 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1828 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1832 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1834 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1836 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1840 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1842 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1844 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1848 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1850 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1851 std::ostringstream oss; oss.precision(15);
1854 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1857 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
1859 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
1861 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1864 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1866 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1869 if(!_start.isEqual(otherC->_start,_time_tolerance))
1871 if(!_end.isEqual(otherC->_end,_time_tolerance))
1873 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1876 void MEDCouplingConstOnTimeInterval::getValueOnTime(mcIdType eltId, double time, double *value) const
1878 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1880 _array->getTuple(eltId,value);
1882 throw INTERP_KERNEL::Exception("No array existing.");
1884 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1887 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const
1889 if(iteration>=_start.getIteration() && iteration<=_end.getIteration())
1891 _array->getTuple(eltId,value);
1893 throw INTERP_KERNEL::Exception("No array existing.");
1895 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1898 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const
1900 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1903 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const
1905 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
1907 std::ostringstream stream;
1908 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
1909 stream << _time_tolerance << " and trying to access on time = " << time;
1910 throw INTERP_KERNEL::Exception(stream.str().c_str());
1914 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1916 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1918 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1919 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1920 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1921 ret->setArray(arr,0);
1925 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1927 std::vector<const DataArrayDouble *> a(other.size());
1929 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1931 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
1933 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
1934 a[i]=itC->getArray();
1936 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1937 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1938 ret->setArray(arr,0);
1942 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
1944 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1946 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
1947 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1948 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1949 ret->setTimeTolerance(getTimeTolerance());
1950 ret->setArray(arr,0);
1954 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
1956 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1958 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
1959 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1960 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1961 ret->setArray(arr,0);
1965 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
1967 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1969 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
1970 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1971 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1972 ret->setArray(arr,0);
1976 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
1978 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1980 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
1981 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1982 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1983 ret->setArray(arr,0);
1987 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
1989 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1991 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
1992 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1993 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1994 ret->setArray(arr,0);
1998 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
2000 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2002 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
2003 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
2004 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2005 ret->setArray(arr,0);
2007 double tmp3=getStartTime(tmp1,tmp2);
2008 ret->setStartTime(tmp3,tmp1,tmp2);
2009 tmp3=getEndTime(tmp1,tmp2);
2010 ret->setEndTime(tmp3,tmp1,tmp2);
2014 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
2016 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2018 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
2020 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
2021 getArray()->addEqual(other->getArray());
2024 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
2026 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2028 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
2029 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
2030 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2031 ret->setArray(arr,0);
2033 double tmp3=getStartTime(tmp1,tmp2);
2034 ret->setStartTime(tmp3,tmp1,tmp2);
2035 tmp3=getEndTime(tmp1,tmp2);
2036 ret->setEndTime(tmp3,tmp1,tmp2);
2040 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
2042 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2044 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
2046 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
2047 getArray()->substractEqual(other->getArray());
2050 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
2052 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2054 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
2055 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
2056 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2057 ret->setArray(arr,0);
2059 double tmp3=getStartTime(tmp1,tmp2);
2060 ret->setStartTime(tmp3,tmp1,tmp2);
2061 tmp3=getEndTime(tmp1,tmp2);
2062 ret->setEndTime(tmp3,tmp1,tmp2);
2066 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2068 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2070 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2072 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2073 getArray()->multiplyEqual(other->getArray());
2076 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2078 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2080 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2081 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2082 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2083 ret->setArray(arr,0);
2085 double tmp3=getStartTime(tmp1,tmp2);
2086 ret->setStartTime(tmp3,tmp1,tmp2);
2087 tmp3=getEndTime(tmp1,tmp2);
2088 ret->setEndTime(tmp3,tmp1,tmp2);
2092 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2094 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2096 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2098 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2099 getArray()->divideEqual(other->getArray());
2102 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2104 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2106 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2107 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2108 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2109 ret->setArray(arr,0);
2111 double tmp3=getStartTime(tmp1,tmp2);
2112 ret->setStartTime(tmp3,tmp1,tmp2);
2113 tmp3=getEndTime(tmp1,tmp2);
2114 ret->setEndTime(tmp3,tmp1,tmp2);
2118 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2120 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2122 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2124 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2125 getArray()->powEqual(other->getArray());
2128 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
2129 _start(other._start),_end(other._end)
2131 if(other._end_array)
2132 _end_array=other._end_array->performCopyOrIncrRef(deepCopy);
2137 void MEDCouplingTwoTimeSteps::updateTime() const
2139 MEDCouplingTimeDiscretization::updateTime();
2141 updateTimeWith(*_end_array);
2144 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
2147 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2149 double val=mesh->getTime(it,order);
2150 _start.setAllInfo(val,it,order);
2151 _end.setAllInfo(val,it,order);
2152 std::string tUnit(mesh->getTimeUnit());
2156 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
2158 return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
2161 std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildrenWithNull() const
2163 std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildrenWithNull());
2164 ret.push_back(_end_array);
2168 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2170 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2171 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2173 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2174 _start.copyFrom(otherC->_start);
2175 _end.copyFrom(otherC->_end);
2178 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2180 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2181 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2183 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2184 if(_end_array && otherC->_end_array)
2185 _end_array->copyStringInfoFrom(*otherC->_end_array);
2188 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2193 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2198 void MEDCouplingTwoTimeSteps::checkConsistencyLight() const
2200 MEDCouplingTimeDiscretization::checkConsistencyLight();
2202 throw INTERP_KERNEL::Exception("No end array specified !");
2203 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2204 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2205 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2206 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2209 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
2211 std::ostringstream oss;
2212 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2215 reason="This has time discretization LINEAR_TIME, other not.";
2218 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
2220 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
2222 if(_end_array!=otherC->_end_array)
2223 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2225 reason.insert(0,"end arrays differ for linear time.");
2228 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2231 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
2233 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2236 if(!_start.isEqual(otherC->_start,_time_tolerance))
2238 if(!_end.isEqual(otherC->_end,_time_tolerance))
2240 if(_end_array!=otherC->_end_array)
2241 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2243 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2246 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0)
2250 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2253 _end_array->decrRef();
2256 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const
2258 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2261 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
2263 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
2265 std::ostringstream stream;
2266 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
2267 stream << _time_tolerance << " and trying to access on time = " << time;
2268 throw INTERP_KERNEL::Exception(stream.str().c_str());
2272 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2276 arrays[1]=_end_array;
2279 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2281 if(array!=_end_array)
2284 _end_array->decrRef();
2287 _end_array->incrRef();
2289 owner->declareAsNew();
2293 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<mcIdType>& tinyInfo) const
2295 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2296 tinyInfo.push_back(_start.getIteration());
2297 tinyInfo.push_back(_start.getOrder());
2298 tinyInfo.push_back(_end.getIteration());
2299 tinyInfo.push_back(_end.getOrder());
2302 tinyInfo.push_back(_end_array->getNumberOfTuples());
2303 tinyInfo.push_back(ToIdType(_end_array->getNumberOfComponents()));
2307 tinyInfo.push_back(-1);
2308 tinyInfo.push_back(-1);
2312 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2314 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2315 tinyInfo.push_back(_start.getTimeValue());
2316 tinyInfo.push_back(_end.getTimeValue());
2319 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2321 std::size_t nbOfCompo=_array->getNumberOfComponents();
2322 for(std::size_t i=0;i<nbOfCompo;i++)
2323 tinyInfo.push_back(_array->getInfoOnComponent(i));
2324 for(std::size_t i=0;i<nbOfCompo;i++)
2325 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2328 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<mcIdType>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2334 _end_array->decrRef();
2335 DataArrayDouble *arr=0;
2336 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2338 arr=DataArrayDouble::New();
2339 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2344 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2346 arr=DataArrayDouble::New();
2347 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2353 void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
2355 static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !";
2356 if(arrays.size()!=2)
2357 throw INTERP_KERNEL::Exception(MSG);
2361 _end_array->decrRef();
2362 _array=0; _end_array=0;
2363 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2366 throw INTERP_KERNEL::Exception(MSG);
2367 arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2368 _array=arrays[0]; _array->incrRef();
2370 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2373 throw INTERP_KERNEL::Exception(MSG);
2374 arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2375 _end_array=arrays[1]; _end_array->incrRef();
2379 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2381 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2382 _start.setTimeValue(tinyInfoD[1]);
2383 _end.setTimeValue(tinyInfoD[2]);
2384 _start.setIteration(FromIdType<int>(tinyInfoI[2]));
2385 _start.setOrder(FromIdType<int>(tinyInfoI[3]));
2386 _end.setIteration(FromIdType<int>(tinyInfoI[4]));
2387 _end.setOrder(FromIdType<int>(tinyInfoI[5]));
2391 * idem getTinySerializationIntInformation except that it is for multi field fetch
2393 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<mcIdType>& tinyInfo) const
2396 tinyInfo[0]=_start.getIteration();
2397 tinyInfo[1]=_start.getOrder();
2398 tinyInfo[2]=_end.getIteration();
2399 tinyInfo[3]=_end.getOrder();
2403 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2405 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2408 tinyInfo[0]=_time_tolerance;
2409 tinyInfo[1]=_start.getTimeValue();
2410 tinyInfo[2]=_end.getTimeValue();
2414 * idem finishUnserialization except that it is for multi field fetch
2416 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD)
2418 _start.setIteration(FromIdType<int>(tinyInfoI[0]));
2419 _start.setOrder(FromIdType<int>(tinyInfoI[1]));
2420 _end.setIteration(FromIdType<int>(tinyInfoI[2]));
2421 _end.setOrder(FromIdType<int>(tinyInfoI[3]));
2422 _time_tolerance=tinyInfoD[0];
2423 _start.setTimeValue(tinyInfoD[1]);
2424 _end.setTimeValue(tinyInfoD[2]);
2427 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
2429 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
2431 std::vector< const DataArrayDouble *> ret(2);
2437 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2440 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
2442 if(arrays.size()!=2)
2443 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2444 setArray(arrays.front(),owner);
2445 setEndArray(arrays.back(),owner);
2448 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCopy):MEDCouplingTwoTimeSteps(other,deepCopy)
2452 MEDCouplingLinearTime::MEDCouplingLinearTime()
2456 std::string MEDCouplingLinearTime::getStringRepr() const
2458 std::ostringstream stream;
2459 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
2460 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
2461 stream << "Time unit is : \"" << getTimeUnit() << "\"";
2462 return stream.str();
2465 void MEDCouplingLinearTime::checkConsistencyLight() const
2467 MEDCouplingTwoTimeSteps::checkConsistencyLight();
2468 if(std::fabs(_start.getTimeValue()-_end.getTimeValue())<_time_tolerance)
2469 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2472 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCopyOrIncrRef(bool deepCopy) const
2474 return new MEDCouplingLinearTime(*this,deepCopy);
2477 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2479 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2481 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2484 if(_end_array==0 && otherC->_end_array==0)
2486 if(_end_array==0 || otherC->_end_array==0)
2488 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2493 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
2495 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2497 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2500 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2504 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2506 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2508 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2512 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2514 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2516 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2519 if(_end_array==0 && otherC->_end_array==0)
2521 if(_end_array==0 || otherC->_end_array==0)
2523 std::size_t nbC1=_end_array->getNumberOfComponents();
2524 std::size_t nbC2=otherC->_end_array->getNumberOfComponents();
2525 if(nbC1!=nbC2 && nbC2!=1)
2530 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2532 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2534 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2539 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2541 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2543 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2544 std::size_t nbComp=vals.size()/2;
2545 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind(std::multiplies<double>(),std::placeholders::_1,alpha));
2546 std::vector<double> tmp(nbComp);
2547 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind(std::multiplies<double>(),std::placeholders::_1,1-alpha));
2548 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2551 void MEDCouplingLinearTime::getValueOnTime(mcIdType eltId, double time, double *value) const
2553 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2555 _array->getTuple(eltId,value);
2557 throw INTERP_KERNEL::Exception("No start array existing.");
2558 std::size_t nbComp=_array->getNumberOfComponents();
2559 std::transform(value,value+nbComp,value,std::bind(std::multiplies<double>(),std::placeholders::_1,alpha));
2560 std::vector<double> tmp(nbComp);
2562 _end_array->getTuple(eltId,&tmp[0]);
2564 throw INTERP_KERNEL::Exception("No end array existing.");
2565 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind(std::multiplies<double>(),std::placeholders::_1,1-alpha));
2566 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2569 void MEDCouplingLinearTime::getValueOnDiscTime(mcIdType eltId, int iteration, int order, double *value) const
2571 if(iteration==_start.getIteration() && order==_start.getOrder())
2574 _array->getTuple(eltId,value);
2576 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2578 if(iteration==_end.getIteration() && order==_end.getOrder())
2581 _end_array->getTuple(eltId,value);
2583 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2586 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2589 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2591 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2593 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2594 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2595 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2596 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2597 ret->setArray(arr1,0);
2598 ret->setEndArray(arr2,0);
2602 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2604 std::vector<const DataArrayDouble *> a(other.size());
2605 std::vector<const DataArrayDouble *> b(other.size());
2607 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2609 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2611 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2612 a[i]=itC->getArray();
2613 b[i]=itC->getEndArray();
2615 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b));
2616 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2617 ret->setArray(arr,0);
2618 ret->setEndArray(arr2,0);
2622 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2624 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2626 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2627 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray()));
2628 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2629 ret->setTimeTolerance(getTimeTolerance());
2630 ret->setArray(arr1,0);
2631 ret->setEndArray(arr2,0);
2635 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2637 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2639 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2640 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray()));
2641 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2642 ret->setArray(arr1,0);
2643 ret->setEndArray(arr2,0);
2647 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2649 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2651 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2652 MCAuto<DataArrayDouble> arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()));
2653 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2654 ret->setArray(arr1,0);
2655 ret->setEndArray(arr2,0);
2659 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2661 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2663 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2664 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2665 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray()));
2666 ret->setArray(arr1,0);
2667 ret->setEndArray(arr2,0);
2671 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2673 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2675 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2676 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray()));
2677 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2678 ret->setArray(arr1,0);
2679 ret->setEndArray(arr2,0);
2683 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2685 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2687 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2688 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray()));
2689 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2690 ret->setArray(arr1,0);
2691 ret->setEndArray(arr2,0);
2695 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2697 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2699 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2701 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2703 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2704 getArray()->addEqual(other->getArray());
2705 getEndArray()->addEqual(other->getEndArray());
2708 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2710 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2712 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2713 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2714 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2715 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2716 ret->setArray(arr1,0);
2717 ret->setEndArray(arr2,0);
2721 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2723 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2725 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2727 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2729 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2730 getArray()->substractEqual(other->getArray());
2731 getEndArray()->substractEqual(other->getEndArray());
2734 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2736 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2738 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2739 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2740 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2741 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2742 ret->setArray(arr1,0);
2743 ret->setEndArray(arr2,0);
2747 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2749 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2751 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2753 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2755 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2756 getArray()->multiplyEqual(other->getArray());
2757 getEndArray()->multiplyEqual(other->getEndArray());
2760 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2762 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2764 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2765 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2766 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2767 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2768 ret->setArray(arr1,0);
2769 ret->setEndArray(arr2,0);
2773 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2775 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2777 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2779 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2781 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2782 getArray()->divideEqual(other->getArray());
2783 getEndArray()->divideEqual(other->getEndArray());
2786 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2788 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2790 throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2791 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2792 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2793 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2794 ret->setArray(arr1,0);
2795 ret->setEndArray(arr2,0);
2799 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2801 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2803 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2805 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2807 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2808 getArray()->powEqual(other->getArray());
2809 getEndArray()->powEqual(other->getEndArray());