using namespace MEDCoupling;
template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<double>;
+template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<float>;
+template class MEDCoupling::MEDCouplingTimeDiscretizationSimple<float>;
template class MEDCoupling::MEDCouplingTimeDiscretizationTemplate<int>;
-
-const char MEDCouplingTimeDiscretizationInt::REPR[]="One time label.";
+template class MEDCoupling::MEDCouplingTimeDiscretizationSimple<int>;
const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
////////////////////////
-MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt()
-{
-}
-
-MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<int>(other,deepCopy),_tk(other._tk)
+MEDCouplingTimeDiscretizationInt::MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<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);
return _array->isEqualWithoutConsideringStr(*(other->getArray()));
}
-double MEDCouplingTimeDiscretizationInt::getEndTime(int& iteration, int& order) const
+////////////////////////
+
+MEDCouplingTimeDiscretizationFloat::MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy):MEDCouplingTimeDiscretizationSimple<float>(other,deepCopy)
{
- throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !");
}
-void MEDCouplingTimeDiscretizationInt::setEndIteration(int it)
+MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::performCopyOrIncrRef(bool deepCopy) const
{
- throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !");
+ return new MEDCouplingTimeDiscretizationFloat(*this,deepCopy);
}
-void MEDCouplingTimeDiscretizationInt::setEndOrder(int order)
+MEDCouplingTimeDiscretizationFloat *MEDCouplingTimeDiscretizationFloat::New(TypeOfTimeDiscretization type)
{
- throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !");
+ switch(type)
+ {
+ case MEDCouplingTimeDiscretizationFloat::DISCRETIZATION:
+ return new MEDCouplingTimeDiscretizationFloat;
+ default:
+ throw INTERP_KERNEL::Exception("Time discretization not implemented yet for intergers !");
+ }
}
-void MEDCouplingTimeDiscretizationInt::setEndTimeValue(double time)
+bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec, std::string& reason) const
{
- throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !");
+ if(prec!=0)
+ throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
+ if(!other)
+ {
+ reason="Time discretization is NULL.";
+ return false;
+ }
+ const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationFloat !");
+ if(!MEDCouplingTimeDiscretizationTemplate<int>::areStrictlyCompatible(other,reason))
+ return false;
+ if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
+ return false;
+ if(_array==other->getArray())
+ return true;
+ return _array->isEqualIfNotWhy(*other->getArray(),reason);
}
-void MEDCouplingTimeDiscretizationInt::setEndTime(double time, int iteration, int order)
+bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec) const
{
- throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !");
+ if(prec!=0)
+ throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr : only precision 0 is supported !");
+ const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
+ if(!otherC)
+ throw INTERP_KERNEL::Exception("isEqualWithoutConsideringStr : other is not a MEDCouplingTimeDiscretizationFloat !");
+ std::string tmp;
+ if(!areStrictlyCompatible(other,tmp))
+ return false;
+ std::string reason;
+ if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
+ return false;
+ if(_array==other->getArray())
+ return true;
+ return _array->isEqualWithoutConsideringStr(*(other->getArray()));
}
////////////////////////
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);
};
-
- class MEDCouplingTimeDiscretizationInt : public MEDCouplingTimeDiscretizationTemplate<int>
+
+ template<class T>
+ class MEDCouplingTimeDiscretizationSimple : public MEDCouplingTimeDiscretizationTemplate<T>
{
public:
- MEDCouplingTimeDiscretizationInt();
- MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy);
- static MEDCouplingTimeDiscretizationInt *New(TypeOfTimeDiscretization type);
+ std::string getStringRepr() const;
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 setEndOrder(int order);
void setEndTimeValue(double time);
void setEndTime(double time, int iteration, int order);
- std::string getStringRepr() const;
TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
+ protected:
+ MEDCouplingTimeDiscretizationSimple(const MEDCouplingTimeDiscretizationSimple<T>& other, bool deepCopy);
+ MEDCouplingTimeDiscretizationSimple() { }
+ protected:
+ MEDCouplingTimeKeeper _tk;
+ private:
+ MEDCOUPLING_EXPORT static const char REPR[];
+ protected:
+ static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
+ };
+
+ class MEDCouplingTimeDiscretizationInt : public MEDCouplingTimeDiscretizationSimple<int>
+ {
+ public:
+ MEDCouplingTimeDiscretizationInt() { }
+ MEDCouplingTimeDiscretizationInt(const MEDCouplingTimeDiscretizationInt& other, bool deepCopy);
+ static MEDCouplingTimeDiscretizationInt *New(TypeOfTimeDiscretization type);
MEDCouplingTimeDiscretizationInt *performCopyOrIncrRef(bool deepCopy) const;
bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec, std::string& reason) const;
bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, int prec) const;
+ };
+
+ class MEDCouplingTimeDiscretizationFloat : public MEDCouplingTimeDiscretizationSimple<float>
+ {
+ public:
+ MEDCouplingTimeDiscretizationFloat() { }
+ MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy);
+ static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+ MEDCouplingTimeDiscretizationFloat *performCopyOrIncrRef(bool deepCopy) const;
+ bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec, std::string& reason) const;
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec) const;
private:
static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
- MEDCOUPLING_EXPORT static const char REPR[];
- protected:
- MEDCouplingTimeKeeper _tk;
};
class MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization
namespace MEDCoupling
{
+ template<class T>
+ const char MEDCouplingTimeDiscretizationSimple<T>::REPR[]="One time label.";
+
template<class T>
const double MEDCouplingTimeDiscretizationTemplate<T>::TIME_TOLERANCE_DFT=1.e-12;
arrays.resize(1);
arrays[0]=_array;
}
+
+ template<class T>
+ std::string MEDCouplingTimeDiscretizationSimple<T>::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 : \"" << this->_time_unit << "\"";
+ return stream.str();
+ }
+
+ template<class T>
+ double MEDCouplingTimeDiscretizationSimple<T>::getEndTime(int& iteration, int& order) const
+ {
+ throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationSimple<T>::setEndIteration(int it)
+ {
+ throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationSimple<T>::setEndOrder(int order)
+ {
+ throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationSimple<T>::setEndTimeValue(double time)
+ {
+ throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !");
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationSimple<T>::setEndTime(double time, int iteration, int order)
+ {
+ throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !");
+ }
+
+ template<class T>
+ MEDCouplingTimeDiscretizationSimple<T>::MEDCouplingTimeDiscretizationSimple(const MEDCouplingTimeDiscretizationSimple<T>& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate<T>(other,deepCopy),_tk(other._tk)
+ {
+ }
}
#endif