}
MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
- _start_time(other._start_time),_end_time(other._end_time),
- _start_iteration(other._start_iteration),_end_iteration(other._end_iteration),
- _start_order(other._start_order),_end_order(other._end_order)
+ _start(other._start),_end(other._end)
{
if(other._end_array)
_end_array=other._end_array->performCopyOrIncrRef(deepCopy);
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;
+ _start.setAllInfo(val,it,order);
+ _end.setAllInfo(val,it,order);
std::string tUnit=mesh->getTimeUnit();
_time_unit=tUnit;
}
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
if(!otherC)
throw INTERP_KERNEL::Exception("MEDCouplingTwoTimeSteps::copyTinyAttrFrom : mismatch of time discretization !");
- _start_time=otherC->_start_time;
- _end_time=otherC->_end_time;
- _start_iteration=otherC->_start_iteration;
- _end_iteration=otherC->_end_iteration;
- _start_order=otherC->_start_order;
- _end_order=otherC->_end_order;
+ _start.copyFrom(otherC->_start);
+ _end.copyFrom(otherC->_end);
}
void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
reason="This has time discretization LINEAR_TIME, other not.";
return false;
}
- if(_start_iteration!=otherC->_start_iteration)
- {
- oss << "start iterations differ. this start iteration=" << _start_iteration << " other start iteration=" << otherC->_start_iteration;
- reason=oss.str();
- return false;
- }
- if(_start_order!=otherC->_start_order)
- {
- oss << "start orders differ. this start order=" << _start_order << " other start order=" << otherC->_start_order;
- reason=oss.str();
- return false;
- }
- if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
- {
- oss << "start times differ. this start time=" << _start_time << " other start time=" << otherC->_start_time;
- reason=oss.str();
- return false;
- }
- if(_end_iteration!=otherC->_end_iteration)
- {
- oss << "end iterations differ. this end iteration=" << _end_iteration << " other end iteration=" << otherC->_end_iteration;
- reason=oss.str();
- return false;
- }
- if(_end_order!=otherC->_end_order)
- {
- oss << "end orders differ. this end order=" << _end_order << " other end order=" << otherC->_end_order;
- reason=oss.str();
- return false;
- }
- if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
- {
- oss << "end times differ. this end time=" << _end_time << " other end time=" << otherC->_end_time;
- reason=oss.str();
- return false;
- }
+ if(!_start.isEqualIfNotWhy(otherC->_start,_time_tolerance,reason))
+ return false;
+ if(!_end.isEqualIfNotWhy(otherC->_end,_time_tolerance,reason))
+ return false;
if(_end_array!=otherC->_end_array)
if(!_end_array->isEqualIfNotWhy(*otherC->_end_array,prec,reason))
{
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(other);
if(!otherC)
return false;
- if(_start_iteration!=otherC->_start_iteration)
- return false;
- if(_end_iteration!=otherC->_end_iteration)
- return false;
- if(_start_order!=otherC->_start_order)
- return false;
- if(_end_order!=otherC->_end_order)
- return false;
- if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
+ if(!_start.isEqual(otherC->_start,_time_tolerance))
return false;
- if(std::fabs(_end_time-otherC->_end_time)>_time_tolerance)
+ if(!_end.isEqual(otherC->_end,_time_tolerance))
return false;
if(_end_array!=otherC->_end_array)
if(!_end_array->isEqualWithoutConsideringStr(*otherC->_end_array,prec))
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
}
-MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1),_end_array(0)
+MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_end_array(0)
{
}
void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const
{
- if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
+ if(time<_start.getTimeValue()-_time_tolerance || time>_end.getTimeValue()+_time_tolerance)
{
std::ostringstream stream;
- stream << "The field is defined between times " << _start_time << " and " << _end_time << " worderh tolerance ";
+ stream << "The field is defined between times " << _start.getTimeValue() << " and " << _end.getTimeValue() << " worderh tolerance ";
stream << _time_tolerance << " and trying to access on time = " << time;
throw INTERP_KERNEL::Exception(stream.str().c_str());
}
void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
- tinyInfo.push_back(_start_iteration);
- tinyInfo.push_back(_start_order);
- tinyInfo.push_back(_end_iteration);
- tinyInfo.push_back(_end_order);
+ tinyInfo.push_back(_start.getIteration());
+ tinyInfo.push_back(_start.getOrder());
+ tinyInfo.push_back(_end.getIteration());
+ tinyInfo.push_back(_end.getOrder());
if(_end_array)
{
tinyInfo.push_back(_end_array->getNumberOfTuples());
void MEDCouplingTwoTimeSteps::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
- tinyInfo.push_back(_start_time);
- tinyInfo.push_back(_end_time);
+ tinyInfo.push_back(_start.getTimeValue());
+ tinyInfo.push_back(_end.getTimeValue());
}
void MEDCouplingTwoTimeSteps::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
- _start_time=tinyInfoD[1];
- _end_time=tinyInfoD[2];
- _start_iteration=tinyInfoI[2];
- _start_order=tinyInfoI[3];
- _end_iteration=tinyInfoI[4];
- _end_order=tinyInfoI[5];
+ _start.setTimeValue(tinyInfoD[1]);
+ _end.setTimeValue(tinyInfoD[2]);
+ _start.setIteration(tinyInfoI[2]);
+ _start.setOrder(tinyInfoI[3]);
+ _end.setIteration(tinyInfoI[4]);
+ _end.setOrder(tinyInfoI[5]);
}
/*!
void MEDCouplingTwoTimeSteps::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
{
tinyInfo.resize(4);
- tinyInfo[0]=_start_iteration;
- tinyInfo[1]=_start_order;
- tinyInfo[2]=_end_iteration;
- tinyInfo[3]=_end_order;
+ tinyInfo[0]=_start.getIteration();
+ tinyInfo[1]=_start.getOrder();
+ tinyInfo[2]=_end.getIteration();
+ tinyInfo[3]=_end.getOrder();
}
/*!
{
tinyInfo.resize(3);
tinyInfo[0]=_time_tolerance;
- tinyInfo[1]=_start_time;
- tinyInfo[2]=_end_time;
+ tinyInfo[1]=_start.getTimeValue();
+ tinyInfo[2]=_end.getTimeValue();
}
/*!
*/
void MEDCouplingTwoTimeSteps::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
{
- _start_iteration=tinyInfoI[0];
- _start_order=tinyInfoI[1];
- _end_iteration=tinyInfoI[2];
- _end_order=tinyInfoI[3];
+ _start.setIteration(tinyInfoI[0]);
+ _start.setOrder(tinyInfoI[1]);
+ _end.setIteration(tinyInfoI[2]);
+ _end.setOrder(tinyInfoI[3]);
_time_tolerance=tinyInfoD[0];
- _start_time=tinyInfoD[1];
- _end_time=tinyInfoD[2];
+ _start.setTimeValue(tinyInfoD[1]);
+ _end.setTimeValue(tinyInfoD[2]);
}
std::vector< const DataArrayDouble *> MEDCouplingTwoTimeSteps::getArraysForTime(double time) const
{
- if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
+ if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
{
std::vector< const DataArrayDouble *> ret(2);
ret[0]=_array;
std::string MEDCouplingLinearTime::getStringRepr() const
{
std::ostringstream stream;
- stream << REPR << " Time interval is defined by :\niteration_start=" << _start_iteration << " order_start=" << _start_order << " and time_start=" << _start_time << "\n";
- stream << "iteration_end=" << _end_iteration << " order_end=" << _end_order << " and end_time=" << _end_time << "\n";
+ stream << REPR << " Time interval is defined by :\niteration_start=" << _start.getIteration() << " order_start=" << _start.getOrder() << " and time_start=" << _start.getTimeValue() << "\n";
+ stream << "iteration_end=" << _end.getIteration() << " order_end=" << _end.getOrder() << " and end_time=" << _end.getTimeValue() << "\n";
stream << "Time unit is : \"" << _time_unit << "\"";
return stream.str();
}
void MEDCouplingLinearTime::checkConsistencyLight() const
{
MEDCouplingTwoTimeSteps::checkConsistencyLight();
- if(std::fabs(_start_time-_end_time)<_time_tolerance)
+ if(std::fabs(_start.getTimeValue()-_end.getTimeValue())<_time_tolerance)
throw INTERP_KERNEL::Exception("Start time and end time are equals regarding time tolerance.");
}
*/
void MEDCouplingLinearTime::getValueForTime(double time, const std::vector<double>& vals, double *res) const
{
- double alpha=(_end_time-time)/(_end_time-_start_time);
+ double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
std::size_t nbComp=vals.size()/2;
std::transform(vals.begin(),vals.begin()+nbComp,res,std::bind2nd(std::multiplies<double>(),alpha));
std::vector<double> tmp(nbComp);
void MEDCouplingLinearTime::getValueOnTime(int eltId, double time, double *value) const
{
- double alpha=(_end_time-time)/(_end_time-_start_time);
+ double alpha=(_end.getTimeValue()-time)/(_end.getTimeValue()-_start.getTimeValue());
int nbComp;
if(_array)
_array->getTuple(eltId,value);
void MEDCouplingLinearTime::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
{
- if(iteration==_start_iteration && order==_start_order)
+ if(iteration==_start.getIteration() && order==_start.getOrder())
{
if(_array)
_array->getTuple(eltId,value);
else
throw INTERP_KERNEL::Exception("iteration order match with start time but no start array existing.");
}
- if(iteration==_end_iteration && order==_end_order)
+ if(iteration==_end.getIteration() && order==_end.getOrder())
{
if(_end_array)
_end_array->getTuple(eltId,value);
a[i]=itC->getArray();
b[i]=itC->getEndArray();
}
- MCAuto<DataArrayDouble> arr=DataArrayDouble::Aggregate(a);
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Aggregate(b);
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr(DataArrayDouble::Aggregate(a)),arr2(DataArrayDouble::Aggregate(b));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::meld on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Meld(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Meld(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Meld(getArray(),other->getArray())),arr2(DataArrayDouble::Meld(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setTimeTolerance(getTimeTolerance());
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::dot on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Dot(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Dot(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Dot(getArray(),other->getArray())),arr2(DataArrayDouble::Dot(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::crossProduct on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::CrossProduct(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::CrossProduct(getArray(),other->getArray())),arr2(DataArrayDouble::CrossProduct(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::max on mismatched time discretization !");
MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Max(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Max(getEndArray(),other->getEndArray());
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Max(getArray(),other->getArray())),arr2(DataArrayDouble::Max(getEndArray(),other->getEndArray()));
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::min on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Min(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Min(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Min(getArray(),other->getArray())),arr2(DataArrayDouble::Min(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;
const MEDCouplingLinearTime *otherC=dynamic_cast<const MEDCouplingLinearTime *>(other);
if(!otherC)
throw INTERP_KERNEL::Exception("LinearTime::add on mismatched time discretization !");
- MCAuto<DataArrayDouble> arr1=DataArrayDouble::Add(getArray(),other->getArray());
- MCAuto<DataArrayDouble> arr2=DataArrayDouble::Add(getEndArray(),other->getEndArray());
- MEDCouplingLinearTime *ret=new MEDCouplingLinearTime;
+ MCAuto<DataArrayDouble> arr1(DataArrayDouble::Add(getArray(),other->getArray())),arr2(DataArrayDouble::Add(getEndArray(),other->getEndArray()));
+ MEDCouplingLinearTime *ret(new MEDCouplingLinearTime);
ret->setArray(arr1,0);
ret->setEndArray(arr2,0);
return ret;