#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingUMesh.hxx"
#include "MEDCouplingTimeDiscretization.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
return ret.retn();
}
-/*!
- * Returns a type of \ref MEDCouplingTemporalDisc "time discretization" of \a this field.
- * \return MEDCoupling::TypeOfTimeDiscretization - an enum item describing the time
- * discretization type.
- */
-TypeOfTimeDiscretization MEDCouplingFieldDouble::getTimeDiscretization() const
+MEDCouplingFieldInt *MEDCouplingFieldDouble::convertToIntField() const
{
- return timeDiscr()->getEnum();
+ MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
+ int t1,t2;
+ double t0(getTime(t1,t2));
+ MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*tmp,getTimeDiscretization()));
+ ret->setTime(t0,t1,t2);
+ if(getArray())
+ {
+ MCAuto<DataArrayInt> arr(getArray()->convertToIntArr());
+ ret->setArray(arr);
+ }
+ return ret.retn();
}
MEDCouplingFieldDouble::MEDCouplingFieldDouble(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<double>(type,MEDCouplingTimeDiscretization::New(td))
namespace MEDCoupling
{
+ class MEDCouplingFieldInt;
class MEDCouplingFieldTemplate;
class MEDCouplingFieldDouble : public MEDCouplingFieldT<double>
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildNewTimeReprFromThis(TypeOfTimeDiscretization td, bool deepCopy) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *nodeToCellDiscretization() const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *cellToNodeDiscretization() const;
- MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldInt *convertToIntField() const;
MEDCOUPLING_EXPORT double getIJK(int cellId, int nodeIdInCell, int compoId) const;
MEDCOUPLING_EXPORT double accumulate(int compId) const;
MEDCOUPLING_EXPORT void accumulate(double *res) const;
#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingMesh.hxx"
{
return new MEDCouplingFieldInt(*this,recDeepCpy);
}
+
+MEDCouplingFieldDouble *MEDCouplingFieldInt::convertToDblField() const
+{
+ MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
+ int t1,t2;
+ double t0(getTime(t1,t2));
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization()));
+ ret->setTime(t0,t1,t2);
+ if(getArray())
+ {
+ MCAuto<DataArrayDouble> arr(getArray()->convertToDblArr());
+ ret->setArray(arr);
+ }
+ return ret.retn();
+}
namespace MEDCoupling
{
+ class MEDCouplingFieldDouble;
class MEDCouplingFieldTemplate;
class MEDCouplingFieldInt : public MEDCouplingFieldT<int>
MEDCOUPLING_EXPORT static MEDCouplingFieldInt *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
MEDCOUPLING_EXPORT MEDCouplingFieldInt *deepCopy() const;
MEDCOUPLING_EXPORT MEDCouplingFieldInt *clone(bool recDeepCpy) const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const;
protected:
MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td);
MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy);
MEDCouplingFieldT(MEDCouplingFieldDiscretization *type, NatureOfField n, MEDCouplingTimeDiscretizationTemplate<T> *timeDiscr);
~MEDCouplingFieldT();
public:
+ MEDCOUPLING_EXPORT TypeOfTimeDiscretization getTimeDiscretization() const;
MEDCOUPLING_EXPORT virtual typename Traits<T>::FieldType *clone(bool recDeepCpy) const = 0;
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT typename Traits<T>::FieldType *cloneWithMesh(bool recDeepCpy) const;
}
}
}
+
+ /*!
+ * Returns a type of \ref MEDCouplingTemporalDisc "time discretization" of \a this field.
+ * \return MEDCoupling::TypeOfTimeDiscretization - an enum item describing the time
+ * discretization type.
+ */
+ template<class T>
+ TypeOfTimeDiscretization MEDCouplingFieldT<T>::getTimeDiscretization() const
+ {
+ return _time_discr->getEnum();
+ }
}
#endif
%newobject MEDCoupling::MEDCouplingFieldDouble::getEndArray;
%newobject MEDCoupling::MEDCouplingFieldDouble::MergeFields;
%newobject MEDCoupling::MEDCouplingFieldDouble::MeldFields;
+%newobject MEDCoupling::MEDCouplingFieldDouble::convertToIntField;
%newobject MEDCoupling::MEDCouplingFieldDouble::doublyContractedProduct;
%newobject MEDCoupling::MEDCouplingFieldDouble::determinant;
%newobject MEDCoupling::MEDCouplingFieldDouble::eigenValues;
%newobject MEDCoupling::MEDCouplingFieldDouble::cellToNodeDiscretization;
%newobject MEDCoupling::MEDCouplingFieldDouble::getValueOnMulti;
%newobject MEDCoupling::MEDCouplingFieldInt::New;
+%newobject MEDCoupling::MEDCouplingFieldInt::convertToDblField;
%newobject MEDCoupling::MEDCouplingFieldInt::getArray;
%newobject MEDCoupling::MEDCouplingFieldInt::deepCopy;
%newobject MEDCoupling::MEDCouplingFieldInt::clone;
}
};
+ class MEDCouplingFieldInt;
+
class MEDCouplingFieldDouble : public MEDCoupling::MEDCouplingField
{
public:
std::string simpleRepr() const throw(INTERP_KERNEL::Exception);
std::string advancedRepr() const throw(INTERP_KERNEL::Exception);
std::string writeVTK(const std::string& fileName, bool isBinary=true) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *convertToIntField() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
MEDCouplingFieldDouble *cloneWithMesh(bool recDeepCpy) const;
MEDCouplingFieldDouble *deepCopy() const;
MEDCouplingFieldInt *deepCopy() const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *clone(bool recDeepCpy) const throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *cloneWithMesh(bool recDeepCpy) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldDouble *convertToDblField() const throw(INTERP_KERNEL::Exception);
%extend {
MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME)
{
{
if(!f)
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
- if(!((DataArray*)arr))
+ if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
- DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
if(!arrOutC)
throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
f->setArray(arrOutC);
DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
{
- if(!((DataArray*)arr))
+ if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
- DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
+ DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
if(!arrOutC)
throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
arrOutC->incrRef();
return ret;
}
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
{
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
- MCAuto<DataArray> arrOut2;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
- DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
- if(!arrOutC)
- throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
- arrOut=arrOutC;
- arrOut->incrRef(); // arrOut2 dies at the end of the func
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
{
if(arr.isNull())
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
- DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
+ DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
if(!arrC)
throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
arrC->incrRef();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on
+ * Returns a new MEDCouplingFieldInt of a given type lying on
* the top level cells of the first mesh in MED file. If \a this field
* has not been constructed via file reading, an exception is thrown.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If \a this field has not been constructed via file reading.
* \throw If the MED file is not readable.
* \throw If no field values lying on the top level support.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
{
if(getFileName().empty())
throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
+ * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of the new field.
* \param [in] mesh - the supporting mesh.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If no field of \a this is lying on \a mesh.
* \throw If the mesh is empty.
* \sa getFieldAtLevel()
* \sa getFieldOnMeshAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
{
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
- * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
+ * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
* For more info, see \ref AdvMEDLoaderAPIFieldRW
* \param [in] type - a spatial discretization of interest.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] mesh - the supporting mesh.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
* \throw If no field of \a this is lying on \a mesh.
* \sa getFieldAtLevel()
* \sa getFieldOnMeshAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
{
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
* \param [in] type - a spatial discretization of interest.
* \param [in] mName - a name of the supporting mesh.
* \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
- * \param [out] arrOut - the DataArrayInt containing values of field.
* \param [in] renumPol - specifies how to permute values of the result field according to
* the optional numbers of cells and nodes, if any. The valid values are
* - 0 - do not permute.
* - 2 - permute nodes.
* - 3 - permute cells and nodes.
*
- * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
+ * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
* caller is to delete this field using decrRef() as it is no more needed.
* \throw If the MED file is not readable.
* \throw If there is no mesh named \a mName in the MED file.
* \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
* \sa getFieldAtLevel()
*/
-MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
+MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
{
if(getFileName().empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
- MCAuto<DataArray> arr;
- MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
- arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
- return ret.retn();
+ throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
+ MCAuto<DataArray> arrOut;
+ MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
+ MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
+ return ret2.retn();
}
/*!
MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
//
MEDLOADER_EXPORT MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
- MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const;
+ MEDLOADER_EXPORT MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
//
MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldInt *field);
%newobject MEDCoupling::MEDFileIntField1TS::New;
%newobject MEDCoupling::MEDFileIntField1TS::field;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtTopLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldOnMeshAtLevel;
+%newobject MEDCoupling::MEDFileIntField1TS::getFieldAtLevelOld;
%newobject MEDCoupling::MEDFileIntField1TS::getUndergroundDataArray;
%newobject MEDCoupling::MEDFileIntField1TS::convertToDouble;
void setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
MEDCouplingFieldInt *field(const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
+ MEDCouplingFieldInt *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
%extend
{
MEDFileIntField1TS() throw(INTERP_KERNEL::Exception)
return self->simpleRepr();
}
- PyObject *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevel(type,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtTopLevel(type,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,meshDimRelToMax,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldOnMeshAtLevel(type,mesh,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
- PyObject *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret1=0;
- MEDCouplingFieldDouble *ret0=self->getFieldAtLevelOld(type,mname,meshDimRelToMax,ret1,renumPol);
- PyObject *ret=PyTuple_New(2);
- PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
- PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ));
- return ret;
- }
-
PyObject *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret1=0;
def testInt32InMEDFileFieldStar1(self):
fname="Pyfile63.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
- arr=f1.getArray().convertToIntArr()
- f1.setArray(None)
+ f1=f1.convertToIntField()
m1=f1.getMesh()
mm1=MEDFileUMesh.New()
mm1.setCoords(m1.getCoords())
mm1.setName(m1.getName())
mm1.write(fname,2)
ff1=MEDFileIntField1TS()
- ff1.setFieldNoProfileSBT(f1,arr)
- a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
- self.assertTrue(b.isEqual(arr))
+ ff1.setFieldNoProfileSBT(f1)
+ a=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
ff1.write(fname,0)
ff2=MEDFileAnyTypeField1TS.New(fname)
self.assertEqual(ff2.getName(),"VectorFieldOnCells")
self.assertEqual(ff2.getTime(),[0,1,2.0])
self.assertTrue(isinstance(ff2,MEDFileIntField1TS))
- a,b=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertEqual(b.getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
- self.assertTrue(b.isEqual(arr))
+ a=ff1.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertEqual(a.getArray().getInfoOnComponents(),['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
ff2.setTime(1,2,3.)
c=ff2.getUndergroundDataArray() ; c*=2
self.assertEqual(ffs1.getTimeSteps(),[(0, 1, 2.0), (1, 2, 3.0)])
self.assertEqual(len(ffs1),2)
self.assertTrue(isinstance(ffs1,MEDFileIntFieldMultiTS))
- a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(arr))
+ a=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
- a,b=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(arr))
+ a=ffs1[2.].getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
self.assertTrue(a.isEqual(f1,1e-12,1e-12))
it=ffs1.__iter__() ; it.next() ; ff2bis=it.next()
- a,b=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- self.assertTrue(b.isEqual(2*arr))
- f1.setTime(3.,1,2)
- self.assertTrue(a.isEqual(f1,1e-12,1e-12))
+ a=ff2bis.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ self.assertTrue(a.getArray().isEqual(2*f1.getArray()))
+ f1.setTime(3.,1,2) ; f1.getArray()[:]*=2
+ self.assertTrue(a.isEqual(f1,1e-12,1e-12)) ; f1.getArray()[:]/=2
bc=DataArrayInt(6,3) ; bc[:]=0 ; bc.setInfoOnComponents(['power [MW/m^3]','density [g/cm^3]','temperature [K]'])
for it in ffs1:
- a,b=it.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
- bc+=b
+ a=it.getFieldOnMeshAtLevel(0,ON_CELLS,mm1)
+ bc+=a.getArray()
pass
- self.assertTrue(bc.isEqual(3*arr))
+ self.assertTrue(bc.isEqual(3*f1.getArray()))
nf1=MEDCouplingFieldDouble(ON_NODES)
nf1.setTime(9.,10,-1)
nf1.setMesh(f1.getMesh())
self.assertTrue(isinstance(ffs[2],MEDFileFieldMultiTS))
self.assertTrue(isinstance(ffs[3],MEDFileIntFieldMultiTS))
#
- self.assertTrue(fs["VectorFieldOnCells"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(arr))
- self.assertTrue(fs["VectorFieldOnCells"][1,2].getUndergroundDataArray().isEqualWithoutConsideringStr(2*arr))
+ self.assertTrue(fs["VectorFieldOnCells"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getArray()))
+ self.assertTrue(fs["VectorFieldOnCells"][1,2].getUndergroundDataArray().isEqualWithoutConsideringStr(2*f1.getArray()))
self.assertTrue(fs["VectorFieldOnNodesPfl"][0].getUndergroundDataArray().isEqualWithoutConsideringStr(narr2))
self.assertTrue(fs["VectorFieldOnNodes"][9.].getUndergroundDataArray().isEqualWithoutConsideringStr(narr))
self.assertTrue(fs["VectorFieldOnNodesDouble"][29.].getUndergroundDataArray().isEqualWithoutConsideringStr(f1.getMesh().getCoords(),1e-12))
self.assertEqual(pfltest.getName(),pflName)
self.assertEqual(ftest.getName(),fieldName)
self.assertTrue(ftest.isEqualWithoutConsideringStr(arr))
- ftest2,vals=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
- self.assertTrue(vals.isEqualWithoutConsideringStr(arr))
+ ftest2=f1ts.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
+ self.assertTrue(ftest2.getArray().isEqualWithoutConsideringStr(arr))
self.assertEqual(ftest2.getTime(),f.getTime())
self.assertEqual(ftest2.getMesh().getNumberOfCells(),len(arr))
pass