X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingTimeDiscretization.txx;h=54a0b19f0f072e8e1d1e310cde2df1e79d28144c;hb=ac1df6b0ba8b337555fb39610c89f678d889580d;hp=4d96c7cc83596eb0f0a3a710561c1369ee1be127;hpb=7f53ba0ad6eebec56c2936b923ac3ae728f41074;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx index 4d96c7cc8..54a0b19f0 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx @@ -22,12 +22,16 @@ #define __MEDCOUPLINGTIMEDISCRETIZATION_TXX__ #include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingMemArray.txx" #include #include namespace MEDCoupling { + template + const char MEDCouplingTimeDiscretizationSimple::REPR[]="One time label."; + template const double MEDCouplingTimeDiscretizationTemplate::TIME_TOLERANCE_DFT=1.e-12; @@ -56,14 +60,14 @@ namespace MEDCoupling template void MEDCouplingTimeDiscretizationTemplate::copyTinyAttrFrom(const MEDCouplingTimeDiscretizationTemplate& other) { + TimeHolder::copyTinyAttrFrom(other); _time_tolerance=other._time_tolerance; - _time_unit=other._time_unit; } template void MEDCouplingTimeDiscretizationTemplate::copyTinyStringsFrom(const MEDCouplingTimeDiscretizationTemplate& other) { - _time_unit=other._time_unit; + TimeHolder::copyTinyAttrFrom(other); if(_array && other._array) _array->copyStringInfoFrom(*other._array); } @@ -71,7 +75,7 @@ namespace MEDCoupling template std::size_t MEDCouplingTimeDiscretizationTemplate::getHeapMemorySizeWithoutChildren() const { - return _time_unit.capacity(); + return getTimeUnit().capacity(); } template @@ -95,9 +99,9 @@ namespace MEDCoupling bool MEDCouplingTimeDiscretizationTemplate::areStrictlyCompatible(const MEDCouplingTimeDiscretizationTemplate *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; } @@ -172,7 +176,7 @@ namespace MEDCoupling } template - MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy):_time_unit(other._time_unit),_time_tolerance(other._time_tolerance) + MEDCouplingTimeDiscretizationTemplate::MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy):TimeHolder(other),_time_tolerance(other._time_tolerance) { if(other._array) _array=other._array->performCopyOrIncrRef(deepCopy); @@ -219,6 +223,125 @@ namespace MEDCoupling arrays.resize(1); arrays[0]=_array; } + + template + void MEDCouplingTimeDiscretizationTemplate::getTinySerializationIntInformation(std::vector& tinyInfo) const + { + if(_array) + { + tinyInfo.push_back(_array->getNumberOfTuples()); + tinyInfo.push_back(_array->getNumberOfComponents()); + } + else + { + tinyInfo.push_back(-1); + tinyInfo.push_back(-1); + } + } + + template + void MEDCouplingTimeDiscretizationTemplate::getTinySerializationDbleInformation(std::vector& tinyInfo) const + { + tinyInfo.push_back(_time_tolerance); + } + + template + void MEDCouplingTimeDiscretizationTemplate::getTinySerializationStrInformation(std::vector& tinyInfo) const + { + int nbOfCompo(_array->getNumberOfComponents()); + for(int i=0;igetInfoOnComponent(i)); + } + + template + void MEDCouplingTimeDiscretizationTemplate::resizeForUnserialization(const std::vector& tinyInfoI, std::vector::ArrayType *>& arrays) + { + arrays.resize(1); + if(_array!=0) + _array->decrRef(); + typename Traits::ArrayType *arr=0; + if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) + { + arr=Traits::ArrayType::New(); + arr->alloc(tinyInfoI[0],tinyInfoI[1]); + } + _array=arr; + arrays[0]=arr; + } + + template + void MEDCouplingTimeDiscretizationTemplate::checkForUnserialization(const std::vector& tinyInfoI, const std::vector::ArrayType *>& arrays) + { + static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !"; + if(arrays.size()!=1) + throw INTERP_KERNEL::Exception(MSG); + if(_array!=0) + _array->decrRef(); + _array=0; + if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1) + { + if(!arrays[0]) + throw INTERP_KERNEL::Exception(MSG); + arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG); + _array=arrays[0]; + _array->incrRef(); + } + } + + template + void MEDCouplingTimeDiscretizationTemplate::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) + { + _time_tolerance=tinyInfoD[0]; + int nbOfCompo=_array->getNumberOfComponents(); + for(int i=0;isetInfoOnComponent(i,tinyInfoS[i]); + } + + ///////////////////////// + + template + std::string MEDCouplingTimeDiscretizationSimple::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->getTimeUnit() << "\""; + return stream.str(); + } + + template + double MEDCouplingTimeDiscretizationSimple::getEndTime(int& iteration, int& order) const + { + throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !"); + } + + template + void MEDCouplingTimeDiscretizationSimple::setEndIteration(int it) + { + throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !"); + } + + template + void MEDCouplingTimeDiscretizationSimple::setEndOrder(int order) + { + throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !"); + } + + template + void MEDCouplingTimeDiscretizationSimple::setEndTimeValue(double time) + { + throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !"); + } + + template + void MEDCouplingTimeDiscretizationSimple::setEndTime(double time, int iteration, int order) + { + throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !"); + } + + template + MEDCouplingTimeDiscretizationSimple::MEDCouplingTimeDiscretizationSimple(const MEDCouplingTimeDiscretizationSimple& other, bool deepCopy):MEDCouplingTimeDiscretizationTemplate(other,deepCopy),_tk(other._tk) + { + } } #endif