MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<typename Traits<T>::ArrayType *>& arrays);
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&dataInt, std::vector<typename Traits<T>::ArrayType *>& arrays) const;
+ MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretizationTemplate<T> *timeDiscrSafe() const;
protected:
- const MEDCouplingTimeDiscretizationTemplate<T> *timeDiscrSafe() const;
MEDCouplingTimeDiscretizationTemplate<T> *timeDiscrSafe();
protected:
MEDCouplingTimeDiscretizationTemplate<T> *_time_discr;
{
}
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy):MEDCouplingField(other,deepCopy)
+{
+}
+
void MEDCouplingFieldTemplate::checkConsistencyLight() const
{
if(_mesh==0)
stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n'));
}
}
+
+MCAuto<MEDCouplingFieldTemplate> MEDCouplingFieldTemplate::clone(bool recDeepCpy) const
+{
+ MCAuto<MEDCouplingFieldTemplate> ret(new MEDCouplingFieldTemplate(*this,recDeepCpy));
+ return ret;
+}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// Author : Anthony Geay (CEA/DEN)
+// Author : Anthony Geay (EDF R&D)
#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__
#define __PARAMEDMEM_MEDCOUPLINGFIELDTEMPLATE_HXX__
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT std::string advancedRepr() const;
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
+ MEDCOUPLING_EXPORT MCAuto<MEDCouplingFieldTemplate> clone(bool recDeepCpy) const;
//
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f);
MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f);
MEDCouplingFieldTemplate(TypeOfField type);
+ MEDCouplingFieldTemplate(const MEDCouplingFieldTemplate& other, bool deepCopy);
};
}
{
std::ostringstream stream;
stream << REPR;
- stream << "\nTime unit is : \"" << _time_unit << "\"";
+ stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
return stream.str();
}
{
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 << "\"";
+ stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
return stream.str();
}
int it=-1,order=-1;
double val=mesh->getTime(it,order);
_tk.setAllInfo(val,it,order);
- std::string tUnit=mesh->getTimeUnit();
- _time_unit=tUnit;
+ std::string tUnit(mesh->getTimeUnit());
+ setTimeUnit(tUnit);
}
void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
std::ostringstream stream;
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 << "\"";
+ stream << "\nTime unit is : \"" << getTimeUnit() << "\"";
return stream.str();
}
_start.setAllInfo(val,it,order);
_end.setAllInfo(val,it,order);
std::string tUnit(mesh->getTimeUnit());
- _time_unit=tUnit;
+ setTimeUnit(tUnit);
}
MEDCouplingTimeDiscretization *MEDCouplingConstOnTimeInterval::performCopyOrIncrRef(bool deepCopy) const
double val=mesh->getTime(it,order);
_start.setAllInfo(val,it,order);
_end.setAllInfo(val,it,order);
- std::string tUnit=mesh->getTimeUnit();
- _time_unit=tUnit;
+ std::string tUnit(mesh->getTimeUnit());
+ setTimeUnit(tUnit);
}
std::size_t MEDCouplingTwoTimeSteps::getHeapMemorySizeWithoutChildren() const
std::ostringstream stream;
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 << "\"";
+ stream << "Time unit is : \"" << getTimeUnit() << "\"";
return stream.str();
}
class DataArrayDouble;
class TimeLabel;
+ class TimeHolder
+ {
+ public:
+ MEDCOUPLING_EXPORT std::string getTimeUnit() const { return _time_unit; }
+ MEDCOUPLING_EXPORT void setTimeUnit(const std::string& unit) { _time_unit=unit; }
+ MEDCOUPLING_EXPORT double getTime(int& iteration, int& order) const { return getStartTime(iteration,order); }
+ MEDCOUPLING_EXPORT virtual double getStartTime(int& iteration, int& order) const = 0;
+ void copyTinyAttrFrom(const TimeHolder& other) { _time_unit=other._time_unit; }
+ protected:
+ TimeHolder() { }
+ TimeHolder(const TimeHolder& other):_time_unit(other._time_unit) { }
+ private:
+ std::string _time_unit;
+ };
+
template<class T>
- class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject
+ class MEDCouplingTimeDiscretizationTemplate : public TimeLabel, public BigMemoryObject, public TimeHolder
{
public:
MEDCOUPLING_EXPORT void updateTime() const;
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 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 MEDCouplingTimeDiscretizationTemplate();
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy);
protected:
- std::string _time_unit;
double _time_tolerance;
typename Traits<T>::ArrayType *_array;
protected:
template<class T>
void MEDCouplingTimeDiscretizationTemplate<T>::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate<T>& other)
{
+ TimeHolder::copyTinyAttrFrom(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;
+ TimeHolder::copyTinyAttrFrom(other);
if(_array && other._array)
_array->copyStringInfoFrom(*other._array);
}
template<class T>
std::size_t MEDCouplingTimeDiscretizationTemplate<T>::getHeapMemorySizeWithoutChildren() const
{
- return _time_unit.capacity();
+ return getTimeUnit().capacity();
}
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)
+ if(getTimeUnit()!=other->getTimeUnit())
{
- oss << "Field discretizations differ : this time unit = \"" << _time_unit << "\" and other time unit = \"" << other->_time_unit << "\" !";
+ oss << "Field discretizations differ : this time unit = \"" << getTimeUnit() << "\" and other time unit = \"" << other->getTimeUnit() << "\" !";
reason=oss.str();
return false;
}
}
template<class T>
- MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance)
+ MEDCouplingTimeDiscretizationTemplate<T>::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy):TimeHolder(other),_time_tolerance(other._time_tolerance)
{
if(other._array)
_array=other._array->performCopyOrIncrRef(deepCopy);
{
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 << "\"";
+ stream << "\nTime unit is : \"" << this->getTimeUnit() << "\"";
return stream.str();
}