From: Anthony Geay Date: Tue, 23 Aug 2016 16:11:25 +0000 (+0200) Subject: MEDCouplingFields are templated X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=354f768e544f0408f4d3ad7a2222a9a66ae82a22;p=tools%2Fmedcoupling.git MEDCouplingFields are templated --- diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 00cda93f4..64f4a24a7 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -20,6 +20,7 @@ #include "MEDCouplingFieldDouble.hxx" #include "MEDCouplingFieldTemplate.hxx" +#include "MEDCouplingFieldT.txx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingTimeDiscretization.hxx" #include "MEDCouplingFieldDiscretization.hxx" @@ -35,6 +36,7 @@ using namespace MEDCoupling; +template class MEDCouplingFieldT; /*! * Creates a new MEDCouplingFieldDouble, of given spatial type and time discretization. @@ -87,7 +89,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::New(const MEDCouplingFieldTempla */ void MEDCouplingFieldDouble::setTimeUnit(const std::string& unit) { - _time_discr->setTimeUnit(unit); + timeDiscr()->setTimeUnit(unit); } /*! @@ -96,7 +98,7 @@ void MEDCouplingFieldDouble::setTimeUnit(const std::string& unit) */ std::string MEDCouplingFieldDouble::getTimeUnit() const { - return _time_discr->getTimeUnit(); + return timeDiscr()->getTimeUnit(); } /*! @@ -108,7 +110,7 @@ std::string MEDCouplingFieldDouble::getTimeUnit() const */ void MEDCouplingFieldDouble::synchronizeTimeWithSupport() { - _time_discr->synchronizeTimeWith(_mesh); + timeDiscr()->synchronizeTimeWith(_mesh); } /*! @@ -208,7 +210,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::deepCopy() const */ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const { - MEDCouplingTimeDiscretization *tdo=_time_discr->buildNewTimeReprFromThis(td,deepCopy); + MEDCouplingTimeDiscretization *tdo=timeDiscr()->buildNewTimeReprFromThis(td,deepCopy); MCAuto disc; if(_type) disc=_type->clone(); @@ -330,7 +332,7 @@ void MEDCouplingFieldDouble::copyTinyStringsFrom(const MEDCouplingField *other) const MEDCouplingFieldDouble *otherC(dynamic_cast(other)); if(otherC) { - _time_discr->copyTinyStringsFrom(*otherC->_time_discr); + timeDiscr()->copyTinyStringsFrom(*otherC->timeDiscr()); } } @@ -345,7 +347,7 @@ void MEDCouplingFieldDouble::copyTinyAttrFrom(const MEDCouplingFieldDouble *othe { if(other) { - _time_discr->copyTinyAttrFrom(*other->_time_discr); + timeDiscr()->copyTinyAttrFrom(*other->timeDiscr()); } } @@ -377,8 +379,8 @@ std::string MEDCouplingFieldDouble::simpleRepr() const { ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; } else { ret << "FieldDouble has no spatial discretization !\n"; } - if(_time_discr) - { ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; } + if(timeDiscr()) + { ret << "FieldDouble time discretization is : " << timeDiscr()->getStringRepr() << "\n"; } else { ret << "FieldDouble has no time discretization !\n"; } ret << "FieldDouble nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n"; @@ -426,8 +428,8 @@ std::string MEDCouplingFieldDouble::advancedRepr() const { ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; } else { ret << "FieldDouble has no space discretization set !\n"; } - if(_time_discr) - { ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; } + if(timeDiscr()) + { ret << "FieldDouble time discretization is : " << timeDiscr()->getStringRepr() << "\n"; } else { ret << "FieldDouble has no time discretization set !\n"; } if(getArray()) @@ -437,7 +439,7 @@ std::string MEDCouplingFieldDouble::advancedRepr() const else ret << "Mesh support information : No mesh set !\n"; std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); int arrayId=0; for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++,arrayId++) { @@ -469,7 +471,7 @@ bool MEDCouplingFieldDouble::isEqualIfNotWhy(const MEDCouplingField *other, doub } if(!MEDCouplingField::isEqualIfNotWhy(other,meshPrec,valsPrec,reason)) return false; - if(!_time_discr->isEqualIfNotWhy(otherC->_time_discr,valsPrec,reason)) + if(!timeDiscr()->isEqualIfNotWhy(otherC->timeDiscr(),valsPrec,reason)) { reason.insert(0,"In FieldDouble time discretizations differ :"); return false; @@ -494,7 +496,7 @@ bool MEDCouplingFieldDouble::isEqualWithoutConsideringStr(const MEDCouplingField return false; if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) return false; - if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr,valsPrec)) + if(!timeDiscr()->isEqualWithoutConsideringStr(otherC->timeDiscr(),valsPrec)) return false; return true; } @@ -511,7 +513,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMerge(const MEDCouplingField *other const MEDCouplingFieldDouble *otherC(dynamic_cast(other)); if(!otherC) return false; - if(!_time_discr->areCompatible(otherC->_time_discr)) + if(!timeDiscr()->areCompatible(otherC->timeDiscr())) return false; return true; } @@ -528,7 +530,7 @@ bool MEDCouplingFieldDouble::areStrictlyCompatible(const MEDCouplingField *other const MEDCouplingFieldDouble *otherC(dynamic_cast(other)); if(!otherC) return false; - if(!_time_discr->areStrictlyCompatible(otherC->_time_discr,tmp)) + if(!timeDiscr()->areStrictlyCompatible(otherC->timeDiscr(),tmp)) return false; return true; } @@ -544,7 +546,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMul(const MEDCouplingField *other) const MEDCouplingFieldDouble *otherC=dynamic_cast(other); if(!otherC) return false; - if(!_time_discr->areStrictlyCompatibleForMul(otherC->_time_discr)) + if(!timeDiscr()->areStrictlyCompatibleForMul(otherC->timeDiscr())) return false; return true; } @@ -560,7 +562,7 @@ bool MEDCouplingFieldDouble::areCompatibleForDiv(const MEDCouplingField *other) const MEDCouplingFieldDouble *otherC(dynamic_cast(other)); if(!otherC) return false; - if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr)) + if(!timeDiscr()->areStrictlyCompatibleForDiv(otherC->timeDiscr())) return false; return true; } @@ -573,7 +575,7 @@ bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble * { if(!MEDCouplingField::areStrictlyCompatible(other)) return false; - if(!_time_discr->areCompatibleForMeld(other->_time_discr)) + if(!timeDiscr()->areCompatibleForMeld(other->timeDiscr())) return false; return true; } @@ -641,7 +643,7 @@ void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool // _type->renumberCells(old2NewBg,check); std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); std::vector arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin()); _type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check); // @@ -707,7 +709,7 @@ void MEDCouplingFieldDouble::renumberNodesWithoutMesh(const int *old2NewBg, int if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !"); std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnNodes(eps,old2NewBg,newNbOfNodes,*iter); @@ -817,7 +819,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, ret->setDiscretization(MCAuto(disc->clonePart(partBg,partEnd))); ret->setMesh(m); std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); std::vector arrs; std::vector< MCAuto > arrsSafe; const int *arrSelBg=arrSelect->begin(); @@ -829,7 +831,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPart(const int *partBg, arr=(*iter)->selectByTupleIdSafe(arrSelBg,arrSelEnd); arrs.push_back(arr); arrsSafe.push_back(arr); } - ret->_time_discr->setArrays(arrs,0); + ret->timeDiscr()->setArrays(arrs,0); return ret.retn(); } @@ -853,7 +855,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPartRange(int begin, int ret->setDiscretization(MCAuto(disc->clonePartRange(begin,end,step))); ret->setMesh(m); std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); std::vector arrs; std::vector< MCAuto > arrsSafe; for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) @@ -872,7 +874,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPartRange(int begin, int } arrs.push_back(arr); arrsSafe.push_back(arr); } - ret->_time_discr->setArrays(arrs,0); + ret->timeDiscr()->setArrays(arrs,0); return ret.retn(); } @@ -883,36 +885,28 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::buildSubPartRange(int begin, int */ TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const { - return _time_discr->getEnum(); + return timeDiscr()->getEnum(); } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type), - _time_discr(MEDCouplingTimeDiscretization::New(td)) +MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT(type,MEDCouplingTimeDiscretization::New(td)) { } /*! * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! ** */ -MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingField(ft,false), - _time_discr(MEDCouplingTimeDiscretization::New(td)) +MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT(ft,MEDCouplingTimeDiscretization::New(td),false) { } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingField(other,deepCopy), - _time_discr(dynamic_cast(other._time_discr->performCopyOrIncrRef(deepCopy))) +MEDCouplingFieldDouble::MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy):MEDCouplingFieldT(other,deepCopy) { } -MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td) +MEDCouplingFieldDouble::MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT(type,n,td) { } -MEDCouplingFieldDouble::~MEDCouplingFieldDouble() -{ - delete _time_discr; -} - /*! * Checks if \a this field is correctly defined, else an exception is thrown. * \throw If the mesh is not set. @@ -925,7 +919,7 @@ MEDCouplingFieldDouble::~MEDCouplingFieldDouble() void MEDCouplingFieldDouble::checkConsistencyLight() const { MEDCouplingField::checkConsistencyLight(); - _time_discr->checkConsistencyLight(); + timeDiscr()->checkConsistencyLight(); _type->checkCoherencyBetween(_mesh,getArray()); } @@ -969,7 +963,7 @@ void MEDCouplingFieldDouble::accumulate(double *res) const double MEDCouplingFieldDouble::getMaxValue() const { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); double ret=-std::numeric_limits::max(); bool isExistingArr=false; for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) @@ -999,7 +993,7 @@ double MEDCouplingFieldDouble::getMaxValue() const double MEDCouplingFieldDouble::getMaxValue2(DataArrayInt*& tupleIds) const { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); double ret=-std::numeric_limits::max(); bool isExistingArr=false; tupleIds=0; @@ -1033,7 +1027,7 @@ double MEDCouplingFieldDouble::getMaxValue2(DataArrayInt*& tupleIds) const double MEDCouplingFieldDouble::getMinValue() const { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); double ret=std::numeric_limits::max(); bool isExistingArr=false; for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) @@ -1063,7 +1057,7 @@ double MEDCouplingFieldDouble::getMinValue() const double MEDCouplingFieldDouble::getMinValue2(DataArrayInt*& tupleIds) const { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); double ret=-std::numeric_limits::max(); bool isExistingArr=false; tupleIds=0; @@ -1348,7 +1342,7 @@ void MEDCouplingFieldDouble::integral(bool isWAbs, double *res) const */ void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) const { - const DataArrayDouble *arr=_time_discr->getArray(); + const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnPos"); if(!((const MEDCouplingFieldDiscretization *)_type)) @@ -1372,7 +1366,7 @@ void MEDCouplingFieldDouble::getValueOnPos(int i, int j, int k, double *res) con */ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) const { - const DataArrayDouble *arr=_time_discr->getArray(); + const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn"); if(!((const MEDCouplingFieldDiscretization *)_type)) @@ -1400,7 +1394,7 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double *res) con */ DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, int nbOfPoints) const { - const DataArrayDouble *arr=_time_discr->getArray(); + const DataArrayDouble *arr=timeDiscr()->getArray(); if(!_mesh) throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOnMulti"); if(!((const MEDCouplingFieldDiscretization *)_type)) @@ -1427,7 +1421,7 @@ DataArrayDouble *MEDCouplingFieldDouble::getValueOnMulti(const double *spaceLoc, */ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, double *res) const { - std::vector< const DataArrayDouble *> arrs=_time_discr->getArraysForTime(time); + std::vector< const DataArrayDouble *> arrs=timeDiscr()->getArraysForTime(time); if(!_mesh) throw INTERP_KERNEL::Exception("No mesh underlying this field to perform getValueOn"); if(!((const MEDCouplingFieldDiscretization *)_type)) @@ -1439,7 +1433,7 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, dou res2.resize(sz+(*iter)->getNumberOfComponents()); _type->getValueOn(*iter,_mesh,spaceLoc,&res2[sz]); } - _time_discr->getValueForTime(time,res2,res); + timeDiscr()->getValueForTime(time,res2,res); } /*! @@ -1452,7 +1446,7 @@ void MEDCouplingFieldDouble::getValueOn(const double *spaceLoc, double time, dou */ void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId) { - _time_discr->applyLin(a,b,compoId); + timeDiscr()->applyLin(a,b,compoId); } /*! @@ -1464,7 +1458,7 @@ void MEDCouplingFieldDouble::applyLin(double a, double b, int compoId) */ void MEDCouplingFieldDouble::applyLin(double a, double b) { - _time_discr->applyLin(a,b); + timeDiscr()->applyLin(a,b); } /*! @@ -1479,7 +1473,7 @@ MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator=(double value) if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform operator = !"); int nbOfTuple=_type->getNumberOfTuples(_mesh); - _time_discr->setOrCreateUniformValueOnAllComponents(nbOfTuple,value); + timeDiscr()->setOrCreateUniformValueOnAllComponents(nbOfTuple,value); return *this; } @@ -1504,7 +1498,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate f if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !"); MCAuto loc=_type->getLocalizationOfDiscValues(_mesh); - _time_discr->fillFromAnalytic(loc,nbOfComp,func); + timeDiscr()->fillFromAnalytic(loc,nbOfComp,func); } /*! @@ -1551,7 +1545,7 @@ void MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const std::string& f if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalytic !"); MCAuto loc=_type->getLocalizationOfDiscValues(_mesh); - _time_discr->fillFromAnalytic(loc,nbOfComp,func); + timeDiscr()->fillFromAnalytic(loc,nbOfComp,func); } /*! @@ -1600,7 +1594,7 @@ void MEDCouplingFieldDouble::fillFromAnalyticCompo(int nbOfComp, const std::stri if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticCompo !"); MCAuto loc=_type->getLocalizationOfDiscValues(_mesh); - _time_discr->fillFromAnalyticCompo(loc,nbOfComp,func); + timeDiscr()->fillFromAnalyticCompo(loc,nbOfComp,func); } /*! @@ -1649,7 +1643,7 @@ void MEDCouplingFieldDouble::fillFromAnalyticNamedCompo(int nbOfComp, const std: if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform fillFromAnalyticNamedCompo !"); MCAuto loc=_type->getLocalizationOfDiscValues(_mesh); - _time_discr->fillFromAnalyticNamedCompo(loc,nbOfComp,varsOrder,func); + timeDiscr()->fillFromAnalyticNamedCompo(loc,nbOfComp,varsOrder,func); } /*! @@ -1666,7 +1660,7 @@ void MEDCouplingFieldDouble::fillFromAnalyticNamedCompo(int nbOfComp, const std: */ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) { - _time_discr->applyFunc(nbOfComp,func); + timeDiscr()->applyFunc(nbOfComp,func); } /*! @@ -1690,7 +1684,7 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val) if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform applyFunc !"); int nbOfTuple=_type->getNumberOfTuples(_mesh); - _time_discr->setUniformValue(nbOfTuple,nbOfComp,val); + timeDiscr()->setUniformValue(nbOfTuple,nbOfComp,val); } /*! @@ -1727,7 +1721,7 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val) */ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) { - _time_discr->applyFunc(nbOfComp,func); + timeDiscr()->applyFunc(nbOfComp,func); } @@ -1767,7 +1761,7 @@ void MEDCouplingFieldDouble::applyFunc(int nbOfComp, const std::string& func) */ void MEDCouplingFieldDouble::applyFuncCompo(int nbOfComp, const std::string& func) { - _time_discr->applyFuncCompo(nbOfComp,func); + timeDiscr()->applyFuncCompo(nbOfComp,func); } /*! @@ -1806,7 +1800,7 @@ void MEDCouplingFieldDouble::applyFuncCompo(int nbOfComp, const std::string& fun */ void MEDCouplingFieldDouble::applyFuncNamedCompo(int nbOfComp, const std::vector& varsOrder, const std::string& func) { - _time_discr->applyFuncNamedCompo(nbOfComp,varsOrder,func); + timeDiscr()->applyFuncNamedCompo(nbOfComp,varsOrder,func); } /*! @@ -1838,7 +1832,7 @@ void MEDCouplingFieldDouble::applyFuncNamedCompo(int nbOfComp, const std::vector */ void MEDCouplingFieldDouble::applyFunc(const std::string& func) { - _time_discr->applyFunc(func); + timeDiscr()->applyFunc(func); } /*! @@ -1848,7 +1842,7 @@ void MEDCouplingFieldDouble::applyFunc(const std::string& func) */ void MEDCouplingFieldDouble::applyFuncFast32(const std::string& func) { - _time_discr->applyFuncFast32(func); + timeDiscr()->applyFuncFast32(func); } /*! @@ -1858,7 +1852,7 @@ void MEDCouplingFieldDouble::applyFuncFast32(const std::string& func) */ void MEDCouplingFieldDouble::applyFuncFast64(const std::string& func) { - _time_discr->applyFuncFast64(func); + timeDiscr()->applyFuncFast64(func); } /*! @@ -1929,7 +1923,7 @@ int MEDCouplingFieldDouble::getNumberOfValues() const void MEDCouplingFieldDouble::updateTime() const { MEDCouplingField::updateTime(); - updateTimeWith(*_time_discr); + updateTimeWith(*timeDiscr()); } std::size_t MEDCouplingFieldDouble::getHeapMemorySizeWithoutChildren() const @@ -1940,9 +1934,9 @@ std::size_t MEDCouplingFieldDouble::getHeapMemorySizeWithoutChildren() const std::vector MEDCouplingFieldDouble::getDirectChildrenWithNull() const { std::vector ret(MEDCouplingField::getDirectChildrenWithNull()); - if(_time_discr) + if(timeDiscr()) { - std::vector ret2(_time_discr->getDirectChildrenWithNull()); + std::vector ret2(timeDiscr()->getDirectChildrenWithNull()); ret.insert(ret.end(),ret2.begin(),ret2.end()); } return ret; @@ -2005,7 +1999,7 @@ double MEDCouplingFieldDouble::getIJK(int cellId, int nodeIdInCell, int compoId) */ void MEDCouplingFieldDouble::setArray(DataArrayDouble *array) { - _time_discr->setArray(array,this); + timeDiscr()->setArray(array,this); } /*! @@ -2018,7 +2012,7 @@ void MEDCouplingFieldDouble::setArray(DataArrayDouble *array) */ void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array) { - _time_discr->setEndArray(array,this); + timeDiscr()->setEndArray(array,this); } /*! @@ -2032,13 +2026,13 @@ void MEDCouplingFieldDouble::setEndArray(DataArrayDouble *array) */ void MEDCouplingFieldDouble::setArrays(const std::vector& arrs) { - _time_discr->setArrays(arrs,this); + timeDiscr()->setArrays(arrs,this); } void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector& tinyInfo) const { tinyInfo.clear(); - _time_discr->getTinySerializationStrInformation(tinyInfo); + timeDiscr()->getTinySerializationStrInformation(tinyInfo); tinyInfo.push_back(_name); tinyInfo.push_back(_desc); tinyInfo.push_back(getTimeUnit()); @@ -2055,9 +2049,9 @@ void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationIntInformation !"); tinyInfo.clear(); tinyInfo.push_back((int)_type->getEnum()); - tinyInfo.push_back((int)_time_discr->getEnum()); + tinyInfo.push_back((int)timeDiscr()->getEnum()); tinyInfo.push_back((int)_nature); - _time_discr->getTinySerializationIntInformation(tinyInfo); + timeDiscr()->getTinySerializationIntInformation(tinyInfo); std::vector tinyInfo2; _type->getTinySerializationIntInformation(tinyInfo2); tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); @@ -2073,7 +2067,7 @@ void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vectorgetTinySerializationDbleInformation(tinyInfo); + timeDiscr()->getTinySerializationDbleInformation(tinyInfo); std::vector tinyInfo2; _type->getTinySerializationDbleInformation(tinyInfo2); tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end()); @@ -2098,7 +2092,7 @@ void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector& ti tinyInfoITmp.pop_back(); std::vector tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz); std::vector tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end()); - _time_discr->resizeForUnserialization(tinyInfoI2,arrays); + timeDiscr()->resizeForUnserialization(tinyInfoI2,arrays); std::vector tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end()); _type->resizeForUnserialization(tinyInfoITmp3,dataInt); } @@ -2117,7 +2111,7 @@ void MEDCouplingFieldDouble::checkForUnserialization(const std::vector& tin tinyInfoITmp.pop_back(); std::vector tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz); std::vector tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end()); - _time_discr->checkForUnserialization(tinyInfoI2,arrays); + timeDiscr()->checkForUnserialization(tinyInfoI2,arrays); std::vector tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end()); _type->checkForUnserialization(tinyInfoITmp3,dataInt); } @@ -2134,7 +2128,7 @@ void MEDCouplingFieldDouble::finishUnserialization(const std::vector& tinyI std::vector tmp1(tmp.begin(),tmp.end()-sz); std::vector tmp2(tmp.end()-sz,tmp.end()); // - _time_discr->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS); + timeDiscr()->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS); _nature=(NatureOfField)tinyInfoI[2]; _type->finishUnserialization(tmp2); int nbOfElemS=(int)tinyInfoS.size(); @@ -2151,7 +2145,7 @@ void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vectorgetArrays(arrays); + timeDiscr()->getArrays(arrays); _type->getSerializationIntArray(dataInt); } @@ -2270,7 +2264,7 @@ bool MEDCouplingFieldDouble::mergeNodes(double eps, double epsOnVals) if(!ret)//no nodes have been merged. return ret; std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); @@ -2309,7 +2303,7 @@ bool MEDCouplingFieldDouble::mergeNodesCenter(double eps, double epsOnVals) if(!ret)//no nodes have been merged. return ret; std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); @@ -2345,7 +2339,7 @@ bool MEDCouplingFieldDouble::zipCoords(double epsOnVals) if(meshC2->getNumberOfNodes()!=oldNbOfNodes) { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnNodes(epsOnVals,arr->getConstPointer(),meshC2->getNumberOfNodes(),*iter); @@ -2386,7 +2380,7 @@ bool MEDCouplingFieldDouble::zipConnectivity(int compType, double epsOnVals) if(meshC2->getNumberOfCells()!=oldNbOfCells) { std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnCells(epsOnVals,meshC,arr->getConstPointer(),meshC2->getNumberOfCells(),*iter); @@ -2418,7 +2412,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::extractSlice3D(const double *ori ret->setMesh(mesh2); MCAuto tupleIds=computeTupleIdsToSelectFromCellIds(cellIds->begin(),cellIds->end()); std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); int i=0; std::vector newArr(arrays.size()); std::vector< MCAuto > newArr2(arrays.size()); @@ -2462,7 +2456,7 @@ bool MEDCouplingFieldDouble::simplexize(int policy) if(oldNbOfCells==newNbOfCells) return false; std::vector arrays; - _time_discr->getArrays(arrays); + timeDiscr()->getArrays(arrays); for(std::vector::const_iterator iter=arrays.begin();iter!=arrays.end();iter++) if(*iter) _type->renumberValuesOnCellsR(_mesh,arr->getConstPointer(),arr->getNbOfElems(),*iter); @@ -2485,8 +2479,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::doublyContractedProduct() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform doublyContractedProduct !"); - MEDCouplingTimeDiscretization *td=_time_discr->doublyContractedProduct(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->doublyContractedProduct(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("DoublyContractedProduct"); ret->setMesh(getMesh()); @@ -2508,8 +2502,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::determinant() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform determinant !"); - MEDCouplingTimeDiscretization *td=_time_discr->determinant(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->determinant(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("Determinant"); ret->setMesh(getMesh()); @@ -2532,8 +2526,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenValues() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform eigenValues !"); - MEDCouplingTimeDiscretization *td=_time_discr->eigenValues(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->eigenValues(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("EigenValues"); ret->setMesh(getMesh()); @@ -2555,8 +2549,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::eigenVectors() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform eigenVectors !"); - MEDCouplingTimeDiscretization *td=_time_discr->eigenVectors(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->eigenVectors(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("EigenVectors"); ret->setMesh(getMesh()); @@ -2580,8 +2574,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::inverse() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform inverse !"); - MEDCouplingTimeDiscretization *td=_time_discr->inverse(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->inverse(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("Inversion"); ret->setMesh(getMesh()); @@ -2605,8 +2599,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::trace() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform trace !"); - MEDCouplingTimeDiscretization *td=_time_discr->trace(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->trace(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("Trace"); ret->setMesh(getMesh()); @@ -2629,8 +2623,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::deviator() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform deviator !"); - MEDCouplingTimeDiscretization *td=_time_discr->deviator(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->deviator(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("Deviator"); ret->setMesh(getMesh()); @@ -2651,8 +2645,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::magnitude() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform magnitude !"); - MEDCouplingTimeDiscretization *td=_time_discr->magnitude(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->magnitude(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName("Magnitude"); ret->setMesh(getMesh()); @@ -2671,8 +2665,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform maxPerTuple !"); - MEDCouplingTimeDiscretization *td=_time_discr->maxPerTuple(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->maxPerTuple(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); std::ostringstream oss; oss << "Max_" << getName(); @@ -2693,7 +2687,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::maxPerTuple() const */ void MEDCouplingFieldDouble::changeNbOfComponents(int newNbOfComp, double dftValue) { - _time_discr->changeNbOfComponents(newNbOfComp,dftValue); + timeDiscr()->changeNbOfComponents(newNbOfComp,dftValue); } /*! @@ -2712,8 +2706,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform keepSelectedComponents !"); - MEDCouplingTimeDiscretization *td=_time_discr->keepSelectedComponents(compoIds); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->keepSelectedComponents(compoIds); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setName(getName()); ret->setMesh(getMesh()); @@ -2734,7 +2728,7 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::keepSelectedComponents(const std */ void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble *f, const std::vector& compoIds) { - _time_discr->setSelectedComponents(f->_time_discr,compoIds); + timeDiscr()->setSelectedComponents(f->timeDiscr(),compoIds); } /*! @@ -2745,7 +2739,7 @@ void MEDCouplingFieldDouble::setSelectedComponents(const MEDCouplingFieldDouble */ void MEDCouplingFieldDouble::sortPerTuple(bool asc) { - _time_discr->sortPerTuple(asc); + timeDiscr()->sortPerTuple(asc); } /*! @@ -2771,12 +2765,12 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const MEDCouplingFie if(!f1->areCompatibleForMerge(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MergeFields on them ! Check support mesh, field nature, and spatial and time discretisation."); const MEDCouplingMesh *m1(f1->getMesh()),*m2(f2->getMesh()); - if(!f1->_time_discr) + if(!f1->timeDiscr()) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no time discr of f1 !"); if(!f1->_type) throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MergeFields : no spatial discr of f1 !"); - MEDCouplingTimeDiscretization *td=f1->_time_discr->aggregate(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->aggregate(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setName(f1->getName()); ret->setDescription(f1->getDescription()); @@ -2827,10 +2821,10 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MergeFields(const std::vectorgetMesh()->buildUnstructured(); ms2[i]=ms[i]; } else { ms[i]=0; ms2[i]=0; } - tds[i]=a[i]->_time_discr; + tds[i]=a[i]->timeDiscr(); } MEDCouplingTimeDiscretization *td=tds[0]->aggregate(tds); - td->copyTinyAttrFrom(*(a[0]->_time_discr)); + td->copyTinyAttrFrom(*(a[0]->timeDiscr())); MCAuto ret=new MEDCouplingFieldDouble(a[0]->getNature(),td,a[0]->_type->clone()); ret->setName(a[0]->getName()); ret->setDescription(a[0]->getDescription()); @@ -2862,8 +2856,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MeldFields(const MEDCouplingFiel { if(!f1->areCompatibleForMeld(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MeldFields on them ! Check support mesh, field nature, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->meld(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->meld(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -2889,8 +2883,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::DotFields(const MEDCouplingField throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::DotFields : input field is NULL !"); if(!f1->areStrictlyCompatibleForMulDiv(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply DotFields on them! Check support mesh, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->dot(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->dot(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MEDCouplingFieldDouble *ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret; @@ -2920,8 +2914,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::CrossProductFields(const MEDCoup throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::CrossProductFields : input field is NULL !"); if(!f1->areStrictlyCompatibleForMulDiv(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply CrossProductFields on them! Check support mesh, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->crossProduct(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->crossProduct(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -2950,8 +2944,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MaxFields(const MEDCouplingField throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MaxFields : input field is NULL !"); if(!f1->areStrictlyCompatible(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MaxFields on them! Check support mesh, field nature, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->max(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->max(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -2980,8 +2974,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MinFields(const MEDCouplingField throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MinFields : input field is NULL !"); if(!f1->areStrictlyCompatible(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MinFields on them! Check support mesh, field nature, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->min(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->min(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3000,8 +2994,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::negate() const { if(!((const MEDCouplingFieldDiscretization *)_type)) throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform negate !"); - MEDCouplingTimeDiscretization *td=_time_discr->negate(); - td->copyTinyAttrFrom(*_time_discr); + MEDCouplingTimeDiscretization *td=timeDiscr()->negate(); + td->copyTinyAttrFrom(*timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(getNature(),td,_type->clone()); ret->setMesh(getMesh()); return ret.retn(); @@ -3026,8 +3020,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::AddFields(const MEDCouplingField throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::AddFields : input field is NULL !"); if(!f1->areStrictlyCompatible(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply AddFields on them! Check support mesh, field nature, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->add(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->add(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3047,7 +3041,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator+=(const MEDCoupli { if(!areStrictlyCompatible(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply += on them! Check support mesh, field nature, and spatial and time discretisation."); - _time_discr->addEqual(other._time_discr); + timeDiscr()->addEqual(other.timeDiscr()); return *this; } @@ -3070,8 +3064,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::SubstractFields(const MEDCouplin throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::SubstractFields : input field is NULL !"); if(!f1->areStrictlyCompatible(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply SubstractFields on them! Check support mesh, field nature, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->substract(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->substract(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(f1->getNature(),td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3091,7 +3085,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator-=(const MEDCoupli { if(!areStrictlyCompatible(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply -= on them! Check support mesh, field nature, and spatial and time discretisation."); - _time_discr->substractEqual(other._time_discr); + timeDiscr()->substractEqual(other.timeDiscr()); return *this; } @@ -3121,8 +3115,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::MultiplyFields(const MEDCoupling throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::MultiplyFields : input field is NULL !"); if(!f1->areCompatibleForMul(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply MultiplyFields on them! Check support mesh, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->multiply(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->multiply(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3153,7 +3147,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator*=(const MEDCoupli { if(!areCompatibleForMul(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply *= on them! Check support mesh, and spatial and time discretisation."); - _time_discr->multiplyEqual(other._time_discr); + timeDiscr()->multiplyEqual(other.timeDiscr()); _nature = NoNature; return *this; } @@ -3182,8 +3176,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::DivideFields(const MEDCouplingFi throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::DivideFields : input field is NULL !"); if(!f1->areCompatibleForDiv(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply DivideFields on them! Check support mesh, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->divide(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->divide(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3210,7 +3204,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator/=(const MEDCoupli { if(!areCompatibleForDiv(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply /= on them! Check support mesh, and spatial and time discretisation."); - _time_discr->divideEqual(other._time_discr); + timeDiscr()->divideEqual(other.timeDiscr()); _nature = NoNature; return *this; } @@ -3226,8 +3220,8 @@ MEDCouplingFieldDouble *MEDCouplingFieldDouble::PowFields(const MEDCouplingField throw INTERP_KERNEL::Exception("MEDCouplingFieldDouble::PowFields : input field is NULL !"); if(!f1->areCompatibleForMul(f2)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply PowFields on them! Check support mesh, and spatial and time discretisation."); - MEDCouplingTimeDiscretization *td=f1->_time_discr->pow(f2->_time_discr); - td->copyTinyAttrFrom(*f1->_time_discr); + MEDCouplingTimeDiscretization *td=f1->timeDiscr()->pow(f2->timeDiscr()); + td->copyTinyAttrFrom(*f1->timeDiscr()); MCAuto ret=new MEDCouplingFieldDouble(NoNature,td,f1->_type->clone()); ret->setMesh(f1->getMesh()); return ret.retn(); @@ -3247,7 +3241,7 @@ const MEDCouplingFieldDouble &MEDCouplingFieldDouble::operator^=(const MEDCoupli { if(!areCompatibleForDiv(&other)) throw INTERP_KERNEL::Exception("Fields are not compatible. Unable to apply ^= on them! Check support mesh, and spatial and time discretisation."); - _time_discr->powEqual(other._time_discr); + timeDiscr()->powEqual(other.timeDiscr()); _nature = NoNature; return *this; } @@ -3337,9 +3331,9 @@ void MEDCouplingFieldDouble::reprQuickOverview(std::ostream& stream) const std::string tmp(oss.str()); stream << "\nMesh info : " << tmp.substr(0,tmp.find('\n')); } - if(_time_discr) + if(timeDiscr()) { - const DataArrayDouble *arr=_time_discr->getArray(); + const DataArrayDouble *arr=timeDiscr()->getArray(); if(arr) { stream << "\n\nArray info : "; @@ -3351,3 +3345,25 @@ void MEDCouplingFieldDouble::reprQuickOverview(std::ostream& stream) const } } } + +MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr() +{ + MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); + if(!ret) + return 0; + MEDCouplingTimeDiscretization *retc(dynamic_cast(ret)); + if(!retc) + throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !"); + return retc; +} + +const MEDCouplingTimeDiscretization *MEDCouplingFieldDouble::timeDiscr() const +{ + const MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); + if(!ret) + return 0; + const MEDCouplingTimeDiscretization *retc(dynamic_cast(ret)); + if(!retc) + throw INTERP_KERNEL::Exception("Field Double Null invalid type of time discr !"); + return retc; +} diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 0e9ab5d37..07e16e42e 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -18,19 +18,18 @@ // // Author : Anthony Geay (CEA/DEN) -#ifndef __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__ -#define __PARAMEDMEM_MEDCOUPLINGFIELDDOUBLE_HXX__ +#ifndef __MEDCOUPLINGFIELDDOUBLE_HXX__ +#define __MEDCOUPLINGFIELDDOUBLE_HXX__ #include "MEDCoupling.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingFieldT.hxx" #include "MEDCouplingMemArray.hxx" namespace MEDCoupling { class MEDCouplingFieldTemplate; - class MEDCouplingFieldDouble : public MEDCouplingField + class MEDCouplingFieldDouble : public MEDCouplingFieldT { public: MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); @@ -194,18 +193,18 @@ namespace MEDCoupling MEDCOUPLING_EXPORT static MEDCouplingFieldDouble *PowFields(const MEDCouplingFieldDouble *f1, const MEDCouplingFieldDouble *f2); MEDCOUPLING_EXPORT static std::string WriteVTK(const std::string& fileName, const std::vector& fs, bool isBinary=true); public: - MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return _time_discr; } - MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return _time_discr; } + MEDCOUPLING_EXPORT const MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() const { return timeDiscr(); } + MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization *getTimeDiscretizationUnderGround() { return timeDiscr(); } MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const; protected: - ~MEDCouplingFieldDouble(); + ~MEDCouplingFieldDouble() { } private: MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td); MEDCouplingFieldDouble(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); MEDCouplingFieldDouble(const MEDCouplingFieldDouble& other, bool deepCopy); MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type); - private: - MEDCouplingTimeDiscretization *_time_discr; + MEDCouplingTimeDiscretization *timeDiscr(); + const MEDCouplingTimeDiscretization *timeDiscr() const; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldInt.cxx b/src/MEDCoupling/MEDCouplingFieldInt.cxx index ce07e67e7..cc4938f34 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt.cxx +++ b/src/MEDCoupling/MEDCouplingFieldInt.cxx @@ -19,11 +19,14 @@ // Author : Yann Pora (EDF R&D) #include "MEDCouplingFieldInt.hxx" +#include "MEDCouplingFieldT.txx" #include "MEDCouplingFieldTemplate.hxx" #include "MEDCouplingMesh.hxx" using namespace MEDCoupling; +template class MEDCouplingFieldT; + MEDCouplingFieldInt *MEDCouplingFieldInt::New(TypeOfField type, TypeOfTimeDiscretization td) { return new MEDCouplingFieldInt(type,td); @@ -37,7 +40,7 @@ MEDCouplingFieldInt *MEDCouplingFieldInt::New(const MEDCouplingFieldTemplate& ft void MEDCouplingFieldInt::checkConsistencyLight() const { MEDCouplingField::checkConsistencyLight(); - _time_discr->checkConsistencyLight(); + timeDiscr()->checkConsistencyLight(); _type->checkCoherencyBetween(_mesh,getArray()); } @@ -50,8 +53,8 @@ std::string MEDCouplingFieldInt::simpleRepr() const { 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"; } + if(timeDiscr()) + { ret << "FieldInt time discretization is : " << timeDiscr()->getStringRepr() << "\n"; } else { ret << "FieldInt has no time discretization !\n"; } ret << "FieldInt nature of field is : \"" << MEDCouplingNatureOfField::GetReprNoThrow(_nature) << "\"\n"; @@ -84,60 +87,55 @@ void MEDCouplingFieldInt::reprQuickOverview(std::ostream& stream) const void MEDCouplingFieldInt::setTimeUnit(const std::string& unit) { - _time_discr->setTimeUnit(unit); + timeDiscr()->setTimeUnit(unit); } std::string MEDCouplingFieldInt::getTimeUnit() const { - return _time_discr->getTimeUnit(); + return timeDiscr()->getTimeUnit(); } void MEDCouplingFieldInt::setTime(double val, int iteration, int order) { - _time_discr->setTime(val,iteration,order); + timeDiscr()->setTime(val,iteration,order); } double MEDCouplingFieldInt::getTime(int& iteration, int& order) const { - return _time_discr->getTime(iteration,order); + return timeDiscr()->getTime(iteration,order); } void MEDCouplingFieldInt::setArray(DataArrayInt *array) { - _time_discr->setArray(array,this); + timeDiscr()->setArray(array,this); } const DataArrayInt *MEDCouplingFieldInt::getArray() const { - return _time_discr->getArray(); + return timeDiscr()->getArray(); } DataArrayInt *MEDCouplingFieldInt::getArray() { - return _time_discr->getArray(); + return timeDiscr()->getArray(); } -MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretizationInt::New(td)) +MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT(type,MEDCouplingTimeDiscretizationInt::New(td)) { } -MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(dynamic_cast(other._time_discr->performCopyOrIncrRef(deepCopy))) +MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingFieldT(other,deepCopy) { } -MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td) +MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT(type,n,td) { } -MEDCouplingFieldInt::~MEDCouplingFieldInt() -{ - 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)) +MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT(ft,MEDCouplingTimeDiscretizationInt::New(td),false) { } @@ -174,7 +172,7 @@ bool MEDCouplingFieldInt::isEqualIfNotWhy(const MEDCouplingField *other, double } if(!MEDCouplingField::isEqualIfNotWhy(other,meshPrec,valsPrec,reason)) return false; - if(!_time_discr->isEqualIfNotWhy(otherC->_time_discr,reason)) + if(!timeDiscr()->isEqualIfNotWhy(otherC->timeDiscr(),reason)) { reason.insert(0,"In FieldInt time discretizations differ :"); return false; @@ -189,7 +187,7 @@ bool MEDCouplingFieldInt::isEqualWithoutConsideringStr(const MEDCouplingField *o return false; if(!MEDCouplingField::isEqualWithoutConsideringStr(other,meshPrec,valsPrec)) return false; - if(!_time_discr->isEqualWithoutConsideringStr(otherC->_time_discr)) + if(!timeDiscr()->isEqualWithoutConsideringStr(otherC->timeDiscr())) return false; return true; } @@ -200,7 +198,7 @@ void MEDCouplingFieldInt::copyTinyStringsFrom(const MEDCouplingField *other) const MEDCouplingFieldInt *otherC(dynamic_cast(other)); if(otherC) { - _time_discr->copyTinyStringsFrom(*otherC->_time_discr); + timeDiscr()->copyTinyStringsFrom(*otherC->timeDiscr()); } } @@ -212,7 +210,7 @@ bool MEDCouplingFieldInt::areStrictlyCompatible(const MEDCouplingField *other) c const MEDCouplingFieldInt *otherC(dynamic_cast(other)); if(!otherC) return false; - if(!_time_discr->areStrictlyCompatible(otherC->_time_discr,tmp)) + if(!timeDiscr()->areStrictlyCompatible(otherC->timeDiscr(),tmp)) return false; return true; } @@ -224,8 +222,29 @@ bool MEDCouplingFieldInt::areStrictlyCompatibleForMulDiv(const MEDCouplingField const MEDCouplingFieldInt *otherC(dynamic_cast(other)); if(!otherC) return false; - if(!_time_discr->areStrictlyCompatibleForDiv(otherC->_time_discr)) + if(!timeDiscr()->areStrictlyCompatibleForDiv(otherC->timeDiscr())) return false; return true; } +MEDCouplingTimeDiscretizationInt *MEDCouplingFieldInt::timeDiscr() +{ + MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); + if(!ret) + return 0; + MEDCouplingTimeDiscretizationInt *retc(dynamic_cast(ret)); + if(!retc) + throw INTERP_KERNEL::Exception("Field Int Null invalid type of time discr !"); + return retc; +} + +const MEDCouplingTimeDiscretizationInt *MEDCouplingFieldInt::timeDiscr() const +{ + const MEDCouplingTimeDiscretizationTemplate *ret(_time_discr); + if(!ret) + return 0; + const MEDCouplingTimeDiscretizationInt *retc(dynamic_cast(ret)); + if(!retc) + throw INTERP_KERNEL::Exception("Field Int Null invalid type of time discr !"); + return retc; +} diff --git a/src/MEDCoupling/MEDCouplingFieldInt.hxx b/src/MEDCoupling/MEDCouplingFieldInt.hxx index 6a401ef4f..38c746378 100644 --- a/src/MEDCoupling/MEDCouplingFieldInt.hxx +++ b/src/MEDCoupling/MEDCouplingFieldInt.hxx @@ -22,8 +22,7 @@ #define __MEDCOUPLINGFIELDINT_HXX__ #include "MEDCoupling.hxx" -#include "MEDCouplingField.hxx" -#include "MEDCouplingTimeDiscretization.hxx" +#include "MEDCouplingFieldT.hxx" #include "MEDCouplingMemArray.hxx" #include @@ -32,7 +31,7 @@ namespace MEDCoupling { class MEDCouplingFieldTemplate; - class MEDCouplingFieldInt : public MEDCouplingField + class MEDCouplingFieldInt : public MEDCouplingFieldT { public: MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME); @@ -60,9 +59,10 @@ namespace MEDCoupling MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy); MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type); MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td); - ~MEDCouplingFieldInt(); + ~MEDCouplingFieldInt() { } private: - MEDCouplingTimeDiscretizationInt *_time_discr; + MEDCouplingTimeDiscretizationInt *timeDiscr(); + const MEDCouplingTimeDiscretizationInt *timeDiscr() const; }; } diff --git a/src/MEDCoupling/MEDCouplingFieldT.hxx b/src/MEDCoupling/MEDCouplingFieldT.hxx new file mode 100644 index 000000000..6f88381ee --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldT.hxx @@ -0,0 +1,46 @@ +// Copyright (C) 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 __MEDCOUPLINGFIELDT_HXX__ +#define __MEDCOUPLINGFIELDT_HXX__ + +#include "MEDCouplingField.hxx" +#include "MEDCouplingTimeDiscretization.hxx" + +namespace MEDCoupling +{ + template + class MEDCouplingTimeDiscretizationTemplate; + + template + class MEDCouplingFieldT : public MEDCouplingField + { + protected: + MEDCouplingFieldT(const MEDCouplingFieldT& other, bool deepCopy); + MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate *timeDiscr, bool deepCopy=true); + MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate *timeDiscr); + MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate *timeDiscr); + ~MEDCouplingFieldT(); + protected: + MEDCouplingTimeDiscretizationTemplate *_time_discr; + }; +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingFieldT.txx b/src/MEDCoupling/MEDCouplingFieldT.txx new file mode 100644 index 000000000..fac31b705 --- /dev/null +++ b/src/MEDCoupling/MEDCouplingFieldT.txx @@ -0,0 +1,55 @@ +// Copyright (C) 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 __MEDCOUPLINGFIELDT_TXX__ +#define __MEDCOUPLINGFIELDT_TXX__ + +#include "MEDCouplingTimeDiscretization.hxx" + +namespace MEDCoupling +{ + template + MEDCouplingFieldT::MEDCouplingFieldT(const MEDCouplingFieldT& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(other._time_discr->performCopyOrIncrRef(deepCopy)) + { + } + + template + MEDCouplingFieldT::MEDCouplingFieldT(const MEDCouplingField& other, MEDCouplingTimeDiscretizationTemplate *timeDiscr, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(timeDiscr) + { + } + + template + MEDCouplingFieldT::MEDCouplingFieldT(TypeOfField type, MEDCouplingTimeDiscretizationTemplate *timeDiscr):MEDCouplingField(type),_time_discr(timeDiscr) + { + } + + template + MEDCouplingFieldT::MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate *timeDiscr):MEDCouplingField(type,n),_time_discr(timeDiscr) + { + } + + template + MEDCouplingFieldT::~MEDCouplingFieldT() + { + delete _time_discr; + } +} + +#endif diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 43c156434..2d55134d8 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -184,34 +184,6 @@ void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vect tinyInfo.push_back(_array->getInfoOnComponent(i)); } -const DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() const -{ - throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); -} - -DataArrayDouble *MEDCouplingTimeDiscretization::getEndArray() -{ - throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); -} - -void MEDCouplingTimeDiscretization::setEndArray(DataArrayDouble *array, TimeLabel *owner) -{ - throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !"); -} - -void MEDCouplingTimeDiscretization::setArrays(const std::vector& arrays, TimeLabel *owner) -{ - if(arrays.size()!=1) - throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one."); - setArray(arrays.back(),owner); -} - -void MEDCouplingTimeDiscretization::getArrays(std::vector& arrays) const -{ - arrays.resize(1); - arrays[0]=_array; -} - bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const { int iteration,order; @@ -862,6 +834,31 @@ bool MEDCouplingTimeDiscretizationInt::isEqualWithoutConsideringStr(const MEDCou return _array->isEqualWithoutConsideringStr(*other->_array); } +double MEDCouplingTimeDiscretizationInt::getEndTime(int& iteration, int& order) const +{ + throw INTERP_KERNEL::Exception("getEndTime : invalid for this type of time discr !"); +} + +void MEDCouplingTimeDiscretizationInt::setEndIteration(int it) +{ + throw INTERP_KERNEL::Exception("setEndIteration : invalid for this type of time discr !"); +} + +void MEDCouplingTimeDiscretizationInt::setEndOrder(int order) +{ + throw INTERP_KERNEL::Exception("setEndOrder : invalid for this type of time discr !"); +} + +void MEDCouplingTimeDiscretizationInt::setEndTimeValue(double time) +{ + throw INTERP_KERNEL::Exception("setEndTimeValue : invalid for this type of time discr !"); +} + +void MEDCouplingTimeDiscretizationInt::setEndTime(double time, int iteration, int order) +{ + throw INTERP_KERNEL::Exception("setEndTime : invalid for this type of time discr !"); +} + //////////////////////// MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel() diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index 310a9f95c..e206713c9 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -57,6 +57,18 @@ namespace MEDCoupling 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 double getEndTime(int& iteration, int& order) const = 0; + MEDCOUPLING_EXPORT virtual void setEndIteration(int it) = 0; + MEDCOUPLING_EXPORT virtual void setEndOrder(int order) = 0; + MEDCOUPLING_EXPORT virtual void setEndTimeValue(double time) = 0; + MEDCOUPLING_EXPORT virtual void setEndTime(double time, int iteration, int order) = 0; + + MEDCOUPLING_EXPORT virtual void setEndArray(typename Traits::ArrayType *array, TimeLabel *owner); + MEDCOUPLING_EXPORT virtual void setArrays(const std::vector< typename Traits::ArrayType *>& arrays, TimeLabel *owner); + MEDCOUPLING_EXPORT virtual const typename Traits::ArrayType *getEndArray() const; + MEDCOUPLING_EXPORT virtual typename Traits::ArrayType *getEndArray(); + MEDCOUPLING_EXPORT virtual void getArrays(std::vector::ArrayType *>& arrays) const; + MEDCOUPLING_EXPORT virtual std::string getStringRepr() const = 0; MEDCOUPLING_EXPORT virtual TypeOfTimeDiscretization getEnum() const = 0; MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretizationTemplate *performCopyOrIncrRef(bool deepCopy) const = 0; @@ -71,10 +83,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual bool areCompatible(const MEDCouplingTimeDiscretizationTemplate *other) const; MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate *other) const; MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate *other) const; + MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate(); protected: MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(); MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate& other, bool deepCopy); - MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate(); protected: std::string _time_unit; double _time_tolerance; @@ -146,20 +158,10 @@ namespace MEDCoupling MEDCOUPLING_EXPORT virtual void finishUnserialization2(const std::vector& tinyInfoI, const std::vector& tinyInfoD) = 0; MEDCOUPLING_EXPORT virtual void checkNoTimePresence() const = 0; MEDCOUPLING_EXPORT virtual void checkTimePresence(double time) const = 0; - MEDCOUPLING_EXPORT virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner); - MEDCOUPLING_EXPORT virtual void setArrays(const std::vector& arrays, TimeLabel *owner); - 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 getValueForTime(double time, const std::vector& vals, double *res) const = 0; - MEDCOUPLING_EXPORT virtual void getArrays(std::vector& arrays) const; + MEDCOUPLING_EXPORT virtual void getValueForTime(double time, const std::vector& vals, double *res) const = 0; MEDCOUPLING_EXPORT virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const; MEDCOUPLING_EXPORT virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const; - MEDCOUPLING_EXPORT virtual double getEndTime(int& iteration, int& order) const = 0; - MEDCOUPLING_EXPORT virtual void setEndIteration(int it) = 0; - MEDCOUPLING_EXPORT virtual void setEndOrder(int order) = 0; - MEDCOUPLING_EXPORT virtual void setEndTimeValue(double time) = 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; // @@ -205,6 +207,11 @@ namespace MEDCoupling 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); } + double getEndTime(int& iteration, int& order) const; + void setEndIteration(int it); + 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; } MEDCouplingTimeDiscretizationInt *performCopyOrIncrRef(bool deepCopy) const; diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx index f03bedf7d..4d96c7cc8 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.txx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.txx @@ -186,6 +186,39 @@ namespace MEDCoupling if(_array) _array->decrRef(); } + + template + void MEDCouplingTimeDiscretizationTemplate::setEndArray(typename Traits::ArrayType *array, TimeLabel *owner) + { + throw INTERP_KERNEL::Exception("setEndArray not available for this type of time discretization !"); + } + + template + void MEDCouplingTimeDiscretizationTemplate::setArrays(const std::vector::ArrayType *>& arrays, TimeLabel *owner) + { + if(arrays.size()!=1) + throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one."); + setArray(arrays.back(),owner); + } + + template + const typename Traits::ArrayType *MEDCouplingTimeDiscretizationTemplate::getEndArray() const + { + throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); + } + + template + typename Traits::ArrayType *MEDCouplingTimeDiscretizationTemplate::getEndArray() + { + throw INTERP_KERNEL::Exception("getEndArray not available for this type of time discretization !"); + } + + template + void MEDCouplingTimeDiscretizationTemplate::getArrays(std::vector::ArrayType *>& arrays) const + { + arrays.resize(1); + arrays[0]=_array; + } } #endif