return new MEDFileField1TS(fileName,fieldName,iteration,order);
}
+MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutDAS& other)
+{
+ return new MEDFileField1TS(other);
+}
+
MEDFileField1TS *MEDFileField1TS::New()
{
return new MEDFileField1TS;
throw e;
}
+MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutDAS& other):MEDFileField1TSWithoutDAS(other)
+{
+}
+
MEDFileField1TS::MEDFileField1TS()
{
}
}
else
{
- std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getTimeSteps : At rank #" << i << " time step is not defined !";
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
return _time_steps.size();
}
+void MEDFileFieldMultiTSWithoutDAS::eraseEmptyTS() throw(INTERP_KERNEL::Exception)
+{
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > newTS;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
+ {
+ const MEDFileField1TSWithoutDAS *tmp=(*it);
+ if(tmp)
+ newTS.push_back(*it);
+ }
+ _time_steps=newTS;
+}
+
+int MEDFileFieldMultiTSWithoutDAS::getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ {
+ const MEDFileField1TSWithoutDAS *tmp(*it);
+ if(tmp)
+ {
+ int it,ord;
+ tmp->getTime(it,ord);
+ if(it==iteration && order==ord)
+ return ret;
+ else
+ oss << "(" << it << "," << ord << "), ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
+int MEDFileFieldMultiTSWithoutDAS::getPosGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int ret=0;
+ std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutDAS::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
+ {
+ const MEDFileField1TSWithoutDAS *tmp(*it);
+ if(tmp)
+ {
+ int it,ord;
+ double ti=tmp->getTime(it,ord);
+ if(fabs(time-ti)<eps)
+ return ret;
+ else
+ oss << ti << ", ";
+ }
+ }
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+}
+
std::vector< std::pair<int,int> > MEDFileFieldMultiTSWithoutDAS::getIterations() const
{
int lgth=_time_steps.size();
return new MEDFileFieldMultiTS(other);
}
+MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception)
+{
+ if(pos<0 || pos>=(int)_time_steps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileField1TSWithoutDAS *item=_time_steps[pos];
+ if(item==0)
+ {
+ std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
+ oss << "\nTry to use following method eraseEmptyTS !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*item);
+ ret->shallowCpyGlobs(*this);
+ ret->incrRef();
+ return ret;
+}
+
+MEDFileField1TS *MEDFileFieldMultiTS::getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosOfTimeStep(iteration,order);
+ return getTimeStepAtPos(pos);
+}
+
+MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepGivenTime(double time, double eps) const throw(INTERP_KERNEL::Exception)
+{
+ int pos=getPosGivenTime(time,eps);
+ return getTimeStepAtPos(pos);
+}
+
std::string MEDFileFieldMultiTS::simpleRepr() const
{
std::ostringstream oss;
int getIteration() const { return _iteration; }
int getOrder() const { return _order; }
double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
- void setTime(double val, int iteration, int order) { _dt=val; _iteration=iteration; _order=order; }
+ void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
std::string getName() const;
void setName(const char *name);
void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
{
public:
static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ static MEDFileField1TS *New(const MEDFileField1TSWithoutDAS& other);
static MEDFileField1TS *New();
std::string simpleRepr() const;
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
+ MEDFileField1TS(const MEDFileField1TSWithoutDAS& other);
MEDFileField1TS();
};
public:
static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const;
+ void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
std::vector< std::pair<int,int> > getIterations() const;
+ int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
static MEDFileFieldMultiTS *New();
static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutDAS& other);
+ //
+ MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
+ MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
+ //
std::string simpleRepr() const;
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
void setIteration(int it) { _iteration=it; }
int getIteration() const { return _iteration; }
void setTimeValue(double time) { _time=time; }
- void setTime(double time, int dt, int it) { _time=time; _iteration=dt; _order=it; }
+ void setTime(int dt, int it, double time) { _time=time; _iteration=dt; _order=it; }
double getTime(int& dt, int& it) { dt=_iteration; it=_order; return _time; }
double getTimeValue() const { return _time; }
void setTimeUnit(const char *unit) { _dt_unit=unit; }