-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// Author : Anthony Geay (CEA/DEN)
#include "MEDCouplingTimeDiscretization.hxx"
-#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingMesh.hxx"
#include <cmath>
#include <sstream>
updateTimeWith(*_array);
}
+std::size_t MEDCouplingTimeDiscretization::getHeapMemorySize() const
+{
+ std::size_t ret=_time_unit.capacity();
+ if(_array)
+ ret+=_array->getHeapMemorySize();
+ return ret;
+}
+
bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->doublyContractedProduct();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
ret->setArrays(arrays3,0);
return ret;
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->determinant();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->eigenValues();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->eigenVectors();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->inverse();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->trace();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->deviator();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->magnitude();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
+ ret->setTimeUnit(getTimeUnit());
+ ret->setArrays(arrays3,0);
+ return ret;
+}
+
+MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::negate() const throw(INTERP_KERNEL::Exception)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ for(std::size_t j=0;j<arrays.size();j++)
+ {
+ if(arrays[j])
+ arrays2[j]=arrays[j]->negate();
+ else
+ arrays2[j]=0;
+ }
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->maxPerTuple();
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->keepSelectedComponents(compoIds);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
MEDCouplingTimeDiscretization *ret=MEDCouplingTimeDiscretization::New(getEnum());
ret->setTimeUnit(getTimeUnit());
other->getArrays(arrays2);
if(arrays1.size()!=arrays2.size())
throw INTERP_KERNEL::Exception("TimeDiscretization::setSelectedComponents : number of arrays mismatch !");
- for(unsigned int i=0;i<arrays1.size();i++)
+ for(std::size_t i=0;i<arrays1.size();i++)
{
if(arrays1[i]!=0 && arrays2[i]!=0)
arrays1[i]->setSelectedComponents(arrays2[i],compoIds);
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->changeNbOfComponents(newNbOfComp,dftValue);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays[j]->sortPerTuple(asc);
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
{
- arrays[j]->incrRef();
- arrays[j]->fillWithValue(value);
- arrays2[j]=arrays[j];
+ arrays2[j]=arrays[j]->changeNbOfComponents(nbOfCompo,value);
+ arrays2[j]->fillWithValue(value);
}
else
{
- DataArrayDouble *tmp=DataArrayDouble::New();
- tmp->alloc(nbOfTuple,nbOfCompo);
- tmp->fillWithValue(value);
- arrays2[j]=tmp;
+ arrays2[j]=DataArrayDouble::New();
+ arrays2[j]->alloc(nbOfTuple,nbOfCompo);
+ arrays2[j]->fillWithValue(value);
}
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
+void MEDCouplingTimeDiscretization::setOrCreateUniformValueOnAllComponents(int nbOfTuple, double value)
+{
+ std::vector<DataArrayDouble *> arrays;
+ getArrays(arrays);
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
+ bool newArr=false;
+ for(std::size_t j=0;j<arrays.size();j++)
+ {
+ if(arrays[j])
+ {
+ arrays2[j]=arrays[j]; arrays2[j]->incrRef();
+ arrays2[j]->fillWithValue(value);
+ }
+ else
+ {
+ newArr=true;
+ arrays2[j]=DataArrayDouble::New();
+ arrays2[j]->alloc(nbOfTuple,1);
+ arrays2[j]->fillWithValue(value);
+ }
+ }
+ if(newArr)
+ {
+ std::vector<DataArrayDouble *> arrays3(arrays.size());
+ for(std::size_t j=0;j<arrays.size();j++)
+ arrays3[j]=arrays2[j];
+ setArrays(arrays3,0);
+ }
+}
+
void MEDCouplingTimeDiscretization::applyLin(double a, double b, int compoId)
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays[j]->applyLin(a,b,compoId);
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->applyFunc(nbOfComp,func);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->applyFunc2(nbOfComp,func);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->applyFunc3(nbOfComp,varsOrder,func);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays2[j]=arrays[j]->applyFunc(func);
arrays2[j]=0;
}
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays[j]->applyFuncFast32(func);
{
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
{
if(arrays[j])
arrays[j]->applyFuncFast64(func);
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays2[j]=loc->applyFunc(nbOfComp,func);
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays2[j]=loc->applyFunc(nbOfComp,func);
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays2[j]=loc->applyFunc2(nbOfComp,func);
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
std::vector<DataArrayDouble *> arrays;
getArrays(arrays);
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > arrays2(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays2[j]=loc->applyFunc3(nbOfComp,varsOrder,func);
std::vector<DataArrayDouble *> arrays3(arrays.size());
- for(int j=0;j<(int)arrays.size();j++)
+ for(std::size_t j=0;j<arrays.size();j++)
arrays3[j]=arrays2[j];
setArrays(arrays3,0);
}
return stream.str();
}
+void MEDCouplingNoTimeLabel::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::synchronizeTimeWith : impossible to synchronize time with a MEDCouplingMesh because the time discretization is incompatible with it !");
+}
+
bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretization *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
getArray()->divideEqual(other->getArray());
}
+MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::pow(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
+ MEDCouplingNoTimeLabel *ret=new MEDCouplingNoTimeLabel;
+ ret->setArray(arr,0);
+ return ret;
+}
+
+void MEDCouplingNoTimeLabel::powEqual(const MEDCouplingTimeDiscretization *other)
+{
+ const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("NoTimeLabel::powEqual on mismatched time discretization !");
+ if(!getArray())
+ throw INTERP_KERNEL::Exception("MEDCouplingNoTimeLabel::powEqual : Data Array is NULL !");
+ getArray()->powEqual(other->getArray());
+}
+
MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
{
return new MEDCouplingNoTimeLabel(*this,deepCpy);
return stream.str();
}
+void MEDCouplingWithTimeStep::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
+ int it=-1,order=-1;
+ double val=mesh->getTime(it,order);
+ _time=val; _iteration=it; _order=order;
+ std::string tUnit=mesh->getTimeUnit();
+ _time_unit=tUnit;
+}
+
void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
getArray()->divideEqual(other->getArray());
}
+MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::pow(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("WithTimeStep::pow on mismatched time discretization !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
+ MEDCouplingWithTimeStep *ret=new MEDCouplingWithTimeStep;
+ ret->setArray(arr,0);
+ int tmp1,tmp2;
+ double tmp3=getStartTime(tmp1,tmp2);
+ ret->setStartTime(tmp3,tmp1,tmp2);
+ return ret;
+}
+
+void MEDCouplingWithTimeStep::powEqual(const MEDCouplingTimeDiscretization *other)
+{
+ const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("WithTimeStep::powEqual on mismatched time discretization !");
+ if(!getArray())
+ throw INTERP_KERNEL::Exception("MEDCouplingWithTimeLabel::powEqual : Data Array is NULL !");
+ getArray()->powEqual(other->getArray());
+}
+
MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
{
return new MEDCouplingWithTimeStep(*this,deepCpy);
return stream.str();
}
+void MEDCouplingConstOnTimeInterval::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
+ int it=-1,order=-1;
+ double val=mesh->getTime(it,order);
+ _start_time=val; _start_iteration=it; _start_order=order;
+ _end_time=val; _end_iteration=it; _end_order=order;
+ std::string tUnit=mesh->getTimeUnit();
+ _time_unit=tUnit;
+}
+
MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCpy(bool deepCpy) const
{
return new MEDCouplingConstOnTimeInterval(*this,deepCpy);
getArray()->divideEqual(other->getArray());
}
+MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::pow(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("pow on mismatched time discretization !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::Pow(getArray(),other->getArray());
+ MEDCouplingConstOnTimeInterval *ret=new MEDCouplingConstOnTimeInterval;
+ ret->setArray(arr,0);
+ int tmp1,tmp2;
+ double tmp3=getStartTime(tmp1,tmp2);
+ ret->setStartTime(tmp3,tmp1,tmp2);
+ tmp3=getEndTime(tmp1,tmp2);
+ ret->setEndTime(tmp3,tmp1,tmp2);
+ return ret;
+}
+
+void MEDCouplingConstOnTimeInterval::powEqual(const MEDCouplingTimeDiscretization *other)
+{
+ const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("ConstOnTimeInterval::powEqual on mismatched time discretization !");
+ if(!getArray())
+ throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::powEqual : Data Array is NULL !");
+ getArray()->powEqual(other->getArray());
+}
+
MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
_start_time(other._start_time),_end_time(other._end_time),
_start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
updateTimeWith(*_end_array);
}
+void MEDCouplingTwoTimeSteps::synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception)
+{
+ if(!mesh)
+ throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::synchronizeTimeWith : mesh instance is NULL ! Impossible to synchronize time !");
+ int it=-1,order=-1;
+ double val=mesh->getTime(it,order);
+ _start_time=val; _start_iteration=it; _start_order=order;
+ _end_time=val; _end_iteration=it; _end_order=order;
+ std::string tUnit=mesh->getTimeUnit();
+ _time_unit=tUnit;
+}
+
+std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySize() const
+{
+ std::size_t ret=0;
+ if(_end_array)
+ ret+=_end_array->getHeapMemorySize();
+ return MEDCouplingTimeDiscretization::getHeapMemorySize()+ret;
+}
+
void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception)
{
MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
getArray()->divideEqual(other->getArray());
getEndArray()->divideEqual(other->getEndArray());
}
+
+MEDCouplingTimeDiscretization *MEDCouplingLinearTime::pow(const MEDCouplingTimeDiscretization *other) const
+{
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("LinearTime::pow on mismatched time discretization !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr1=DataArrayDouble::Pow(getArray(),other->getArray());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=DataArrayDouble::Pow(getEndArray(),other->getEndArray());
+ MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ ret->setArray(arr1,0);
+ ret->setEndArray(arr2,0);
+ return ret;
+}
+
+void MEDCouplingLinearTime::powEqual(const MEDCouplingTimeDiscretization *other)
+{
+ const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("LinearTime::addEqual on mismatched time discretization !");
+ if(!getArray())
+ throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array is NULL !");
+ if(!getEndArray())
+ throw INTERP_KERNEL::Exception("MEDCouplingLinearTime::powEqual : Data Array (end) is NULL !");
+ getArray()->powEqual(other->getArray());
+ getEndArray()->powEqual(other->getEndArray());
+}