From f8b70ec5f5862f7ec3f0cba5ff16b956cdc63d32 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 24 Jan 2011 15:49:02 +0000 Subject: [PATCH] Multi time. --- src/MEDCoupling/MEDCouplingCMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingCMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingDefinitionTime.cxx | 200 +++++++++++++++++- src/MEDCoupling/MEDCouplingDefinitionTime.hxx | 37 +++- src/MEDCoupling/MEDCouplingExtrudedMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingExtrudedMesh.hxx | 2 +- src/MEDCoupling/MEDCouplingField.cxx | 2 +- src/MEDCoupling/MEDCouplingField.hxx | 2 +- .../MEDCouplingFieldDiscretization.cxx | 4 +- .../MEDCouplingFieldDiscretization.hxx | 4 +- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 2 +- src/MEDCoupling/MEDCouplingFieldDouble.hxx | 2 +- src/MEDCoupling/MEDCouplingFieldOverTime.cxx | 3 + src/MEDCoupling/MEDCouplingFieldOverTime.hxx | 5 + src/MEDCoupling/MEDCouplingMemArray.cxx | 73 ++++++- src/MEDCoupling/MEDCouplingMemArray.hxx | 9 +- src/MEDCoupling/MEDCouplingMultiFields.cxx | 8 +- src/MEDCoupling/MEDCouplingMultiFields.hxx | 2 +- src/MEDCoupling/MEDCouplingPointSet.cxx | 4 +- src/MEDCoupling/MEDCouplingPointSet.hxx | 2 +- src/MEDCoupling/MEDCouplingRemapper.cxx | 2 +- src/MEDCoupling/MEDCouplingRemapper.hxx | 2 +- .../MEDCouplingTimeDiscretization.cxx | 4 +- .../MEDCouplingTimeDiscretization.hxx | 4 +- src/MEDCoupling/MEDCouplingTimeLabel.cxx | 6 +- src/MEDCoupling/MEDCouplingTimeLabel.hxx | 8 +- src/MEDCoupling/MEDCouplingUMesh.cxx | 2 +- src/MEDCoupling/MEDCouplingUMesh.hxx | 2 +- .../Test/MEDCouplingBasicsTest4.cxx | 16 +- src/MEDCoupling_Swig/MEDCoupling.i | 36 +++- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 67 ++++++ .../MEDCouplingDataForTest.py | 55 +++++ 32 files changed, 524 insertions(+), 47 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx index 3c8ce1a41..7827fd50b 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCMesh.cxx @@ -82,7 +82,7 @@ MEDCouplingCMesh *MEDCouplingCMesh::clone(bool recDeepCpy) const return new MEDCouplingCMesh(*this,recDeepCpy); } -void MEDCouplingCMesh::updateTime() +void MEDCouplingCMesh::updateTime() const { if(_x_array) updateTimeWith(*_x_array); diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx index eb6acf42a..3b3e50aa7 100644 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCMesh.hxx @@ -34,7 +34,7 @@ namespace ParaMEDMEM static MEDCouplingCMesh *New(); MEDCouplingMesh *deepCpy() const; MEDCouplingCMesh *clone(bool recDeepCpy) const; - void updateTime(); + void updateTime() const; MEDCouplingMeshType getType() const { return CARTESIAN; } void copyTinyStringsFrom(const MEDCouplingMesh *other) throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingMesh *other, double prec) const; diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx index 7b7b0af74..47836da6d 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.cxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.cxx @@ -24,6 +24,8 @@ using namespace ParaMEDMEM; +const double MEDCouplingDefinitionTime::EPS_DFT=1e-15; + MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector& arrId, int fieldId) throw(INTERP_KERNEL::Exception) { static const char msg[]="TimeSlice::New : mismatch of arrays number of a fieldDouble and its policy !!! Internal error !!!"; @@ -56,6 +58,21 @@ MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCou } } +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDiscretization type, const std::vector& tiI, const std::vector& tiD) throw(INTERP_KERNEL::Exception) +{ + switch(type) + { + case ONE_TIME: + return MEDCouplingDefinitionTimeSliceInst::New(tiI,tiD); + case CONST_ON_TIME_INTERVAL: + return MEDCouplingDefinitionTimeSliceCstOnTI::New(tiI,tiD); + case LINEAR_TIME: + return MEDCouplingDefinitionTimeSliceLT::New(tiI,tiD); + default: + throw INTERP_KERNEL::Exception("MEDCouplingDefinitionTimeSlice::New : unrecognized time discretization type !"); + } +} + bool MEDCouplingDefinitionTimeSlice::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const { if(_mesh_id!=other._mesh_id) @@ -125,8 +142,45 @@ bool MEDCouplingDefinitionTimeSlice::isBeforeMe(const MEDCouplingDefinitionTimeS return (o1& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst; + ret->unserialize(tiI,tiD); + return ret; +} + +void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(3); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; + tiD.resize(1); + tiD[0]=_instant; +} + +void MEDCouplingDefinitionTimeSliceInst::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; + _instant=tiD[0]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceInst::getTimeType() const +{ + return ONE_TIME; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceInst::copy() const +{ + return new MEDCouplingDefinitionTimeSliceInst(*this); +} + bool MEDCouplingDefinitionTimeSliceInst::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const { + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceInst *otherC=dynamic_cast(&other); + if(!otherC) + return false; + return fabs(otherC->_instant-_instant)& ret) const @@ -175,8 +229,28 @@ MEDCouplingDefinitionTimeSliceInst::MEDCouplingDefinitionTimeSliceInst(const MED _instant=t1; } +MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceCstOnTI *ret=new MEDCouplingDefinitionTimeSliceCstOnTI; + ret->unserialize(tiI,tiD); + return ret; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceCstOnTI::copy() const +{ + return new MEDCouplingDefinitionTimeSliceCstOnTI(*this); +} + bool MEDCouplingDefinitionTimeSliceCstOnTI::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const { + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceCstOnTI *otherC=dynamic_cast(&other); + if(!otherC) + return false; + if(fabs(otherC->_start-_start)>eps) + return false; + return fabs(otherC->_end-_end)& ret) const @@ -214,6 +288,25 @@ double MEDCouplingDefinitionTimeSliceCstOnTI::getEndTime() const return _end; } +void MEDCouplingDefinitionTimeSliceCstOnTI::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(3); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; + tiD.resize(2); + tiD[0]=_start; tiD[1]=_end; +} + +void MEDCouplingDefinitionTimeSliceCstOnTI::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; + _start=tiD[0]; _end=tiD[1]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceCstOnTI::getTimeType() const +{ + return CONST_ON_TIME_INTERVAL; +} + MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId) { int tmp1,tmp2; @@ -223,8 +316,30 @@ MEDCouplingDefinitionTimeSliceCstOnTI::MEDCouplingDefinitionTimeSliceCstOnTI(con _end=t2; } +MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector& tiI, const std::vector& tiD) +{ + MEDCouplingDefinitionTimeSliceLT *ret=new MEDCouplingDefinitionTimeSliceLT; + ret->unserialize(tiI,tiD); + return ret; +} + +MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSliceLT::copy() const +{ + return new MEDCouplingDefinitionTimeSliceLT(*this); +} + bool MEDCouplingDefinitionTimeSliceLT::isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const { + if(!MEDCouplingDefinitionTimeSlice::isEqual(other,eps)) + return false; + const MEDCouplingDefinitionTimeSliceLT *otherC=dynamic_cast(&other); + if(!otherC) + return false; + if(_array_id_end!=otherC->_array_id_end) + return false; + if(fabs(otherC->_start-_start)>eps) + return false; + return fabs(otherC->_end-_end)& ret) const @@ -282,6 +397,25 @@ int MEDCouplingDefinitionTimeSliceLT::getEndId() const return _array_id_end; } +void MEDCouplingDefinitionTimeSliceLT::getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const +{ + tiI.resize(4); + tiI[0]=_mesh_id; tiI[1]=_array_id; tiI[2]=_field_id; tiI[3]=_array_id_end; + tiD.resize(2); + tiD[0]=_start; tiD[1]=_end; +} + +void MEDCouplingDefinitionTimeSliceLT::unserialize(const std::vector& tiI, const std::vector& tiD) +{ + _mesh_id=tiI[0]; _array_id=tiI[1]; _field_id=tiI[2]; _array_id_end=tiI[3]; + _start=tiD[0]; _end=tiD[1]; +} + +TypeOfTimeDiscretization MEDCouplingDefinitionTimeSliceLT::getTimeType() const +{ + return LINEAR_TIME; +} + MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception):MEDCouplingDefinitionTimeSlice(f,meshId,arrId,fieldId),_array_id_end(arr2Id) { int tmp1,tmp2; @@ -291,7 +425,7 @@ MEDCouplingDefinitionTimeSliceLT::MEDCouplingDefinitionTimeSliceLT(const MEDCoup _end=t2; } -MEDCouplingDefinitionTime::MEDCouplingDefinitionTime() +MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT) { } @@ -324,6 +458,25 @@ MEDCouplingDefinitionTime::MEDCouplingDefinitionTime(const std::vectorcopy(); +} + +bool MEDCouplingDefinitionTime::isEqual(const MEDCouplingDefinitionTime& other) const +{ + std::size_t sz=_slices.size(); + if(sz!=other._slices.size()) + return false; + for(std::size_t i=0;iisEqual(*other._slices[i],_eps)) + return false; + return true; +} + void MEDCouplingDefinitionTime::getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) { std::vector meshIds; @@ -401,3 +554,48 @@ void MEDCouplingDefinitionTime::appendRepr(std::ostream& stream) const stream << std::endl; } } + +void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector& tinyInfoI, std::vector& tinyInfoD) const +{ + int sz=_slices.size(); + tinyInfoD.resize(1); + tinyInfoD[0]=_eps; + tinyInfoI.resize(3*sz+2); + tinyInfoI[0]=sz; + std::vector coreData; + for(int i=0;i tmp1; + std::vector tmp2; + tinyInfoI[i+2]=(int)_slices[i]->getTimeType(); + _slices[i]->getTinySerializationInformation(tmp1,tmp2); + tinyInfoI[i+sz+2]=tmp1.size(); + tinyInfoI[i+2*sz+2]=tmp2.size(); + coreData.insert(coreData.end(),tmp1.begin(),tmp1.end()); + tinyInfoD.insert(tinyInfoD.end(),tmp2.begin(),tmp2.end()); + } + tinyInfoI[1]=coreData.size(); + tinyInfoI.insert(tinyInfoI.end(),coreData.begin(),coreData.end()); +} + +void MEDCouplingDefinitionTime::unserialize(const std::vector& tinyInfoI, const std::vector& tinyInfoD) +{ + int sz=tinyInfoI[0]; + _slices.resize(sz); + _eps=tinyInfoD[0]; + int offset1=0; + int offset2=1; + for(int i=0;i tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1); + std::vector tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2); + MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2); + _slices[i]=pt; + offset1+=sz1; + offset2+=sz2; + } +} + diff --git a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx index e5becae04..e728e373d 100644 --- a/src/MEDCoupling/MEDCouplingDefinitionTime.hxx +++ b/src/MEDCoupling/MEDCouplingDefinitionTime.hxx @@ -36,7 +36,9 @@ namespace ParaMEDMEM { public: static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector& arrId, int fieldId) throw(INTERP_KERNEL::Exception); + static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector& tiI, const std::vector& tiD) throw(INTERP_KERNEL::Exception); int getArrayId() const { return _array_id; } + virtual MEDCouplingDefinitionTimeSlice *copy() const = 0; virtual bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; virtual void getHotSpotsTime(std::vector& ret) const = 0; virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0; @@ -46,11 +48,14 @@ namespace ParaMEDMEM virtual void appendRepr(std::ostream& stream) const; virtual double getStartTime() const = 0; virtual double getEndTime() const = 0; + virtual void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const = 0; + virtual TypeOfTimeDiscretization getTimeType() const = 0; bool isFullyIncludedInMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; bool isOverllapingWithMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; bool isAfterMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; bool isBeforeMe(const MEDCouplingDefinitionTimeSlice *other, double eps) const; protected: + MEDCouplingDefinitionTimeSlice() { } MEDCouplingDefinitionTimeSlice(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); protected: int _mesh_id; @@ -61,6 +66,8 @@ namespace ParaMEDMEM class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice { public: + static MEDCouplingDefinitionTimeSliceInst *New(const std::vector& tiI, const std::vector& tiD); + MEDCouplingDefinitionTimeSlice *copy() const; bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; void getHotSpotsTime(std::vector& ret) const; void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); @@ -68,8 +75,13 @@ namespace ParaMEDMEM void appendRepr(std::ostream& stream) const; double getStartTime() const; double getEndTime() const; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; public: MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceInst() { } protected: double _instant; }; @@ -77,6 +89,8 @@ namespace ParaMEDMEM class MEDCouplingDefinitionTimeSliceCstOnTI : public MEDCouplingDefinitionTimeSlice { public: + static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector& tiI, const std::vector& tiD); + MEDCouplingDefinitionTimeSlice *copy() const; bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; void getHotSpotsTime(std::vector& ret) const; void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); @@ -84,17 +98,23 @@ namespace ParaMEDMEM void appendRepr(std::ostream& stream) const; double getStartTime() const; double getEndTime() const; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; public: MEDCouplingDefinitionTimeSliceCstOnTI(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceCstOnTI() { } protected: double _start; double _end; }; - class MEDCouplingDefinitionTimeSliceLT : public MEDCouplingDefinitionTimeSlice { public: + static MEDCouplingDefinitionTimeSliceLT *New(const std::vector& tiI, const std::vector& tiD); + MEDCouplingDefinitionTimeSlice *copy() const; bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const; void getHotSpotsTime(std::vector& ret) const; void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); @@ -103,8 +123,13 @@ namespace ParaMEDMEM double getStartTime() const; double getEndTime() const; int getEndId() const; + void getTinySerializationInformation(std::vector& tiI, std::vector& tiD) const; + void unserialize(const std::vector& tiI, const std::vector& tiD); + TypeOfTimeDiscretization getTimeType() const; public: MEDCouplingDefinitionTimeSliceLT(const MEDCouplingFieldDouble *f, int meshId, int arrId, int arr2Id, int fieldId) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingDefinitionTimeSliceLT() { } protected: int _array_id_end; double _start; @@ -115,18 +140,22 @@ namespace ParaMEDMEM { public: MEDCouplingDefinitionTime(); - bool isEqual(const MEDCouplingDefinitionTime& other, double eps) const; MEDCouplingDefinitionTime(const std::vector& fs, const std::vector& meshRefs, const std::vector >& arrRefs) throw(INTERP_KERNEL::Exception); + void assign(const MEDCouplingDefinitionTime& other); + bool isEqual(const MEDCouplingDefinitionTime& other) const; double getTimeResolution() const { return _eps; } void getIdsOnTimeRight(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); void getIdsOnTimeLeft(double tm, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception); + void getIdsOnTime(double tm, std::vector& meshIds, std::vector& arrIds, std::vector& arrIdsInField, std::vector& fieldIds) const throw(INTERP_KERNEL::Exception); std::vector getHotSpotsTime() const; void appendRepr(std::ostream& stream) const; - private: - void getIdsOnTime(double tm, std::vector& meshIds, std::vector& arrIds, std::vector& arrIdsInField, std::vector& fieldIds) const throw(INTERP_KERNEL::Exception); + public: + void getTinySerializationInformation(std::vector& tinyInfoI, std::vector& tinyInfoD) const; + void unserialize(const std::vector& tinyInfoI, const std::vector& tinyInfoD); private: double _eps; std::vector< MEDCouplingAutoRefCountObjectPtr > _slices; + static const double EPS_DFT; }; } diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx index c288087c1..b6d9558a5 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.cxx @@ -306,7 +306,7 @@ void MEDCouplingExtrudedMesh::getBoundingBox(double *bbox) const bbox[2*id+1]+=tmp[id]; } -void MEDCouplingExtrudedMesh::updateTime() +void MEDCouplingExtrudedMesh::updateTime() const { if(_mesh2D) { diff --git a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx index 91c5a80ca..7d87aabf2 100644 --- a/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx +++ b/src/MEDCoupling/MEDCouplingExtrudedMesh.hxx @@ -59,7 +59,7 @@ namespace ParaMEDMEM std::string advancedRepr() const; void checkCoherency() const throw (INTERP_KERNEL::Exception); void getBoundingBox(double *bbox) const; - void updateTime(); + void updateTime() const; void renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception); MEDCouplingUMesh *getMesh2D() const { return _mesh2D; } MEDCouplingUMesh *getMesh1D() const { return _mesh1D; } diff --git a/src/MEDCoupling/MEDCouplingField.cxx b/src/MEDCoupling/MEDCouplingField.cxx index 91534d687..6e22c527a 100644 --- a/src/MEDCoupling/MEDCouplingField.cxx +++ b/src/MEDCoupling/MEDCouplingField.cxx @@ -86,7 +86,7 @@ bool MEDCouplingField::areStrictlyCompatible(const MEDCouplingField *other) cons return _mesh==other->_mesh; } -void MEDCouplingField::updateTime() +void MEDCouplingField::updateTime() const { if(_mesh) updateTimeWith(*_mesh); diff --git a/src/MEDCoupling/MEDCouplingField.hxx b/src/MEDCoupling/MEDCouplingField.hxx index 2823103b2..da3acc1ad 100644 --- a/src/MEDCoupling/MEDCouplingField.hxx +++ b/src/MEDCoupling/MEDCouplingField.hxx @@ -71,7 +71,7 @@ namespace ParaMEDMEM void getCellIdsHavingGaussLocalization(int locId, std::vector& cellIds) const throw(INTERP_KERNEL::Exception); const MEDCouplingGaussLocalization& getGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception); protected: - void updateTime(); + void updateTime() const; protected: MEDCouplingField(TypeOfField type); MEDCouplingField(const MEDCouplingField& other); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx index 10da3cf4b..92ba48099 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx @@ -93,7 +93,7 @@ bool MEDCouplingFieldDiscretization::isEqualWithoutConsideringStr(const MEDCoupl /*! * Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally. */ -void MEDCouplingFieldDiscretization::updateTime() +void MEDCouplingFieldDiscretization::updateTime() const { } @@ -594,7 +594,7 @@ MEDCouplingFieldDiscretizationPerCell::MEDCouplingFieldDiscretizationPerCell(con _discr_per_cell=arr->deepCpy(); } -void MEDCouplingFieldDiscretizationPerCell::updateTime() +void MEDCouplingFieldDiscretizationPerCell::updateTime() const { if(_discr_per_cell) updateTimeWith(*_discr_per_cell); diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx index 1c742d2e2..80a3f49ae 100644 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx @@ -42,7 +42,7 @@ namespace ParaMEDMEM static MEDCouplingFieldDiscretization *New(TypeOfField type); double getPrecision() const { return _precision; } void setPrecision(double val) { _precision=val; } - void updateTime(); + void updateTime() const; static TypeOfField getTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception); virtual TypeOfField getEnum() const = 0; virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const = 0; @@ -159,7 +159,7 @@ namespace ParaMEDMEM MEDCouplingFieldDiscretizationPerCell(); MEDCouplingFieldDiscretizationPerCell(const MEDCouplingFieldDiscretizationPerCell& other); ~MEDCouplingFieldDiscretizationPerCell(); - void updateTime(); + void updateTime() const; void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception); bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const; bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const; diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 0df85211a..ae8d1ff35 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -899,7 +899,7 @@ int MEDCouplingFieldDouble::getNumberOfValues() const throw(INTERP_KERNEL::Excep return getArray()->getNbOfElems(); } -void MEDCouplingFieldDouble::updateTime() +void MEDCouplingFieldDouble::updateTime() const { MEDCouplingField::updateTime(); updateTimeWith(*_time_discr); diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 990ca94dc..b10f4be6d 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -114,7 +114,7 @@ namespace ParaMEDMEM int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); int getNumberOfValues() const throw(INTERP_KERNEL::Exception); - void updateTime(); + void updateTime() const; // void getTinySerializationIntInformation(std::vector& tinyInfo) const; void getTinySerializationDbleInformation(std::vector& tinyInfo) const; diff --git a/src/MEDCoupling/MEDCouplingFieldOverTime.cxx b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx index b8978b053..39842a43b 100644 --- a/src/MEDCoupling/MEDCouplingFieldOverTime.cxx +++ b/src/MEDCoupling/MEDCouplingFieldOverTime.cxx @@ -159,3 +159,6 @@ MEDCouplingFieldOverTime::MEDCouplingFieldOverTime(const std::vector getMeshes() const throw(INTERP_KERNEL::Exception); std::vector getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception); std::vector getArrays() const throw(INTERP_KERNEL::Exception); std::vector getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception); MEDCouplingDefinitionTime getDefinitionTimeZone() const; + protected: + MEDCouplingFieldOverTime(); private: MEDCouplingFieldOverTime(const std::vector& fs) throw(INTERP_KERNEL::Exception); }; diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index 42656389e..c731e2634 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -1003,7 +1003,7 @@ DataArrayDouble *DataArrayDouble::applyFunc(int nbOfComp, const char *func) cons int oldNbOfComp=getNumberOfComponents(); if((int)vars.size()>oldNbOfComp) { - std::ostringstream oss; oss << "The field has a " << oldNbOfComp << " components and there are "; + std::ostringstream oss; oss << "The field has " << oldNbOfComp << " components and there are "; oss << vars.size() << " variables : "; std::copy(vars.begin(),vars.end(),std::ostream_iterator(oss," ")); throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -2549,3 +2549,74 @@ int *DataArrayInt::CheckAndPreparePermutation(const int *start, const int *end) delete [] work; return ret; } + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayInt::getTinySerializationIntInformation(std::vector& tinyInfo) const +{ + tinyInfo.resize(2); + if(isAllocated()) + { + tinyInfo[0]=getNumberOfTuples(); + tinyInfo[1]=getNumberOfComponents(); + } + else + { + tinyInfo[0]=-1; + tinyInfo[1]=-1; + } +} + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * Server side. + */ +void DataArrayInt::getTinySerializationStrInformation(std::vector& tinyInfo) const +{ + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + tinyInfo.resize(nbOfCompo+1); + tinyInfo[0]=getName(); + for(int i=0;i& tinyInfoI) +{ + int nbOfTuple=tinyInfoI[0]; + int nbOfComp=tinyInfoI[1]; + if(nbOfTuple!=-1 || nbOfComp!=-1) + { + alloc(nbOfTuple,nbOfComp); + return true; + } + return false; +} + +/*! + * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class. + * This method returns if a feeding is needed. + */ +void DataArrayInt::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS) +{ + setName(tinyInfoS[0].c_str()); + if(isAllocated()) + { + int nbOfCompo=getNumberOfComponents(); + for(int i=0;i& tinyInfo) const; void getTinySerializationStrInformation(std::vector& tinyInfo) const; @@ -296,9 +296,14 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo); MEDCOUPLING_EXPORT void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); } //! nothing to do here because this class does not aggregate any TimeLabel instance. - MEDCOUPLING_EXPORT void updateTime() { } + MEDCOUPLING_EXPORT void updateTime() const { } public: MEDCOUPLING_EXPORT static int *CheckAndPreparePermutation(const int *start, const int *end); + public: + void getTinySerializationIntInformation(std::vector& tinyInfo) const; + void getTinySerializationStrInformation(std::vector& tinyInfo) const; + bool resizeForUnserialization(const std::vector& tinyInfoI); + void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoS); private: DataArrayInt() { } private: diff --git a/src/MEDCoupling/MEDCouplingMultiFields.cxx b/src/MEDCoupling/MEDCouplingMultiFields.cxx index aaf3d6f98..013ca88b6 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.cxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.cxx @@ -170,15 +170,15 @@ const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldAtPos(int id) cons return _fs[id]; } -void MEDCouplingMultiFields::updateTime() +void MEDCouplingMultiFields::updateTime() const { - std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_fs.begin(); + std::vector< MEDCouplingAutoRefCountObjectPtr >::const_iterator it=_fs.begin(); for(;it!=_fs.end();it++) - if((MEDCouplingFieldDouble *)(*it)) + if((const MEDCouplingFieldDouble *)(*it)) (*it)->updateTime(); it=_fs.begin(); for(;it!=_fs.end();it++) - if((MEDCouplingFieldDouble *)(*it)) + if((const MEDCouplingFieldDouble *)(*it)) updateTimeWith(*(*it)); } diff --git a/src/MEDCoupling/MEDCouplingMultiFields.hxx b/src/MEDCoupling/MEDCouplingMultiFields.hxx index 26a6a1a18..e0999173d 100644 --- a/src/MEDCoupling/MEDCouplingMultiFields.hxx +++ b/src/MEDCoupling/MEDCouplingMultiFields.hxx @@ -57,7 +57,7 @@ namespace ParaMEDMEM virtual std::vector getDifferentMeshes(std::vector& refs) const throw(INTERP_KERNEL::Exception); virtual std::vector getArrays() const throw(INTERP_KERNEL::Exception); virtual std::vector getDifferentArrays(std::vector< std::vector >& refs) const throw(INTERP_KERNEL::Exception); - void updateTime(); + void updateTime() const; void getTinySerializationInformation(std::vector& tinyInfo, std::vector& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const; void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& ft, const std::vector& ms, diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx index 4fa44dc4f..30a3ceff0 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ b/src/MEDCoupling/MEDCouplingPointSet.cxx @@ -65,7 +65,7 @@ int MEDCouplingPointSet::getSpaceDimension() const throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !"); } -void MEDCouplingPointSet::updateTime() +void MEDCouplingPointSet::updateTime() const { if(_coords) { @@ -174,7 +174,7 @@ DataArrayInt *MEDCouplingPointSet::buildPermArrayForMergeNode(int limitNodeId, d /*! * This methods searches for each node n1 nodes in _coords that are less far than 'prec' from n1. if any these nodes are stored in params * comm and commIndex. - * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged. + * @param limitNodeId is the limit node id. All nodes which id is strictly lower than 'limitNodeId' will not be merged each other. * @param comm out parameter (not inout) * @param commIndex out parameter (not inout) */ diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index 0085f7f40..b84a128d4 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -42,7 +42,7 @@ namespace ParaMEDMEM MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy); ~MEDCouplingPointSet(); public: - void updateTime(); + void updateTime() const; int getNumberOfNodes() const; int getSpaceDimension() const; void setCoords(DataArrayDouble *coords); diff --git a/src/MEDCoupling/MEDCouplingRemapper.cxx b/src/MEDCoupling/MEDCouplingRemapper.cxx index 76026ff8c..872ec333e 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.cxx +++ b/src/MEDCoupling/MEDCouplingRemapper.cxx @@ -335,7 +335,7 @@ int MEDCouplingRemapper::prepareEE(const char *method) throw(INTERP_KERNEL::Exce return 1; } -void MEDCouplingRemapper::updateTime() +void MEDCouplingRemapper::updateTime() const { } diff --git a/src/MEDCoupling/MEDCouplingRemapper.hxx b/src/MEDCoupling/MEDCouplingRemapper.hxx index 14d402d03..07d2be0a0 100644 --- a/src/MEDCoupling/MEDCouplingRemapper.hxx +++ b/src/MEDCoupling/MEDCouplingRemapper.hxx @@ -56,7 +56,7 @@ namespace ParaMEDMEM private: int prepareUU(const char *method) throw(INTERP_KERNEL::Exception); int prepareEE(const char *method) throw(INTERP_KERNEL::Exception); - void updateTime(); + void updateTime() const; void releaseData(bool matrixSuppression); void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField); void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx index 5e761d8fb..a86a7ca23 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx @@ -83,7 +83,7 @@ void MEDCouplingTimeDiscretization::checkCoherency() const throw(INTERP_KERNEL:: throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !"); } -void MEDCouplingTimeDiscretization::updateTime() +void MEDCouplingTimeDiscretization::updateTime() const { if(_array) updateTimeWith(*_array); @@ -1893,7 +1893,7 @@ MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& _end_array=0; } -void MEDCouplingTwoTimeSteps::updateTime() +void MEDCouplingTwoTimeSteps::updateTime() const { MEDCouplingTimeDiscretization::updateTime(); if(_end_array) diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx index aa5e4ccd9..844b197b5 100644 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx @@ -38,7 +38,7 @@ namespace ParaMEDMEM MEDCouplingTimeDiscretization(); MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy); public: - void updateTime(); + void updateTime() const; static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type); void setTimeUnit(const char *unit) { _time_unit=unit; } const char *getTimeUnit() const { return _time_unit.c_str(); } @@ -341,7 +341,7 @@ namespace ParaMEDMEM MEDCouplingTwoTimeSteps(); ~MEDCouplingTwoTimeSteps(); public: - void updateTime(); + void updateTime() const; void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other); void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other); DataArrayDouble *getEndArray() const; diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx index dad0d5900..8c0115fbb 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.cxx @@ -31,18 +31,18 @@ TimeLabel::~TimeLabel() { } - TimeLabel& TimeLabel::operator=(const TimeLabel& other) +TimeLabel& TimeLabel::operator=(const TimeLabel& other) { _time=GLOBAL_TIME++; return *this; } -void TimeLabel::declareAsNew() +void TimeLabel::declareAsNew() const { _time=GLOBAL_TIME++; } -void TimeLabel::updateTimeWith(const TimeLabel& other) +void TimeLabel::updateTimeWith(const TimeLabel& other) const { if(_timesetTime(2.7,20,21); MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs); MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone(); - dt.appendRepr(std::cout); std::vector hs=dt.getHotSpotsTime(); CPPUNIT_ASSERT_EQUAL(6,(int)hs.size()); const double expected1[]={0.2,0.7,1.2,1.35,1.7,2.7}; @@ -138,6 +137,21 @@ void MEDCouplingBasicsTest::testFieldOverTime1() CPPUNIT_ASSERT_EQUAL(4,arrId); CPPUNIT_ASSERT_EQUAL(0,arrIdInField); CPPUNIT_ASSERT_EQUAL(4,fieldId); + // + MEDCouplingDefinitionTime dt2; + CPPUNIT_ASSERT(!dt2.isEqual(dt)); + dt2.assign(dt); + dt2.assign(dt);//to check memory management + CPPUNIT_ASSERT(dt2.isEqual(dt)); + // + MEDCouplingDefinitionTime dt3; + std::vector tmp1; + std::vector tmp2; + CPPUNIT_ASSERT(!dt2.isEqual(dt3)); + dt2.getTinySerializationInformation(tmp1,tmp2); + dt3.unserialize(tmp1,tmp2); + CPPUNIT_ASSERT(dt2.isEqual(dt3)); + // for(std::vector::iterator it=fs.begin();it!=fs.end();it++) (*it)->decrRef(); fot->decrRef(); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 42ecdfcd9..545c936ce 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -476,7 +476,7 @@ namespace ParaMEDMEM class MEDCouplingPointSet : public ParaMEDMEM::MEDCouplingMesh { public: - void updateTime(); + void updateTime() const; void setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception); DataArrayDouble *getCoordinatesAndOwner() const throw(INTERP_KERNEL::Exception); bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const throw(INTERP_KERNEL::Exception); @@ -717,7 +717,7 @@ namespace ParaMEDMEM static MEDCouplingUMesh *New(); static MEDCouplingUMesh *New(const char *meshName, int meshDim); MEDCouplingUMesh *clone(bool recDeepCpy) const; - void updateTime(); + void updateTime() const; void checkCoherency() const throw(INTERP_KERNEL::Exception); void setMeshDimension(int meshDim) throw(INTERP_KERNEL::Exception); void allocateCells(int nbOfCells) throw(INTERP_KERNEL::Exception); @@ -1868,7 +1868,7 @@ namespace ParaMEDMEM void setEndOrder(int order) throw(INTERP_KERNEL::Exception); void setTimeValue(double val) throw(INTERP_KERNEL::Exception); void setEndTimeValue(double val) throw(INTERP_KERNEL::Exception); - void updateTime() throw(INTERP_KERNEL::Exception); + void updateTime() const throw(INTERP_KERNEL::Exception); void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double prec) throw(INTERP_KERNEL::Exception); bool mergeNodes(double eps, double epsOnVals=1e-15) throw(INTERP_KERNEL::Exception); @@ -2339,6 +2339,11 @@ namespace ParaMEDMEM class MEDCouplingDefinitionTime { public: + MEDCouplingDefinitionTime(); + void assign(const MEDCouplingDefinitionTime& other); + bool isEqual(const MEDCouplingDefinitionTime& other) const; + double getTimeResolution() const; + std::vector getHotSpotsTime() const; %extend { std::string __str__() const @@ -2347,6 +2352,30 @@ namespace ParaMEDMEM self->appendRepr(oss); return oss.str(); } + + PyObject *getIdsOnTimeRight(double tm) const throw(INTERP_KERNEL::Exception) + { + int meshId,arrId,arrIdInField,fieldId; + self->getIdsOnTimeRight(tm,meshId,arrId,arrIdInField,fieldId); + PyObject *res=PyList_New(4); + PyList_SetItem(res,0,PyInt_FromLong(meshId)); + PyList_SetItem(res,1,PyInt_FromLong(arrId)); + PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + return res; + } + + PyObject *getIdsOnTimeLeft(double tm) const throw(INTERP_KERNEL::Exception) + { + int meshId,arrId,arrIdInField,fieldId; + self->getIdsOnTimeLeft(tm,meshId,arrId,arrIdInField,fieldId); + PyObject *res=PyList_New(4); + PyList_SetItem(res,0,PyInt_FromLong(meshId)); + PyList_SetItem(res,1,PyInt_FromLong(arrId)); + PyList_SetItem(res,2,PyInt_FromLong(arrIdInField)); + PyList_SetItem(res,3,PyInt_FromLong(fieldId)); + return res; + } } }; @@ -2355,6 +2384,7 @@ namespace ParaMEDMEM public: double getTimeTolerance() const throw(INTERP_KERNEL::Exception); MEDCouplingDefinitionTime getDefinitionTimeZone() const; + %extend { std::string __str__() const diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 1d672befd..5249f0f0b 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -6006,6 +6006,73 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(mfs.isEqual(mfs2,1e-12,1e-12)) pass + def testFieldOverTime1(self): + fs=MEDCouplingDataForTest.buildMultiFields_2(); + self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs); + f4bis=fs[4].buildNewTimeReprFromThis(ONE_TIME,False); + fs[4]=f4bis; + self.assertRaises(InterpKernelException,MEDCouplingFieldOverTime.New,fs); + f4bis.setTime(2.7,20,21); + fot=MEDCouplingFieldOverTime.New(fs); + dt=fot.getDefinitionTimeZone(); + hs=dt.getHotSpotsTime(); + self.assertEqual(6,len(hs)); + expected1=[0.2,0.7,1.2,1.35,1.7,2.7] + for i in xrange(6): + self.assertAlmostEqual(expected1[i],hs[i],12); + pass + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.2); + self.assertEqual(0,meshId); + self.assertEqual(0,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(0,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(0.7); + self.assertEqual(0,meshId); + self.assertEqual(1,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(1,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeLeft(1.2);#**** WARNING left here + self.assertEqual(0,meshId); + self.assertEqual(2,arrId); + self.assertEqual(1,arrIdInField); + self.assertEqual(1,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.2);#**** WARNING right again here + self.assertEqual(1,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(2,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.35); + self.assertEqual(1,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(2,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(1.7); + self.assertEqual(0,meshId); + self.assertEqual(3,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(3,fieldId); + # + meshId,arrId,arrIdInField,fieldId=dt.getIdsOnTimeRight(2.7); + self.assertEqual(1,meshId); + self.assertEqual(4,arrId); + self.assertEqual(0,arrIdInField); + self.assertEqual(4,fieldId); + # + dt2=MEDCouplingDefinitionTime(); + self.assertTrue(not dt2.isEqual(dt)); + dt2.assign(dt); + dt2.assign(dt);#to check memory management + self.assertTrue(dt2.isEqual(dt)); + # + dt3=MEDCouplingDefinitionTime(); + # + pass + def testDAICheckAndPreparePermutation1(self): vals1=[9,10,0,6,4,11,3,7]; expect1=[5,6,0,3,2,7,1,4]; diff --git a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py index 846495e78..7b57ab663 100644 --- a/src/MEDCoupling_Swig/MEDCouplingDataForTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingDataForTest.py @@ -376,6 +376,60 @@ class MEDCouplingDataForTest: ret=MEDCouplingMultiFields.New([f0,f1,f2,f3,f4]); return ret; + def buildMultiFields_2(cls): + m1=MEDCouplingDataForTest.build2DTargetMesh_1(); + m1.setName("m1"); + m2=MEDCouplingDataForTest.build2DTargetMesh_1(); + m2.setName("m2"); + vals0=[-0.7,-1.,-2.,-3.,-4.]; + vals1=[0.,1.,2.,3.,4.]; + vals1_1=[170.,171.,172.,173.,174.]; + vals2=[5.,6.,7.,8.,9.]; + vals4=[15.,16.,17.,18.,19.]; + d0=DataArrayDouble.New(); + d0.setValues(vals0,5,1); + d1=DataArrayDouble.New(); + d1.setValues(vals1,5,1); + d1_1=DataArrayDouble.New(); + d1_1.setValues(vals1_1,5,1); + d2=DataArrayDouble.New(); + d2.setValues(vals2,5,1); + d4=DataArrayDouble.New(); + d4.setValues(vals4,5,1); + d0.setName("d0"); d1.setName("d1"); d1_1.setName("d1_1"); d2.setName("d2"); d4.setName("d4"); + d0.setInfoOnComponent(0,"c1"); + d1.setInfoOnComponent(0,"c6"); + d1_1.setInfoOnComponent(0,"c9"); + d2.setInfoOnComponent(0,"c5"); + d4.setInfoOnComponent(0,"c7"); + f0=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f0.setMesh(m1); + f0.setArray(d0); + f0.setTime(0.2,5,6); + f0.setName("f0"); + f1=MEDCouplingFieldDouble.New(ON_CELLS,LINEAR_TIME); + f1.setMesh(m1); + f1.setArrays([d1,d1_1]); + f1.setStartTime(0.7,7,8); + f1.setEndTime(1.2,9,10); + f1.setName("f1"); + f2=MEDCouplingFieldDouble.New(ON_CELLS,CONST_ON_TIME_INTERVAL); + f2.setMesh(m2); + f2.setArray(d2); + f2.setTime(1.2,11,12); + f2.setEndTime(1.5,13,14); + f2.setName("f2"); + f3=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME); + f3.setMesh(m1); + f3.setArray(d2); + f3.setTime(1.7,15,16); + f3.setName("f3"); + f4=MEDCouplingFieldDouble.New(ON_CELLS,NO_TIME); + f4.setMesh(m2); + f4.setArray(d4); + f4.setName("f4"); + return [f0,f1,f2,f3,f4] + build2DTargetMesh_1=classmethod(build2DTargetMesh_1) build2DSourceMesh_1=classmethod(build2DSourceMesh_1) build3DTargetMesh_1=classmethod(build3DTargetMesh_1) @@ -391,4 +445,5 @@ class MEDCouplingDataForTest: build2DTargetMesh_3=classmethod(build2DTargetMesh_3) build2DTargetMesh_4=classmethod(build2DTargetMesh_4) buildMultiFields_1=classmethod(buildMultiFields_1) + buildMultiFields_2=classmethod(buildMultiFields_2) pass -- 2.39.2