}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other,deepCopy),
- _time_discr(other._time_discr->performCopyOrIncrRef(deepCopy))
+ _time_discr(dynamic_cast<MEDCouplingTimeDiscretization *>(other._time_discr->performCopyOrIncrRef(deepCopy)))
{
}
// Author : Yann Pora (EDF R&D)
#include "MEDCouplingFieldInt.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingMesh.hxx"
using namespace MEDCoupling;
return new MEDCouplingFieldInt(type,td);
}
+MEDCouplingFieldInt *MEDCouplingFieldInt::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
+{
+ return new MEDCouplingFieldInt(ft,td);
+}
+
void MEDCouplingFieldInt::checkConsistencyLight() const
{
MEDCouplingField::checkConsistencyLight();
- if(_array.isNull())
- throw INTERP_KERNEL::Exception("MEDCouplingFieldInt::checkConsistencyLight : array is null !");
+ _time_discr->checkConsistencyLight();
_type->checkCoherencyBetween(_mesh,getArray());
}
std::string MEDCouplingFieldInt::simpleRepr() const
{
- return std::string();
+ std::ostringstream ret;
+ ret << "FieldInt with name : \"" << getName() << "\"\n";
+ ret << "Description of field is : \"" << getDescription() << "\"\n";
+ if(_type)
+ { ret << "FieldInt space discretization is : " << _type->getStringRepr() << "\n"; }
+ else
+ { ret << "FieldInt has no spatial discretization !\n"; }
+ if(_time_discr)
+ { ret << "FieldInt time discretization is : " << _time_discr->getStringRepr() << "\n"; }
+ else
+ { ret << "FieldInt has no time discretization !\n"; }
+ ret << "FieldInt nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n";
+ if(getArray())
+ {
+ if(getArray()->isAllocated())
+ {
+ int nbOfCompo=getArray()->getNumberOfComponents();
+ ret << "FieldInt default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
+ ret << "FieldInt default array has following info on components : ";
+ for(int i=0;i<nbOfCompo;i++)
+ ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
+ ret << "\n";
+ }
+ else
+ {
+ ret << "Array set but not allocated !\n";
+ }
+ }
+ if(_mesh)
+ ret << "Mesh support information :\n__________________________\n" << _mesh->simpleRepr();
+ else
+ ret << "Mesh support information : No mesh set !\n";
+ return ret.str();
}
void MEDCouplingFieldInt::reprQuickOverview(std::ostream& stream) const
void MEDCouplingFieldInt::setArray(DataArrayInt *array)
{
- MCAuto<DataArrayInt> array2(array);
- if(array2.isNotNull())
- array2->incrRef();
- _array=array2;
- //_time_discr->setArray(array,this);
+ _time_discr->setArray(array,this);
}
const DataArrayInt *MEDCouplingFieldInt::getArray() const
{
- return _array;
+ return _time_discr->getArray();
}
DataArrayInt *MEDCouplingFieldInt::getArray()
{
- return _array;
+ return _time_discr->getArray();
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretization::New(td))
+MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))
{
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(other._time_discr->performCopyOrIncrRef(deepCopy))
+MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(dynamic_cast<MEDCouplingTimeDiscretizationInt *>(other._time_discr->performCopyOrIncrRef(deepCopy)))
{
- if(other._array.isNull())
- return ;
- if(deepCopy)
- {
- _array=other._array->deepCopy();
- }
- else
- {
- _array=other._array;
- }
}
-MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
+MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
{
}
{
delete _time_discr;
}
+
+/*!
+ * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
+ */
+MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft,false),_time_discr(MEDCouplingTimeDiscretizationInt::New(td))
+{
+}
//
// Author : Yann Pora (EDF R&D)
-#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDINT_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGFIELDINT_HXX__
+#ifndef __MEDCOUPLINGFIELDINT_HXX__
+#define __MEDCOUPLINGFIELDINT_HXX__
#include "MEDCoupling.hxx"
#include "MEDCouplingField.hxx"
namespace MEDCoupling
{
+ class MEDCouplingFieldTemplate;
+
class MEDCouplingFieldInt : public MEDCouplingField
{
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
+ MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
protected:
MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td);
MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy);
- MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
+ MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type);
+ MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
~MEDCouplingFieldInt();
private:
- MEDCouplingTimeDiscretization *_time_discr;
- MCAuto<DataArrayInt> _array;// agy : don't panic ! this is temporary ! templatization of time discr is planned !
+ MEDCouplingTimeDiscretizationInt *_time_discr;
};
}
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingMesh.hxx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
return new MEDCouplingFieldTemplate(f);
}
+MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldInt& f)
+{
+ return new MEDCouplingFieldTemplate(f);
+}
+
/*!
* The user should \b not use this method. Only useful for CORBA serialization/unserialization.
*/
checkConsistencyLight();
}
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f):MEDCouplingField(f,false)
+{
+ forceTimeOfThis(f);
+ checkConsistencyLight();
+}
+
MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(TypeOfField type):MEDCouplingField(type)
{
}
namespace MEDCoupling
{
+ class MEDCouplingFieldInt;
class MEDCouplingFieldDouble;
/*!
* \brief A field template can be seen as a field without the array of values.
{
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f);
+ MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldInt& f);
MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(TypeOfField type);
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT std::string advancedRepr() const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
private:
MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f);
+ MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f);
MEDCouplingFieldTemplate(TypeOfField type);
};
}
//
// Author : Anthony Geay (CEA/DEN)
-#ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
+#ifndef __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
+#define __MEDCOUPLING_MEDCOUPLINGMEMARRAY_HXX__
#include "MEDCoupling.hxx"
#include "MEDCouplingTimeLabel.hxx"
//
// Author : Anthony Geay (CEA/DEN)
-#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingTimeDiscretization.txx"
#include "MCAuto.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingMesh.hxx"
-#include <cmath>
-#include <sstream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace MEDCoupling;
-const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12;
+template class MEDCouplingTimeDiscretizationTemplate<double>;
+template class MEDCouplingTimeDiscretizationTemplate<int>;
+
+const char MEDCouplingTimeDiscretizationInt::REPR[]="One time label.";
const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
}
}
-void MEDCouplingTimeDiscretization::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
-{
- _time_tolerance=other._time_tolerance;
- _time_unit=other._time_unit;
-}
-
-void MEDCouplingTimeDiscretization::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
-{
- _time_unit=other._time_unit;
- if(_array && other._array)
- _array->copyStringInfoFrom(*other._array);
-}
-
-void MEDCouplingTimeDiscretization::checkConsistencyLight() const
-{
- if(!_array)
- throw INTERP_KERNEL::Exception("Field invalid because no values set !");
- if(_time_tolerance<0.)
- throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
-}
-
-void MEDCouplingTimeDiscretization::updateTime() const
-{
- if(_array)
- updateTimeWith(*_array);
-}
-
-std::size_t MEDCouplingTimeDiscretization::getHeapMemorySizeWithoutChildren() const
-{
- std::size_t ret(_time_unit.capacity());
- return ret;
-}
-
-std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretization::getDirectChildrenWithNull() const
-{
- std::vector<const BigMemoryObject *> ret;
- ret.push_back(_array);
- return ret;
-}
-
-bool MEDCouplingTimeDiscretization::areCompatible(const MEDCouplingTimeDiscretization *other) const
-{
- if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- return false;
- if(_array==0 && other->_array==0)
- return true;
- if(_array==0 || other->_array==0)
- return false;
- if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
- return false;
- return true;
-}
-
-bool MEDCouplingTimeDiscretization::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
-{
- std::ostringstream oss; oss.precision(15);
- if(_time_unit!=other->_time_unit)
- {
- oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
- reason=oss.str();
- return false;
- }
- if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- {
- oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
- reason=oss.str();
- return false;
- }
- if(_array==0 && other->_array==0)
- return true;
- if(_array==0 || other->_array==0)
- {
- reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
- return false;
- }
- if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
- return false;
- if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
- return false;
- return true;
-}
-
bool MEDCouplingTimeDiscretization::areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const
{
if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
return true;
}
-bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
-{
- if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- return false;
- if(_array==0 && other->_array==0)
- return true;
- if(_array==0 || other->_array==0)
- return false;
- int nbC1=_array->getNumberOfComponents();
- int nbC2=other->_array->getNumberOfComponents();
- int nbMin=std::min(nbC1,nbC2);
- if(nbC1!=nbC2 && nbMin!=1)
- return false;
- return true;
-}
-
-bool MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
-{
- if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- return false;
- if(_array==0 && other->_array==0)
- return true;
- if(_array==0 || other->_array==0)
- return false;
- int nbC1=_array->getNumberOfComponents();
- int nbC2=other->_array->getNumberOfComponents();
- if(nbC1!=nbC2 && nbC2!=1)
- return false;
- return true;
-}
-
bool MEDCouplingTimeDiscretization::isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const
{
if(!areStrictlyCompatible(other,reason))
tinyInfo.push_back(_array->getInfoOnComponent(i));
}
-MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
-{
-}
-
-MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
-{
- if(other._array)
- _array=other._array->performCopyOrIncrRef(deepCopy);
- else
- _array=0;
-}
-
-MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
-{
- if(_array)
- _array->decrRef();
-}
-
-void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
-{
- if(array!=_array)
- {
- if(_array)
- _array->decrRef();
- _array=array;
- if(_array)
- _array->incrRef();
- if(owner)
- owner->declareAsNew();
- }
-}
-
const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const
{
throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !");
setArrays(arrays3,0);
}
+////////////////////////
+
+bool MEDCouplingTimeKeeper::isEqualIfNotWhy(const MEDCouplingTimeKeeper& other, double prec, std::string& reason) const
+{
+ std::ostringstream oss;
+ if(_iteration!=other._iteration)
+ {
+ oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << other._iteration;
+ reason=oss.str();
+ return false;
+ }
+ if(_order!=other._order)
+ {
+ oss << "orders differ. this order=" << _order << " other order=" << other._order;
+ reason=oss.str();
+ return false;
+ }
+ if(std::fabs(_time-other._time)>prec)
+ {
+ oss << "times differ. this time=" << _time << " other time=" << other._time;
+ reason=oss.str();
+ return false;
+ }
+ return true;
+}
+
+bool MEDCouplingTimeKeeper::isEqual(const MEDCouplingTimeKeeper& other, double prec) const
+{
+ if(_iteration!=other._iteration)
+ return false;
+ if(_order!=other._order)
+ return false;
+ if(std::fabs(_time-other._time)>prec)
+ return false;
+ return true;
+}
+
+void MEDCouplingTimeKeeper::copyFrom(const MEDCouplingTimeKeeper& other)
+{
+ _time=other._time;
+ _iteration=other._iteration;
+ _order=other._order;
+}
+
+void MEDCouplingTimeKeeper::checkTimePresence(double time, double eps) const
+{
+ if(std::fabs(time-_time)>eps)
+ {
+ std::ostringstream stream;
+ stream << "The field is defined on time " << _time << " with eps=" << eps << " and asking time = " << time << " !";
+ throw INTERP_KERNEL::Exception(stream.str().c_str());
+ }
+}
+
+////////////////////////
+
+MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt()
+{
+}
+
+MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<int>(other,deepCopy)
+{
+}
+
+std::string MEDCouplingTimeDiscretizationInt::getStringRepr() const
+{
+ std::ostringstream stream;
+ stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
+ stream << "\nTime unit is : \"" << _time_unit << "\"";
+ return stream.str();
+}
+
+MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::performCopyOrIncrRef(bool deepCopy) const
+{
+ return new MEDCouplingTimeDiscretizationInt(*this,deepCopy);
+}
+
+MEDCouplingTimeDiscretizationInt *MEDCouplingTimeDiscretizationInt::New(TypeOfTimeDiscretization type)
+{
+ switch(type)
+ {
+ case MEDCouplingTimeDiscretizationInt::DISCRETIZATION:
+ return new MEDCouplingTimeDiscretizationInt;
+ default:
+ throw INTERP_KERNEL::Exception("Time discretization not implemented yet for intergers !");
+ }
+}
+
+
+////////////////////////
+
MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
{
}
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
+bool MEDCouplingNoTimeLabel::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingNoTimeLabel::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
_time_tolerance=tinyInfoD[0];
}
-MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),
- _time(other._time),_iteration(other._iteration),_order(other._order)
+MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCopy):MEDCouplingTimeDiscretization(other,deepCopy),_tk(other._tk)
{
}
-MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_iteration(-1),_order(-1)
+MEDCouplingWithTimeStep::MEDCouplingWithTimeStep()
{
}
std::string MEDCouplingWithTimeStep::getStringRepr() const
{
std::ostringstream stream;
- stream << REPR << " Time is defined by iteration=" << _iteration << " order=" << _order << " and time=" << _time << ".";
+ stream << REPR << " Time is defined by iteration=" << _tk.getIteration() << " order=" << _tk.getOrder() << " and time=" << _tk.getTimeValue() << ".";
stream << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
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;
+ _tk.setAllInfo(val,it,order);
std::string tUnit=mesh->getTimeUnit();
_time_unit=tUnit;
}
void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
- tinyInfo.push_back(_iteration);
- tinyInfo.push_back(_order);
+ tinyInfo.push_back(_tk.getIteration());
+ tinyInfo.push_back(_tk.getOrder());
}
void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
{
MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
- tinyInfo.push_back(_time);
+ tinyInfo.push_back(_tk.getTimeValue());
}
void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
- _time=tinyInfoD[1];
- _iteration=tinyInfoI[2];
- _order=tinyInfoI[3];
+ _tk.setTimeValue(tinyInfoD[1]);
+ _tk.setIteration(tinyInfoI[2]);
+ _tk.setOrder(tinyInfoI[3]);
}
/*!
void MEDCouplingWithTimeStep::getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const
{
tinyInfo.resize(2);
- tinyInfo[0]=_iteration;
- tinyInfo[1]=_order;
+ tinyInfo[0]=_tk.getIteration();
+ tinyInfo[1]=_tk.getOrder();
}
/*!
{
tinyInfo.resize(2);
tinyInfo[0]=_time_tolerance;
- tinyInfo[1]=_time;
+ tinyInfo[1]=_tk.getTimeValue();
}
/*!
*/
void MEDCouplingWithTimeStep::finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
{
- _iteration=tinyInfoI[0];
- _order=tinyInfoI[1];
+ _tk.setIteration(tinyInfoI[0]);
+ _tk.setOrder(tinyInfoI[1]);
_time_tolerance=tinyInfoD[0];
- _time=tinyInfoD[1];
+ _tk.setTimeValue(tinyInfoD[1]);
}
-bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingWithTimeStep::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
reason="This has time discretization ONE_TIME, other not.";
return false;
}
- if(_iteration!=otherC->_iteration)
- {
- oss << "iterations differ. this iteration=" << _iteration << " other iteration=" << otherC->_iteration;
- reason=oss.str();
- return false;
- }
- if(_order!=otherC->_order)
- {
- oss << "orders differ. this order=" << _order << " other order=" << otherC->_order;
- reason=oss.str();
- return false;
- }
- if(std::fabs(_time-otherC->_time)>_time_tolerance)
- {
- oss << "times differ. this time=" << _time << " other time=" << otherC->_time;
- reason=oss.str();
- return false;
- }
+ if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
+ return false;
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
if(!otherC)
return false;
- if(_iteration!=otherC->_iteration)
- return false;
- if(_order!=otherC->_order)
- return false;
- if(std::fabs(_time-otherC->_time)>_time_tolerance)
- return false;
+ if(!_tk.isEqual(otherC->_tk,_time_tolerance))
+ return false;
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
}
-void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingWithTimeStep::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
{
MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(&other);
if(!otherC)
throw INTERP_KERNEL::Exception("MEDCouplingWithTimeStep::copyTinyAttrFrom : mismatch of time discretization !");
- _time=otherC->_time;
- _iteration=otherC->_iteration;
- _order=otherC->_order;
+ _tk.copyFrom(otherC->_tk);
}
MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::aggregate(const MEDCouplingTimeDiscretization *other) const
void MEDCouplingWithTimeStep::checkTimePresence(double time) const
{
- if(std::fabs(time-_time)>_time_tolerance)
- {
- std::ostringstream stream;
- stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
- throw INTERP_KERNEL::Exception(stream.str().c_str());
- }
+ _tk.checkTimePresence(time,_time_tolerance);
}
std::vector< const DataArrayDouble *> MEDCouplingWithTimeStep::getArraysForTime(double time) const
{
- if(std::fabs(time-_time)<=_time_tolerance)
+ if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
{
std::vector< const DataArrayDouble *> ret(1);
ret[0]=_array;
void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const
{
- if(std::fabs(time-_time)<=_time_tolerance)
+ if(std::fabs(time-_tk.getTimeValue())<=_time_tolerance)
if(_array)
_array->getTuple(eltId,value);
else
void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
{
- if(_iteration==iteration && _order==order)
+ if(_tk.getIteration()==iteration && _tk.getOrder()==order)
if(_array)
_array->getTuple(eltId,value);
else
throw INTERP_KERNEL::Exception("No data on this discrete time.");
}
-MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval():_start_time(0.),_end_time(0.),_start_iteration(-1),_end_iteration(-1),_start_order(-1),_end_order(-1)
+MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval()
{
}
-void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingConstOnTimeInterval::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
{
MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(&other);
if(!otherC)
throw INTERP_KERNEL::Exception("MEDCouplingConstOnTimeInterval::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 MEDCouplingConstOnTimeInterval::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());
}
void MEDCouplingConstOnTimeInterval::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 MEDCouplingConstOnTimeInterval::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 MEDCouplingConstOnTimeInterval::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 MEDCouplingConstOnTimeInterval::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]);
}
MEDCouplingConstOnTimeInterval::MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& 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)
+ MEDCouplingTimeDiscretization(other,deepCopy),_start(other._start),_end(other._end)
{
}
std::string MEDCouplingConstOnTimeInterval::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 << "\nTime unit is : \"" << _time_unit << "\"";
return stream.str();
}
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();
+ _start.setAllInfo(val,it,order);
+ _end.setAllInfo(val,it,order);
+ std::string tUnit(mesh->getTimeUnit());
_time_unit=tUnit;
}
std::vector< const DataArrayDouble *> MEDCouplingConstOnTimeInterval::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(1);
ret[0]=_array;
std::copy(vals.begin(),vals.end(),res);
}
-bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingConstOnTimeInterval::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
reason="This has time discretization CONST_ON_TIME_INTERVAL, 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;
return MEDCouplingTimeDiscretization::isEqualIfNotWhy(other,prec,reason);
}
const MEDCouplingConstOnTimeInterval *otherC=dynamic_cast<const MEDCouplingConstOnTimeInterval *>(other);
if(!otherC)
return false;
- if(_start_iteration!=otherC->_start_iteration)
- return false;
- if(_start_order!=otherC->_start_order)
- return false;
- if(std::fabs(_start_time-otherC->_start_time)>_time_tolerance)
- return false;
- if(_end_iteration!=otherC->_end_iteration)
- return false;
- if(_end_order!=otherC->_end_order)
+ 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;
return MEDCouplingTimeDiscretization::isEqualWithoutConsideringStr(other,prec);
}
void MEDCouplingConstOnTimeInterval::getValueOnTime(int eltId, double time, double *value) const
{
- if(time>_start_time-_time_tolerance && time<_end_time+_time_tolerance)
+ if(time>_start.getTimeValue()-_time_tolerance && time<_end.getTimeValue()+_time_tolerance)
if(_array)
_array->getTuple(eltId,value);
else
void MEDCouplingConstOnTimeInterval::getValueOnDiscTime(int eltId, int iteration, int order, double *value) const
{
- if(iteration>=_start_iteration && iteration<=_end_iteration)
+ if(iteration>=_start.getIteration() && iteration<=_end.getIteration())
if(_array)
_array->getTuple(eltId,value);
else
void MEDCouplingConstOnTimeInterval::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());
}
return ret;
}
-void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingTwoTimeSteps::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
{
MEDCouplingTimeDiscretization::copyTinyAttrFrom(other);
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
_end_order=otherC->_end_order;
}
-void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other)
+void MEDCouplingTwoTimeSteps::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other)
{
MEDCouplingTimeDiscretization::copyTinyStringsFrom(other);
const MEDCouplingTwoTimeSteps *otherC=dynamic_cast<const MEDCouplingTwoTimeSteps *>(&other);
return new MEDCouplingLinearTime(*this,deepCopy);
}
-bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areCompatible(other))
return false;
return true;
}
-bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const
+bool MEDCouplingLinearTime::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatible(other,reason))
return false;
return ret;
}
-bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForMul(other))
return false;
return otherC!=0;
}
-bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const
+bool MEDCouplingLinearTime::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const
{
if(!MEDCouplingTimeDiscretization::areStrictlyCompatibleForDiv(other))
return false;
//
// Author : Anthony Geay (CEA/DEN)
-#ifndef __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
+#ifndef __MEDCOUPLINGTIMEDISCRETIZATION_HXX__
+#define __MEDCOUPLINGTIMEDISCRETIZATION_HXX__
#include "MEDCoupling.hxx"
#include "MEDCouplingTimeLabel.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "InterpKernelException.hxx"
+#include "MEDCouplingTraits.hxx"
#include <vector>
class DataArrayDouble;
class TimeLabel;
- class MEDCouplingTimeDiscretization : public TimeLabel, public BigMemoryObject
+ template<class T>
+ class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject
{
- protected:
- MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization();
- MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCopy);
public:
MEDCOUPLING_EXPORT void updateTime() const;
- MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const;
- MEDCOUPLING_EXPORT virtual std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDCOUPLING_EXPORT static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+ MEDCOUPLING_EXPORT virtual void setArray(typename Traits<T>::ArrayType *array, TimeLabel *owner);
+ MEDCOUPLING_EXPORT typename Traits<T>::ArrayType *getArray() { return _array; }
+ MEDCOUPLING_EXPORT const typename Traits<T>::ArrayType *getArray() const { return _array; }
MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; }
MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; }
- MEDCOUPLING_EXPORT virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
- MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
+ MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_tolerance=val; }
+ MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_tolerance; }
+ MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return getStartTime(iteration,order); }
+ MEDCOUPLING_EXPORT void setTime(double time, int iteration, int order) { setStartTime(time,iteration,order); }
+ MEDCOUPLING_EXPORT void setIteration(int it) { setStartIteration(it); }
+ MEDCOUPLING_EXPORT void setOrder(int order) { setStartOrder(order); }
+ MEDCOUPLING_EXPORT void setTimeValue(double val) { setStartTimeValue(val); }
+ MEDCOUPLING_EXPORT virtual double getStartTime(int& iteration, int& order) const = 0;
+ MEDCOUPLING_EXPORT virtual void setStartIteration(int it) = 0;
+ MEDCOUPLING_EXPORT virtual void setStartOrder(int order) = 0;
+ MEDCOUPLING_EXPORT virtual void setStartTime(double time, int iteration, int order) = 0;
+ MEDCOUPLING_EXPORT virtual void setStartTimeValue(double time) = 0;
+ MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0;
+ MEDCOUPLING_EXPORT virtual TypeOfTimeDiscretization getEnum() const = 0;
+ MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretizationTemplate<T> *performCopyOrIncrRef(bool deepCopy) const = 0;
+ //
+ MEDCOUPLING_EXPORT virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other);
+ MEDCOUPLING_EXPORT virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other);
MEDCOUPLING_EXPORT virtual void checkConsistencyLight() const;
- MEDCOUPLING_EXPORT virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDCOUPLING_EXPORT virtual std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ //
+ MEDCOUPLING_EXPORT virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other, std::string& reason) const;
+ MEDCOUPLING_EXPORT virtual bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
+ MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
+ MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
+ protected:
+ MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate();
+ MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy);
+ MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate();
+ protected:
+ std::string _time_unit;
+ double _time_tolerance;
+ typename Traits<T>::ArrayType *_array;
+ protected:
+ static const double TIME_TOLERANCE_DFT;
+ };
+
+ class MEDCouplingTimeKeeper
+ {
+ public:
+ MEDCOUPLING_EXPORT MEDCouplingTimeKeeper():_time(0.),_iteration(-1),_order(-1) { }
+ MEDCOUPLING_EXPORT double getAllInfo(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
+ MEDCOUPLING_EXPORT void setAllInfo(double time, int iteration, int order) { _time=time; _iteration=iteration; _order=order; }
+ MEDCOUPLING_EXPORT int getIteration() const { return _iteration; }
+ MEDCOUPLING_EXPORT void setIteration(int it) { _iteration=it; }
+ MEDCOUPLING_EXPORT int getOrder() const { return _order; }
+ MEDCOUPLING_EXPORT void setOrder(int order) { _order=order; }
+ MEDCOUPLING_EXPORT double getTimeValue() const { return _time; }
+ MEDCOUPLING_EXPORT void setTimeValue(double time) { _time=time; }
+ MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeKeeper& other, double prec, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingTimeKeeper& other, double prec) const;
+ MEDCOUPLING_EXPORT void copyFrom(const MEDCouplingTimeKeeper& other);
+ MEDCOUPLING_EXPORT void checkTimePresence(double time, double eps) const;
+ private:
+ double _time;
+ int _iteration;
+ int _order;
+ };
+
+ class MEDCouplingTimeDiscretization : public MEDCouplingTimeDiscretizationTemplate<double>
+ {
+ protected:
+ MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization() { }
+ MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<double>(other,deepCopy) { }
+ public:
+ MEDCOUPLING_EXPORT static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
MEDCOUPLING_EXPORT virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
MEDCOUPLING_EXPORT virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCopy) const;
- MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0;
- MEDCOUPLING_EXPORT virtual TypeOfTimeDiscretization getEnum() const = 0;
MEDCOUPLING_EXPORT virtual void synchronizeTimeWith(const MEDCouplingMesh *mesh) = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
MEDCOUPLING_EXPORT virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
- MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const = 0;
- MEDCOUPLING_EXPORT void setTimeTolerance(double val) { _time_tolerance=val; }
- MEDCOUPLING_EXPORT double getTimeTolerance() const { return _time_tolerance; }
MEDCOUPLING_EXPORT virtual void checkNoTimePresence() const = 0;
MEDCOUPLING_EXPORT virtual void checkTimePresence(double time) const = 0;
- MEDCOUPLING_EXPORT virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
MEDCOUPLING_EXPORT virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
MEDCOUPLING_EXPORT virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner);
- MEDCOUPLING_EXPORT DataArrayDouble *getArray() { return _array; }
- MEDCOUPLING_EXPORT const DataArrayDouble *getArray() const { return _array; }
MEDCOUPLING_EXPORT virtual const DataArrayDouble *getEndArray() const;
MEDCOUPLING_EXPORT virtual DataArrayDouble *getEndArray();
MEDCOUPLING_EXPORT virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const = 0;
MEDCOUPLING_EXPORT virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
MEDCOUPLING_EXPORT virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return getStartTime(iteration,order); }
- MEDCOUPLING_EXPORT virtual double getStartTime(int& iteration, int& order) const = 0;
MEDCOUPLING_EXPORT virtual double getEndTime(int& iteration, int& order) const = 0;
- MEDCOUPLING_EXPORT void setTime(double time, int iteration, int order) { setStartTime(time,iteration,order); }
- MEDCOUPLING_EXPORT void setIteration(int it) { setStartIteration(it); }
- MEDCOUPLING_EXPORT void setOrder(int order) { setStartOrder(order); }
- MEDCOUPLING_EXPORT void setTimeValue(double val) { setStartTimeValue(val); }
- MEDCOUPLING_EXPORT virtual void setStartIteration(int it) = 0;
MEDCOUPLING_EXPORT virtual void setEndIteration(int it) = 0;
- MEDCOUPLING_EXPORT virtual void setStartOrder(int order) = 0;
MEDCOUPLING_EXPORT virtual void setEndOrder(int order) = 0;
- MEDCOUPLING_EXPORT virtual void setStartTimeValue(double time) = 0;
MEDCOUPLING_EXPORT virtual void setEndTimeValue(double time) = 0;
- MEDCOUPLING_EXPORT virtual void setStartTime(double time, int iteration, int order) = 0;
MEDCOUPLING_EXPORT virtual void setEndTime(double time, int iteration, int order) = 0;
MEDCOUPLING_EXPORT virtual void getValueOnTime(int eltId, double time, double *value) const = 0;
MEDCOUPLING_EXPORT virtual void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const = 0;
MEDCOUPLING_EXPORT virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const std::string& func);
MEDCOUPLING_EXPORT virtual void fillFromAnalyticCompo(const DataArrayDouble *loc, int nbOfComp, const std::string& func);
MEDCOUPLING_EXPORT virtual void fillFromAnalyticNamedCompo(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const std::string& func);
- //
- MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretization();
- protected:
- std::string _time_unit;
- double _time_tolerance;
- DataArrayDouble *_array;
+ };
+
+ class MEDCouplingTimeDiscretizationInt : public MEDCouplingTimeDiscretizationTemplate<int>
+ {
+ public:
+ MEDCouplingTimeDiscretizationInt();
+ MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy);
+ static MEDCouplingTimeDiscretizationInt *New(TypeOfTimeDiscretization type);
+ double getStartTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); }
+ void setStartIteration(int it) { _tk.setIteration(it); }
+ void setStartOrder(int order) { _tk.setOrder(order); }
+ void setStartTimeValue(double time) { _tk.setTimeValue(time); }
+ void setStartTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); }
+ std::string getStringRepr() const;
+ TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ MEDCouplingTimeDiscretizationInt *performCopyOrIncrRef(bool deepCopy) const;
+ private:
+ static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
+ MEDCOUPLING_EXPORT static const char REPR[];
protected:
- static const double TIME_TOLERANCE_DFT;
+ MEDCouplingTimeKeeper _tk;
};
-
+
class MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization
{
public:
MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const;
MEDCOUPLING_EXPORT void checkNoTimePresence() const { }
public:
MEDCOUPLING_EXPORT MEDCouplingWithTimeStep();
MEDCOUPLING_EXPORT std::string getStringRepr() const;
- MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
+ MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other);
MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh);
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
- MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const;
MEDCOUPLING_EXPORT void checkNoTimePresence() const;
MEDCOUPLING_EXPORT void checkTimePresence(double time) const;
- MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _time=time; _iteration=iteration; _order=order; }
- MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _time=time; _iteration=iteration; _order=order; }
- MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
- MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _time; }
- MEDCOUPLING_EXPORT void setStartIteration(int it) { _iteration=it; }
- MEDCOUPLING_EXPORT void setEndIteration(int it) { _iteration=it; }
- MEDCOUPLING_EXPORT void setStartOrder(int order) { _order=order; }
- MEDCOUPLING_EXPORT void setEndOrder(int order) { _order=order; }
- MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _time=time; }
- MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _time=time; }
+ MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _tk.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _tk.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT void setStartIteration(int it) { _tk.setIteration(it); }
+ MEDCOUPLING_EXPORT void setEndIteration(int it) { _tk.setIteration(it); }
+ MEDCOUPLING_EXPORT void setStartOrder(int order) { _tk.setOrder(order); }
+ MEDCOUPLING_EXPORT void setEndOrder(int order) { _tk.setOrder(order); }
+ MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _tk.setTimeValue(time); }
+ MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _tk.setTimeValue(time); }
MEDCOUPLING_EXPORT std::vector< const DataArrayDouble *> getArraysForTime(double time) const;
MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
MEDCOUPLING_EXPORT void getValueOnTime(int eltId, double time, double *value) const;
private:
static const char EXCEPTION_MSG[];
protected:
- double _time;
- int _iteration;
- int _order;
+ MEDCouplingTimeKeeper _tk;
};
class MEDCouplingConstOnTimeInterval : public MEDCouplingTimeDiscretization
MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCopy);
public:
MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval();
- MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
+ MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other);
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const;
- MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
MEDCOUPLING_EXPORT void divideEqual(const MEDCouplingTimeDiscretization *other);
MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void powEqual(const MEDCouplingTimeDiscretization *other);
- MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start_time=time; _start_iteration=iteration; _start_order=order; }
- MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end_time=time; _end_iteration=iteration; _end_order=order; }
- MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { iteration=_start_iteration; order=_start_order; return _start_time; }
- MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { iteration=_end_iteration; order=_end_order; return _end_time; }
- MEDCOUPLING_EXPORT void setStartIteration(int it) { _start_iteration=it; }
- MEDCOUPLING_EXPORT void setEndIteration(int it) { _end_iteration=it; }
- MEDCOUPLING_EXPORT void setStartOrder(int order) { _start_order=order; }
- MEDCOUPLING_EXPORT void setEndOrder(int order) { _end_order=order; }
- MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start_time=time; }
- MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end_time=time; }
+ MEDCOUPLING_EXPORT void setStartTime(double time, int iteration, int order) { _start.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT void setEndTime(double time, int iteration, int order) { _end.setAllInfo(time,iteration,order); }
+ MEDCOUPLING_EXPORT double getStartTime(int& iteration, int& order) const { return _start.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT double getEndTime(int& iteration, int& order) const { return _end.getAllInfo(iteration,order); }
+ MEDCOUPLING_EXPORT void setStartIteration(int it) { _start.setIteration(it); }
+ MEDCOUPLING_EXPORT void setEndIteration(int it) { _end.setIteration(it); }
+ MEDCOUPLING_EXPORT void setStartOrder(int order) { _start.setOrder(order); }
+ MEDCOUPLING_EXPORT void setEndOrder(int order) { _end.setOrder(order); }
+ MEDCOUPLING_EXPORT void setStartTimeValue(double time) { _start.setTimeValue(time); }
+ MEDCOUPLING_EXPORT void setEndTimeValue(double time) { _end.setTimeValue(time); }
MEDCOUPLING_EXPORT void checkNoTimePresence() const;
MEDCOUPLING_EXPORT void checkTimePresence(double time) const;
public:
private:
static const char EXCEPTION_MSG[];
protected:
- double _start_time;
- double _end_time;
- int _start_iteration;
- int _end_iteration;
- int _start_order;
- int _end_order;
+ MEDCouplingTimeKeeper _start;
+ MEDCouplingTimeKeeper _end;
};
class MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization
MEDCOUPLING_EXPORT void synchronizeTimeWith(const MEDCouplingMesh *mesh);
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
- MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
+ MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other);
+ MEDCOUPLING_EXPORT void copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<double>& other);
MEDCOUPLING_EXPORT const DataArrayDouble *getEndArray() const;
MEDCOUPLING_EXPORT DataArrayDouble *getEndArray();
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *performCopyOrIncrRef(bool deepCopy) const;
- MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
- MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
+ MEDCOUPLING_EXPORT bool areCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<double> *other, std::string& reason) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
+ MEDCOUPLING_EXPORT bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<double> *other) const;
MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
MEDCOUPLING_EXPORT void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
MEDCOUPLING_EXPORT void getValueOnTime(int eltId, double time, double *value) const;
--- /dev/null
+// Copyright (C) 2007-2016 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay (EDF R&D)
+
+#ifndef __MEDCOUPLINGTIMEDISCRETIZATION_TXX__
+#define __MEDCOUPLINGTIMEDISCRETIZATION_TXX__
+
+#include "MEDCouplingTimeDiscretization.hxx"
+
+#include <cmath>
+#include <sstream>
+
+namespace MEDCoupling
+{
+ template<class T>
+ const double MEDCouplingTimeDiscretizationTemplate<T>::TIME_TOLERANCE_DFT=1.e-12;
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::updateTime() const
+ {
+ if(_array)
+ updateTimeWith(*_array);
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::setArray(typename Traits<T>::ArrayType *array, TimeLabel *owner)
+ {
+ if(array!=_array)
+ {
+ if(_array)
+ _array->decrRef();
+ _array=array;
+ if(_array)
+ _array->incrRef();
+ if(owner)
+ owner->declareAsNew();
+ }
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other)
+ {
+ _time_tolerance=other._time_tolerance;
+ _time_unit=other._time_unit;
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other)
+ {
+ _time_unit=other._time_unit;
+ if(_array && other._array)
+ _array->copyStringInfoFrom(*other._array);
+ }
+
+ template<class T>
+ std::size_t MEDCouplingTimeDiscretizationTemplate<T>::getHeapMemorySizeWithoutChildren() const
+ {
+ return _time_unit.capacity();
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::checkConsistencyLight() const
+ {
+ if(!_array)
+ throw INTERP_KERNEL::Exception("Field invalid because no values set !");
+ if(_time_tolerance<0.)
+ throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
+ }
+
+ template<class T>
+ std::vector<const BigMemoryObject *> MEDCouplingTimeDiscretizationTemplate<T>::getDirectChildrenWithNull() const
+ {
+ std::vector<const BigMemoryObject *> ret;
+ ret.push_back(_array);
+ return ret;
+ }
+
+ template<class T>
+ bool MEDCouplingTimeDiscretizationTemplate<T>::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other, std::string& reason) const
+ {
+ std::ostringstream oss; oss.precision(15);
+ if(_time_unit!=other->_time_unit)
+ {
+ oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ {
+ oss << "Field discretizations differ : this time tolerance = \"" << _time_tolerance << "\" and other time tolerance = \"" << other->_time_tolerance << "\" !";
+ reason=oss.str();
+ return false;
+ }
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ {
+ reason="Field discretizations differ : Only one timediscretization between the two this and other has a DataArrayDouble for values defined";
+ return false;
+ }
+ if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
+ return false;
+ if(_array->getNumberOfTuples()!=other->_array->getNumberOfTuples())
+ return false;
+ return true;
+ }
+
+ template<class T>
+ bool MEDCouplingTimeDiscretizationTemplate<T>::areCompatible(const MEDCouplingTimeDiscretizationTemplate<T> *other) const
+ {
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ return false;
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ return false;
+ if(_array->getNumberOfComponents()!=other->_array->getNumberOfComponents())
+ return false;
+ return true;
+ }
+
+ template<class T>
+ bool MEDCouplingTimeDiscretizationTemplate<T>::areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<T> *other) const
+ {
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ return false;
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ return false;
+ int nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
+ int nbMin(std::min(nbC1,nbC2));
+ if(nbC1!=nbC2 && nbMin!=1)
+ return false;
+ return true;
+ }
+
+ template<class T>
+ bool MEDCouplingTimeDiscretizationTemplate<T>::areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<T> *other) const
+ {
+ if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
+ return false;
+ if(_array==0 && other->_array==0)
+ return true;
+ if(_array==0 || other->_array==0)
+ return false;
+ int nbC1(_array->getNumberOfComponents()),nbC2(other->_array->getNumberOfComponents());
+ if(nbC1!=nbC2 && nbC2!=1)
+ return false;
+ return true;
+ }
+
+ template<class T>
+ MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
+ {
+ }
+
+ template<class T>
+ MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
+ {
+ if(other._array)
+ _array=other._array->performCopyOrIncrRef(deepCopy);
+ else
+ _array=0;
+ }
+
+ template<class T>
+ MEDCouplingTimeDiscretizationTemplate<T>::~MEDCouplingTimeDiscretizationTemplate()
+ {
+ if(_array)
+ _array->decrRef();
+ }
+}
+
+#endif
{
public:
static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingFieldTemplate *New(const MEDCouplingFieldInt& f) throw(INTERP_KERNEL::Exception);
static MEDCouplingFieldTemplate *New(TypeOfField type);
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
{
return MEDCouplingFieldTemplate::New(f);
}
+
+ MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f) throw(INTERP_KERNEL::Exception)
+ {
+ return MEDCouplingFieldTemplate::New(f);
+ }
MEDCouplingFieldTemplate(TypeOfField type) throw(INTERP_KERNEL::Exception)
{
{
public:
static MEDCouplingFieldInt *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
+ static MEDCouplingFieldInt *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
void setTimeUnit(const std::string& unit) throw(INTERP_KERNEL::Exception);
std::string getTimeUnit() const throw(INTERP_KERNEL::Exception);
void setTime(double val, int iteration, int order) throw(INTERP_KERNEL::Exception);
return MEDCouplingFieldInt::New(type,td);
}
+ MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME)
+ {
+ return MEDCouplingFieldInt::New(ft,td);
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();