1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingTimeDiscretization.txx"
23 #include "MEDCouplingMemArray.hxx"
24 #include "MEDCouplingMesh.hxx"
30 using namespace MEDCoupling;
32 template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<double>;
33 template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<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<int>& 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<int>& 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 correspondance are not defined symetrically !");
381 void MEDCouplingTimeDiscretization::changeNbOfComponents(int 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(int 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(int 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 MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<int>(other,deepCopy)
701 MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::performCopyOrIncrRef(bool deepCopy) const
703 return new MEDCouplingTimeDiscretizationInt(*this,deepCopy);
706 MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::New(TypeOfTimeDiscretization type)
710 case MEDCouplingTimeDiscretizationInt::DISCRETIZATION:
711 return new MEDCouplingTimeDiscretizationInt;
713 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for intergers !");
717 bool MEDCouplingTimeDiscretizationInt::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, int 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 MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(other));
728 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationInt !");
729 if(!MEDCouplingTimeDiscretizationTemplate<int>::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 MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec) const
741 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr : only precision 0 is supported !");
742 const MEDCouplingTimeDiscretizationInt *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationInt *>(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 MEDCouplingTimeDiscretizationFloat::MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<float>(other,deepCopy)
762 MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::performCopyOrIncrRef(bool deepCopy) const
764 return new MEDCouplingTimeDiscretizationFloat(*this,deepCopy);
767 MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::New(TypeOfTimeDiscretization type)
771 case MEDCouplingTimeDiscretizationFloat::DISCRETIZATION:
772 return new MEDCouplingTimeDiscretizationFloat;
774 throw INTERP_KERNEL::Exception("Time discretization not implemented yet for intergers !");
778 bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float 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 MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
789 throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationFloat !");
790 if(!MEDCouplingTimeDiscretizationTemplate<float>::areStrictlyCompatible(other,reason))
792 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
794 if(_array==other->getArray())
796 return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
799 bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec) const
802 throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr : only precision 0 is supported !");
803 const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
805 throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationFloat !");
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()),prec);
817 ////////////////////////
819 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
823 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy)
827 std::string MEDCouplingNoTimeLabel::getStringRepr() const
829 std::ostringstream stream;
831 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
835 void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh)
837 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
840 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
842 if(!MEDCouplingTimeDiscretization::areCompatible(other))
844 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
848 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
850 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
852 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
855 reason.insert(0,"time discretization of this is NO_TIME, other has a different time discretization.");
859 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
861 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
863 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
867 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
869 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
871 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
875 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
877 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
879 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
883 bool MEDCouplingNoTimeLabel::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
885 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
888 reason="This has time discretization NO_TIME, other not.";
891 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
894 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
896 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
899 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
902 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
904 const MEDCouplingNoTimeLabel *otherC(dynamic_cast<const MEDCouplingNoTimeLabel *>(other));
906 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
907 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(getArray(),other->getArray()));
908 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
909 ret->setArray(arr,0);
913 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
915 std::vector<const DataArrayDouble *> a(other.size());
917 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
919 const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
921 throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
922 a[i]=itC->getArray();
924 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a));
925 MEDCouplingNoTimeLabel *ret(new MEDCouplingNoTimeLabel);
926 ret->setArray(arr,0);
930 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
932 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
934 throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
935 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
936 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
937 ret->setTimeTolerance(getTimeTolerance());
938 ret->setArray(arr,0);
942 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
944 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
946 throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
947 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
948 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
949 ret->setArray(arr,0);
953 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
955 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
957 throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
958 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
959 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
960 ret->setArray(arr,0);
964 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
966 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
968 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
969 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
970 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
971 ret->setArray(arr,0);
975 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
977 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
979 throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
980 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
981 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
982 ret->setArray(arr,0);
986 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
988 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
990 throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
991 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
992 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
993 ret->setArray(arr,0);
997 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
999 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1001 throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
1003 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::addEqual : Data Array is NULL !");
1004 getArray()->addEqual(other->getArray());
1007 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
1009 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1011 throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
1013 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substract : Data Array is NULL !");
1014 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1015 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1016 ret->setArray(arr,0);
1020 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
1022 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1024 throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
1026 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::substractEqual : Data Array is NULL !");
1027 getArray()->substractEqual(other->getArray());
1030 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
1032 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1034 throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
1035 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1036 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1037 ret->setArray(arr,0);
1041 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1043 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1045 throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
1047 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::multiplyEqual : Data Array is NULL !");
1048 getArray()->multiplyEqual(other->getArray());
1051 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
1053 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1055 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
1056 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1057 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1058 ret->setArray(arr,0);
1062 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
1064 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1066 throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
1068 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::divideEqual : Data Array is NULL !");
1069 getArray()->divideEqual(other->getArray());
1072 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
1074 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1076 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
1077 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1078 MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
1079 ret->setArray(arr,0);
1083 void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
1085 const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
1087 throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
1089 throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
1090 getArray()->powEqual(other->getArray());
1093 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCopyOrIncrRef(bool deepCopy) const
1095 return new MEDCouplingNoTimeLabel(*this,deepCopy);
1098 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const
1100 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1103 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const
1105 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1108 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1110 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1113 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const
1115 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1118 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const
1120 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1123 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const
1125 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1128 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const
1130 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1133 void MEDCouplingNoTimeLabel::setStartIteration(int it)
1135 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1138 void MEDCouplingNoTimeLabel::setEndIteration(int it)
1140 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1143 void MEDCouplingNoTimeLabel::setStartOrder(int order)
1145 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1148 void MEDCouplingNoTimeLabel::setEndOrder(int order)
1150 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1153 void MEDCouplingNoTimeLabel::setStartTimeValue(double time)
1155 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1158 void MEDCouplingNoTimeLabel::setEndTimeValue(double time)
1160 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1163 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order)
1165 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1168 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order)
1170 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1173 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const
1175 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1178 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1180 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1184 * idem getTinySerializationIntInformation except that it is for multi field fetch
1186 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1192 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1194 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1197 tinyInfo[0]=_time_tolerance;
1201 * idem finishUnserialization except that it is for multi field fetch
1203 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1205 _time_tolerance=tinyInfoD[0];
1208 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),_tk(other._tk)
1212 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep()
1216 std::string MEDCouplingWithTimeStep::getStringRepr() const
1218 std::ostringstream stream;
1219 stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
1220 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
1221 return stream.str();
1224 void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1227 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1229 double val=mesh->getTime(it,order);
1230 _tk.setAllInfo(val,it,order);
1231 std::string tUnit(mesh->getTimeUnit());
1235 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1237 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1238 tinyInfo.push_back(_tk.getIteration());
1239 tinyInfo.push_back(_tk.getOrder());
1242 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1244 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1245 tinyInfo.push_back(_tk.getTimeValue());
1248 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1250 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1251 _tk.setTimeValue(tinyInfoD[1]);
1252 _tk.setIteration(tinyInfoI[2]);
1253 _tk.setOrder(tinyInfoI[3]);
1257 * idem getTinySerializationIntInformation except that it is for multi field fetch
1259 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1262 tinyInfo[0]=_tk.getIteration();
1263 tinyInfo[1]=_tk.getOrder();
1267 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1269 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1272 tinyInfo[0]=_time_tolerance;
1273 tinyInfo[1]=_tk.getTimeValue();
1277 * idem finishUnserialization except that it is for multi field fetch
1279 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1281 _tk.setIteration(tinyInfoI[0]);
1282 _tk.setOrder(tinyInfoI[1]);
1283 _time_tolerance=tinyInfoD[0];
1284 _tk.setTimeValue(tinyInfoD[1]);
1287 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1289 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1291 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1295 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1297 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1299 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1302 reason.insert(0,"time discretization of this is ONE_TIME, other has a different time discretization.");
1306 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1308 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1310 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1314 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1316 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1318 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1322 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1324 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1326 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1330 bool MEDCouplingWithTimeStep::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1332 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1333 std::ostringstream oss; oss.precision(15);
1336 reason="This has time discretization ONE_TIME, other not.";
1339 if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
1341 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1344 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1346 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1349 if(!_tk.isEqual(otherC->_tk,_time_tolerance))
1351 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1354 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1356 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1357 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
1359 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
1360 _tk.copyFrom(otherC->_tk);
1363 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
1365 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1367 throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
1368 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1369 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1370 ret->setArray(arr,0);
1374 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1376 std::vector<const DataArrayDouble *> a(other.size());
1378 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1380 const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
1382 throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
1383 a[i]=itC->getArray();
1385 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1386 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1387 ret->setArray(arr,0);
1391 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
1393 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1395 throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
1396 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1397 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1398 ret->setArray(arr,0);
1402 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
1404 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1406 throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
1407 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1408 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1409 ret->setArray(arr,0);
1413 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
1415 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1417 throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
1418 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1419 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1420 ret->setArray(arr,0);
1424 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
1426 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1428 throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
1429 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1430 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1431 ret->setArray(arr,0);
1435 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
1437 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1439 throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
1440 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1441 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1442 ret->setArray(arr,0);
1446 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
1448 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1450 throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
1451 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1452 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1453 ret->setArray(arr,0);
1455 double tmp3=getStartTime(tmp1,tmp2);
1456 ret->setStartTime(tmp3,tmp1,tmp2);
1460 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
1462 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1464 throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
1466 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::addEqual : Data Array is NULL !");
1467 getArray()->addEqual(other->getArray());
1470 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
1472 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1474 throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
1475 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1476 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1477 ret->setArray(arr,0);
1479 double tmp3=getStartTime(tmp1,tmp2);
1480 ret->setStartTime(tmp3,tmp1,tmp2);
1484 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
1486 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1488 throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
1490 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::substractEqual : Data Array is NULL !");
1491 getArray()->substractEqual(other->getArray());
1494 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
1496 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1498 throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
1499 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1500 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1501 ret->setArray(arr,0);
1503 double tmp3=getStartTime(tmp1,tmp2);
1504 ret->setStartTime(tmp3,tmp1,tmp2);
1508 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
1510 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1512 throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
1514 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::multiplyEqual : Data Array is NULL !");
1515 getArray()->multiplyEqual(other->getArray());
1518 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
1520 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1522 throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
1523 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
1524 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1525 ret->setArray(arr,0);
1527 double tmp3=getStartTime(tmp1,tmp2);
1528 ret->setStartTime(tmp3,tmp1,tmp2);
1532 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
1534 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1536 throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
1538 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::divideEqual : Data Array is NULL !");
1539 getArray()->divideEqual(other->getArray());
1542 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
1544 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1546 throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
1547 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
1548 MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
1549 ret->setArray(arr,0);
1551 double tmp3=getStartTime(tmp1,tmp2);
1552 ret->setStartTime(tmp3,tmp1,tmp2);
1556 void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
1558 const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
1560 throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
1562 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
1563 getArray()->powEqual(other->getArray());
1566 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCopyOrIncrRef(bool deepCopy) const
1568 return new MEDCouplingWithTimeStep(*this,deepCopy);
1571 void MEDCouplingWithTimeStep::checkNoTimePresence() const
1573 throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
1576 void MEDCouplingWithTimeStep::checkTimePresence(double time) const
1578 _tk.checkTimePresence(time,_time_tolerance);
1581 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
1583 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1585 std::vector< const DataArrayDouble *> ret(1);
1590 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1593 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1595 std::copy(vals.begin(),vals.end(),res);
1598 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const
1600 if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
1602 _array->getTuple(eltId,value);
1604 throw INTERP_KERNEL::Exception("No array existing.");
1606 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1609 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1611 if(_tk.getIteration()==iteration && _tk.getOrder()==order)
1613 _array->getTuple(eltId,value);
1615 throw INTERP_KERNEL::Exception("No array existing.");
1617 throw INTERP_KERNEL::Exception("No data on this discrete time.");
1620 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval()
1624 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
1626 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
1627 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
1629 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
1630 _start.copyFrom(otherC->_start);
1631 _end.copyFrom(otherC->_end);
1634 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
1636 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
1637 tinyInfo.push_back(_start.getIteration());
1638 tinyInfo.push_back(_start.getOrder());
1639 tinyInfo.push_back(_end.getIteration());
1640 tinyInfo.push_back(_end.getOrder());
1643 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
1645 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
1646 tinyInfo.push_back(_start.getTimeValue());
1647 tinyInfo.push_back(_end.getTimeValue());
1650 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
1652 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
1653 _start.setTimeValue(tinyInfoD[1]);
1654 _end.setTimeValue(tinyInfoD[2]);
1655 _start.setIteration(tinyInfoI[2]);
1656 _start.setOrder(tinyInfoI[3]);
1657 _end.setIteration(tinyInfoI[4]);
1658 _end.setOrder(tinyInfoI[5]);
1662 * idem getTinySerializationIntInformation except that it is for multi field fetch
1664 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
1667 tinyInfo[0]=_start.getIteration();
1668 tinyInfo[1]=_start.getOrder();
1669 tinyInfo[2]=_end.getIteration();
1670 tinyInfo[3]=_end.getOrder();
1674 * idem getTinySerializationDbleInformation except that it is for multi field fetch
1676 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
1679 tinyInfo[0]=_time_tolerance;
1680 tinyInfo[1]=_start.getTimeValue();
1681 tinyInfo[2]=_end.getTimeValue();
1685 * idem finishUnserialization except that it is for multi field fetch
1687 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
1689 _start.setIteration(tinyInfoI[0]);
1690 _start.setOrder(tinyInfoI[1]);
1691 _end.setIteration(tinyInfoI[2]);
1692 _end.setOrder(tinyInfoI[3]);
1693 _time_tolerance=tinyInfoD[0];
1694 _start.setTimeValue(tinyInfoD[1]);
1695 _end.setTimeValue(tinyInfoD[2]);
1698 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCopy):
1699 MEDCouplingTimeDiscretization(other,deepCopy),_start(other._start),_end(other._end)
1703 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
1705 std::ostringstream stream;
1706 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
1707 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
1708 stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
1709 return stream.str();
1712 void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh)
1715 throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
1717 double val=mesh->getTime(it,order);
1718 _start.setAllInfo(val,it,order);
1719 _end.setAllInfo(val,it,order);
1720 std::string tUnit(mesh->getTimeUnit());
1724 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCopyOrIncrRef(bool deepCopy) const
1726 return new MEDCouplingConstOnTimeInterval(*this,deepCopy);
1729 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const
1731 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1733 std::vector< const DataArrayDouble *> ret(1);
1738 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1741 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
1743 std::copy(vals.begin(),vals.end(),res);
1746 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1748 if(!MEDCouplingTimeDiscretization::areCompatible(other))
1750 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1754 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
1756 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
1758 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1761 reason.insert(0,"time discretization of this is CONST_ON_TIME_INTERVAL, other has a different time discretization.");
1765 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1767 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
1769 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1773 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
1775 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
1777 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1781 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
1783 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
1785 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1789 bool MEDCouplingConstOnTimeInterval::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
1791 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1792 std::ostringstream oss; oss.precision(15);
1795 reason="This has time discretization CONST_ON_TIME_INTERVAL, other not.";
1798 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
1800 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
1802 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
1805 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
1807 const MEDCouplingConstOnTimeInterval *otherC(dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other));
1810 if(!_start.isEqual(otherC->_start,_time_tolerance))
1812 if(!_end.isEqual(otherC->_end,_time_tolerance))
1814 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
1817 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const
1819 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
1821 _array->getTuple(eltId,value);
1823 throw INTERP_KERNEL::Exception("No array existing.");
1825 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1828 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
1830 if(iteration>=_start.getIteration() && iteration<=_end.getIteration())
1832 _array->getTuple(eltId,value);
1834 throw INTERP_KERNEL::Exception("No array existing.");
1836 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
1839 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const
1841 throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
1844 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const
1846 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
1848 std::ostringstream stream;
1849 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
1850 stream << _time_tolerance << " and trying to access on time = " << time;
1851 throw INTERP_KERNEL::Exception(stream.str().c_str());
1855 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
1857 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1859 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
1860 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
1861 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1862 ret->setArray(arr,0);
1866 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
1868 std::vector<const DataArrayDouble *> a(other.size());
1870 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
1872 const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
1874 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
1875 a[i]=itC->getArray();
1877 MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
1878 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1879 ret->setArray(arr,0);
1883 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
1885 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1887 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
1888 MCAuto<DataArrayDouble> arr=DataArrayDouble::Meld(getArray(),other->getArray());
1889 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1890 ret->setTimeTolerance(getTimeTolerance());
1891 ret->setArray(arr,0);
1895 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
1897 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1899 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
1900 MCAuto<DataArrayDouble> arr=DataArrayDouble::Dot(getArray(),other->getArray());
1901 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1902 ret->setArray(arr,0);
1906 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
1908 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1910 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
1911 MCAuto<DataArrayDouble> arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
1912 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1913 ret->setArray(arr,0);
1917 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
1919 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1921 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
1922 MCAuto<DataArrayDouble> arr=DataArrayDouble::Max(getArray(),other->getArray());
1923 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1924 ret->setArray(arr,0);
1928 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
1930 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1932 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
1933 MCAuto<DataArrayDouble> arr=DataArrayDouble::Min(getArray(),other->getArray());
1934 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1935 ret->setArray(arr,0);
1939 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
1941 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1943 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
1944 MCAuto<DataArrayDouble> arr=DataArrayDouble::Add(getArray(),other->getArray());
1945 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1946 ret->setArray(arr,0);
1948 double tmp3=getStartTime(tmp1,tmp2);
1949 ret->setStartTime(tmp3,tmp1,tmp2);
1950 tmp3=getEndTime(tmp1,tmp2);
1951 ret->setEndTime(tmp3,tmp1,tmp2);
1955 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
1957 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1959 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
1961 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractaddEqual : Data Array is NULL !");
1962 getArray()->addEqual(other->getArray());
1965 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
1967 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1969 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
1970 MCAuto<DataArrayDouble> arr=DataArrayDouble::Substract(getArray(),other->getArray());
1971 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1972 ret->setArray(arr,0);
1974 double tmp3=getStartTime(tmp1,tmp2);
1975 ret->setStartTime(tmp3,tmp1,tmp2);
1976 tmp3=getEndTime(tmp1,tmp2);
1977 ret->setEndTime(tmp3,tmp1,tmp2);
1981 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
1983 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1985 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
1987 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::substractEqual : Data Array is NULL !");
1988 getArray()->substractEqual(other->getArray());
1991 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
1993 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
1995 throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
1996 MCAuto<DataArrayDouble> arr=DataArrayDouble::Multiply(getArray(),other->getArray());
1997 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
1998 ret->setArray(arr,0);
2000 double tmp3=getStartTime(tmp1,tmp2);
2001 ret->setStartTime(tmp3,tmp1,tmp2);
2002 tmp3=getEndTime(tmp1,tmp2);
2003 ret->setEndTime(tmp3,tmp1,tmp2);
2007 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2009 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2011 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
2013 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::multiplyEqual : Data Array is NULL !");
2014 getArray()->multiplyEqual(other->getArray());
2017 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
2019 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2021 throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
2022 MCAuto<DataArrayDouble> arr=DataArrayDouble::Divide(getArray(),other->getArray());
2023 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2024 ret->setArray(arr,0);
2026 double tmp3=getStartTime(tmp1,tmp2);
2027 ret->setStartTime(tmp3,tmp1,tmp2);
2028 tmp3=getEndTime(tmp1,tmp2);
2029 ret->setEndTime(tmp3,tmp1,tmp2);
2033 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
2035 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2037 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
2039 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::divideEqual : Data Array is NULL !");
2040 getArray()->divideEqual(other->getArray());
2043 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
2045 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2047 throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
2048 MCAuto<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
2049 MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
2050 ret->setArray(arr,0);
2052 double tmp3=getStartTime(tmp1,tmp2);
2053 ret->setStartTime(tmp3,tmp1,tmp2);
2054 tmp3=getEndTime(tmp1,tmp2);
2055 ret->setEndTime(tmp3,tmp1,tmp2);
2059 void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
2061 const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
2063 throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
2065 throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
2066 getArray()->powEqual(other->getArray());
2069 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
2070 _start(other._start),_end(other._end)
2072 if(other._end_array)
2073 _end_array=other._end_array->performCopyOrIncrRef(deepCopy);
2078 void MEDCouplingTwoTimeSteps::updateTime() const
2080 MEDCouplingTimeDiscretization::updateTime();
2082 updateTimeWith(*_end_array);
2085 void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh)
2088 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
2090 double val=mesh->getTime(it,order);
2091 _start.setAllInfo(val,it,order);
2092 _end.setAllInfo(val,it,order);
2093 std::string tUnit(mesh->getTimeUnit());
2097 std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
2099 return MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren();
2102 std::vector<const BigMemoryObject *> MEDCouplingTwoTimeSteps::getDirectChildrenWithNull() const
2104 std::vector<const BigMemoryObject *> ret(MEDCouplingTimeDiscretization::getDirectChildrenWithNull());
2105 ret.push_back(_end_array);
2109 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2111 MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
2112 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2114 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
2115 _start.copyFrom(otherC->_start);
2116 _end.copyFrom(otherC->_end);
2119 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
2121 MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
2122 const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
2124 throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
2125 if(_end_array && otherC->_end_array)
2126 _end_array->copyStringInfoFrom(*otherC->_end_array);
2129 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
2134 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
2139 void MEDCouplingTwoTimeSteps::checkConsistencyLight() const
2141 MEDCouplingTimeDiscretization::checkConsistencyLight();
2143 throw INTERP_KERNEL::Exception("No end array specified !");
2144 if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
2145 throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
2146 if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
2147 throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
2150 bool MEDCouplingTwoTimeSteps::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec, std::string& reason) const
2152 std::ostringstream oss;
2153 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2156 reason="This has time discretization LINEAR_TIME, other not.";
2159 if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
2161 if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
2163 if(_end_array!=otherC->_end_array)
2164 if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
2166 reason.insert(0,"end arrays differ for linear time.");
2169 return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
2172 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<double> *other, double prec) const
2174 const MEDCouplingTwoTimeSteps *otherC(dynamic_cast<const MEDCouplingTwoTimeSteps *>(other));
2177 if(!_start.isEqual(otherC->_start,_time_tolerance))
2179 if(!_end.isEqual(otherC->_end,_time_tolerance))
2181 if(_end_array!=otherC->_end_array)
2182 if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
2184 return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
2187 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0)
2191 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
2194 _end_array->decrRef();
2197 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const
2199 throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
2202 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
2204 if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
2206 std::ostringstream stream;
2207 stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
2208 stream << _time_tolerance << " and trying to access on time = " << time;
2209 throw INTERP_KERNEL::Exception(stream.str().c_str());
2213 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
2217 arrays[1]=_end_array;
2220 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
2222 if(array!=_end_array)
2225 _end_array->decrRef();
2228 _end_array->incrRef();
2230 owner->declareAsNew();
2234 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
2236 MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
2237 tinyInfo.push_back(_start.getIteration());
2238 tinyInfo.push_back(_start.getOrder());
2239 tinyInfo.push_back(_end.getIteration());
2240 tinyInfo.push_back(_end.getOrder());
2243 tinyInfo.push_back(_end_array->getNumberOfTuples());
2244 tinyInfo.push_back(_end_array->getNumberOfComponents());
2248 tinyInfo.push_back(-1);
2249 tinyInfo.push_back(-1);
2253 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
2255 MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
2256 tinyInfo.push_back(_start.getTimeValue());
2257 tinyInfo.push_back(_end.getTimeValue());
2260 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
2262 int nbOfCompo=_array->getNumberOfComponents();
2263 for(int i=0;i<nbOfCompo;i++)
2264 tinyInfo.push_back(_array->getInfoOnComponent(i));
2265 for(int i=0;i<nbOfCompo;i++)
2266 tinyInfo.push_back(_end_array->getInfoOnComponent(i));
2269 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
2275 _end_array->decrRef();
2276 DataArrayDouble *arr=0;
2277 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2279 arr=DataArrayDouble::New();
2280 arr->alloc(tinyInfoI[0],tinyInfoI[1]);
2285 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2287 arr=DataArrayDouble::New();
2288 arr->alloc(tinyInfoI[6],tinyInfoI[7]);
2294 void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
2296 static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !";
2297 if(arrays.size()!=2)
2298 throw INTERP_KERNEL::Exception(MSG);
2302 _end_array->decrRef();
2303 _array=0; _end_array=0;
2304 if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
2307 throw INTERP_KERNEL::Exception(MSG);
2308 arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2309 _array=arrays[0]; _array->incrRef();
2311 if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
2314 throw INTERP_KERNEL::Exception(MSG);
2315 arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
2316 _end_array=arrays[1]; _end_array->incrRef();
2320 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
2322 MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
2323 _start.setTimeValue(tinyInfoD[1]);
2324 _end.setTimeValue(tinyInfoD[2]);
2325 _start.setIteration(tinyInfoI[2]);
2326 _start.setOrder(tinyInfoI[3]);
2327 _end.setIteration(tinyInfoI[4]);
2328 _end.setOrder(tinyInfoI[5]);
2332 * idem getTinySerializationIntInformation except that it is for multi field fetch
2334 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
2337 tinyInfo[0]=_start.getIteration();
2338 tinyInfo[1]=_start.getOrder();
2339 tinyInfo[2]=_end.getIteration();
2340 tinyInfo[3]=_end.getOrder();
2344 * idem getTinySerializationDbleInformation except that it is for multi field fetch
2346 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
2349 tinyInfo[0]=_time_tolerance;
2350 tinyInfo[1]=_start.getTimeValue();
2351 tinyInfo[2]=_end.getTimeValue();
2355 * idem finishUnserialization except that it is for multi field fetch
2357 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
2359 _start.setIteration(tinyInfoI[0]);
2360 _start.setOrder(tinyInfoI[1]);
2361 _end.setIteration(tinyInfoI[2]);
2362 _end.setOrder(tinyInfoI[3]);
2363 _time_tolerance=tinyInfoD[0];
2364 _start.setTimeValue(tinyInfoD[1]);
2365 _end.setTimeValue(tinyInfoD[2]);
2368 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
2370 if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
2372 std::vector< const DataArrayDouble *> ret(2);
2378 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2381 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner)
2383 if(arrays.size()!=2)
2384 throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
2385 setArray(arrays.front(),owner);
2386 setEndArray(arrays.back(),owner);
2389 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCopy):MEDCouplingTwoTimeSteps(other,deepCopy)
2393 MEDCouplingLinearTime::MEDCouplingLinearTime()
2397 std::string MEDCouplingLinearTime::getStringRepr() const
2399 std::ostringstream stream;
2400 stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
2401 stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
2402 stream << "Time unit is : \"" << getTimeUnit() << "\"";
2403 return stream.str();
2406 void MEDCouplingLinearTime::checkConsistencyLight() const
2408 MEDCouplingTwoTimeSteps::checkConsistencyLight();
2409 if(std::fabs(_start.getTimeValue()-_end.getTimeValue())<_time_tolerance)
2410 throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
2413 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCopyOrIncrRef(bool deepCopy) const
2415 return new MEDCouplingLinearTime(*this,deepCopy);
2418 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2420 if(!MEDCouplingTimeDiscretization::areCompatible(other))
2422 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2425 if(_end_array==0 && otherC->_end_array==0)
2427 if(_end_array==0 || otherC->_end_array==0)
2429 if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
2434 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
2436 if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
2438 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2441 reason.insert(0,"time discretization of this is LINEAR_TIME, other has a different time discretization.");
2445 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2447 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
2449 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2453 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
2455 if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
2457 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2460 if(_end_array==0 && otherC->_end_array==0)
2462 if(_end_array==0 || otherC->_end_array==0)
2464 int nbC1=_end_array->getNumberOfComponents();
2465 int nbC2=otherC->_end_array->getNumberOfComponents();
2466 if(nbC1!=nbC2 && nbC2!=1)
2471 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
2473 if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
2475 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2480 * vals is expected to be of size 2*_array->getNumberOfTuples()==_array->getNumberOfTuples()+_end_array->getNumberOfTuples()
2482 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
2484 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2485 std::size_t nbComp=vals.size()/2;
2486 std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
2487 std::vector<double> tmp(nbComp);
2488 std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2489 std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
2492 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
2494 double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
2497 _array->getTuple(eltId,value);
2499 throw INTERP_KERNEL::Exception("No start array existing.");
2500 nbComp=_array->getNumberOfComponents();
2501 std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
2502 std::vector<double> tmp(nbComp);
2504 _end_array->getTuple(eltId,&tmp[0]);
2506 throw INTERP_KERNEL::Exception("No end array existing.");
2507 std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
2508 std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
2511 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
2513 if(iteration==_start.getIteration() && order==_start.getOrder())
2516 _array->getTuple(eltId,value);
2518 throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
2520 if(iteration==_end.getIteration() && order==_end.getOrder())
2523 _end_array->getTuple(eltId,value);
2525 throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
2528 throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
2531 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
2533 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2535 throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
2536 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
2537 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
2538 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2539 ret->setArray(arr1,0);
2540 ret->setEndArray(arr2,0);
2544 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
2546 std::vector<const DataArrayDouble *> a(other.size());
2547 std::vector<const DataArrayDouble *> b(other.size());
2549 for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
2551 const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
2553 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
2554 a[i]=itC->getArray();
2555 b[i]=itC->getEndArray();
2557 MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b));
2558 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2559 ret->setArray(arr,0);
2560 ret->setEndArray(arr2,0);
2564 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
2566 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2568 throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
2569 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray()));
2570 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2571 ret->setTimeTolerance(getTimeTolerance());
2572 ret->setArray(arr1,0);
2573 ret->setEndArray(arr2,0);
2577 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
2579 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2581 throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
2582 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray()));
2583 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2584 ret->setArray(arr1,0);
2585 ret->setEndArray(arr2,0);
2589 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
2591 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2593 throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
2594 MCAuto<DataArrayDouble> arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()));
2595 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2596 ret->setArray(arr1,0);
2597 ret->setEndArray(arr2,0);
2601 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
2603 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2605 throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
2606 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2607 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray()));
2608 ret->setArray(arr1,0);
2609 ret->setEndArray(arr2,0);
2613 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
2615 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2617 throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
2618 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray()));
2619 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2620 ret->setArray(arr1,0);
2621 ret->setEndArray(arr2,0);
2625 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
2627 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2629 throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
2630 MCAuto<DataArrayDouble> arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray()));
2631 MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
2632 ret->setArray(arr1,0);
2633 ret->setEndArray(arr2,0);
2637 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
2639 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2641 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2643 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array is NULL !");
2645 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::addEqual : Data Array (end) is NULL !");
2646 getArray()->addEqual(other->getArray());
2647 getEndArray()->addEqual(other->getEndArray());
2650 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
2652 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2654 throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
2655 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Substract(getArray(),other->getArray());
2656 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
2657 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2658 ret->setArray(arr1,0);
2659 ret->setEndArray(arr2,0);
2663 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
2665 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2667 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2669 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array is NULL !");
2671 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::substractEqual : Data Array (end) is NULL !");
2672 getArray()->substractEqual(other->getArray());
2673 getEndArray()->substractEqual(other->getEndArray());
2676 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
2678 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2680 throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
2681 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
2682 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
2683 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2684 ret->setArray(arr1,0);
2685 ret->setEndArray(arr2,0);
2689 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
2691 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2693 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2695 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array is NULL !");
2697 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::multiplyEqual : Data Array (end) is NULL !");
2698 getArray()->multiplyEqual(other->getArray());
2699 getEndArray()->multiplyEqual(other->getEndArray());
2702 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
2704 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2706 throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
2707 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Divide(getArray(),other->getArray());
2708 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
2709 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2710 ret->setArray(arr1,0);
2711 ret->setEndArray(arr2,0);
2715 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
2717 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2719 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2721 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array is NULL !");
2723 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::divideEqual : Data Array (end) is NULL !");
2724 getArray()->divideEqual(other->getArray());
2725 getEndArray()->divideEqual(other->getEndArray());
2728 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
2730 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2732 throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
2733 MCAuto<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
2734 MCAuto<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
2735 MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
2736 ret->setArray(arr1,0);
2737 ret->setEndArray(arr2,0);
2741 void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
2743 const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
2745 throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
2747 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
2749 throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
2750 getArray()->powEqual(other->getArray());
2751 getEndArray()->powEqual(other->getEndArray());