Back to index

salome-med  6.5.0
MEDCouplingTimeDiscretization.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingTimeDiscretization.hxx"
00021 #include "MEDCouplingMemArray.hxx"
00022 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
00023 
00024 #include <cmath>
00025 #include <sstream>
00026 #include <iterator>
00027 #include <algorithm>
00028 #include <functional>
00029 
00030 using namespace ParaMEDMEM;
00031 
00032 const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12;
00033 
00034 const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
00035 
00036 const char MEDCouplingNoTimeLabel::REPR[]="No time label defined.";
00037 
00038 const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
00039 
00040 const char MEDCouplingWithTimeStep::REPR[]="One time label.";
00041 
00042 const char MEDCouplingConstOnTimeInterval::EXCEPTION_MSG[]="No data on this time.";
00043 
00044 const char MEDCouplingConstOnTimeInterval::REPR[]="Constant on a time interval.";
00045 
00046 const char MEDCouplingTwoTimeSteps::EXCEPTION_MSG[]="No data on this time.";
00047 
00048 const char MEDCouplingLinearTime::REPR[]="Linear time between 2 time steps.";
00049 
00050 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
00051 {
00052   switch(type)
00053     {
00054     case MEDCouplingNoTimeLabel::DISCRETIZATION:
00055       return new MEDCouplingNoTimeLabel;
00056     case MEDCouplingWithTimeStep::DISCRETIZATION:
00057       return new MEDCouplingWithTimeStep;
00058     case MEDCouplingConstOnTimeInterval::DISCRETIZATION:
00059       return new MEDCouplingConstOnTimeInterval;
00060     case MEDCouplingLinearTime::DISCRETIZATION:
00061       return new MEDCouplingLinearTime;
00062     default:
00063       throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
00064     }
00065 }
00066 
00067 void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
00068 {
00069   _time_tolerance=other._time_tolerance;
00070   _time_unit=other._time_unit;
00071 }
00072 
00073 void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
00074 {
00075   _time_unit=other._time_unit;
00076   if(_array && other._array)
00077     _array->copyStringInfoFrom(*other._array);
00078 }
00079 
00080 void MEDCouplingTimeDiscretization::checkCoherency() const throw(INTERP_KERNEL::Exception)
00081 {
00082   if(!_array)
00083     throw INTERP_KERNEL::Exception("Field invalid because no values set !");
00084   if(_time_tolerance<0.)
00085     throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
00086 }
00087 
00088 void MEDCouplingTimeDiscretization::updateTime() const
00089 {
00090   if(_array)
00091     updateTimeWith(*_array);
00092 }
00093 
00094 bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
00095 {
00096   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
00097     return false;
00098   if(_array==0 && other->_array==0)
00099     return true;
00100   if(_array==0 || other->_array==0)
00101     return false;
00102   if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
00103     return false;
00104   return true;
00105 }
00106 
00107 bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
00108 {
00109   if(_time_unit!=other->_time_unit)
00110     return false;
00111   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
00112     return false;
00113   if(_array==0 && other->_array==0)
00114     return true;
00115   if(_array==0 || other->_array==0)
00116     return false;
00117   if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
00118     return false;
00119   if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
00120     return false;
00121   return true;
00122 }
00123 
00124 bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
00125 {
00126   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
00127     return false;
00128   if(_array==0 && other->_array==0)
00129     return true;
00130   if(_array==0 || other->_array==0)
00131     return false;
00132   if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
00133     return false;
00134   return true;
00135 }
00136 
00137 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
00138 {
00139   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
00140     return false;
00141   if(_array==0 && other->_array==0)
00142     return true;
00143   if(_array==0 || other->_array==0)
00144     return false;
00145   int nbC1=_array->getNumberOfComponents();
00146   int nbC2=other->_array->getNumberOfComponents();
00147   int nbMin=std::min(nbC1,nbC2);
00148   if(nbC1!=nbC2 && nbMin!=1)
00149     return false;
00150   return true;
00151 }
00152 
00153 bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
00154 {
00155   if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
00156     return false;
00157   if(_array==0 && other->_array==0)
00158     return true;
00159   if(_array==0 || other->_array==0)
00160     return false;
00161   int nbC1=_array->getNumberOfComponents();
00162   int nbC2=other->_array->getNumberOfComponents();
00163   if(nbC1!=nbC2 && nbC2!=1)
00164     return false;
00165   return true;
00166 }
00167 
00168 bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
00169 {
00170   if(!areStrictlyCompatible(other))
00171     return false;
00172   if(_array==other->_array)
00173     return true;
00174   return _array->isEqual(*other->_array,prec);
00175 }
00176 
00177 bool MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
00178 {
00179   if(!areStrictlyCompatible(other))
00180     return false;
00181   if(_array==other->_array)
00182     return true;
00183   return _array->isEqualWithoutConsideringStr(*other->_array,prec);
00184 }
00185 
00186 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const
00187 {
00188   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(type);
00189   ret->setTimeUnit(getTimeUnit());
00190   const DataArrayDouble *arrSrc=getArray();
00191   DataArrayDouble *arr=0;
00192   if(arrSrc)
00193     arr=arrSrc->performCpy(deepCpy);
00194   else
00195     arr=0;
00196   ret->setArray(arr,0);
00197   arr->decrRef();
00198   return ret;
00199 }
00200 
00201 void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
00202 {
00203   if(_array)
00204     {
00205       tinyInfo.push_back(_array->getNumberOfTuples());
00206       tinyInfo.push_back(_array->getNumberOfComponents());
00207     }
00208   else
00209     {
00210       tinyInfo.push_back(-1);
00211       tinyInfo.push_back(-1);
00212     }
00213 }
00214 
00215 void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
00216 {
00217   arrays.resize(1);
00218   if(_array!=0)
00219     _array->decrRef();
00220   DataArrayDouble *arr=0;
00221   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
00222     {
00223       arr=DataArrayDouble::New();
00224       arr->alloc(tinyInfoI[0],tinyInfoI[1]);
00225     }
00226   _array=arr;
00227   arrays[0]=arr;
00228 }
00229 
00230 void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
00231 {
00232   _time_tolerance=tinyInfoD[0];
00233   int nbOfCompo=_array->getNumberOfComponents();
00234   for(int i=0;i<nbOfCompo;i++)
00235     _array->setInfoOnComponent(i,tinyInfoS[i].c_str());
00236 }
00237 
00238 void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
00239 {
00240   tinyInfo.push_back(_time_tolerance);
00241 }
00242 
00243 void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
00244 {
00245   int nbOfCompo=_array->getNumberOfComponents();
00246   for(int i=0;i<nbOfCompo;i++)
00247     tinyInfo.push_back(_array->getInfoOnComponent(i));
00248 }
00249 
00250 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
00251 {
00252 }
00253 
00254 MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
00255 {
00256   if(other._array)
00257     _array=other._array->performCpy(deepCpy);
00258   else
00259     _array=0;
00260 }
00261 
00262 MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
00263 {
00264   if(_array)
00265     _array->decrRef();
00266 }
00267 
00268 void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
00269 {
00270   if(array!=_array)
00271     {
00272       if(_array)
00273         _array->decrRef();
00274       _array=array;
00275       if(_array)
00276         _array->incrRef();
00277       if(owner)
00278         owner->declareAsNew();
00279     }
00280 }
00281 
00282 const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
00283 {
00284   throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
00285 }
00286 
00287 DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray()
00288 {
00289   throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
00290 }
00291 
00292 void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner)
00293 {
00294   throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !");
00295 }
00296 
00297 void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
00298 {
00299   if(arrays.size()!=1)
00300     throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
00301   setArray(arrays.back(),owner);
00302 }
00303 
00304 void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
00305 {
00306   arrays.resize(1);
00307   arrays[0]=_array;
00308 }
00309 
00310 bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
00311 {
00312   int iteration,order;
00313   double time1=getEndTime(iteration,order)-_time_tolerance;
00314   double time2=other->getStartTime(iteration,order)+other->getTimeTolerance();
00315   return time1<=time2;
00316 }
00317 
00318 bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
00319 {
00320   int iteration,order;
00321   double time1=getEndTime(iteration,order)+_time_tolerance;
00322   double time2=other->getStartTime(iteration,order)-other->getTimeTolerance();
00323   return time1<time2;
00324 }
00325 
00326 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::doublyContractedProduct() const throw(INTERP_KERNEL::Exception)
00327 {
00328   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00329   ret->setTimeUnit(getTimeUnit());
00330   std::vector<DataArrayDouble *> arrays;
00331   getArrays(arrays);
00332   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00333   for(int j=0;j<(int)arrays.size();j++)
00334     {
00335       if(arrays[j])
00336         arrays2[j]=arrays[j]->doublyContractedProduct();
00337       else
00338         arrays2[j]=0;
00339     }
00340   std::vector<DataArrayDouble *> arrays3(arrays.size());
00341   for(int j=0;j<(int)arrays.size();j++)
00342     arrays3[j]=arrays2[j];
00343   ret->setArrays(arrays3,0);
00344   return ret;
00345 }
00346 
00347 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::determinant() const throw(INTERP_KERNEL::Exception)
00348 {
00349   std::vector<DataArrayDouble *> arrays;
00350   getArrays(arrays);
00351   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00352   for(int j=0;j<(int)arrays.size();j++)
00353     {
00354       if(arrays[j])
00355         arrays2[j]=arrays[j]->determinant();
00356       else
00357         arrays2[j]=0;
00358     }
00359   std::vector<DataArrayDouble *> arrays3(arrays.size());
00360   for(int j=0;j<(int)arrays.size();j++)
00361     arrays3[j]=arrays2[j];
00362   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00363   ret->setTimeUnit(getTimeUnit());
00364   ret->setArrays(arrays3,0);
00365   return ret;
00366 }
00367 
00368 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenValues() const throw(INTERP_KERNEL::Exception)
00369 {
00370   std::vector<DataArrayDouble *> arrays;
00371   getArrays(arrays);
00372   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00373   for(int j=0;j<(int)arrays.size();j++)
00374     {
00375       if(arrays[j])
00376         arrays2[j]=arrays[j]->eigenValues();
00377       else
00378         arrays2[j]=0;
00379     }
00380   std::vector<DataArrayDouble *> arrays3(arrays.size());
00381   for(int j=0;j<(int)arrays.size();j++)
00382     arrays3[j]=arrays2[j];
00383   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00384   ret->setTimeUnit(getTimeUnit());
00385   ret->setArrays(arrays3,0);
00386   return ret;
00387 }
00388 
00389 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::eigenVectors() const throw(INTERP_KERNEL::Exception)
00390 {
00391   std::vector<DataArrayDouble *> arrays;
00392   getArrays(arrays);
00393   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00394   for(int j=0;j<(int)arrays.size();j++)
00395     {
00396       if(arrays[j])
00397         arrays2[j]=arrays[j]->eigenVectors();
00398       else
00399         arrays2[j]=0;
00400     }
00401   std::vector<DataArrayDouble *> arrays3(arrays.size());
00402   for(int j=0;j<(int)arrays.size();j++)
00403     arrays3[j]=arrays2[j];
00404   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00405   ret->setTimeUnit(getTimeUnit());
00406   ret->setArrays(arrays3,0);
00407   return ret;
00408 }
00409 
00410 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::inverse() const throw(INTERP_KERNEL::Exception)
00411 {
00412   std::vector<DataArrayDouble *> arrays;
00413   getArrays(arrays);
00414   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00415   for(int j=0;j<(int)arrays.size();j++)
00416     {
00417       if(arrays[j])
00418         arrays2[j]=arrays[j]->inverse();
00419       else
00420         arrays2[j]=0;
00421     }
00422   std::vector<DataArrayDouble *> arrays3(arrays.size());
00423   for(int j=0;j<(int)arrays.size();j++)
00424     arrays3[j]=arrays2[j];
00425   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00426   ret->setTimeUnit(getTimeUnit());
00427   ret->setArrays(arrays3,0);
00428   return ret;
00429 }
00430 
00431 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::trace() const throw(INTERP_KERNEL::Exception)
00432 {
00433   std::vector<DataArrayDouble *> arrays;
00434   getArrays(arrays);
00435   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00436   for(int j=0;j<(int)arrays.size();j++)
00437     {
00438       if(arrays[j])
00439         arrays2[j]=arrays[j]->trace();
00440       else
00441         arrays2[j]=0;
00442     }
00443   std::vector<DataArrayDouble *> arrays3(arrays.size());
00444   for(int j=0;j<(int)arrays.size();j++)
00445     arrays3[j]=arrays2[j];
00446   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00447   ret->setTimeUnit(getTimeUnit());
00448   ret->setArrays(arrays3,0);
00449   return ret;
00450 }
00451 
00452 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::deviator() const throw(INTERP_KERNEL::Exception)
00453 {
00454   std::vector<DataArrayDouble *> arrays;
00455   getArrays(arrays);
00456   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00457   for(int j=0;j<(int)arrays.size();j++)
00458     {
00459       if(arrays[j])
00460         arrays2[j]=arrays[j]->deviator();
00461       else
00462         arrays2[j]=0;
00463     }
00464   std::vector<DataArrayDouble *> arrays3(arrays.size());
00465   for(int j=0;j<(int)arrays.size();j++)
00466     arrays3[j]=arrays2[j];
00467   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00468   ret->setTimeUnit(getTimeUnit());
00469   ret->setArrays(arrays3,0);
00470   return ret;
00471 }
00472 
00473 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::magnitude() const throw(INTERP_KERNEL::Exception)
00474 {
00475   std::vector<DataArrayDouble *> arrays;
00476   getArrays(arrays);
00477   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00478   for(int j=0;j<(int)arrays.size();j++)
00479     {
00480       if(arrays[j])
00481         arrays2[j]=arrays[j]->magnitude();
00482       else
00483         arrays2[j]=0;
00484     }
00485   std::vector<DataArrayDouble *> arrays3(arrays.size());
00486   for(int j=0;j<(int)arrays.size();j++)
00487     arrays3[j]=arrays2[j];
00488   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00489   ret->setTimeUnit(getTimeUnit());
00490   ret->setArrays(arrays3,0);
00491   return ret;
00492 }
00493 
00494 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::maxPerTuple() const throw(INTERP_KERNEL::Exception)
00495 {
00496   std::vector<DataArrayDouble *> arrays;
00497   getArrays(arrays);
00498   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00499   for(int j=0;j<(int)arrays.size();j++)
00500     {
00501       if(arrays[j])
00502         arrays2[j]=arrays[j]->maxPerTuple();
00503       else
00504         arrays2[j]=0;
00505     }
00506   std::vector<DataArrayDouble *> arrays3(arrays.size());
00507   for(int j=0;j<(int)arrays.size();j++)
00508     arrays3[j]=arrays2[j];
00509   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00510   ret->setTimeUnit(getTimeUnit());
00511   ret->setArrays(arrays3,0);
00512   return ret;
00513 }
00514 
00515 MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception)
00516 {
00517   std::vector<DataArrayDouble *> arrays;
00518   getArrays(arrays);
00519   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00520   for(int j=0;j<(int)arrays.size();j++)
00521     {
00522       if(arrays[j])
00523         arrays2[j]=arrays[j]->keepSelectedComponents(compoIds);
00524       else
00525         arrays2[j]=0;
00526     }
00527   std::vector<DataArrayDouble *> arrays3(arrays.size());
00528   for(int j=0;j<(int)arrays.size();j++)
00529     arrays3[j]=arrays2[j];
00530   MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
00531   ret->setTimeUnit(getTimeUnit());
00532   ret->setArrays(arrays3,0);
00533   return ret;
00534 }
00535 
00536 void MEDCouplingTimeDiscretization::setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception)
00537 {
00538   std::vector<DataArrayDouble *> arrays1,arrays2;
00539   getArrays(arrays1);
00540   other->getArrays(arrays2);
00541   if(arrays1.size()!=arrays2.size())
00542     throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
00543   for(unsigned int i=0;i<arrays1.size();i++)
00544     {
00545       if(arrays1[i]!=0 && arrays2[i]!=0)
00546         arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
00547       else if(arrays1[i]!=0 || arrays2[i]!=0)
00548         throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : some time array in correspondance are not defined symetrically !");
00549     }
00550 }
00551 
00552 void MEDCouplingTimeDiscretization::changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception)
00553 {
00554   std::vector<DataArrayDouble *> arrays;
00555   getArrays(arrays);
00556   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00557   for(int j=0;j<(int)arrays.size();j++)
00558     {
00559       if(arrays[j])
00560         arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
00561       else
00562         arrays2[j]=0;
00563     }
00564   std::vector<DataArrayDouble *> arrays3(arrays.size());
00565   for(int j=0;j<(int)arrays.size();j++)
00566     arrays3[j]=arrays2[j];
00567   setArrays(arrays3,0);
00568 }
00569 
00570 void MEDCouplingTimeDiscretization::sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception)
00571 {
00572   std::vector<DataArrayDouble *> arrays;
00573   getArrays(arrays);
00574   for(int j=0;j<(int)arrays.size();j++)
00575     {
00576       if(arrays[j])
00577         arrays[j]->sortPerTuple(asc);
00578     }
00579 }
00580 
00581 void MEDCouplingTimeDiscretization::setUniformValue(int nbOfTuple, int nbOfCompo, double value)
00582 {
00583   std::vector<DataArrayDouble *> arrays;
00584   getArrays(arrays);
00585   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00586   for(int j=0;j<(int)arrays.size();j++)
00587     {
00588       if(arrays[j])
00589         {
00590           arrays[j]->incrRef();
00591           arrays[j]->fillWithValue(value);
00592           arrays2[j]=arrays[j];
00593         }
00594       else
00595         {
00596           DataArrayDouble *tmp=DataArrayDouble::New();
00597           tmp->alloc(nbOfTuple,nbOfCompo);
00598           tmp->fillWithValue(value);
00599           arrays2[j]=tmp;
00600         }
00601     }
00602   std::vector<DataArrayDouble *> arrays3(arrays.size());
00603   for(int j=0;j<(int)arrays.size();j++)
00604     arrays3[j]=arrays2[j];
00605   setArrays(arrays3,0);
00606 }
00607 
00608 void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
00609 {
00610   std::vector<DataArrayDouble *> arrays;
00611   getArrays(arrays);
00612   for(int j=0;j<(int)arrays.size();j++)
00613     {
00614       if(arrays[j])
00615         arrays[j]->applyLin(a,b,compoId);
00616     }
00617 }
00618 
00619 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, FunctionToEvaluate func)
00620 {
00621   std::vector<DataArrayDouble *> arrays;
00622   getArrays(arrays);
00623   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00624   for(int j=0;j<(int)arrays.size();j++)
00625     {
00626       if(arrays[j])
00627         arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
00628       else
00629         arrays2[j]=0;
00630     }
00631   std::vector<DataArrayDouble *> arrays3(arrays.size());
00632   for(int j=0;j<(int)arrays.size();j++)
00633     arrays3[j]=arrays2[j];
00634   setArrays(arrays3,0);
00635 }
00636 
00637 void MEDCouplingTimeDiscretization::applyFunc(int nbOfComp, const char *func)
00638 {
00639   std::vector<DataArrayDouble *> arrays;
00640   getArrays(arrays);
00641   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00642   for(int j=0;j<(int)arrays.size();j++)
00643     {
00644       if(arrays[j])
00645         arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
00646       else
00647         arrays2[j]=0;
00648     }
00649   std::vector<DataArrayDouble *> arrays3(arrays.size());
00650   for(int j=0;j<(int)arrays.size();j++)
00651     arrays3[j]=arrays2[j];
00652   setArrays(arrays3,0);
00653 }
00654 
00655 void MEDCouplingTimeDiscretization::applyFunc2(int nbOfComp, const char *func)
00656 {
00657   std::vector<DataArrayDouble *> arrays;
00658   getArrays(arrays);
00659   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00660   for(int j=0;j<(int)arrays.size();j++)
00661     {
00662       if(arrays[j])
00663         arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
00664       else
00665         arrays2[j]=0;
00666     }
00667   std::vector<DataArrayDouble *> arrays3(arrays.size());
00668   for(int j=0;j<(int)arrays.size();j++)
00669     arrays3[j]=arrays2[j];
00670   setArrays(arrays3,0);
00671 }
00672 
00673 void MEDCouplingTimeDiscretization::applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func)
00674 {
00675   std::vector<DataArrayDouble *> arrays;
00676   getArrays(arrays);
00677   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00678   for(int j=0;j<(int)arrays.size();j++)
00679     {
00680       if(arrays[j])
00681         arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
00682       else
00683         arrays2[j]=0;
00684     }
00685   std::vector<DataArrayDouble *> arrays3(arrays.size());
00686   for(int j=0;j<(int)arrays.size();j++)
00687     arrays3[j]=arrays2[j];
00688   setArrays(arrays3,0);
00689 }
00690 
00691 void MEDCouplingTimeDiscretization::applyFunc(const char *func)
00692 {
00693   std::vector<DataArrayDouble *> arrays;
00694   getArrays(arrays);
00695   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00696   for(int j=0;j<(int)arrays.size();j++)
00697     {
00698       if(arrays[j])
00699         arrays2[j]=arrays[j]->applyFunc(func);
00700       else
00701         arrays2[j]=0;
00702     }
00703   std::vector<DataArrayDouble *> arrays3(arrays.size());
00704   for(int j=0;j<(int)arrays.size();j++)
00705     arrays3[j]=arrays2[j];
00706   setArrays(arrays3,0);
00707 }
00708 
00709 void MEDCouplingTimeDiscretization::applyFuncFast32(const char *func)
00710 {
00711   std::vector<DataArrayDouble *> arrays;
00712   getArrays(arrays);
00713   for(int j=0;j<(int)arrays.size();j++)
00714     {
00715       if(arrays[j])
00716         arrays[j]->applyFuncFast32(func);
00717     }
00718 }
00719 
00720 void MEDCouplingTimeDiscretization::applyFuncFast64(const char *func)
00721 {
00722   std::vector<DataArrayDouble *> arrays;
00723   getArrays(arrays);
00724   for(int j=0;j<(int)arrays.size();j++)
00725     {
00726       if(arrays[j])
00727         arrays[j]->applyFuncFast64(func);
00728     }
00729 }
00730 
00731 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception)
00732 {
00733   std::vector<DataArrayDouble *> arrays;
00734   getArrays(arrays);
00735   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00736   for(int j=0;j<(int)arrays.size();j++)
00737     arrays2[j]=loc->applyFunc(nbOfComp,func);
00738   std::vector<DataArrayDouble *> arrays3(arrays.size());
00739   for(int j=0;j<(int)arrays.size();j++)
00740     arrays3[j]=arrays2[j];
00741   setArrays(arrays3,0);
00742 }
00743 
00744 void MEDCouplingTimeDiscretization::fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00745 {
00746   std::vector<DataArrayDouble *> arrays;
00747   getArrays(arrays);
00748   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00749   for(int j=0;j<(int)arrays.size();j++)
00750     arrays2[j]=loc->applyFunc(nbOfComp,func);
00751   std::vector<DataArrayDouble *> arrays3(arrays.size());
00752   for(int j=0;j<(int)arrays.size();j++)
00753     arrays3[j]=arrays2[j];
00754   setArrays(arrays3,0);
00755 }
00756 
00757 void MEDCouplingTimeDiscretization::fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception)
00758 {
00759   std::vector<DataArrayDouble *> arrays;
00760   getArrays(arrays);
00761   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00762   for(int j=0;j<(int)arrays.size();j++)
00763     arrays2[j]=loc->applyFunc2(nbOfComp,func);
00764   std::vector<DataArrayDouble *> arrays3(arrays.size());
00765   for(int j=0;j<(int)arrays.size();j++)
00766     arrays3[j]=arrays2[j];
00767   setArrays(arrays3,0);
00768 }
00769 
00770 void MEDCouplingTimeDiscretization::fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception)
00771 {
00772   std::vector<DataArrayDouble *> arrays;
00773   getArrays(arrays);
00774   std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
00775   for(int j=0;j<(int)arrays.size();j++)
00776     arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
00777   std::vector<DataArrayDouble *> arrays3(arrays.size());
00778   for(int j=0;j<(int)arrays.size();j++)
00779     arrays3[j]=arrays2[j];
00780   setArrays(arrays3,0);
00781 }
00782 
00783 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
00784 {
00785 }
00786 
00787 MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
00788 {
00789 }
00790 
00791 std::string MEDCouplingNoTimeLabel::getStringRepr() const
00792 {
00793   std::ostringstream stream;
00794   stream << REPR;
00795   stream << "\nTime unit is : \"" << _time_unit << "\"";
00796   return stream.str();
00797 }
00798 
00799 bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
00800 {
00801   if(!MEDCouplingTimeDiscretization::areCompatible(other))
00802     return false;
00803   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00804   return otherC!=0;
00805 }
00806 
00807 bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
00808 {
00809   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
00810     return false;
00811   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00812   return otherC!=0;
00813 }
00814 
00815 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
00816 {
00817   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
00818     return false;
00819   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00820   return otherC!=0;
00821 }
00822 
00823 bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
00824 {
00825   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
00826     return false;
00827   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00828   return otherC!=0;
00829 }
00830 
00831 bool MEDCouplingNoTimeLabel::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
00832 {
00833   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
00834     return false;
00835   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00836   return otherC!=0;
00837 }
00838 
00839 bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
00840 {
00841   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00842   if(!otherC)
00843     return false;
00844   return MEDCouplingTimeDiscretization::isEqual(other,prec);
00845 }
00846 
00847 bool MEDCouplingNoTimeLabel::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
00848 {
00849   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00850   if(!otherC)
00851     return false;
00852   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
00853 }
00854 
00855 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const MEDCouplingTimeDiscretization *other) const
00856 {
00857   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00858   if(!otherC)
00859     throw INTERP_KERNEL::Exception("NoTimeLabel::aggregation on mismatched time discretization !");
00860   DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
00861   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00862   ret->setArray(arr,0);
00863   arr->decrRef();
00864   return ret;
00865 }
00866 
00867 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
00868 {
00869   std::vector<const DataArrayDouble *> a(other.size());
00870   int i=0;
00871   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
00872     {
00873       const MEDCouplingNoTimeLabel *itC=dynamic_cast<const MEDCouplingNoTimeLabel *>(*it);
00874       if(!itC)
00875         throw INTERP_KERNEL::Exception("NoTimeLabel::aggregate on mismatched time discretization !");
00876       a[i]=itC->getArray();
00877     }
00878   DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
00879   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00880   ret->setArray(arr,0);
00881   arr->decrRef();
00882   return ret;
00883 }
00884 
00885 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::meld(const MEDCouplingTimeDiscretization *other) const
00886 {
00887   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00888   if(!otherC)
00889     throw INTERP_KERNEL::Exception("NoTimeLabel::meld on mismatched time discretization !");
00890   DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
00891   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00892   ret->setTimeTolerance(getTimeTolerance());
00893   ret->setArray(arr,0);
00894   arr->decrRef();
00895   return ret;
00896 }
00897 
00898 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::dot(const MEDCouplingTimeDiscretization *other) const
00899 {
00900   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00901   if(!otherC)
00902     throw INTERP_KERNEL::Exception("NoTimeLabel::dot on mismatched time discretization !");
00903   DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
00904   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00905   ret->setArray(arr,0);
00906   arr->decrRef();
00907   return ret;
00908 }
00909 
00910 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::crossProduct(const MEDCouplingTimeDiscretization *other) const
00911 {
00912   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00913   if(!otherC)
00914     throw INTERP_KERNEL::Exception("NoTimeLabel::crossProduct on mismatched time discretization !");
00915   DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
00916   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00917   ret->setArray(arr,0);
00918   arr->decrRef();
00919   return ret;
00920 }
00921 
00922 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::max(const MEDCouplingTimeDiscretization *other) const
00923 {
00924   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00925   if(!otherC)
00926     throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
00927   DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
00928   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00929   ret->setArray(arr,0);
00930   arr->decrRef();
00931   return ret;
00932 }
00933 
00934 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::min(const MEDCouplingTimeDiscretization *other) const
00935 {
00936   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00937   if(!otherC)
00938     throw INTERP_KERNEL::Exception("NoTimeLabel::max on mismatched time discretization !");
00939   DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
00940   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00941   ret->setArray(arr,0);
00942   arr->decrRef();
00943   return ret;
00944 }
00945 
00946 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::add(const MEDCouplingTimeDiscretization *other) const
00947 {
00948   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00949   if(!otherC)
00950     throw INTERP_KERNEL::Exception("NoTimeLabel::add on mismatched time discretization !");
00951   DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
00952   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00953   ret->setArray(arr,0);
00954   arr->decrRef();
00955   return ret;
00956 }
00957 
00958 void MEDCouplingNoTimeLabel::addEqual(const MEDCouplingTimeDiscretization *other)
00959 {
00960   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00961   if(!otherC)
00962     throw INTERP_KERNEL::Exception("NoTimeLabel::addEqual on mismatched time discretization !");
00963   getArray()->addEqual(other->getArray());
00964 }
00965 
00966 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::substract(const MEDCouplingTimeDiscretization *other) const
00967 {
00968   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00969   if(!otherC)
00970     throw INTERP_KERNEL::Exception("NoTimeLabel::substract on mismatched time discretization !");
00971   DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
00972   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00973   ret->setArray(arr,0);
00974   arr->decrRef();
00975   return ret;
00976 }
00977 
00978 void MEDCouplingNoTimeLabel::substractEqual(const MEDCouplingTimeDiscretization *other)
00979 {
00980   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00981   if(!otherC)
00982     throw INTERP_KERNEL::Exception("NoTimeLabel::substractEqual on mismatched time discretization !");
00983   getArray()->substractEqual(other->getArray());
00984 }
00985 
00986 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::multiply(const MEDCouplingTimeDiscretization *other) const
00987 {
00988   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
00989   if(!otherC)
00990     throw INTERP_KERNEL::Exception("NoTimeLabel::multiply on mismatched time discretization !");
00991   DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
00992   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
00993   ret->setArray(arr,0);
00994   arr->decrRef();
00995   return ret;
00996 }
00997 
00998 void MEDCouplingNoTimeLabel::multiplyEqual(const MEDCouplingTimeDiscretization *other)
00999 {
01000   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
01001   if(!otherC)
01002     throw INTERP_KERNEL::Exception("NoTimeLabel::multiplyEqual on mismatched time discretization !");
01003   getArray()->multiplyEqual(other->getArray());
01004 }
01005 
01006 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::divide(const MEDCouplingTimeDiscretization *other) const
01007 {
01008   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
01009   if(!otherC)
01010     throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
01011   DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
01012   MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
01013   ret->setArray(arr,0);
01014   arr->decrRef();
01015   return ret;
01016 }
01017 
01018 void MEDCouplingNoTimeLabel::divideEqual(const MEDCouplingTimeDiscretization *other)
01019 {
01020   const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
01021   if(!otherC)
01022     throw INTERP_KERNEL::Exception("NoTimeLabel::divideEqual on mismatched time discretization !");
01023   getArray()->divideEqual(other->getArray());
01024 }
01025 
01026 MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
01027 {
01028   return new MEDCouplingNoTimeLabel(*this,deepCpy);
01029 }
01030 
01031 void MEDCouplingNoTimeLabel::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
01032 {
01033   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01034 }
01035 
01036 std::vector< const DataArrayDouble *> MEDCouplingNoTimeLabel::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
01037 {
01038   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01039 }
01040 
01041 void MEDCouplingNoTimeLabel::getValueForTime(double time, const std::vector<double>& vals, double *res) const
01042 {
01043   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01044 }
01045 
01046 bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
01047 {
01048   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01049 }
01050 
01051 bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
01052 {
01053   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01054 }
01055 
01056 double MEDCouplingNoTimeLabel::getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
01057 {
01058   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01059 }
01060 
01061 double MEDCouplingNoTimeLabel::getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception)
01062 {
01063   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01064 }
01065 
01066 void MEDCouplingNoTimeLabel::setStartIteration(int it) throw(INTERP_KERNEL::Exception)
01067 {
01068   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01069 }
01070 
01071 void MEDCouplingNoTimeLabel::setEndIteration(int it) throw(INTERP_KERNEL::Exception)
01072 {
01073   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01074 }
01075 
01076 void MEDCouplingNoTimeLabel::setStartOrder(int order) throw(INTERP_KERNEL::Exception)
01077 {
01078   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01079 }
01080 
01081 void MEDCouplingNoTimeLabel::setEndOrder(int order) throw(INTERP_KERNEL::Exception)
01082 {
01083   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01084 }
01085 
01086 void MEDCouplingNoTimeLabel::setStartTimeValue(double time) throw(INTERP_KERNEL::Exception)
01087 {
01088   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01089 }
01090 
01091 void MEDCouplingNoTimeLabel::setEndTimeValue(double time) throw(INTERP_KERNEL::Exception)
01092 {
01093   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01094 }
01095 
01096 void MEDCouplingNoTimeLabel::setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
01097 {
01098   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01099 }
01100 
01101 void MEDCouplingNoTimeLabel::setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception)
01102 {
01103   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01104 }
01105 
01106 void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
01107 {
01108   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01109 }
01110 
01111 void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
01112 {
01113   throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01114 }
01115 
01119 void MEDCouplingNoTimeLabel::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
01120 {
01121   tinyInfo.clear();
01122 }
01123 
01127 void MEDCouplingNoTimeLabel::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
01128 {
01129   tinyInfo.resize(1);
01130   tinyInfo[0]=_time_tolerance;
01131 }
01132 
01136 void MEDCouplingNoTimeLabel::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
01137 {
01138   _time_tolerance=tinyInfoD[0];
01139 }
01140 
01141 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
01142                                                                                                      _time(other._time),_iteration(other._iteration),_order(other._order)
01143 {
01144 }
01145 
01146 MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
01147 {
01148 }
01149 
01150 std::string MEDCouplingWithTimeStep::getStringRepr() const
01151 {
01152   std::ostringstream stream;
01153   stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
01154   stream << "\nTime unit is : \"" << _time_unit << "\"";
01155   return stream.str();
01156 }
01157 
01158 void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
01159 {
01160   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
01161   tinyInfo.push_back(_iteration);
01162   tinyInfo.push_back(_order);
01163 }
01164 
01165 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
01166 {
01167   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
01168   tinyInfo.push_back(_time);
01169 }
01170 
01171 void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
01172 {
01173   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
01174   _time=tinyInfoD[1];
01175   _iteration=tinyInfoI[2];
01176   _order=tinyInfoI[3];
01177 }
01178 
01182 void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
01183 {
01184   tinyInfo.resize(2);
01185   tinyInfo[0]=_iteration;
01186   tinyInfo[1]=_order;
01187 }
01188 
01192 void MEDCouplingWithTimeStep::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
01193 {
01194   tinyInfo.resize(2);
01195   tinyInfo[0]=_time_tolerance;
01196   tinyInfo[1]=_time;
01197 }
01198 
01202 void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
01203 {
01204   _iteration=tinyInfoI[0];
01205   _order=tinyInfoI[1];
01206   _time_tolerance=tinyInfoD[0];
01207   _time=tinyInfoD[1];
01208 }
01209 
01210 bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
01211 {
01212   if(!MEDCouplingTimeDiscretization::areCompatible(other))
01213     return false;
01214   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01215   return otherC!=0;
01216 }
01217 
01218 bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
01219 {
01220   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
01221     return false;
01222   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01223   return otherC!=0;
01224 }
01225 
01226 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
01227 {
01228   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
01229     return false;
01230   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01231   return otherC!=0;
01232 }
01233 
01234 bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
01235 {
01236   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
01237     return false;
01238   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01239   return otherC!=0;
01240 }
01241 
01242 bool MEDCouplingWithTimeStep::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
01243 {
01244   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
01245     return false;
01246   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01247   return otherC!=0;
01248 }
01249 
01250 bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
01251 {
01252   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01253   if(!otherC)
01254     return false;
01255   if(_iteration!=otherC->_iteration)
01256     return false;
01257   if(_order!=otherC->_order)
01258     return false;
01259   if(std::fabs(_time-otherC->_time)>_time_tolerance)
01260     return false;
01261   return MEDCouplingTimeDiscretization::isEqual(other,prec);
01262 }
01263 
01264 bool MEDCouplingWithTimeStep::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
01265 {
01266   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01267   if(!otherC)
01268     return false;
01269   if(_iteration!=otherC->_iteration)
01270     return false;
01271   if(_order!=otherC->_order)
01272     return false;
01273   if(std::fabs(_time-otherC->_time)>_time_tolerance)
01274     return false;
01275   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
01276 }
01277 
01278 void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
01279 {
01280   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
01281   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
01282   if(!otherC)
01283     throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
01284   _time=otherC->_time;
01285   _iteration=otherC->_iteration;
01286   _order=otherC->_order;
01287 }
01288 
01289 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
01290 {
01291   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01292   if(!otherC)
01293     throw INTERP_KERNEL::Exception("WithTimeStep::aggregation on mismatched time discretization !");
01294   DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
01295   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01296   ret->setArray(arr,0);
01297   arr->decrRef();
01298   return ret;
01299 }
01300 
01301 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
01302 {
01303   std::vector<const DataArrayDouble *> a(other.size());
01304   int i=0;
01305   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
01306     {
01307       const MEDCouplingWithTimeStep *itC=dynamic_cast<const MEDCouplingWithTimeStep *>(*it);
01308       if(!itC)
01309         throw INTERP_KERNEL::Exception("WithTimeStep::aggregate on mismatched time discretization !");
01310       a[i]=itC->getArray();
01311     }
01312   DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
01313   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01314   ret->setArray(arr,0);
01315   arr->decrRef();
01316   return ret;
01317 }
01318 
01319 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::meld(const MEDCouplingTimeDiscretization *other) const
01320 {
01321   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01322   if(!otherC)
01323     throw INTERP_KERNEL::Exception("WithTimeStep::meld on mismatched time discretization !");
01324   DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
01325   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01326   ret->setArray(arr,0);
01327   arr->decrRef();
01328   return ret;
01329 }
01330 
01331 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::dot(const MEDCouplingTimeDiscretization *other) const
01332 {
01333   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01334   if(!otherC)
01335     throw INTERP_KERNEL::Exception("WithTimeStep::dot on mismatched time discretization !");
01336   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01337   DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
01338   ret->setArray(arr,0);
01339   arr->decrRef();
01340   return ret;
01341 }
01342 
01343 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::crossProduct(const MEDCouplingTimeDiscretization *other) const
01344 {
01345   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01346   if(!otherC)
01347     throw INTERP_KERNEL::Exception("WithTimeStep::crossProduct on mismatched time discretization !");
01348   DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
01349   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01350   ret->setArray(arr,0);
01351   arr->decrRef();
01352   return ret;
01353 }
01354 
01355 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::max(const MEDCouplingTimeDiscretization *other) const
01356 {
01357   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01358   if(!otherC)
01359     throw INTERP_KERNEL::Exception("WithTimeStep::max on mismatched time discretization !");
01360   DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
01361   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01362   ret->setArray(arr,0);
01363   arr->decrRef();
01364   return ret;
01365 }
01366 
01367 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::min(const MEDCouplingTimeDiscretization *other) const
01368 {
01369   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01370   if(!otherC)
01371     throw INTERP_KERNEL::Exception("WithTimeStep::min on mismatched time discretization !");
01372   DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
01373   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01374   ret->setArray(arr,0);
01375   arr->decrRef();
01376   return ret;
01377 }
01378 
01379 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::add(const MEDCouplingTimeDiscretization *other) const
01380 {
01381   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01382   if(!otherC)
01383     throw INTERP_KERNEL::Exception("WithTimeStep::add on mismatched time discretization !");
01384   DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
01385   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01386   ret->setArray(arr,0);
01387   arr->decrRef();
01388   int tmp1,tmp2;
01389   double tmp3=getStartTime(tmp1,tmp2);
01390   ret->setStartTime(tmp3,tmp1,tmp2);
01391   return ret;
01392 }
01393 
01394 void MEDCouplingWithTimeStep::addEqual(const MEDCouplingTimeDiscretization *other)
01395 {
01396   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01397   if(!otherC)
01398     throw INTERP_KERNEL::Exception("WithTimeStep::addEqual on mismatched time discretization !");
01399   getArray()->addEqual(other->getArray());
01400 }
01401 
01402 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::substract(const MEDCouplingTimeDiscretization *other) const
01403 {
01404   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01405   if(!otherC)
01406     throw INTERP_KERNEL::Exception("WithTimeStep::substract on mismatched time discretization !");
01407   DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
01408   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01409   ret->setArray(arr,0);
01410   arr->decrRef();
01411   int tmp1,tmp2;
01412   double tmp3=getStartTime(tmp1,tmp2);
01413   ret->setStartTime(tmp3,tmp1,tmp2);
01414   return ret;
01415 }
01416 
01417 void MEDCouplingWithTimeStep::substractEqual(const MEDCouplingTimeDiscretization *other)
01418 {
01419   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01420   if(!otherC)
01421     throw INTERP_KERNEL::Exception("WithTimeStep::substractEqual on mismatched time discretization !");
01422   getArray()->substractEqual(other->getArray());
01423 }
01424 
01425 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::multiply(const MEDCouplingTimeDiscretization *other) const
01426 {
01427   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01428   if(!otherC)
01429     throw INTERP_KERNEL::Exception("WithTimeStep::multiply on mismatched time discretization !");
01430   DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
01431   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01432   ret->setArray(arr,0);
01433   arr->decrRef();
01434   int tmp1,tmp2;
01435   double tmp3=getStartTime(tmp1,tmp2);
01436   ret->setStartTime(tmp3,tmp1,tmp2);
01437   return ret;
01438 }
01439 
01440 void MEDCouplingWithTimeStep::multiplyEqual(const MEDCouplingTimeDiscretization *other)
01441 {
01442   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01443   if(!otherC)
01444     throw INTERP_KERNEL::Exception("WithTimeStep::multiplyEqual on mismatched time discretization !");
01445   getArray()->multiplyEqual(other->getArray());
01446 }
01447 
01448 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::divide(const MEDCouplingTimeDiscretization *other) const
01449 {
01450   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01451   if(!otherC)
01452     throw INTERP_KERNEL::Exception("WithTimeStep::divide on mismatched time discretization !");
01453   DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
01454   MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
01455   ret->setArray(arr,0);
01456   arr->decrRef();
01457   int tmp1,tmp2;
01458   double tmp3=getStartTime(tmp1,tmp2);
01459   ret->setStartTime(tmp3,tmp1,tmp2);
01460   return ret;
01461 }
01462 
01463 void MEDCouplingWithTimeStep::divideEqual(const MEDCouplingTimeDiscretization *other)
01464 {
01465   const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
01466   if(!otherC)
01467     throw INTERP_KERNEL::Exception("WithTimeStep::divideEqual on mismatched time discretization !");
01468   getArray()->divideEqual(other->getArray());
01469 }
01470 
01471 MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
01472 {
01473   return new MEDCouplingWithTimeStep(*this,deepCpy);
01474 }
01475 
01476 void MEDCouplingWithTimeStep::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
01477 {
01478   throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
01479 }
01480 
01481 void MEDCouplingWithTimeStep::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
01482 {
01483   if(std::fabs(time-_time)>_time_tolerance)
01484     {
01485       std::ostringstream stream;
01486       stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
01487       throw INTERP_KERNEL::Exception(stream.str().c_str());
01488     }
01489 }
01490 
01491 std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
01492 {
01493   if(std::fabs(time-_time)<=_time_tolerance)
01494     {
01495       std::vector< const DataArrayDouble *> ret(1);
01496       ret[0]=_array;
01497       return ret;
01498     }
01499   else
01500     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01501 }
01502 
01503 void MEDCouplingWithTimeStep::getValueForTime(double time, const std::vector<double>& vals, double *res) const
01504 {
01505   std::copy(vals.begin(),vals.end(),res);
01506 }
01507 
01508 void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
01509 {
01510   if(std::fabs(time-_time)<=_time_tolerance)
01511     if(_array)
01512       _array->getTuple(eltId,value);
01513     else
01514       throw INTERP_KERNEL::Exception("No array existing.");
01515   else
01516     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01517 }
01518 
01519 void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
01520 {
01521   if(_iteration==iteration && _order==order)
01522     if(_array)
01523       _array->getTuple(eltId,value);
01524     else
01525       throw INTERP_KERNEL::Exception("No array existing.");
01526   else
01527     throw INTERP_KERNEL::Exception("No data on this discrete time.");
01528 }
01529 
01530 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
01531 {
01532 }
01533 
01534 void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
01535 {
01536   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
01537   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
01538   if(!otherC)
01539     throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::copyTinyAttrFrom : mismatch of time discretization !");
01540   _start_time=otherC->_start_time;
01541   _end_time=otherC->_end_time;
01542   _start_iteration=otherC->_start_iteration;
01543   _end_iteration=otherC->_end_iteration;
01544   _start_order=otherC->_start_order;
01545   _end_order=otherC->_end_order;
01546 }
01547 
01548 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
01549 {
01550   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
01551   tinyInfo.push_back(_start_iteration);
01552   tinyInfo.push_back(_start_order);
01553   tinyInfo.push_back(_end_iteration);
01554   tinyInfo.push_back(_end_order);
01555 }
01556 
01557 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
01558 {
01559   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
01560   tinyInfo.push_back(_start_time);
01561   tinyInfo.push_back(_end_time);
01562 }
01563 
01564 void MEDCouplingConstOnTimeInterval::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
01565 {
01566   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
01567   _start_time=tinyInfoD[1];
01568   _end_time=tinyInfoD[2];
01569   _start_iteration=tinyInfoI[2];
01570   _start_order=tinyInfoI[3];
01571   _end_iteration=tinyInfoI[4];
01572   _end_order=tinyInfoI[5];
01573 }
01574 
01578 void MEDCouplingConstOnTimeInterval::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
01579 {
01580   tinyInfo.resize(4);
01581   tinyInfo[0]=_start_iteration;
01582   tinyInfo[1]=_start_order;
01583   tinyInfo[2]=_end_iteration;
01584   tinyInfo[3]=_end_order;
01585 }
01586 
01590 void MEDCouplingConstOnTimeInterval::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
01591 {
01592   tinyInfo.resize(3);
01593   tinyInfo[0]=_time_tolerance;
01594   tinyInfo[1]=_start_time;
01595   tinyInfo[2]=_end_time;
01596 }
01597 
01601 void MEDCouplingConstOnTimeInterval::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
01602 {
01603   _start_iteration=tinyInfoI[0];
01604   _start_order=tinyInfoI[1];
01605   _end_iteration=tinyInfoI[2];
01606   _end_order=tinyInfoI[3];
01607   _time_tolerance=tinyInfoD[0];
01608   _start_time=tinyInfoD[1];
01609   _end_time=tinyInfoD[2];
01610 }
01611 
01612 MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy):
01613   MEDCouplingTimeDiscretization(other,deepCpy),_start_time(other._start_time),_end_time(other._end_time),_start_iteration(other._start_iteration),
01614   _end_iteration(other._end_iteration),_start_order(other._start_order),_end_order(other._end_order)
01615 {
01616 }
01617 
01618 std::string MEDCouplingConstOnTimeInterval::getStringRepr() const
01619 {
01620   std::ostringstream stream;
01621   stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
01622   stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
01623   stream << "\nTime unit is : \"" << _time_unit << "\"";
01624   return stream.str();
01625 }
01626 
01627 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
01628 {
01629   return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
01630 }
01631 
01632 std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
01633 {
01634   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
01635     {
01636       std::vector< const DataArrayDouble *> ret(1);
01637       ret[0]=_array;
01638       return ret;
01639     }
01640   else
01641     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01642 }
01643 
01644 void MEDCouplingConstOnTimeInterval::getValueForTime(double time, const std::vector<double>& vals, double *res) const
01645 {
01646   std::copy(vals.begin(),vals.end(),res);
01647 }
01648 
01649 bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
01650 {
01651   if(!MEDCouplingTimeDiscretization::areCompatible(other))
01652     return false;
01653   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01654   return otherC!=0;
01655 }
01656 
01657 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
01658 {
01659   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
01660     return false;
01661   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01662   return otherC!=0;
01663 }
01664 
01665 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
01666 {
01667   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
01668     return false;
01669   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01670   return otherC!=0;
01671 }
01672 
01673 bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
01674 {
01675   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
01676     return false;
01677   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01678   return otherC!=0;
01679 }
01680 
01681 bool MEDCouplingConstOnTimeInterval::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
01682 {
01683   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
01684     return false;
01685   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01686   return otherC!=0;
01687 }
01688 
01689 bool MEDCouplingConstOnTimeInterval::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
01690 {
01691   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01692   if(!otherC)
01693     return false;
01694   if(_start_iteration!=otherC->_start_iteration)
01695     return false;
01696   if(_start_order!=otherC->_start_order)
01697     return false;
01698   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
01699     return false;
01700   if(_end_iteration!=otherC->_end_iteration)
01701     return false;
01702   if(_end_order!=otherC->_end_order)
01703     return false;
01704   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
01705     return false;
01706   return MEDCouplingTimeDiscretization::isEqual(other,prec);
01707 }
01708 
01709 bool MEDCouplingConstOnTimeInterval::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
01710 {
01711   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01712   if(!otherC)
01713     return false;
01714   if(_start_iteration!=otherC->_start_iteration)
01715     return false;
01716   if(_start_order!=otherC->_start_order)
01717     return false;
01718   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
01719     return false;
01720   if(_end_iteration!=otherC->_end_iteration)
01721     return false;
01722   if(_end_order!=otherC->_end_order)
01723     return false;
01724   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
01725     return false;
01726   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
01727 }
01728 
01729 void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
01730 {
01731   if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
01732     if(_array)
01733       _array->getTuple(eltId,value);
01734     else
01735       throw INTERP_KERNEL::Exception("No array existing.");
01736   else
01737     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01738 }
01739 
01740 void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
01741 {
01742   if(iteration>=_start_iteration && iteration<=_end_iteration)
01743     if(_array)
01744       _array->getTuple(eltId,value);
01745     else
01746       throw INTERP_KERNEL::Exception("No array existing.");
01747   else
01748     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
01749 }
01750 
01751 void MEDCouplingConstOnTimeInterval::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
01752 {
01753   throw INTERP_KERNEL::Exception("No time specified on a field defined as constant on one time interval");
01754 }
01755 
01756 void MEDCouplingConstOnTimeInterval::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
01757 {
01758   if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
01759     {
01760       std::ostringstream stream;
01761       stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
01762       stream << _time_tolerance << " and trying to access on time = " << time;
01763       throw INTERP_KERNEL::Exception(stream.str().c_str());
01764     }
01765 }
01766 
01767 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const MEDCouplingTimeDiscretization *other) const
01768 {
01769   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01770   if(!otherC)
01771     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregation on mismatched time discretization !");
01772   DataArrayDouble *arr=DataArrayDouble::Aggregate(getArray(),other->getArray());
01773   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01774   ret->setArray(arr,0);
01775   arr->decrRef();
01776   return ret;
01777 }
01778 
01779 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
01780 {
01781   std::vector<const DataArrayDouble *> a(other.size());
01782   int i=0;
01783   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
01784     {
01785       const MEDCouplingConstOnTimeInterval *itC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(*it);
01786       if(!itC)
01787         throw INTERP_KERNEL::Exception("ConstOnTimeInterval::aggregate on mismatched time discretization !");
01788       a[i]=itC->getArray();
01789     }
01790   DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
01791   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01792   ret->setArray(arr,0);
01793   arr->decrRef();
01794   return ret;
01795 }
01796 
01797 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::meld(const MEDCouplingTimeDiscretization *other) const
01798 {
01799   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01800   if(!otherC)
01801     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::meld on mismatched time discretization !");
01802   DataArrayDouble *arr=DataArrayDouble::Meld(getArray(),other->getArray());
01803   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01804   ret->setTimeTolerance(getTimeTolerance());
01805   ret->setArray(arr,0);
01806   arr->decrRef();
01807   return ret;
01808 }
01809 
01810 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::dot(const MEDCouplingTimeDiscretization *other) const
01811 {
01812   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01813   if(!otherC)
01814     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::dot on mismatched time discretization !");
01815   DataArrayDouble *arr=DataArrayDouble::Dot(getArray(),other->getArray());
01816   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01817   ret->setArray(arr,0);
01818   arr->decrRef();
01819   return ret;
01820 }
01821 
01822 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::crossProduct(const MEDCouplingTimeDiscretization *other) const
01823 {
01824   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01825   if(!otherC)
01826     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::crossProduct on mismatched time discretization !");
01827   DataArrayDouble *arr=DataArrayDouble::CrossProduct(getArray(),other->getArray());
01828   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01829   ret->setArray(arr,0);
01830   arr->decrRef();
01831   return ret;
01832 }
01833 
01834 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::max(const MEDCouplingTimeDiscretization *other) const
01835 {
01836   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01837   if(!otherC)
01838     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::max on mismatched time discretization !");
01839   DataArrayDouble *arr=DataArrayDouble::Max(getArray(),other->getArray());
01840   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01841   ret->setArray(arr,0);
01842   arr->decrRef();
01843   return ret;
01844 }
01845 
01846 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::min(const MEDCouplingTimeDiscretization *other) const
01847 {
01848   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01849   if(!otherC)
01850     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::min on mismatched time discretization !");
01851   DataArrayDouble *arr=DataArrayDouble::Min(getArray(),other->getArray());
01852   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01853   ret->setArray(arr,0);
01854   arr->decrRef();
01855   return ret;
01856 }
01857 
01858 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::add(const MEDCouplingTimeDiscretization *other) const
01859 {
01860   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01861   if(!otherC)
01862     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::add on mismatched time discretization !");
01863   DataArrayDouble *arr=DataArrayDouble::Add(getArray(),other->getArray());
01864   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01865   ret->setArray(arr,0);
01866   arr->decrRef();
01867   int tmp1,tmp2;
01868   double tmp3=getStartTime(tmp1,tmp2);
01869   ret->setStartTime(tmp3,tmp1,tmp2);
01870   tmp3=getEndTime(tmp1,tmp2);
01871   ret->setEndTime(tmp3,tmp1,tmp2);
01872   return ret;
01873 }
01874 
01875 void MEDCouplingConstOnTimeInterval::addEqual(const MEDCouplingTimeDiscretization *other)
01876 {
01877   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01878   if(!otherC)
01879     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::addEqual on mismatched time discretization !");
01880   getArray()->addEqual(other->getArray());
01881 }
01882  
01883 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::substract(const MEDCouplingTimeDiscretization *other) const
01884 {
01885   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01886   if(!otherC)
01887     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substract on mismatched time discretization !");
01888   DataArrayDouble *arr=DataArrayDouble::Substract(getArray(),other->getArray());
01889   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01890   ret->setArray(arr,0);
01891   arr->decrRef();
01892   int tmp1,tmp2;
01893   double tmp3=getStartTime(tmp1,tmp2);
01894   ret->setStartTime(tmp3,tmp1,tmp2);
01895   tmp3=getEndTime(tmp1,tmp2);
01896   ret->setEndTime(tmp3,tmp1,tmp2);
01897   return ret;
01898 }
01899 
01900 void MEDCouplingConstOnTimeInterval::substractEqual(const MEDCouplingTimeDiscretization *other)
01901 {
01902   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01903   if(!otherC)
01904     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::substractEqual on mismatched time discretization !");
01905   getArray()->substractEqual(other->getArray());
01906 }
01907 
01908 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::multiply(const MEDCouplingTimeDiscretization *other) const
01909 {
01910   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01911   if(!otherC)
01912     throw INTERP_KERNEL::Exception("multiply on mismatched time discretization !");
01913   DataArrayDouble *arr=DataArrayDouble::Multiply(getArray(),other->getArray());
01914   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01915   ret->setArray(arr,0);
01916   arr->decrRef();
01917   int tmp1,tmp2;
01918   double tmp3=getStartTime(tmp1,tmp2);
01919   ret->setStartTime(tmp3,tmp1,tmp2);
01920   tmp3=getEndTime(tmp1,tmp2);
01921   ret->setEndTime(tmp3,tmp1,tmp2);
01922   return ret;
01923 }
01924 
01925 void MEDCouplingConstOnTimeInterval::multiplyEqual(const MEDCouplingTimeDiscretization *other)
01926 {
01927   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01928   if(!otherC)
01929     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::multiplyEqual on mismatched time discretization !");
01930   getArray()->multiplyEqual(other->getArray());
01931 }
01932 
01933 MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::divide(const MEDCouplingTimeDiscretization *other) const
01934 {
01935   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01936   if(!otherC)
01937     throw INTERP_KERNEL::Exception("divide on mismatched time discretization !");
01938   DataArrayDouble *arr=DataArrayDouble::Divide(getArray(),other->getArray());
01939   MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
01940   ret->setArray(arr,0);
01941   arr->decrRef();
01942   int tmp1,tmp2;
01943   double tmp3=getStartTime(tmp1,tmp2);
01944   ret->setStartTime(tmp3,tmp1,tmp2);
01945   tmp3=getEndTime(tmp1,tmp2);
01946   ret->setEndTime(tmp3,tmp1,tmp2);
01947   return ret;
01948 }
01949 
01950 void MEDCouplingConstOnTimeInterval::divideEqual(const MEDCouplingTimeDiscretization *other)
01951 {
01952   const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
01953   if(!otherC)
01954     throw INTERP_KERNEL::Exception("ConstOnTimeInterval::divideEqual on mismatched time discretization !");
01955   getArray()->divideEqual(other->getArray());
01956 }
01957 
01958 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
01959                                                                                                      _start_time(other._start_time),_end_time(other._end_time),
01960                                                                                                      _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
01961                                                                                                      _start_order(other._start_order),_end_order(other._end_order)
01962 {
01963   if(other._end_array)
01964     _end_array=other._end_array->performCpy(deepCpy);
01965   else
01966     _end_array=0;
01967 }
01968 
01969 void MEDCouplingTwoTimeSteps::updateTime() const
01970 {
01971   MEDCouplingTimeDiscretization::updateTime();
01972   if(_end_array)
01973     updateTimeWith(*_end_array);
01974 }
01975 
01976 void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
01977 {
01978   MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
01979   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
01980   if(!otherC)
01981     throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
01982   _start_time=otherC->_start_time;
01983   _end_time=otherC->_end_time;
01984   _start_iteration=otherC->_start_iteration;
01985   _end_iteration=otherC->_end_iteration;
01986   _start_order=otherC->_start_order;
01987   _end_order=otherC->_end_order;
01988 }
01989 
01990 void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
01991 {
01992   MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
01993   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
01994   if(!otherC)
01995     throw INTERP_KERNEL::Exception("Trying to operate copyTinyStringsFrom on different field type (two times//one time) !");
01996   if(_end_array && otherC->_end_array)
01997     _end_array->copyStringInfoFrom(*otherC->_end_array);
01998 }
01999 
02000 const DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray() const
02001 {
02002   return _end_array;
02003 }
02004 
02005 DataArrayDouble *MEDCouplingTwoTimeSteps::getEndArray()
02006 {
02007   return _end_array;
02008 }
02009 
02010 void MEDCouplingTwoTimeSteps::checkCoherency() const throw(INTERP_KERNEL::Exception)
02011 {
02012   MEDCouplingTimeDiscretization::checkCoherency();
02013   if(!_end_array)
02014     throw INTERP_KERNEL::Exception("No end array specified !");
02015   if(_array->getNumberOfComponents()!=_end_array->getNumberOfComponents())
02016     throw INTERP_KERNEL::Exception("The number of components mismatch between the start and the end arrays !");
02017   if(_array->getNumberOfTuples()!=_end_array->getNumberOfTuples())
02018     throw INTERP_KERNEL::Exception("The number of tuples mismatch between the start and the end arrays !");
02019 }
02020 
02021 bool MEDCouplingTwoTimeSteps::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
02022 {
02023   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
02024   if(!otherC)
02025     return false;
02026   if(_start_iteration!=otherC->_start_iteration)
02027     return false;
02028   if(_end_iteration!=otherC->_end_iteration)
02029     return false;
02030   if(_start_order!=otherC->_start_order)
02031     return false;
02032   if(_end_order!=otherC->_end_order)
02033     return false;
02034   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
02035     return false;
02036   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
02037     return false;
02038   if(_end_array!=otherC->_end_array)
02039     if(!_end_array->isEqual(*otherC->_end_array,prec))
02040       return false;
02041   return MEDCouplingTimeDiscretization::isEqual(other,prec);
02042 }
02043 
02044 bool MEDCouplingTwoTimeSteps::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const
02045 {
02046   const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
02047   if(!otherC)
02048     return false;
02049   if(_start_iteration!=otherC->_start_iteration)
02050     return false;
02051   if(_end_iteration!=otherC->_end_iteration)
02052     return false;
02053   if(_start_order!=otherC->_start_order)
02054     return false;
02055   if(_end_order!=otherC->_end_order)
02056     return false;
02057   if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
02058     return false;
02059   if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
02060     return false;
02061   if(_end_array!=otherC->_end_array)
02062     if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
02063       return false;
02064   return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
02065 }
02066 
02067 MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
02068 {
02069 }
02070 
02071 MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
02072 {
02073   if(_end_array)
02074     _end_array->decrRef();
02075 }
02076 
02077 void MEDCouplingTwoTimeSteps::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
02078 {
02079   throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
02080 }
02081 
02082 void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
02083 {
02084   if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
02085     {
02086       std::ostringstream stream;
02087       stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
02088       stream << _time_tolerance << " and trying to access on time = " << time;
02089       throw INTERP_KERNEL::Exception(stream.str().c_str());
02090     }
02091 }
02092 
02093 void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
02094 {
02095   arrays.resize(2);
02096   arrays[0]=_array;
02097   arrays[1]=_end_array;
02098 }
02099 
02100 void MEDCouplingTwoTimeSteps::setEndArray(DataArrayDouble *array, TimeLabel *owner)
02101 {
02102   if(array!=_end_array)
02103     {
02104       if(_end_array)
02105         _end_array->decrRef();
02106       _end_array=array;
02107       if(_end_array)
02108         _end_array->incrRef();
02109       if(owner)
02110         owner->declareAsNew();
02111     }
02112 }
02113 
02114 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
02115 {
02116   MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
02117   tinyInfo.push_back(_start_iteration);
02118   tinyInfo.push_back(_start_order);
02119   tinyInfo.push_back(_end_iteration);
02120   tinyInfo.push_back(_end_order);
02121   if(_end_array)
02122     {
02123       tinyInfo.push_back(_end_array->getNumberOfTuples());
02124       tinyInfo.push_back(_end_array->getNumberOfComponents());
02125     }
02126   else
02127     {
02128       tinyInfo.push_back(-1);
02129       tinyInfo.push_back(-1);
02130     }
02131 }
02132 
02133 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
02134 {
02135   MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
02136   tinyInfo.push_back(_start_time);
02137   tinyInfo.push_back(_end_time);
02138 }
02139 
02140 void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
02141 {
02142   int nbOfCompo=_array->getNumberOfComponents();
02143   for(int i=0;i<nbOfCompo;i++)
02144     tinyInfo.push_back(_array->getInfoOnComponent(i));
02145   for(int i=0;i<nbOfCompo;i++)
02146     tinyInfo.push_back(_end_array->getInfoOnComponent(i));
02147 }
02148 
02149 void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
02150 {
02151   arrays.resize(2);
02152   if(_array!=0)
02153     _array->decrRef();
02154   if(_end_array!=0)
02155     _end_array->decrRef();
02156   DataArrayDouble *arr=0;
02157   if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
02158     {
02159       arr=DataArrayDouble::New();
02160       arr->alloc(tinyInfoI[0],tinyInfoI[1]);
02161     }
02162   _array=arr;
02163   arrays[0]=arr;
02164   arr=0;
02165   if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
02166     {
02167       arr=DataArrayDouble::New();
02168       arr->alloc(tinyInfoI[6],tinyInfoI[7]);
02169     }
02170   _end_array=arr;
02171   arrays[1]=arr;
02172 }
02173 
02174 void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
02175 {
02176   MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
02177   _start_time=tinyInfoD[1];
02178   _end_time=tinyInfoD[2];
02179   _start_iteration=tinyInfoI[2];
02180   _start_order=tinyInfoI[3];
02181   _end_iteration=tinyInfoI[4];
02182   _end_order=tinyInfoI[5];
02183 }
02184 
02188 void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
02189 {
02190   tinyInfo.resize(4);
02191   tinyInfo[0]=_start_iteration;
02192   tinyInfo[1]=_start_order;
02193   tinyInfo[2]=_end_iteration;
02194   tinyInfo[3]=_end_order;
02195 }
02196 
02200 void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const
02201 {
02202   tinyInfo.resize(3);
02203   tinyInfo[0]=_time_tolerance;
02204   tinyInfo[1]=_start_time;
02205   tinyInfo[2]=_end_time;
02206 }
02207 
02211 void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
02212 {
02213   _start_iteration=tinyInfoI[0];
02214   _start_order=tinyInfoI[1];
02215   _end_iteration=tinyInfoI[2];
02216   _end_order=tinyInfoI[3];
02217   _time_tolerance=tinyInfoD[0];
02218   _start_time=tinyInfoD[1];
02219   _end_time=tinyInfoD[2];
02220 }
02221 
02222 std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const throw(INTERP_KERNEL::Exception)
02223 {
02224    if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
02225     {
02226       std::vector< const DataArrayDouble *> ret(2);
02227       ret[0]=_array;
02228       ret[1]=_end_array;
02229       return ret;
02230     }
02231   else
02232     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
02233 }
02234 
02235 void MEDCouplingTwoTimeSteps::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
02236 {
02237   if(arrays.size()!=2)
02238     throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::setArrays : number of arrays must be two.");
02239   setArray(arrays.front(),owner);
02240   setEndArray(arrays.back(),owner);
02241 }
02242 
02243 MEDCouplingLinearTime::MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy):MEDCouplingTwoTimeSteps(other,deepCpy)
02244 {
02245 }
02246 
02247 MEDCouplingLinearTime::MEDCouplingLinearTime()
02248 {
02249 }
02250 
02251 std::string MEDCouplingLinearTime::getStringRepr() const
02252 {
02253   std::ostringstream stream;
02254   stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
02255   stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
02256   stream << "Time unit is : \"" << _time_unit << "\"";
02257   return stream.str();
02258 }
02259 
02260 void MEDCouplingLinearTime::checkCoherency() const throw(INTERP_KERNEL::Exception)
02261 {
02262   MEDCouplingTwoTimeSteps::checkCoherency();
02263   if(std::fabs(_start_time-_end_time)<_time_tolerance)
02264     throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
02265 }
02266 
02267 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::performCpy(bool deepCpy) const
02268 {
02269   return new MEDCouplingLinearTime(*this,deepCpy);
02270 }
02271 
02272 bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
02273 {
02274   if(!MEDCouplingTimeDiscretization::areCompatible(other))
02275     return false;
02276   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02277   if(otherC==0)
02278     return false;
02279   if(_end_array==0 && otherC->_end_array==0)
02280     return true;
02281   if(_end_array==0 || otherC->_end_array==0)
02282     return false;
02283   if(_end_array->getNumberOfComponents()!=otherC->_end_array->getNumberOfComponents())
02284     return false;
02285   return true;
02286 }
02287 
02288 bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other) const
02289 {
02290   if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other))
02291     return false;
02292   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02293   return otherC!=0;
02294 }
02295 
02296 bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
02297 {
02298   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
02299     return false;
02300   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02301   return otherC!=0;
02302 }
02303 
02304 bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
02305 {
02306   if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
02307     return false;
02308   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02309   if(otherC==0)
02310     return false;
02311   if(_end_array==0 && otherC->_end_array==0)
02312     return true;
02313   if(_end_array==0 || otherC->_end_array==0)
02314     return false;
02315   int nbC1=_end_array->getNumberOfComponents();
02316   int nbC2=otherC->_end_array->getNumberOfComponents();
02317   if(nbC1!=nbC2 && nbC2!=1)
02318     return false;
02319   return true;
02320 }
02321 
02322 bool MEDCouplingLinearTime::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
02323 {
02324   if(!MEDCouplingTimeDiscretization::areCompatibleForMeld(other))
02325     return false;
02326   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02327   return otherC!=0;
02328 }
02329 
02333 void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
02334 {
02335   double alpha=(_end_time-time)/(_end_time-_start_time);
02336   std::size_t nbComp=vals.size()/2;
02337   std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
02338   std::vector<double> tmp(nbComp);
02339   std::transform(vals.begin()+nbComp,vals.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
02340   std::transform(tmp.begin(),tmp.end(),res,res,std::plus<double>());
02341 }
02342 
02343 void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
02344 {
02345   double alpha=(_end_time-time)/(_end_time-_start_time);
02346   int nbComp;
02347   if(_array)
02348     _array->getTuple(eltId,value);
02349   else
02350     throw INTERP_KERNEL::Exception("No start array existing.");
02351   nbComp=_array->getNumberOfComponents();
02352   std::transform(value,value+nbComp,value,std::bind2nd(std::multiplies<double>(),alpha));
02353   std::vector<double> tmp(nbComp);
02354   if(_end_array)
02355     _end_array->getTuple(eltId,&tmp[0]);
02356   else
02357     throw INTERP_KERNEL::Exception("No end array existing.");
02358   std::transform(tmp.begin(),tmp.end(),tmp.begin(),std::bind2nd(std::multiplies<double>(),1-alpha));
02359   std::transform(tmp.begin(),tmp.end(),value,value,std::plus<double>());
02360 }
02361 
02362 void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception)
02363 {
02364   if(iteration==_start_iteration && order==_start_order)
02365     {
02366       if(_array)
02367         _array->getTuple(eltId,value);
02368       else
02369         throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
02370     }
02371   if(iteration==_end_iteration && order==_end_order)
02372     {
02373       if(_end_array)
02374         _end_array->getTuple(eltId,value);
02375       else
02376         throw INTERP_KERNEL::Exception("iteration order match with end time but no end array existing.");
02377     }
02378   else
02379     throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
02380 }
02381 
02382 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const MEDCouplingTimeDiscretization *other) const
02383 {
02384   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02385   if(!otherC)
02386     throw INTERP_KERNEL::Exception("LinearTime::aggregation on mismatched time discretization !");
02387   DataArrayDouble *arr1=DataArrayDouble::Aggregate(getArray(),other->getArray());
02388   DataArrayDouble *arr2=DataArrayDouble::Aggregate(getEndArray(),other->getEndArray());
02389   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02390   ret->setArray(arr1,0);
02391   arr1->decrRef();
02392   ret->setEndArray(arr2,0);
02393   arr2->decrRef();
02394   return ret;
02395 }
02396 
02397 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const
02398 {
02399   std::vector<const DataArrayDouble *> a(other.size());
02400   std::vector<const DataArrayDouble *> b(other.size());
02401   int i=0;
02402   for(std::vector<const MEDCouplingTimeDiscretization *>::const_iterator it=other.begin();it!=other.end();it++,i++)
02403     {
02404       const MEDCouplingLinearTime *itC=dynamic_cast<const MEDCouplingLinearTime *>(*it);
02405       if(!itC)
02406         throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::aggregate on mismatched time discretization !");
02407       a[i]=itC->getArray();
02408       b[i]=itC->getEndArray();
02409     }
02410   DataArrayDouble *arr=DataArrayDouble::Aggregate(a);
02411   DataArrayDouble *arr2=DataArrayDouble::Aggregate(b);
02412   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02413   ret->setArray(arr,0);
02414   arr->decrRef();
02415   ret->setEndArray(arr2,0);
02416   arr2->decrRef();
02417   return ret;
02418 }
02419 
02420 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::meld(const MEDCouplingTimeDiscretization *other) const
02421 {
02422   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02423   if(!otherC)
02424     throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
02425   DataArrayDouble *arr1=DataArrayDouble::Meld(getArray(),other->getArray());
02426   DataArrayDouble *arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
02427   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02428   ret->setTimeTolerance(getTimeTolerance());
02429   ret->setArray(arr1,0);
02430   arr1->decrRef();
02431   ret->setEndArray(arr2,0);
02432   arr2->decrRef();
02433   return ret;
02434 }
02435 
02436 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::dot(const MEDCouplingTimeDiscretization *other) const
02437 {
02438   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02439   if(!otherC)
02440     throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
02441   DataArrayDouble *arr1=DataArrayDouble::Dot(getArray(),other->getArray());
02442   DataArrayDouble *arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
02443   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02444   ret->setArray(arr1,0);
02445   arr1->decrRef();
02446   ret->setEndArray(arr2,0);
02447   arr2->decrRef();
02448   return ret;
02449 }
02450 
02451 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::crossProduct(const MEDCouplingTimeDiscretization *other) const
02452 {
02453   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02454   if(!otherC)
02455     throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
02456   DataArrayDouble *arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
02457   DataArrayDouble *arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
02458   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02459   ret->setArray(arr1,0);
02460   arr1->decrRef();
02461   ret->setEndArray(arr2,0);
02462   arr2->decrRef();
02463   return ret;
02464 }
02465 
02466 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::max(const MEDCouplingTimeDiscretization *other) const
02467 {
02468   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02469   if(!otherC)
02470     throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
02471   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02472   DataArrayDouble *arr1=DataArrayDouble::Max(getArray(),other->getArray());
02473   ret->setArray(arr1,0);
02474   arr1->decrRef();
02475   DataArrayDouble *arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
02476   ret->setEndArray(arr2,0);
02477   arr2->decrRef();
02478   return ret;
02479 }
02480 
02481 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::min(const MEDCouplingTimeDiscretization *other) const
02482 {
02483   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02484   if(!otherC)
02485     throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
02486   DataArrayDouble *arr1=DataArrayDouble::Min(getArray(),other->getArray());
02487   DataArrayDouble *arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
02488   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02489   ret->setArray(arr1,0);
02490   arr1->decrRef();
02491   ret->setEndArray(arr2,0);
02492   arr2->decrRef();
02493   return ret;
02494 }
02495 
02496 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::add(const MEDCouplingTimeDiscretization *other) const
02497 {
02498   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02499   if(!otherC)
02500     throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
02501   DataArrayDouble *arr1=DataArrayDouble::Add(getArray(),other->getArray());
02502   DataArrayDouble *arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
02503   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02504   ret->setArray(arr1,0);
02505   arr1->decrRef();
02506   ret->setEndArray(arr2,0);
02507   arr2->decrRef();
02508   return ret;
02509 }
02510 
02511 void MEDCouplingLinearTime::addEqual(const MEDCouplingTimeDiscretization *other)
02512 {
02513   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02514   if(!otherC)
02515     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
02516   getArray()->addEqual(other->getArray());
02517   getEndArray()->addEqual(other->getEndArray());
02518 }
02519 
02520 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::substract(const MEDCouplingTimeDiscretization *other) const
02521 {
02522   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02523   if(!otherC)
02524     throw INTERP_KERNEL::Exception("LinearTime::substract on mismatched time discretization !");
02525   DataArrayDouble *arr1=DataArrayDouble::Substract(getArray(),other->getArray());
02526   DataArrayDouble *arr2=DataArrayDouble::Substract(getEndArray(),other->getEndArray());
02527   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02528   ret->setArray(arr1,0);
02529   arr1->decrRef();
02530   ret->setEndArray(arr2,0);
02531   arr2->decrRef();
02532   return ret;
02533 }
02534 
02535 void MEDCouplingLinearTime::substractEqual(const MEDCouplingTimeDiscretization *other)
02536 {
02537   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02538   if(!otherC)
02539     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
02540   getArray()->substractEqual(other->getArray());
02541   getEndArray()->substractEqual(other->getEndArray());
02542 }
02543 
02544 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::multiply(const MEDCouplingTimeDiscretization *other) const
02545 {
02546   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02547   if(!otherC)
02548     throw INTERP_KERNEL::Exception("LinearTime::multiply on mismatched time discretization !");
02549   DataArrayDouble *arr1=DataArrayDouble::Multiply(getArray(),other->getArray());
02550   DataArrayDouble *arr2=DataArrayDouble::Multiply(getEndArray(),other->getEndArray());
02551   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02552   ret->setArray(arr1,0);
02553   arr1->decrRef();
02554   ret->setEndArray(arr2,0);
02555   arr2->decrRef();
02556   return ret;
02557 }
02558 
02559 void MEDCouplingLinearTime::multiplyEqual(const MEDCouplingTimeDiscretization *other)
02560 {
02561   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02562   if(!otherC)
02563     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
02564   getArray()->multiplyEqual(other->getArray());
02565   getEndArray()->multiplyEqual(other->getEndArray());
02566 }
02567 
02568 MEDCouplingTimeDiscretization *MEDCouplingLinearTime::divide(const MEDCouplingTimeDiscretization *other) const
02569 {
02570   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02571   if(!otherC)
02572     throw INTERP_KERNEL::Exception("LinearTime::divide on mismatched time discretization !");
02573   DataArrayDouble *arr1=DataArrayDouble::Divide(getArray(),other->getArray());
02574   DataArrayDouble *arr2=DataArrayDouble::Divide(getEndArray(),other->getEndArray());
02575   MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
02576   ret->setArray(arr1,0);
02577   arr1->decrRef();
02578   ret->setEndArray(arr2,0);
02579   arr2->decrRef();
02580   return ret;
02581 }
02582 
02583 void MEDCouplingLinearTime::divideEqual(const MEDCouplingTimeDiscretization *other)
02584 {
02585   const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
02586   if(!otherC)
02587     throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
02588   getArray()->divideEqual(other->getArray());
02589   getEndArray()->divideEqual(other->getEndArray());
02590 }