return new MEDCouplingCMesh(*this,recDeepCpy);
}
-void MEDCouplingCMesh::updateTime()
+void MEDCouplingCMesh::updateTime() const
{
if(_x_array)
updateTimeWith(*_x_array);
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;
using namespace ParaMEDMEM;
+const double MEDCouplingDefinitionTime::EPS_DFT=1e-15;
+
MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& 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 !!!";
}
}
+MEDCouplingDefinitionTimeSlice *MEDCouplingDefinitionTimeSlice::New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& 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)
return (o1<t1+eps && o2<t1+eps);
}
+MEDCouplingDefinitionTimeSliceInst *MEDCouplingDefinitionTimeSliceInst::New(const std::vector<int>& tiI, const std::vector<double>& tiD)
+{
+ MEDCouplingDefinitionTimeSliceInst *ret=new MEDCouplingDefinitionTimeSliceInst;
+ ret->unserialize(tiI,tiD);
+ return ret;
+}
+
+void MEDCouplingDefinitionTimeSliceInst::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceInst *>(&other);
+ if(!otherC)
+ return false;
+ return fabs(otherC->_instant-_instant)<eps;
}
void MEDCouplingDefinitionTimeSliceInst::getHotSpotsTime(std::vector<double>& ret) const
_instant=t1;
}
+MEDCouplingDefinitionTimeSliceCstOnTI *MEDCouplingDefinitionTimeSliceCstOnTI::New(const std::vector<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceCstOnTI *>(&other);
+ if(!otherC)
+ return false;
+ if(fabs(otherC->_start-_start)>eps)
+ return false;
+ return fabs(otherC->_end-_end)<eps;
}
void MEDCouplingDefinitionTimeSliceCstOnTI::getHotSpotsTime(std::vector<double>& ret) const
return _end;
}
+void MEDCouplingDefinitionTimeSliceCstOnTI::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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;
_end=t2;
}
+MEDCouplingDefinitionTimeSliceLT *MEDCouplingDefinitionTimeSliceLT::New(const std::vector<int>& tiI, const std::vector<double>& 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<const MEDCouplingDefinitionTimeSliceLT *>(&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)<eps;
}
void MEDCouplingDefinitionTimeSliceLT::getHotSpotsTime(std::vector<double>& ret) const
return _array_id_end;
}
+void MEDCouplingDefinitionTimeSliceLT::getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& 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<int>& tiI, const std::vector<double>& 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;
_end=t2;
}
-MEDCouplingDefinitionTime::MEDCouplingDefinitionTime()
+MEDCouplingDefinitionTime::MEDCouplingDefinitionTime():_eps(EPS_DFT)
{
}
}
}
+void MEDCouplingDefinitionTime::assign(const MEDCouplingDefinitionTime& other)
+{
+ std::size_t sz=other._slices.size();
+ _slices.resize(sz);
+ for(std::size_t i=0;i<sz;i++)
+ _slices[i]=other._slices[i]->copy();
+}
+
+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;i<sz;i++)
+ if(!_slices[i]->isEqual(*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<int> meshIds;
stream << std::endl;
}
}
+
+void MEDCouplingDefinitionTime::getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const
+{
+ int sz=_slices.size();
+ tinyInfoD.resize(1);
+ tinyInfoD[0]=_eps;
+ tinyInfoI.resize(3*sz+2);
+ tinyInfoI[0]=sz;
+ std::vector<int> coreData;
+ for(int i=0;i<sz;i++)
+ {
+ std::vector<int> tmp1;
+ std::vector<double> 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<int>& tinyInfoI, const std::vector<double>& tinyInfoD)
+{
+ int sz=tinyInfoI[0];
+ _slices.resize(sz);
+ _eps=tinyInfoD[0];
+ int offset1=0;
+ int offset2=1;
+ for(int i=0;i<sz;i++)
+ {
+ TypeOfTimeDiscretization ty=(TypeOfTimeDiscretization) tinyInfoI[i+2];
+ int sz1=tinyInfoI[i+sz+2];
+ int sz2=tinyInfoI[i+2*sz+2];
+ std::vector<int> tmp1(tinyInfoI.begin()+3*sz+2+offset1,tinyInfoI.begin()+3*sz+2+offset1+sz1);
+ std::vector<double> tmp2(tinyInfoD.begin()+offset2,tinyInfoD.begin()+offset2+sz2);
+ MEDCouplingDefinitionTimeSlice *pt=MEDCouplingDefinitionTimeSlice::New(ty,tmp1,tmp2);
+ _slices[i]=pt;
+ offset1+=sz1;
+ offset2+=sz2;
+ }
+}
+
{
public:
static MEDCouplingDefinitionTimeSlice *New(const MEDCouplingFieldDouble *f, int meshId, const std::vector<int>& arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ static MEDCouplingDefinitionTimeSlice *New(TypeOfTimeDiscretization type, const std::vector<int>& tiI, const std::vector<double>& 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<double>& ret) const = 0;
virtual void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception) = 0;
virtual void appendRepr(std::ostream& stream) const;
virtual double getStartTime() const = 0;
virtual double getEndTime() const = 0;
+ virtual void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& 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;
class MEDCouplingDefinitionTimeSliceInst : public MEDCouplingDefinitionTimeSlice
{
public:
+ static MEDCouplingDefinitionTimeSliceInst *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
void getHotSpotsTime(std::vector<double>& ret) const;
void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
void appendRepr(std::ostream& stream) const;
double getStartTime() const;
double getEndTime() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ TypeOfTimeDiscretization getTimeType() const;
public:
MEDCouplingDefinitionTimeSliceInst(const MEDCouplingFieldDouble *f, int meshId, int arrId, int fieldId) throw(INTERP_KERNEL::Exception);
+ protected:
+ MEDCouplingDefinitionTimeSliceInst() { }
protected:
double _instant;
};
class MEDCouplingDefinitionTimeSliceCstOnTI : public MEDCouplingDefinitionTimeSlice
{
public:
+ static MEDCouplingDefinitionTimeSliceCstOnTI *New(const std::vector<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
void getHotSpotsTime(std::vector<double>& ret) const;
void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
void appendRepr(std::ostream& stream) const;
double getStartTime() const;
double getEndTime() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& 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<int>& tiI, const std::vector<double>& tiD);
+ MEDCouplingDefinitionTimeSlice *copy() const;
bool isEqual(const MEDCouplingDefinitionTimeSlice& other, double eps) const;
void getHotSpotsTime(std::vector<double>& ret) const;
void getIdsOnTime(double tm, double eps, int& meshId, int& arrId, int& arrIdInField, int& fieldId) const throw(INTERP_KERNEL::Exception);
double getStartTime() const;
double getEndTime() const;
int getEndId() const;
+ void getTinySerializationInformation(std::vector<int>& tiI, std::vector<double>& tiD) const;
+ void unserialize(const std::vector<int>& tiI, const std::vector<double>& 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;
{
public:
MEDCouplingDefinitionTime();
- bool isEqual(const MEDCouplingDefinitionTime& other, double eps) const;
MEDCouplingDefinitionTime(const std::vector<const MEDCouplingFieldDouble *>& fs, const std::vector<int>& meshRefs, const std::vector<std::vector<int> >& 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<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
std::vector<double> getHotSpotsTime() const;
void appendRepr(std::ostream& stream) const;
- private:
- void getIdsOnTime(double tm, std::vector<int>& meshIds, std::vector<int>& arrIds, std::vector<int>& arrIdsInField, std::vector<int>& fieldIds) const throw(INTERP_KERNEL::Exception);
+ public:
+ void getTinySerializationInformation(std::vector<int>& tinyInfoI, std::vector<double>& tinyInfoD) const;
+ void unserialize(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
private:
double _eps;
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingDefinitionTimeSlice> > _slices;
+ static const double EPS_DFT;
};
}
bbox[2*id+1]+=tmp[id];
}
-void MEDCouplingExtrudedMesh::updateTime()
+void MEDCouplingExtrudedMesh::updateTime() const
{
if(_mesh2D)
{
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; }
return _mesh==other->_mesh;
}
-void MEDCouplingField::updateTime()
+void MEDCouplingField::updateTime() const
{
if(_mesh)
updateTimeWith(*_mesh);
void getCellIdsHavingGaussLocalization(int locId, std::vector<int>& 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);
/*!
* Excepted for MEDCouplingFieldDiscretizationPerCell no underlying TimeLabel object : nothing to do in generally.
*/
-void MEDCouplingFieldDiscretization::updateTime()
+void MEDCouplingFieldDiscretization::updateTime() const
{
}
_discr_per_cell=arr->deepCpy();
}
-void MEDCouplingFieldDiscretizationPerCell::updateTime()
+void MEDCouplingFieldDiscretizationPerCell::updateTime() const
{
if(_discr_per_cell)
updateTimeWith(*_discr_per_cell);
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;
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;
return getArray()->getNbOfElems();
}
-void MEDCouplingFieldDouble::updateTime()
+void MEDCouplingFieldDouble::updateTime() const
{
MEDCouplingField::updateTime();
updateTimeWith(*_time_discr);
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<int>& tinyInfo) const;
void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
checkCoherency();
}
+MEDCouplingFieldOverTime::MEDCouplingFieldOverTime()
+{
+}
std::string simpleRepr() const;
bool isEqual(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
bool isEqualWithoutConsideringStr(const MEDCouplingMultiFields *other, double meshPrec, double valsPrec) const;
+ //void getIdsToFetch(double time, int& fieldId, int& arrId, int& meshId) const;
+ //void setFieldOnId(int fieldId, MEDCouplingFieldDouble *f);
+ //void dispatchPointers();
std::vector<MEDCouplingMesh *> getMeshes() const throw(INTERP_KERNEL::Exception);
std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+ protected:
+ MEDCouplingFieldOverTime();
private:
MEDCouplingFieldOverTime(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception);
};
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<std::string>(oss," "));
throw INTERP_KERNEL::Exception(oss.str().c_str());
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<int>& 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<std::string>& tinyInfo) const
+{
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ tinyInfo.resize(nbOfCompo+1);
+ tinyInfo[0]=getName();
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo[i+1]=getInfoOnComponent(i);
+ }
+ else
+ {
+ tinyInfo.resize(1);
+ tinyInfo[0]=getName();
+ }
+}
+
+/*!
+ * Useless method for end user. Only for MPI/Corba/File serialsation for multi arrays class.
+ * This method returns if a feeding is needed.
+ */
+bool DataArrayInt::resizeForUnserialization(const std::vector<int>& 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<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS)
+{
+ setName(tinyInfoS[0].c_str());
+ if(isAllocated())
+ {
+ int nbOfCompo=getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ setInfoOnComponent(i,tinyInfoS[i+1].c_str());
+ }
+}
MEDCOUPLING_EXPORT static DataArrayDouble *Divide(const DataArrayDouble *a1, const DataArrayDouble *a2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT void divideEqual(const DataArrayDouble *other) throw(INTERP_KERNEL::Exception);
//! nothing to do here because this class does not aggregate any TimeLabel instance.
- MEDCOUPLING_EXPORT void updateTime() { }
+ MEDCOUPLING_EXPORT void updateTime() const { }
public:
void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
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<int>& tinyInfo) const;
+ void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
+ bool resizeForUnserialization(const std::vector<int>& tinyInfoI);
+ void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<std::string>& tinyInfoS);
private:
DataArrayInt() { }
private:
return _fs[id];
}
-void MEDCouplingMultiFields::updateTime()
+void MEDCouplingMultiFields::updateTime() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::iterator it=_fs.begin();
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::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));
}
virtual std::vector<MEDCouplingMesh *> getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception);
virtual std::vector<DataArrayDouble *> getArrays() const throw(INTERP_KERNEL::Exception);
virtual std::vector<DataArrayDouble *> getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception);
- void updateTime();
+ void updateTime() const;
void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const;
void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !");
}
-void MEDCouplingPointSet::updateTime()
+void MEDCouplingPointSet::updateTime() const
{
if(_coords)
{
/*!
* 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)
*/
MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy);
~MEDCouplingPointSet();
public:
- void updateTime();
+ void updateTime() const;
int getNumberOfNodes() const;
int getSpaceDimension() const;
void setCoords(DataArrayDouble *coords);
return 1;
}
-void MEDCouplingRemapper::updateTime()
+void MEDCouplingRemapper::updateTime() const
{
}
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);
throw INTERP_KERNEL::Exception("time tolerance is expected to be greater than 0. !");
}
-void MEDCouplingTimeDiscretization::updateTime()
+void MEDCouplingTimeDiscretization::updateTime() const
{
if(_array)
updateTimeWith(*_array);
_end_array=0;
}
-void MEDCouplingTwoTimeSteps::updateTime()
+void MEDCouplingTwoTimeSteps::updateTime() const
{
MEDCouplingTimeDiscretization::updateTime();
if(_end_array)
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(); }
MEDCouplingTwoTimeSteps();
~MEDCouplingTwoTimeSteps();
public:
- void updateTime();
+ void updateTime() const;
void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other);
void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
DataArrayDouble *getEndArray() const;
{
}
- 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(_time<other._time)
_time=other._time;
public:
TimeLabel& operator=(const TimeLabel& other);
//! This method should be called when write access has been done on this.
- void declareAsNew();
+ void declareAsNew() const;
//! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
- virtual void updateTime() = 0;
+ virtual void updateTime() const = 0;
unsigned int getTimeOfThis() const { return _time; }
protected:
TimeLabel();
virtual ~TimeLabel();
- void updateTimeWith(const TimeLabel& other);
+ void updateTimeWith(const TimeLabel& other) const;
private:
static unsigned int GLOBAL_TIME;
- unsigned int _time;
+ mutable unsigned int _time;
};
}
return new MEDCouplingUMesh(*this,recDeepCpy);
}
-void MEDCouplingUMesh::updateTime()
+void MEDCouplingUMesh::updateTime() const
{
MEDCouplingPointSet::updateTime();
if(_nodal_connec)
MEDCOUPLING_EXPORT static MEDCouplingUMesh *New(const char *meshName, int meshDim);
MEDCOUPLING_EXPORT MEDCouplingMesh *deepCpy() const;
MEDCOUPLING_EXPORT MEDCouplingUMesh *clone(bool recDeepCpy) const;
- MEDCOUPLING_EXPORT void updateTime();
+ MEDCOUPLING_EXPORT void updateTime() const;
MEDCOUPLING_EXPORT MEDCouplingMeshType getType() const { return UNSTRUCTURED; }
MEDCOUPLING_EXPORT bool isEqual(const MEDCouplingMesh *other, double prec) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
f4bis->setTime(2.7,20,21);
MEDCouplingFieldOverTime *fot=MEDCouplingFieldOverTime::New(fs);
MEDCouplingDefinitionTime dt=fot->getDefinitionTimeZone();
- dt.appendRepr(std::cout);
std::vector<double> 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};
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<int> tmp1;
+ std::vector<double> tmp2;
+ CPPUNIT_ASSERT(!dt2.isEqual(dt3));
+ dt2.getTinySerializationInformation(tmp1,tmp2);
+ dt3.unserialize(tmp1,tmp2);
+ CPPUNIT_ASSERT(dt2.isEqual(dt3));
+ //
for(std::vector<MEDCouplingFieldDouble *>::iterator it=fs.begin();it!=fs.end();it++)
(*it)->decrRef();
fot->decrRef();
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);
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);
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);
class MEDCouplingDefinitionTime
{
public:
+ MEDCouplingDefinitionTime();
+ void assign(const MEDCouplingDefinitionTime& other);
+ bool isEqual(const MEDCouplingDefinitionTime& other) const;
+ double getTimeResolution() const;
+ std::vector<double> getHotSpotsTime() const;
%extend
{
std::string __str__() const
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;
+ }
}
};
public:
double getTimeTolerance() const throw(INTERP_KERNEL::Exception);
MEDCouplingDefinitionTime getDefinitionTimeZone() const;
+
%extend
{
std::string __str__() const
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];
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)
build2DTargetMesh_3=classmethod(build2DTargetMesh_3)
build2DTargetMesh_4=classmethod(build2DTargetMesh_4)
buildMultiFields_1=classmethod(buildMultiFields_1)
+ buildMultiFields_2=classmethod(buildMultiFields_2)
pass