%newobject ParaMEDMEM::MEDFileFields::getFieldAtPos;
%newobject ParaMEDMEM::MEDFileFields::__getitem__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::New;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepAtPos;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStep;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::getTimeStepGivenTime;
+%newobject ParaMEDMEM::MEDFileFieldMultiTS::__getitem__;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldAtTopLevel;
%newobject ParaMEDMEM::MEDFileFieldMultiTS::getFieldOnMeshAtLevel;
void setIteration(int it);
int getIteration();
void setTimeValue(double time);
- void setTime(double time, int dt, int it);
+ void setTime(int dt, int it, double time);
double getTimeValue() const;
void setTimeUnit(const char *unit);
const char *getTimeUnit() const;
int tmp1,tmp2;
double tmp0=self->getTime(tmp1,tmp2);
PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_double(tmp0));
- PyList_SetItem(res,1,SWIG_From_int(tmp1));
- PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ PyList_SetItem(res,0,SWIG_From_int(tmp1));
+ PyList_SetItem(res,1,SWIG_From_int(tmp2));
+ PyList_SetItem(res,2,SWIG_From_double(tmp0));
return res;
}
int getNumberOfComponents() const;
bool isDealingTS(int iteration, int order) const;
const std::vector<std::string>& getInfo() const;
- void setTime(double val, int iteration, int order);
+ void setTime(int iteration, int order, double val);
%extend
{
PyObject *getTime()
int tmp1,tmp2;
double tmp0=self->getTime(tmp1,tmp2);
PyObject *res = PyList_New(3);
- PyList_SetItem(res,0,SWIG_From_double(tmp0));
- PyList_SetItem(res,1,SWIG_From_int(tmp1));
- PyList_SetItem(res,2,SWIG_From_int(tmp2));
+ PyList_SetItem(res,0,SWIG_From_int(tmp1));
+ PyList_SetItem(res,1,SWIG_From_int(tmp2));
+ PyList_SetItem(res,2,SWIG_From_double(tmp0));
return res;
}
{
public:
int getNumberOfTS() const;
+ void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
+ int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
+ int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
std::string getName() const;
void setName(const char *name);
std::string getMeshName() const throw(INTERP_KERNEL::Exception);
public:
static MEDFileFieldMultiTS *New();
static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
+ //
+ 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);
+ //
void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
return self->simpleRepr();
}
+ MEDFileField1TS *__getitem__(PyObject *elt0) const throw(INTERP_KERNEL::Exception)
+ {
+ if(elt0 && PyInt_Check(elt0))
+ {//fmts[3]
+ int pos=PyInt_AS_LONG(elt0);
+ return self->getTimeStepAtPos(pos);
+ }
+ else if(elt0 && PyTuple_Check(elt0))
+ {
+ if(PyTuple_Size(elt0)==2)
+ {
+ PyObject *o0=PyTuple_GetItem(elt0,0);
+ PyObject *o1=PyTuple_GetItem(elt0,1);
+ if(PyInt_Check(o0) && PyInt_Check(o1))
+ {//fmts(1,-1)
+ int iter=PyInt_AS_LONG(o0);
+ int order=PyInt_AS_LONG(o1);
+ return self->getTimeStep(iter,order);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size 2 but two integers are expected in this tuple to request a time steps !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input param ! input is a tuple of size != 2 ! two integers are expected in this tuple to request a time steps !");
+ }
+ else if(elt0 && PyFloat_Check(elt0))
+ {
+ double val=PyFloat_AS_DOUBLE(elt0);
+ return self->getTimeStepGivenTime(val);
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::__getitem__ : invalid input params ! expected fmts[int], fmts[int,int] or fmts[double] to request time step !");
+ }
+
PyObject *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
def testMEDMesh6(self):
outFileName="MEDFileMesh5.med"
m=MEDFileCMesh.New()
- m.setTime(2.3,-1,-1)
+ m.setTime(-1,-1,2.3)
m1=MEDCouplingCMesh.New();
da=DataArrayDouble.New()
da.setValues([0.,1.,2.],3,1)
self.assertEqual(expected1,mm.getFamilyArr(1,"family1").getValues())
m2=mm.getMesh()
tt=m.getTime()
- m1.setTime(tt[0],tt[1],tt[2])
+ m1.setTime(tt[2],tt[0],tt[1])
m1.setName(m.getName())
m1.setTimeUnit(m.getTimeUnit())
m1.setDescription(m.getDescription())
mm=MEDFileMesh.New("Pyfile17.med")
mm.write("Pyfile17_bis.med",2)
ff=MEDFileFieldMultiTS.New("Pyfile17.med","MeasureOfMesh_Extruded")
+ self.assertEqual([3,4],ff[1].getTime()[:-1])
+ self.assertEqual([3,4],ff[3,4].getTime()[:-1])
+ self.assertEqual([3,4],ff[0.01].getTime()[:-1])
ff.write("Pyfile17_bis.med",0)
pass
ff1.setFieldNoProfileSBT(f1)
ff1.write(fname,0)
f2=MEDLoader.ReadFieldCell(fname,f1.getMesh().getName(),0,f1.getName(),f1.getTime()[1],f1.getTime()[2]);
- ti,itt,orr=ff1.getTime()
+ itt,orr,ti=ff1.getTime()
self.assertEqual(0,itt); self.assertEqual(1,orr); self.assertAlmostEqual(2.,ti,14);
self.assertTrue(f1.isEqual(f2,1e-12,1e-12))
- ff1.setTime(2.3,3,4)
- ti,itt,orr=ff1.getTime()
+ ff1.setTime(3,4,2.3)
+ itt,orr,ti=ff1.getTime()
self.assertEqual(3,itt); self.assertEqual(4,orr); self.assertAlmostEqual(2.3,ti,14);
da,infos=ff1.getUndergroundDataArrayExt()
f2.getArray().setName(da.getName())#da has the same name than f2
m1bis=d2.getMeshes().getMeshAtPos(0).getMeshAtLevel(0)
self.assertTrue(m1.isEqual(m1bis,1e-12))
self.assertEqual(('f1', 'f21', 'f22'),d2.getFields().getFieldsNames())
- self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldAtPos(2).getTimeSteps())
- self.assertEqual([(-1, -1, 0.0)],d2.getFields()[2].getTimeSteps())
- self.assertEqual([(-1, -1, 0.0)],d2.getFields().getFieldWithName("f21").getTimeSteps())
- self.assertEqual([(-1, -1, 0.0)],d2.getFields()["f21"].getTimeSteps())
+ self.assertEqual([(-1,-1,0.0)],d2.getFields().getFieldAtPos(2).getTimeSteps())
+ self.assertEqual([(-1,-1,0.0)],d2.getFields()[2].getTimeSteps())
+ self.assertEqual([(-1,-1,0.0)],d2.getFields().getFieldWithName("f21").getTimeSteps())
+ self.assertEqual([(-1,-1,0.0)],d2.getFields()["f21"].getTimeSteps())
pass
def testMEDField9(self):
self.assertTrue(vals.isEqual(d,1e-14))
#
ff2=MEDFileFieldMultiTS.New(fname,f1.getName())
- self.assertEqual([(-1, -1, 0.0), (1, 2, 1.2)],ff2.getTimeSteps())
+ self.assertEqual([(-1,-1,0.0), (1,2,1.2)],ff2.getTimeSteps())
vals,pfl=ff2.getFieldWithProfile(ON_CELLS,1,2,0,mm1) ; vals.setName("")
self.assertTrue(pfl.isEqualWithoutConsideringStr(da))
self.assertTrue(vals.isEqual(e,1e-14))