self.assertTrue(not fieldOnNodes1.isEqual(fieldOnCells1,1e-12,1e-15));
#
fieldOnCells2=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
+ self.assertEqual(fieldOnCells2.getMesh(),None) # to check that convertMesh wrapping do not raise but return Py_None
self.assertTrue(not fieldOnCells1.isEqual(fieldOnCells2,1e-12,1e-15));
self.assertTrue(not fieldOnCells2.isEqual(fieldOnCells1,1e-12,1e-15));
fieldOnCells1=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME);
static PyObject *convertMesh(ParaMEDMEM::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mesh)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
if(dynamic_cast<ParaMEDMEM::MEDCouplingExtrudedMesh *>(mesh))
static PyObject *convertFieldDiscretization(ParaMEDMEM::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!fd)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP0 *>(fd))
ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDiscretizationP0,owner);
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldDiscretizationP1 *>(fd))
static PyObject *convertDataArrayChar(ParaMEDMEM::DataArrayChar *dac, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!dac)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::DataArrayByte *>(dac))
ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayByte,owner);
if(dynamic_cast<ParaMEDMEM::DataArrayAsciiChar *>(dac))
static PyObject *convertDataArray(ParaMEDMEM::DataArray *dac, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!dac)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::DataArrayDouble *>(dac))
ret=SWIG_NewPointerObj((void*)dac,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,owner);
if(dynamic_cast<ParaMEDMEM::DataArrayInt *>(dac))
static PyObject* convertMultiFields(ParaMEDMEM::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mfs)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDCouplingFieldOverTime *>(mfs))
ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldOverTime,owner);
else
using namespace ParaMEDMEM;
+const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
+const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
+
MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const char *locName)
{
return new MEDFileFieldLoc(fid,locName);
//= MEDFileAnyTypeField1TSWithoutSDA
+/*!
+ * Prints a string describing \a this field into a stream. This string is outputted
+ * by \c print Python command.
+ * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
+ * \param [in,out] oss - the out stream.
+ * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
+ * info id printed, else, not.
+ */
+void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
+{
+ std::string startOfLine(bkOffset,' ');
+ oss << startOfLine << "Field ";
+ if(bkOffset==0)
+ oss << "[Type=" << getTypeStr() << "] ";
+ oss << "on One time Step ";
+ if(f1tsId>=0)
+ oss << "(" << f1tsId << ") ";
+ oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
+ oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
+ const DataArray *arr=getUndergroundDataArray();
+ if(arr)
+ {
+ const std::vector<std::string> &comps=arr->getInfoOnComponents();
+ if(f1tsId<0)
+ {
+ oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
+ oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
+ for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
+ oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
+ }
+ if(arr->isAllocated())
+ {
+ oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
+ }
+ else
+ oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
+ }
+ else
+ {
+ oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
+ }
+ oss << startOfLine << "----------------------" << std::endl;
+ if(!_field_per_mesh.empty())
+ {
+ int i=0;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
+ {
+ const MEDFileFieldPerMesh *cur=(*it2);
+ if(cur)
+ cur->simpleRepr(bkOffset,oss,i);
+ else
+ oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
+ }
+ }
+ else
+ {
+ oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
+ }
+ oss << startOfLine << "----------------------" << std::endl;
+}
+
MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):_iteration(iteration),_order(order),_csit(csit)
{
}
return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
}
-/*!
- * Prints a string describing \a this field into a stream. This string is outputted
- * by \c print Python command.
- * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
- * \param [in,out] oss - the out stream.
- * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
- * info id printed, else, not.
- */
-void MEDFileField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
-{
- std::string startOfLine(bkOffset,' ');
- oss << startOfLine << "Field on One time Step ";
- if(f1tsId>=0)
- oss << "(" << f1tsId << ") ";
- oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
- oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
- const DataArrayDouble *arr=_arr;
- if(arr)
- {
- const std::vector<std::string> &comps=arr->getInfoOnComponents();
- if(f1tsId<0)
- {
- oss << startOfLine << "Field Name : \"" << arr->getName() << "\"." << std::endl;
- oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
- for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
- oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
- }
- if(arr->isAllocated())
- {
- oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
- }
- else
- oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
- }
- else
- {
- oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
- }
- oss << startOfLine << "----------------------" << std::endl;
- if(!_field_per_mesh.empty())
- {
- int i=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
- {
- const MEDFileFieldPerMesh *cur=(*it2);
- if(cur)
- cur->simpleRepr(bkOffset,oss,i);
- else
- oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
- }
- }
- else
- {
- oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
- }
- oss << startOfLine << "----------------------" << std::endl;
-}
-
/*!
* Returns all attributes and values of parts of \a this field lying on a given mesh.
* Each part differs from other ones by a type of supporting mesh entity. The _i_-th
return 0;
}
+const char *MEDFileField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return TYPE_STR;
+}
+
/*!
* Returns a pointer to the underground DataArrayDouble instance. So the
* caller should not decrRef() it. This method allows for a direct access to the field
arr->setInfoAndChangeNbOfCompo(infos);
}
+const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return TYPE_STR;
+}
+
/*!
* Returns a pointer to the underground DataArrayInt instance. So the
* caller should not decrRef() it. This method allows for a direct access to the field
return getUndergroundDataArrayInt();
}
-/*!
- * Prints a string describing \a this field into a stream. This string is outputted
- * by \c print Python command.
- * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
- * \param [in,out] oss - the out stream.
- * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
- * info id printed, else, not.
- */
-void MEDFileIntField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
-{
- // to implement (to factorize)
-}
-
MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
return new MEDFileIntField1TSWithoutSDA(*this);
void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
{
std::string startLine(bkOffset,' ');
- oss << startLine << "Field multi time steps";
+ oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
if(fmtsId>=0)
oss << " (" << fmtsId << ")";
oss << " has the following name: \"" << _name << "\"." << std::endl;
return new MEDFileField1TSWithoutSDA;
}
+const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return MEDFileField1TSWithoutSDA::TYPE_STR;
+}
+
MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
return new MEDFileFieldMultiTSWithoutSDA(*this);
return new MEDFileIntField1TSWithoutSDA;
}
+const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const throw(INTERP_KERNEL::Exception)
+{
+ return MEDFileIntField1TSWithoutSDA::TYPE_STR;
+}
+
MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const throw(INTERP_KERNEL::Exception)
{
return new MEDFileIntFieldMultiTSWithoutSDA(*this);
int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception);
void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const = 0;
+ virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
virtual MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
+ virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) = 0;
virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception) = 0;
virtual void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) = 0;
class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
{
public:
- void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
DataArrayDouble *getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception);
const DataArrayDouble *getOrCreateAndGetArrayDouble() const;
protected:
MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
+ public:
+ static const char TYPE_STR[];
};
/*!
public:
MEDFileIntField1TSWithoutSDA();
static MEDFileIntField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
- void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception);
MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
protected:
MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr;
+ public:
+ static const char TYPE_STR[];
};
/*!
public:
std::size_t getHeapMemorySize() const;
virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
+ virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0;
virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception) = 0;
const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
public:
static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(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);
protected:
public:
static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
+ const char *getTypeStr() const throw(INTERP_KERNEL::Exception);
MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception);
protected:
MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName);
return MEDFileIntField1TS::New(fileName,fieldName,iteration,order);
}
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
return MEDFileIntFieldMultiTS::New(fileName,fieldName);
}
+ std::string __str__() const throw(INTERP_KERNEL::Exception)
+ {
+ return self->simpleRepr();
+ }
+
PyObject *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
static PyObject* convertMEDFileMesh(ParaMEDMEM::MEDFileMesh* mesh, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!mesh)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<ParaMEDMEM::MEDFileUMesh *>(mesh))
ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDFileUMesh,owner);
if(dynamic_cast<ParaMEDMEM::MEDFileCMesh *>(mesh))
static PyObject* convertMEDFileParameter1TS(ParaMEDMEM::MEDFileParameter1TS* p1ts, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!p1ts)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<MEDFileParameterDouble1TS *>(p1ts))
ret=SWIG_NewPointerObj((void*)p1ts,SWIGTYPE_p_ParaMEDMEM__MEDFileParameterDouble1TS,owner);
if(dynamic_cast<MEDFileParameterDouble1TSWTI *>(p1ts))
static PyObject* convertMEDFileField1TS(ParaMEDMEM::MEDFileAnyTypeField1TS *p, int owner) throw(INTERP_KERNEL::Exception)
{
PyObject *ret=0;
+ if(!p)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<MEDFileField1TS *>(p))
ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileField1TS,owner);
if(dynamic_cast<MEDFileIntField1TS *>(p))
{
PyObject *ret=0;
if(!p)
- return SWIG_NewPointerObj((void*)0,SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,owner);
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
if(dynamic_cast<MEDFileFieldMultiTS *>(p))
ret=SWIG_NewPointerObj((void*)p,SWIGTYPE_p_ParaMEDMEM__MEDFileFieldMultiTS,owner);
if(dynamic_cast<MEDFileIntFieldMultiTS *>(p))
MEDFileFields* pointeFields = pointeMed->getFields();
for ( int i = 0; i < pointeFields->getNumberOfFields(); ++i )
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ts = dynamic_cast<MEDFileFieldMultiTS *>(pointeFields->getFieldAtPos(i));
+ MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ts = pointeFields->getFieldAtPos(i);
if ( std::string("fieldnodeint") == ts->getName())
{
pointeFields->destroyFieldAtPos( i );