}
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDCalculator
return _MEDCalculator.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
import _MEDCalculator
return _MEDCalculator.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDCalculator
return _MEDCalculator.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDCalculator
return _MEDCalculator.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDCalculator
return _MEDCalculator.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleImod(self,*args):
import _MEDCalculator
return _MEDCalculator.DataArrayIntTuple____imod___(self, self, *args)
+def ParaMEDMEMDenseMatrixIadd(self,*args):
+ import _MEDCalculator
+ return _MEDCalculator.DenseMatrix____iadd___(self, self, *args)
+def ParaMEDMEMDenseMatrixIsub(self,*args):
+ import _MEDCalculator
+ return _MEDCalculator.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDCalculator
+ return _MEDCalculator.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
arr=0;
}
+/*!
+ * Empty : Not a bug
+ */
+void MEDCouplingFieldDiscretization::checkForUnserialization(const std::vector<int>& tinyInfo, const DataArrayInt *arr)
+{
+}
+
/*!
* Empty : Not a bug
*/
else
_discr_per_cell=0;
arr=_discr_per_cell;
- int nbOfLoc=tinyInfo[1];
- _loc.clear();
- int dim=tinyInfo[2];
- int delta=-1;
- if(nbOfLoc>0)
- delta=((int)tinyInfo.size()-3)/nbOfLoc;
- for(int i=0;i<nbOfLoc;i++)
+ commonUnserialization(tinyInfo);
+}
+
+void MEDCouplingFieldDiscretizationGauss::checkForUnserialization(const std::vector<int>& tinyInfo, const DataArrayInt *arr)
+{
+ static const char MSG[]="MEDCouplingFieldDiscretizationGauss::checkForUnserialization : expect to have one not null DataArrayInt !";
+ int val=tinyInfo[0];
+ if(val>=0)
{
- std::vector<int> tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta);
- MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp);
- _loc.push_back(elt);
+ if(!arr)
+ throw INTERP_KERNEL::Exception(MSG);
+ arr->checkNbOfTuplesAndComp(val,1,MSG);
+ _discr_per_cell=const_cast<DataArrayInt *>(arr);
+ _discr_per_cell->incrRef();
}
+ else
+ _discr_per_cell=0;
+ commonUnserialization(tinyInfo);
}
void MEDCouplingFieldDiscretizationGauss::finishUnserialization(const std::vector<double>& tinyInfo)
_loc=tmpLoc;
}
+void MEDCouplingFieldDiscretizationGauss::commonUnserialization(const std::vector<int>& tinyInfo)
+{
+ int nbOfLoc=tinyInfo[1];
+ _loc.clear();
+ int dim=tinyInfo[2];
+ int delta=-1;
+ if(nbOfLoc>0)
+ delta=((int)tinyInfo.size()-3)/nbOfLoc;
+ for(int i=0;i<nbOfLoc;i++)
+ {
+ std::vector<int> tmp(tinyInfo.begin()+3+i*delta,tinyInfo.begin()+3+(i+1)*delta);
+ MEDCouplingGaussLocalization elt=MEDCouplingGaussLocalization::BuildNewInstanceFromTinyInfo(dim,tmp);
+ _loc.push_back(elt);
+ }
+}
+
MEDCouplingFieldDiscretizationGaussNE::MEDCouplingFieldDiscretizationGaussNE()
{
}
MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector<double>& tinyInfo);
MEDCOUPLING_EXPORT virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
+ MEDCOUPLING_EXPORT virtual void checkForUnserialization(const std::vector<int>& tinyInfo, const DataArrayInt *arr);
MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector<double>& refCoo,
const std::vector<double>& gsCoo, const std::vector<double>& wg);
MEDCOUPLING_EXPORT virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, const int *begin, const int *end, const std::vector<double>& refCoo,
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<double>& tinyInfo);
MEDCOUPLING_EXPORT void getSerializationIntArray(DataArrayInt *& arr) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *& arr);
+ MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector<int>& tinyInfo, const DataArrayInt *arr);
MEDCOUPLING_EXPORT double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const;
MEDCOUPLING_EXPORT void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const;
MEDCOUPLING_EXPORT MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const;
void zipGaussLocalizations();
int getOffsetOfCell(int cellId) const;
void checkLocalizationId(int locId) const;
+ void commonUnserialization(const std::vector<int>& tinyInfo);
public:
static const char REPR[];
static const TypeOfField TYPE;
* @param dataInt out parameter. If not null the pointer is already owned by \a this after the call of this method. In this case no decrRef must be applied.
* @param arrays out parameter is a vector resized to the right size. The pointers in the vector is already owned by \a this after the call of this method.
* No decrRef must be applied to every instances in returned vector.
+ * \sa checkForUnserialization
*/
void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays)
{
_type->resizeForUnserialization(tinyInfoITmp3,dataInt);
}
+/*!
+ * This method is extremely close to resizeForUnserialization except that here the arrays in \a dataInt and in \a arrays are attached in \a this
+ * after having checked that size is correct. This method is used in python pickeling context to avoid copy of data.
+ * \sa resizeForUnserialization
+ */
+void MEDCouplingFieldDouble::checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<DataArrayDouble *>& arrays)
+{
+ if(!((const MEDCouplingFieldDiscretization *)_type))
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !");
+ std::vector<int> tinyInfoITmp(tinyInfoI);
+ int sz=tinyInfoITmp.back();
+ tinyInfoITmp.pop_back();
+ std::vector<int> tinyInfoITmp2(tinyInfoITmp.begin(),tinyInfoITmp.end()-sz);
+ std::vector<int> tinyInfoI2(tinyInfoITmp2.begin()+3,tinyInfoITmp2.end());
+ _time_discr->checkForUnserialization(tinyInfoI2,arrays);
+ std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
+ _type->checkForUnserialization(tinyInfoITmp3,dataInt);
+}
+
void MEDCouplingFieldDouble::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
if(!((const MEDCouplingFieldDiscretization *)_type))
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays);
+ MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<DataArrayDouble *>& arrays);
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
MEDCOUPLING_EXPORT void serialize(DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays) const;
//
arrays[0]=arr;
}
+void MEDCouplingTimeDiscretization::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
+{
+ static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size one !";
+ if(arrays.size()!=1)
+ throw INTERP_KERNEL::Exception(MSG);
+ if(_array!=0)
+ _array->decrRef();
+ _array=0;
+ if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
+ {
+ if(!arrays[0])
+ throw INTERP_KERNEL::Exception(MSG);
+ arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
+ _array=arrays[0];
+ _array->incrRef();
+ }
+}
+
void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
_time_tolerance=tinyInfoD[0];
arrays[1]=arr;
}
+void MEDCouplingTwoTimeSteps::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays)
+{
+ static const char MSG[]="MEDCouplingTimeDiscretization::checkForUnserialization : arrays in input is expected to have size two !";
+ if(arrays.size()!=2)
+ throw INTERP_KERNEL::Exception(MSG);
+ if(_array!=0)
+ _array->decrRef();
+ if(_end_array!=0)
+ _end_array->decrRef();
+ _array=0; _end_array=0;
+ if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
+ {
+ if(!arrays[0])
+ throw INTERP_KERNEL::Exception(MSG);
+ arrays[0]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
+ _array=arrays[0]; _array->incrRef();
+ }
+ if(tinyInfoI[6]!=-1 && tinyInfoI[7]!=-1)
+ {
+ if(!arrays[1])
+ throw INTERP_KERNEL::Exception(MSG);
+ arrays[1]->checkNbOfTuplesAndComp(tinyInfoI[0],tinyInfoI[1],MSG);
+ _end_array=arrays[1]; _end_array->incrRef();
+ }
+}
+
void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
{
MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
MEDCOUPLING_EXPORT virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
+ MEDCOUPLING_EXPORT virtual void checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays);
MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
MEDCOUPLING_EXPORT virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
+ MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<DataArrayDouble *>& arrays);
MEDCOUPLING_EXPORT void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
MEDCOUPLING_EXPORT void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
}
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDenseMatrixIsub(self,*args):
import _MEDCouplingClient
return _MEDCouplingClient.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDCouplingClient
+ return _MEDCouplingClient.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
}
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDenseMatrixIsub(self,*args):
import _MEDCouplingCorba
return _MEDCouplingCorba.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDCouplingCorba
+ return _MEDCouplingCorba.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
IF(NUMPY_FOUND)
ADD_TEST(MEDCouplingNumPyTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingNumPyTest.py)
SET_TESTS_PROPERTIES(MEDCouplingNumPyTest PROPERTIES ENVIRONMENT "${tests_env}")
+ ADD_TEST(MEDCouplingPickleTest ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/MEDCouplingPickleTest.py)
+ SET_TESTS_PROPERTIES(MEDCouplingPickleTest PROPERTIES ENVIRONMENT "${tests_env}")
ENDIF(NUMPY_FOUND)
%include "MEDCouplingCommon.i"
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDCoupling
return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
import _MEDCoupling
return _MEDCoupling.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDCoupling
return _MEDCoupling.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDCoupling
return _MEDCoupling.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDCoupling
return _MEDCoupling.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDenseMatrixIsub(self,*args):
import _MEDCoupling
return _MEDCoupling.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
virtual MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
virtual bool areCompatibleForMerge(const MEDCouplingMesh *other) const throw(INTERP_KERNEL::Exception);
virtual DataArrayInt *simplexize(int policy) throw(INTERP_KERNEL::Exception);
+ virtual void unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
static MEDCouplingMesh *MergeMeshes(const MEDCouplingMesh *mesh1, const MEDCouplingMesh *mesh2) throw(INTERP_KERNEL::Exception);
static bool IsStaticGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
static bool IsLinearGeometricType(INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
PyList_SetItem(res,2,SWIG_From_int(tmp2));
return res;
}
-
+
int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
{
double val;
PyList_SetItem(res,i,PyInt_FromLong(*iL));
return res;
}
+
+ virtual PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> a0;
+ std::vector<int> a1;
+ std::vector<std::string> a2;
+ self->getTinySerializationInformation(a0,a1,a2);
+ PyObject *ret(PyTuple_New(3));
+ PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0));
+ PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1));
+ int sz(a2.size());
+ PyObject *ret2(PyList_New(sz));
+ {
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret2,i,PyString_FromString(a2[i].c_str()));
+ }
+ PyTuple_SetItem(ret,2,ret2);
+ return ret;
+ }
+
+ virtual PyObject *serialize() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *a0Tmp(0);
+ DataArrayDouble *a1Tmp(0);
+ self->serialize(a0Tmp,a1Tmp);
+ PyObject *ret(PyTuple_New(2));
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(a0Tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(a1Tmp),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<std::string> littleStrings;
+ self->resizeForUnserialization(tinyInfo,a1,a2,littleStrings);
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {// put an empty dict in input to say to __new__ to call __init__...
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ PyTuple_SetItem(ret,0,ret0);
+ return ret;
+ }
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ PyObject *ret0(ParaMEDMEM_MEDCouplingMesh_getTinySerializationInformation(self));
+ PyObject *ret1(ParaMEDMEM_MEDCouplingMesh_serialize(self));
+ PyObject *ret(PyTuple_New(2));
+ PyTuple_SetItem(ret,0,ret0);
+ PyTuple_SetItem(ret,1,ret1);
+ return ret;
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="MEDCouplingMesh.__setstate__ : expected input is a tuple of size 2 !";
+ if(!PyTuple_Check(inp))
+ throw INTERP_KERNEL::Exception(MSG);
+ int sz(PyTuple_Size(inp));
+ if(sz!=2)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *elt0(PyTuple_GetItem(inp,0));
+ PyObject *elt1(PyTuple_GetItem(inp,1));
+ std::vector<double> a0;
+ std::vector<int> a1;
+ std::vector<std::string> a2;
+ DataArrayInt *b0(0);
+ DataArrayDouble *b1(0);
+ {
+ if(!PyTuple_Check(elt0) && PyTuple_Size(elt0)!=3)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *a0py(PyTuple_GetItem(elt0,0)),*a1py(PyTuple_GetItem(elt0,1)),*a2py(PyTuple_GetItem(elt0,2));
+ int tmp(-1);
+ fillArrayWithPyListDbl3(a0py,tmp,a0);
+ convertPyToNewIntArr3(a1py,a1);
+ fillStringVector(a2py,a2);
+ }
+ {
+ if(!PyTuple_Check(elt1) && PyTuple_Size(elt1)!=2)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *b0py(PyTuple_GetItem(elt1,0)),*b1py(PyTuple_GetItem(elt1,1));
+ void *argp(0);
+ int status(SWIG_ConvertPtr(b0py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0));
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ b0=reinterpret_cast<DataArrayInt *>(argp);
+ status=SWIG_ConvertPtr(b1py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,0|0);
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ b1=reinterpret_cast<DataArrayDouble *>(argp);
+ }
+ // useless here to call resizeForUnserialization because arrays are well resized.
+ self->unserialization(a0,a1,b0,b1,a2);
+ }
static MEDCouplingMesh *MergeMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
{
{
return MEDCouplingUMesh::New(meshName,meshDim);
}
-
+
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingUMesh");
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
{
return MEDCouplingExtrudedMesh::New(mesh3D,mesh2D,cell2DId);
}
+
+ MEDCouplingExtrudedMesh()
+ {
+ return MEDCouplingExtrudedMesh::New();
+ }
+
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingExtrudedMesh");
+ }
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *sortHexa8EachOther() throw(INTERP_KERNEL::Exception);
%extend
{
+ MEDCoupling1SGTUMesh()
+ {
+ return MEDCoupling1SGTUMesh::New();
+ }
+
MEDCoupling1SGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
return MEDCoupling1SGTUMesh::New(name,type);
return MEDCoupling1SGTUMesh::New(m);
}
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCoupling1SGTUMesh");
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
bool isPacked() const throw(INTERP_KERNEL::Exception);
%extend
{
+ MEDCoupling1DGTUMesh()
+ {
+ return MEDCoupling1DGTUMesh::New();
+ }
MEDCoupling1DGTUMesh(const std::string& name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
return MEDCoupling1DGTUMesh::New(name,type);
return MEDCoupling1DGTUMesh::New(m);
}
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCoupling1DGTUMesh");
+ }
+
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
{
return MEDCouplingCMesh::New(meshName);
}
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingCMesh");
+ }
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
{
return MEDCouplingCurveLinearMesh::New(meshName);
}
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingCurveLinearMesh");
+ }
std::string __str__() const throw(INTERP_KERNEL::Exception)
{
return self->simpleRepr();
return ParaMEDMEM_MEDCouplingIMesh_New__SWIG_1(meshName,spaceDim,nodeStrct,origin,dxyz);
}
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfEmptyDictInInput(cls,args,"MEDCouplingIMesh");
+ }
+
void setNodeStruct(PyObject *nodeStrct) throw(INTERP_KERNEL::Exception)
{
int sw,sz,val0;
convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCouplingFieldDouble *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCouplingFieldDouble,"MEDCouplingFieldDouble",tmp);
return MEDCouplingFieldDouble::WriteVTK(fileName,tmp,isBinary);
}
+
+ PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<double> a0;
+ std::vector<int> a1;
+ std::vector<std::string> a2;
+ self->getTinySerializationDbleInformation(a0);
+ self->getTinySerializationIntInformation(a1);
+ self->getTinySerializationStrInformation(a2);
+ //
+ PyObject *ret(PyTuple_New(3));
+ PyTuple_SetItem(ret,0,convertDblArrToPyList2(a0));
+ PyTuple_SetItem(ret,1,convertIntArrToPyList2(a1));
+ int sz(a2.size());
+ PyObject *ret2(PyList_New(sz));
+ {
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret2,i,PyString_FromString(a2[i].c_str()));
+ }
+ PyTuple_SetItem(ret,2,ret2);
+ return ret;
+ }
+
+ PyObject *serialize() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret0(0);
+ std::vector<DataArrayDouble *> ret1;
+ self->serialize(ret0,ret1);
+ if(ret0)
+ ret0->incrRef();
+ std::size_t sz(ret1.size());
+ PyObject *ret(PyTuple_New(2));
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyObject *ret1Py(PyList_New(sz));
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(ret1[i])
+ ret1[i]->incrRef();
+ PyList_SetItem(ret1Py,i,SWIG_NewPointerObj(SWIG_as_voidptr(ret1[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ }
+ PyTuple_SetItem(ret,1,ret1Py);
+ return ret;
+ }
+
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="MEDCouplingFieldDouble.__new__ : the args in input is expected to be a tuple !";
+ if(!PyTuple_Check(args))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ ////
+ PyObject *a(PyInt_FromLong(0));
+ PyObject *uniqueElt(PyDict_GetItem(PyTuple_GetItem(args,1),a));
+ Py_DECREF(a);
+ if(!uniqueElt)
+ throw INTERP_KERNEL::Exception(MSG);
+ if(!PyTuple_Check(uniqueElt) || PyTuple_Size(uniqueElt)!=2)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *tmp2(PyObject_CallObject(initMeth,uniqueElt));
+ Py_XDECREF(tmp2);
+ ////
+ Py_DECREF(initMeth);
+ }
+ return instance;
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {// put an empty dict in input to say to __new__ to call __init__...
+ self->checkCoherency();
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ {
+ PyObject *a(PyInt_FromLong(0)),*b(PyInt_FromLong(self->getTypeOfField())),*c(PyInt_FromLong(self->getTimeDiscretization()));
+ PyObject *d(PyTuple_New(2)); PyTuple_SetItem(d,0,b); PyTuple_SetItem(d,1,c);
+ PyDict_SetItem(ret0,a,d);
+ Py_DECREF(a); Py_DECREF(d);
+ }
+ PyTuple_SetItem(ret,0,ret0);
+ return ret;
+ }
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ self->checkCoherency();
+ PyObject *ret0(ParaMEDMEM_MEDCouplingFieldDouble_getTinySerializationInformation(self));
+ PyObject *ret1(ParaMEDMEM_MEDCouplingFieldDouble_serialize(self));
+ const MEDCouplingMesh *mesh(self->getMesh());
+ if(mesh)
+ mesh->incrRef();
+ PyObject *ret(PyTuple_New(3));
+ PyTuple_SetItem(ret,0,ret0);
+ PyTuple_SetItem(ret,1,ret1);
+ PyTuple_SetItem(ret,2,convertMesh(const_cast<MEDCouplingMesh *>(mesh),SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="MEDCouplingFieldDouble.__setstate__ : expected input is a tuple of size 3 !";
+ if(!PyTuple_Check(inp))
+ throw INTERP_KERNEL::Exception(MSG);
+ int sz(PyTuple_Size(inp));
+ if(sz!=3)
+ throw INTERP_KERNEL::Exception(MSG);
+ // mesh
+ PyObject *elt2(PyTuple_GetItem(inp,2));
+ void *argp=0;
+ int status(SWIG_ConvertPtr(elt2,&argp,SWIGTYPE_p_ParaMEDMEM__MEDCouplingMesh,0|0));
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ self->setMesh(reinterpret_cast< const MEDCouplingUMesh * >(argp));
+ //
+ PyObject *elt0(PyTuple_GetItem(inp,0));
+ PyObject *elt1(PyTuple_GetItem(inp,1));
+ std::vector<double> a0;
+ std::vector<int> a1;
+ std::vector<std::string> a2;
+ DataArrayInt *b0(0);
+ std::vector<DataArrayDouble *>b1;
+ {
+ if(!PyTuple_Check(elt0) && PyTuple_Size(elt0)!=3)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *a0py(PyTuple_GetItem(elt0,0)),*a1py(PyTuple_GetItem(elt0,1)),*a2py(PyTuple_GetItem(elt0,2));
+ int tmp(-1);
+ fillArrayWithPyListDbl3(a0py,tmp,a0);
+ convertPyToNewIntArr3(a1py,a1);
+ fillStringVector(a2py,a2);
+ }
+ {
+ if(!PyTuple_Check(elt1) && PyTuple_Size(elt1)!=2)
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *b0py(PyTuple_GetItem(elt1,0)),*b1py(PyTuple_GetItem(elt1,1));
+ void *argp(0);
+ int status(SWIG_ConvertPtr(b0py,&argp,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,0|0));
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ b0=reinterpret_cast<DataArrayInt *>(argp);
+ convertFromPyObjVectorOfObj<ParaMEDMEM::DataArrayDouble *>(b1py,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,"DataArrayDouble",b1);
+ }
+ self->checkForUnserialization(a1,b0,b1);
+ // useless here to call resizeForUnserialization because arrays are well resized.
+ self->finishUnserialization(a1,a0,a2);
+ }
}
};
{
Py_XINCREF(obj);
PyArrayObject *objC=reinterpret_cast<PyArrayObject *>(obj);
- objC->flags|=NPY_OWNDATA;
+ objC->flags|=NPY_ARRAY_OWNDATA;
Py_XDECREF(weakRefOnOwner);
Py_XDECREF(obj);
}
if(PyArray_ISBEHAVED(elt0))//aligned and writeable and in machine byte-order
{
PyArrayObject *elt0C=reinterpret_cast<PyArrayObject *>(elt0);
- PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_OWNDATA)?elt0C:NULL;
- int mask=NPY_OWNDATA; mask=~mask;
+ PyArrayObject *eltOwning=(PyArray_FLAGS(elt0C) & NPY_ARRAY_OWNDATA)?elt0C:NULL;
+ int mask=NPY_ARRAY_OWNDATA; mask=~mask;
elt0C->flags&=mask;
PyObject *deepestObj=elt0;
PyObject *base=elt0C->base;
if(base) deepestObj=base;
+ bool isSpetialCase(false);
while(base)
{
if(PyArray_Check(base))
{
PyArrayObject *baseC=reinterpret_cast<PyArrayObject *>(base);
- eltOwning=(PyArray_FLAGS(baseC) & NPY_OWNDATA)?baseC:eltOwning;
+ eltOwning=(PyArray_FLAGS(baseC) & NPY_ARRAY_OWNDATA)?baseC:eltOwning;
baseC->flags&=mask;
base=baseC->base;
if(base) deepestObj=base;
}
else
- break;
+ {
+ isSpetialCase=true;
+ break;
+ }
+ }
+ if(isSpetialCase)
+ {// this case is present for numpy arrayint coming from load of pickelized string. The owner of elt0 is not an array -> A copy is requested.
+ std::size_t nbOfElems(sz0*sz1);
+ T *dataCpy=(T*)malloc(sizeof(T)*nbOfElems);
+ std::copy(reinterpret_cast<const T*>(data),reinterpret_cast<const T*>(data)+nbOfElems,dataCpy);
+ ret->useArray(dataCpy,true,ParaMEDMEM::C_DEALLOC,sz0,sz1);
+ return ret.retn();
}
typename ParaMEDMEM::MemArray<T>& mma=ret->accessToMemArray();
if(eltOwning==NULL)
/* If this array owns its own data, stop collapsing */
- if (PyArray_CHKFLAGS(obj_arr, NPY_OWNDATA)) {
+ if (PyArray_CHKFLAGS(obj_arr, NPY_ARRAY_OWNDATA )) {
break;
}
//
%pythoncode %{
+InterpKernelException.__reduce__=INTERPKERNELExceptionReduce
+DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew)
DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd
DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub
DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul
DataArrayDouble.__idiv__=ParaMEDMEMDataArrayDoubleIdiv
DataArrayDouble.__ipow__=ParaMEDMEMDataArrayDoubleIpow
+DataArrayInt.__new__=classmethod(ParaMEDMEMDataArrayIntnew)
DataArrayInt.__iadd__=ParaMEDMEMDataArrayIntIadd
DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub
DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul
DenseMatrix.__iadd__=ParaMEDMEMDenseMatrixIadd
DenseMatrix.__isub__=ParaMEDMEMDenseMatrixIsub
+MEDCouplingUMesh.__new__=classmethod(ParaMEDMEMMEDCouplingUMeshnew)
+MEDCoupling1DGTUMesh.__new__=classmethod(ParaMEDMEMMEDCoupling1DGTUMeshnew)
+MEDCoupling1SGTUMesh.__new__=classmethod(ParaMEDMEMMEDCoupling1SGTUMeshnew)
+MEDCouplingCurveLinearMesh.__new__=classmethod(ParaMEDMEMMEDCouplingCurveLinearMeshnew)
+MEDCouplingCMesh.__new__=classmethod(ParaMEDMEMMEDCouplingCMeshnew)
+MEDCouplingIMesh.__new__=classmethod(ParaMEDMEMMEDCouplingIMeshnew)
+MEDCouplingExtrudedMesh.__new__=classmethod(ParaMEDMEMMEDCouplingExtrudedMeshnew)
+MEDCouplingFieldDouble.__new__=classmethod(ParaMEDMEMMEDCouplingFieldDoublenew)
+
+del INTERPKERNELExceptionReduce
+del ParaMEDMEMDataArrayDoublenew
del ParaMEDMEMDataArrayDoubleIadd
del ParaMEDMEMDataArrayDoubleIsub
del ParaMEDMEMDataArrayDoubleImul
del ParaMEDMEMMEDCouplingFieldDoubleImul
del ParaMEDMEMMEDCouplingFieldDoubleIdiv
del ParaMEDMEMMEDCouplingFieldDoubleIpow
+del ParaMEDMEMDataArrayIntnew
del ParaMEDMEMDataArrayIntIadd
del ParaMEDMEMDataArrayIntIsub
del ParaMEDMEMDataArrayIntImul
del ParaMEDMEMDataArrayIntTupleImod
del ParaMEDMEMDenseMatrixIadd
del ParaMEDMEMDenseMatrixIsub
+del ParaMEDMEMMEDCouplingUMeshnew
+del ParaMEDMEMMEDCoupling1DGTUMeshnew
+del ParaMEDMEMMEDCoupling1SGTUMeshnew
+del ParaMEDMEMMEDCouplingCurveLinearMeshnew
+del ParaMEDMEMMEDCouplingCMeshnew
+del ParaMEDMEMMEDCouplingIMeshnew
+del ParaMEDMEMMEDCouplingExtrudedMeshnew
+del ParaMEDMEMMEDCouplingFieldDoublenew
%}
GetIndicesOfSlice(sly,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getNumberOfItemGivenBESRelative (wrap) : the input slice is invalid !");
return DataArray::GetNumberOfItemGivenBESRelative(strt,stp,step,"");
}
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ PyObject *ret(PyTuple_New(2));
+ std::string a0(self->getName());
+ const std::vector<std::string> &a1(self->getInfoOnComponents());
+ PyTuple_SetItem(ret,0,PyString_FromString(a0.c_str()));
+ //
+ int sz(a1.size());
+ PyObject *ret1(PyList_New(sz));
+ for(int i=0;i<sz;i++)
+ PyList_SetItem(ret1,i,PyString_FromString(a1[i].c_str()));
+ PyTuple_SetItem(ret,1,ret1);
+ //
+ return ret;
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayDouble.__setstate__ : expected input is a tuple of size 2 with string as 1st arg and list of string as 2nd arg !";
+ if(!PyTuple_Check(inp))
+ throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid input ! Invalid overwrite of __getstate__ ?");
+ int sz(PyTuple_Size(inp));
+ if(sz!=2)
+ throw INTERP_KERNEL::Exception("DataArrayDouble.__setstate__ : invalid tuple in input ! Should be of size 2 ! Invalid overwrite of __getstate__ ?");
+ PyObject *a0(PyTuple_GetItem(inp,0));
+ if(!PyString_Check(a0))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *a1(PyTuple_GetItem(inp,1));
+ std::vector<std::string> a1cpp;
+ if(!fillStringVector(a1,a1cpp))
+ throw INTERP_KERNEL::Exception(MSG);
+ self->setName(PyString_AsString(a0));
+ self->setInfoOnComponents(a1cpp);
+ }
}
};
PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
return ret;
}
+
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayDouble.__new__ : the args in input is expected to be a tuple !";
+ if(!PyTuple_Check(args))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ int sz(PyTuple_Size(args));
+
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *zeNumpyRepr(0);
+ PyObject *tmp1(PyInt_FromLong(0));
+ zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
+ Py_DECREF(tmp1);
+ PyObject *tmp3(PyTuple_New(1));
+ PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ }
+ Py_DECREF(initMeth);
+ return instance;
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {
+#ifdef WITH_NUMPY
+ if(!self->isAllocated())
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : self is not allocated !");
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ PyObject *numpyArryObj(ParaMEDMEM_DataArrayDouble_toNumPyArray(self));
+ {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ...
+ PyObject *tmp1(PyInt_FromLong(0));
+ PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj);
+ PyTuple_SetItem(ret,0,ret0);
+ }
+ return ret;
+#else
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayDouble.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
+#endif
+ }
}
};
PyTuple_SetItem(pyRet,1,ret1Py);
return pyRet;
}
+
+ // serialization
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ static const char MSG[]="DataArrayInt.__new__ : the args in input is expected to be a tuple !";
+ if(!PyTuple_Check(args))
+ throw INTERP_KERNEL::Exception(MSG);
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ int sz(PyTuple_Size(args));
+
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==1 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *zeNumpyRepr(0);
+ PyObject *tmp1(PyInt_FromLong(0));
+ zeNumpyRepr=PyDict_GetItem(PyTuple_GetItem(args,1),tmp1);//borrowed
+ Py_DECREF(tmp1);
+ PyObject *tmp3(PyTuple_New(1));
+ PyTuple_SetItem(tmp3,0,zeNumpyRepr); Py_XINCREF(zeNumpyRepr);
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ }
+ Py_DECREF(initMeth);
+ return instance;
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {
+#ifdef WITH_NUMPY
+ if(!self->isAllocated())
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : self is not allocated !");
+ PyObject *ret(PyTuple_New(1));
+ PyObject *ret0(PyDict_New());
+ PyObject *numpyArryObj(ParaMEDMEM_DataArrayInt_toNumPyArray(self));
+ {// create a dict to discriminite in __new__ if __init__ should be called. Not beautiful but not idea ...
+ PyObject *tmp1(PyInt_FromLong(0));
+ PyDict_SetItem(ret0,tmp1,numpyArryObj); Py_DECREF(tmp1); Py_DECREF(numpyArryObj);
+ PyTuple_SetItem(ret,0,ret0);
+ }
+ return ret;
+#else
+ throw INTERP_KERNEL::Exception("PyWrap of DataArrayInt.__getnewargs__ : not implemented because numpy is not active in your configuration ! No serialization/unserialization available without numpy !");
+#endif
+ }
}
};
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+from MEDCoupling import *
+from MEDCouplingDataForTest import MEDCouplingDataForTest
+
+if MEDCouplingHasNumPyBindings():
+ from numpy import *
+ pass
+
+from platform import architecture
+from sys import getrefcount
+
+import os,gc,weakref,cPickle,unittest
+
+class MEDCouplingPickleTest(unittest.TestCase):
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test1(self):
+ """ Test of a simple DataArrayDouble."""
+ x=DataArrayDouble(10,1) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
+ x.setName("toto")
+ pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
+ xx=cPickle.loads(pickled)
+ self.assertTrue(xx.isEqual(x,1e-16))
+ # Bigger to check that the behavior is OK for large strings.
+ x=DataArrayDouble(1200) ; x.iota() ; x.setInfoOnComponents(["aa"])
+ x.setName("titi")
+ pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
+ xx=cPickle.loads(pickled)
+ self.assertTrue(xx.isEqual(x,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test2(self):
+ """ Test of a simple DataArrayInt."""
+ x=DataArrayInt(10) ; x.iota() ; x.rearrange(2) ; x.setInfoOnComponents(["aa","bbb"])
+ x.setName("toto")
+ pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
+ xx=cPickle.loads(pickled)
+ self.assertTrue(xx.isEqual(x))
+ # Bigger to check that the behavior is OK for large strings.
+ x=DataArrayInt(1200) ; x.iota() ; x.setInfoOnComponents(["aa"])
+ x.setName("titi")
+ pickled=cPickle.dumps(x,cPickle.HIGHEST_PROTOCOL)
+ xx=cPickle.loads(pickled)
+ self.assertTrue(xx.isEqual(x))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test3(self):
+ """ Test of a MEDCouplingUMesh pickeling."""
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr)
+ m=m.buildUnstructured()
+ m.setName("mesh")
+ m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"])
+ m.checkCoherency()
+ st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(m,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test4(self):
+ """ Idem test3 except that here serialization/deserialization is done explicitely."""
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr)
+ m=m.buildUnstructured()
+ m.setName("mesh")
+ m.getCoords().setInfoOnComponents(["aa","bbb","ddddd"])
+ m.checkCoherency()
+ #
+ a0,a1,a2=m.getTinySerializationInformation()
+ b0,b1=m.serialize()
+ m2=MEDCouplingUMesh()
+ m2.unserialization(a0,a1,b0,b1,a2);
+ self.assertTrue(m2.isEqual(m,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test5(self):
+ """ Test of a MEDCouplingCMesh pickeling."""
+ arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"])
+ arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"])
+ arrZ=DataArrayDouble(7) ; arrZ.iota() ; arrZ.setInfoOnComponents(["cccc"])
+ #
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ)
+ m.setName("mesh")
+ m.checkCoherency()
+ st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(m,1e-16))
+ self.assertTrue(m2.getCoordsAt(0).isEqual(arrX,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test6(self):
+ """ Test of a MEDCoupling1SGTUMesh pickeling."""
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+ m=m.build1SGTUnstructured()
+ self.assertTrue(isinstance(m,MEDCoupling1SGTUMesh))
+ st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(m,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test7(self):
+ """ Test of a MEDCoupling1DGTUMesh pickeling."""
+ arr=DataArrayDouble(10) ; arr.iota()
+ m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+ m=m.buildUnstructured() ; m.convertAllToPoly()
+ m=MEDCoupling1DGTUMesh(m)
+ self.assertTrue(isinstance(m,MEDCoupling1DGTUMesh))
+ st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(m,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test8(self):
+ """ Test of a MEDCouplingExtrudedMesh pickeling."""
+ arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"])
+ arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"])
+ arrZ=DataArrayDouble(7) ; arrZ.iota() ; arrZ.setInfoOnComponents(["cccc"])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY,arrZ)
+ mesh3D=m.buildUnstructured() ; del m
+ #
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY)
+ mesh2D=m.buildUnstructured() ; del m
+ #
+ mesh2D.setCoords(mesh3D.getCoords())
+ mesh=MEDCouplingExtrudedMesh(mesh3D,mesh2D,0) ; del mesh3D,mesh2D
+ self.assertTrue(isinstance(mesh,MEDCouplingExtrudedMesh))
+ st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(mesh,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test9(self):
+ """ Test of a MEDCouplingCurveLinearMesh pickeling."""
+ arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"])
+ arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY)
+ m=m.buildUnstructured()
+ #
+ mesh=MEDCouplingCurveLinearMesh() ; mesh.setCoords(m.getCoords()) ; del m
+ mesh.setNodeGridStructure([10,5])
+ st=cPickle.dumps(mesh,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(mesh,1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test10(self):
+ """ Test of a MEDCouplingIMesh pickeling."""
+ m=MEDCouplingIMesh("mesh",3,DataArrayInt([3,1,4]),DataArrayDouble([1.5,2.5,3.5]),DataArrayDouble((0.5,1.,0.25))) ; m.setAxisUnit("km")
+ m.checkCoherency()
+ st=cPickle.dumps(m,cPickle.HIGHEST_PROTOCOL)
+ m2=cPickle.loads(st)
+ self.assertTrue(m2.isEqual(m,1e-16))
+ self.assertEqual(m2.getName(),m.getName())
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test11(self):
+ """ Test of MEDCouplingFieldDouble lying on MEDCouplingCMesh pickeling. """
+ arrX=DataArrayDouble(10) ; arrX.iota() ; arrX.setInfoOnComponents(["aa"])
+ arrY=DataArrayDouble(5) ; arrY.iota() ; arrY.setInfoOnComponents(["bbb"])
+ m=MEDCouplingCMesh() ; m.setCoords(arrX,arrY)
+ f=m.getMeasureField(True)
+ f.setName("aname")
+ a=f.getArray()
+ b=a[:] ; b.iota(7000.)
+ f.setArray(DataArrayDouble.Meld(a,b))
+ f.getArray().setInfoOnComponents(["u1","vv2"])
+ f.checkCoherency();
+ #
+ st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
+ f2=cPickle.loads(st)
+ self.assertTrue(f2.isEqual(f,1e-16,1e-16))
+ self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test12(self):
+ """ Test of MEDCouplingFieldDouble on Gauss Points lying on MEDCouplingUMesh pickeling."""
+ _a=0.446948490915965;
+ _b=0.091576213509771;
+ _p1=0.11169079483905;
+ _p2=0.0549758718227661;
+ refCoo1=[ 0.,0., 1.,0., 0.,1. ]
+ gsCoo1=[ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
+ 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 ]
+ wg1=[ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 ]
+ _refCoo1=refCoo1
+ _gsCoo1=gsCoo1
+ _wg1=wg1
+ #
+ m=MEDCouplingDataForTest.build2DTargetMesh_1();
+ f=MEDCouplingFieldDouble.New(ON_GAUSS_PT,NO_TIME);
+ f.setMesh(m);
+ self.assertEqual(5,f.getNumberOfMeshPlacesExpected());
+ self.assertEqual(0,f.getNbOfGaussLocalization());
+ f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
+ f.setGaussLocalizationOnType(NORM_TRI3,_refCoo1,_gsCoo1,_wg1); # not a bug only to check that it works well
+ self.assertRaises(InterpKernelException,f.setGaussLocalizationOnType,NORM_QUAD4,_refCoo1,_gsCoo1,_wg1)
+ self.assertEqual(1,f.getNbOfGaussLocalization());
+ refCoo2=[ 0.,0., 1.,0., 1.,1., 0.,1. ]
+ _refCoo2=refCoo2
+ _gsCoo1=_gsCoo1[0:4]
+ _wg1=_wg1[0:2]
+ f.setGaussLocalizationOnType(NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
+ self.assertEqual(2,f.getNbOfGaussLocalization());
+ array=DataArrayDouble.New();
+ ptr=18*2*[None]
+ for i in xrange(18*2):
+ ptr[i]=float(i+1)
+ array.setValues(ptr,18,2);
+ ptr=array.getPointer();
+ f.setArray(array);
+ f.setName("MyFirstFieldOnGaussPoint");
+ f.checkCoherency();
+ self.assertAlmostEqual(27.,f.getIJK(2,5,0),14);
+ self.assertAlmostEqual(16.,f.getIJK(1,5,1),14);
+ #
+ f.clearGaussLocalizations();
+ self.assertEqual(0,f.getNbOfGaussLocalization());
+ self.assertRaises(InterpKernelException,f.checkCoherency);
+ ids1=[0,1,3,4]
+ self.assertRaises(InterpKernelException,f.setGaussLocalizationOnCells,ids1,_refCoo2,_gsCoo1,_wg1);
+ self.assertEqual(0,f.getNbOfGaussLocalization());
+ ids2=[0,4]
+ f.setGaussLocalizationOnCells(ids2,_refCoo2,_gsCoo1,_wg1);
+ self.assertEqual(1,f.getNbOfGaussLocalization());
+ self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
+ self.assertRaises(InterpKernelException,f.getGaussLocalizationIdOfOneCell,1);
+ ids3=[1,2]
+ f.setGaussLocalizationOnCells(ids3,_refCoo1,_gsCoo1,_wg1);
+ self.assertEqual(2,f.getNbOfGaussLocalization());
+ self.assertEqual(0,f.getGaussLocalizationIdOfOneCell(0));
+ self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(1));
+ self.assertEqual(1,f.getGaussLocalizationIdOfOneCell(2));
+ self.assertRaises(InterpKernelException,f.checkCoherency);#<- cell 3 has no localization
+ ids4=[3]
+ _gsCoo2=_gsCoo1;
+ _wg2=_wg1;
+ _gsCoo2[0]=0.8888777776666;
+ _wg2[0]=0.1234567892377;
+ f.setGaussLocalizationOnCells(ids4,_refCoo2,_gsCoo2,_wg2);
+ self.assertEqual(3,f.getNbOfGaussLocalization());
+ tmpIds=f.getCellIdsHavingGaussLocalization(0);
+ self.assertEqual(ids2,list(tmpIds.getValues()));
+ self.assertRaises(InterpKernelException,f.checkCoherency);#<- it's always not ok because undelying array not with the good size.
+ array2=f.getArray().substr(0,10);
+ f.setArray(array2);
+ f.checkCoherency();
+ ####
+ st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
+ f2=cPickle.loads(st)
+ self.assertTrue(f2.isEqual(f,1e-16,1e-16))
+ self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
+ pass
+
+ def test13(self):
+ eStr="This is an exception."
+ e=InterpKernelException(eStr)
+ self.assertEqual(e.what(),eStr)
+ st=cPickle.dumps(e,cPickle.HIGHEST_PROTOCOL)
+ e2=cPickle.loads(st)
+ self.assertTrue(e is not e2)
+ self.assertTrue(isinstance(e2,InterpKernelException))
+ self.assertEqual(e2.what(),eStr)
+ pass
+
+ def setUp(self):
+ pass
+ pass
+
+if __name__=="__main__":
+ unittest.main()
%extend
{
std::string __str__() const
- {
- return std::string(self->what());
- }
+ {
+ return std::string(self->what());
+ }
}
};
}
return std::string(script);
}
}
+
+%pythoncode %{
+def INTERPKERNELExceptionReduceFunct(a,b):
+ ret=InterpKernelException.__new__(a)
+ ret.__init__(*b)
+ return ret
+def INTERPKERNELExceptionReduce(self):
+ return INTERPKERNELExceptionReduceFunct,(InterpKernelException,(self.what(),))
+%}
}
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.DataArrayInt____new___(cls,args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDenseMatrixIsub(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
{ throw INTERP_KERNEL::Exception(msg); }
}
}
+
+static PyObject *NewMethWrapCallInitOnlyIfEmptyDictInInput(PyObject *cls, PyObject *args, const char *clsName)
+{
+ if(!PyTuple_Check(args))
+ {
+ std::ostringstream oss; oss << clsName << ".__new__ : the args in input is expected to be a tuple !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ PyObject *builtinsd(PyEval_GetBuiltins());//borrowed
+ PyObject *obj(PyDict_GetItemString(builtinsd,"object"));//borrowed
+ PyObject *selfMeth(PyObject_GetAttrString(obj,"__new__"));
+ //
+ PyObject *tmp0(PyTuple_New(1));
+ PyTuple_SetItem(tmp0,0,cls); Py_XINCREF(cls);
+ PyObject *instance(PyObject_CallObject(selfMeth,tmp0));
+ Py_DECREF(tmp0);
+ Py_DECREF(selfMeth);
+ if(PyTuple_Size(args)==2 && PyDict_Check(PyTuple_GetItem(args,1)) && PyDict_Size(PyTuple_GetItem(args,1))==0 )
+ {// NOT general case. only true if in unpickeling context ! call __init__. Because for all other cases, __init__ is called right after __new__ !
+ PyObject *initMeth(PyObject_GetAttrString(instance,"__init__"));
+ PyObject *tmp3(PyTuple_New(0));
+ PyObject *tmp2(PyObject_CallObject(initMeth,tmp3));
+ Py_XDECREF(tmp2);
+ Py_DECREF(tmp3);
+ Py_DECREF(initMeth);
+ }
+ return instance;
+}
%include "MEDLoaderCommon.i"
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _MEDLoader
return _MEDLoader.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
import _MEDLoader
return _MEDLoader.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _MEDLoader
return _MEDLoader.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _MEDLoader
return _MEDLoader.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _MEDLoader
return _MEDLoader.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDenseMatrixIsub(self,*args):
import _MEDLoader
return _MEDLoader.DenseMatrix____isub___(self, self, *args)
+def ParaMEDMEMMEDCouplingUMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1DGTUMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCoupling1DGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCoupling1SGTUMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCoupling1SGTUMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCurveLinearMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingCurveLinearMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingCMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingCMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingIMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingIMesh____new___(cls,args)
+def ParaMEDMEMMEDCouplingExtrudedMeshnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingExtrudedMesh____new___(cls,args)
%}
%include "MEDCouplingFinalize.i"
%}
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDoubleTuple____idiv___(self, self, *args)
+def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.MEDCouplingFieldDouble____new___(cls,args)
def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____iadd___(self, self, *args)
def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____iadd___(self, self, *args)
%include "MEDRenumberCommon.i"
%pythoncode %{
+def ParaMEDMEMDataArrayDoublenew(cls,*args):
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____new___(cls,args)
def ParaMEDMEMDataArrayDoubleIadd(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDouble____iadd___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIsub(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDouble____isub___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____isub___(self, self, *args)
def ParaMEDMEMDataArrayDoubleImul(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDouble____imul___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____imul___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIdiv(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDouble____idiv___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____idiv___(self, self, *args)
def ParaMEDMEMDataArrayDoubleIpow(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDouble____ipow___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDouble____ipow___(self, self, *args)
+def ParaMEDMEMDataArrayIntnew(cls,*args):
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____new___(cls,args)
def ParaMEDMEMDataArrayIntIadd(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____iadd___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____iadd___(self, self, *args)
def ParaMEDMEMDataArrayIntIsub(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____isub___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____isub___(self, self, *args)
def ParaMEDMEMDataArrayIntImul(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____imul___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____imul___(self, self, *args)
def ParaMEDMEMDataArrayIntIdiv(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____idiv___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____idiv___(self, self, *args)
def ParaMEDMEMDataArrayIntImod(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____imod___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____imod___(self, self, *args)
def ParaMEDMEMDataArrayIntIpow(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayInt____ipow___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayInt____ipow___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDoubleTuple____iadd___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDoubleTuple____iadd___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDoubleTuple____isub___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDoubleTuple____isub___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDoubleTuple____imul___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDoubleTuple____imul___(self, self, *args)
def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayDoubleTuple____idiv___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayDoubleTuple____idiv___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayIntTuple____iadd___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayIntTuple____iadd___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayIntTuple____isub___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayIntTuple____isub___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleImul(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayIntTuple____imul___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayIntTuple____imul___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayIntTuple____idiv___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayIntTuple____idiv___(self, self, *args)
def ParaMEDMEMDataArrayIntTupleImod(self,*args):
- import _MEDCoupling
- return _MEDCoupling.DataArrayIntTuple____imod___(self, self, *args)
+ import _MEDRenumber
+ return _MEDRenumber.DataArrayIntTuple____imod___(self, self, *args)
%}
+
%pythoncode %{
+InterpKernelException.__reduce__=INTERPKERNELExceptionReduce
+DataArrayDouble.__new__=classmethod(ParaMEDMEMDataArrayDoublenew)
DataArrayDouble.__iadd__=ParaMEDMEMDataArrayDoubleIadd
DataArrayDouble.__isub__=ParaMEDMEMDataArrayDoubleIsub
DataArrayDouble.__imul__=ParaMEDMEMDataArrayDoubleImul
DataArrayDouble.__idiv__=ParaMEDMEMDataArrayDoubleIdiv
DataArrayDouble.__ipow__=ParaMEDMEMDataArrayDoubleIpow
+DataArrayInt.__new__=classmethod(ParaMEDMEMDataArrayIntnew)
DataArrayInt.__iadd__=ParaMEDMEMDataArrayIntIadd
DataArrayInt.__isub__=ParaMEDMEMDataArrayIntIsub
DataArrayInt.__imul__=ParaMEDMEMDataArrayIntImul
DataArrayIntTuple.__idiv__=ParaMEDMEMDataArrayIntTupleIdiv
DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod
+del INTERPKERNELExceptionReduce
+del ParaMEDMEMDataArrayDoublenew
del ParaMEDMEMDataArrayDoubleIadd
del ParaMEDMEMDataArrayDoubleIsub
del ParaMEDMEMDataArrayDoubleImul
del ParaMEDMEMDataArrayDoubleIdiv
+del ParaMEDMEMDataArrayIntnew
del ParaMEDMEMDataArrayIntIadd
del ParaMEDMEMDataArrayIntIsub
del ParaMEDMEMDataArrayIntImul