]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Pickelization of (squashed merge of agy/PyPickelingOfMCObj) :
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 2 Mar 2015 10:04:33 +0000 (11:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 18 Mar 2015 14:01:44 +0000 (15:01 +0100)
- DataArrayDouble, DataArrayInt
- MEDCouplingUMesh, MEDCoupling1SGTUMesh, MEDCoupling1DGTUMesh, MEDCouplingCMesh, MEDCouplingIMesh, MEDCouplingCurveLinearMesh, MEDCouplingExtrudedMesh
- MEDCouplingFieldDouble
- InterpKernelException
For multiprocessing users and to ease exchange of data across PyNodes in YACS.

22 files changed:
src/MEDCalculator/Swig/MEDCalculator.i
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx
src/MEDCoupling/MEDCouplingFieldDouble.cxx
src/MEDCoupling/MEDCouplingFieldDouble.hxx
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingTimeDiscretization.hxx
src/MEDCouplingCorba_Swig/Client/MEDCouplingClient.i
src/MEDCouplingCorba_Swig/MEDCouplingCorba.i
src/MEDCoupling_Swig/CMakeLists.txt
src/MEDCoupling_Swig/MEDCoupling.i
src/MEDCoupling_Swig/MEDCouplingCommon.i
src/MEDCoupling_Swig/MEDCouplingDataArrayTypemaps.i
src/MEDCoupling_Swig/MEDCouplingFinalize.i
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDCoupling_Swig/MEDCouplingPickleTest.py [new file with mode: 0644]
src/MEDCoupling_Swig/MEDCouplingRefCountObject.i
src/MEDCoupling_Swig/MEDCouplingRemapper.i
src/MEDCoupling_Swig/MEDCouplingTypemaps.i
src/MEDLoader/Swig/MEDLoader.i
src/ParaMEDMEM_Swig/ParaMEDMEM.i
src/RENUMBER_Swig/MEDRenumber.i

index d33d669b53a6329a2472b5148ccfe0d85198f3ce..b5e287a87d9527749d9ca361e04653e0652f8be2 100644 (file)
@@ -315,6 +315,9 @@ namespace ParaMEDMEM
 }
 
 %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)
@@ -342,6 +345,9 @@ def ParaMEDMEMDataArrayDoubleTupleImul(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)
@@ -357,6 +363,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -390,6 +399,33 @@ def ParaMEDMEMDataArrayIntTupleIdiv(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"
index aed5885e006ece449f7dc4f79914efc0db25a932..0be106c7533d71ddc268ee5fb296c377cd368532 100644 (file)
@@ -347,6 +347,13 @@ void MEDCouplingFieldDiscretization::resizeForUnserialization(const std::vector<
   arr=0;
 }
 
+/*!
+ * Empty : Not a bug
+ */
+void MEDCouplingFieldDiscretization::checkForUnserialization(const std::vector<int>& tinyInfo, const DataArrayInt *arr)
+{
+}
+
 /*!
  * Empty : Not a bug
  */
@@ -1609,18 +1616,24 @@ void MEDCouplingFieldDiscretizationGauss::resizeForUnserialization(const std::ve
   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)
@@ -2061,6 +2074,22 @@ void MEDCouplingFieldDiscretizationGauss::zipGaussLocalizations()
   _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()
 {
 }
index bf369faedf8a4c9a9e7f999aa477a8ef3c7113e8..e4868efe42a4a7649199e23e4a346ca05f1f814e 100644 (file)
@@ -92,6 +92,7 @@ namespace ParaMEDMEM
     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,
@@ -251,6 +252,7 @@ namespace ParaMEDMEM
     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;
@@ -285,6 +287,7 @@ namespace ParaMEDMEM
     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;
index 9847697237ac56282484064fdedc5b0ea6c82e4a..3fbd09d472f248465d3c29d00bc217bceeb0385a 100644 (file)
@@ -2088,6 +2088,7 @@ void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector<dou
  * @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)
 {
@@ -2104,6 +2105,25 @@ void MEDCouplingFieldDouble::resizeForUnserialization(const std::vector<int>& ti
   _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))
index b62dd66e6bc88aa97a614a5d8f5f3c7d80cf2abf..ee9a2506a23b3116e415a4aab445af33872b3e41 100644 (file)
@@ -140,6 +140,7 @@ namespace ParaMEDMEM
     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;
     //
index 6cff3a51b7b0ca1c76445510b4b0b66cff9a3ae2..cb456a02454054f4ad19ffb91275d76bf660f2c8 100644 (file)
@@ -258,6 +258,24 @@ void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<i
   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];
@@ -2465,6 +2483,32 @@ void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& t
   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);
index 91fde2e43ec933d1590b6cf05e59d7906beaefc4..3bf7b82adef5e3acd5991d1052a6cd075601f44e 100644 (file)
@@ -82,6 +82,7 @@ namespace ParaMEDMEM
     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;
@@ -396,6 +397,7 @@ namespace ParaMEDMEM
     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;
index 726bbb263e158eaf8abfa29143104278fd074403..ab8ba14762dd1bfd9bf049fd80233260eac06c79 100644 (file)
@@ -555,6 +555,9 @@ namespace ParaMEDMEM
 }
 
 %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)
@@ -570,6 +573,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(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)
@@ -585,6 +591,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -636,6 +645,27 @@ def ParaMEDMEMDenseMatrixIadd(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"
index 3ca70dcbd984f6a1c801db70321e4bcadeae9eeb..a57298512b0d22970730c2ca6a0677889e1911f9 100644 (file)
@@ -315,6 +315,9 @@ namespace ParaMEDMEM
 }
 
 %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)
@@ -330,6 +333,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(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)
@@ -345,6 +351,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -396,6 +405,27 @@ def ParaMEDMEMDenseMatrixIadd(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"
index 28c1d951af747d41e87eeb4f167a0520bac2b4eb..108897c53d9a83060acfc51fc54f8593ac5a1125 100644 (file)
@@ -90,4 +90,6 @@ SET_TESTS_PROPERTIES(MEDCouplingRemapperTest PROPERTIES ENVIRONMENT "${tests_env
 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)
index 577c576cecdd19efd6573777b3753a92e2e042b7..d6450452e4f9ac6c5c55dbccc0cb122284b91787 100644 (file)
@@ -20,6 +20,9 @@
 %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)
@@ -35,6 +38,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(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)
@@ -50,6 +56,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -101,6 +110,27 @@ def ParaMEDMEMDenseMatrixIadd(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"
index 0639745d32cd3a0dd1054f2f13155e4627357fa0..cb242a15b6f7cca99a0c35ddaf600b34a58c954e 100644 (file)
@@ -586,6 +586,7 @@ namespace ParaMEDMEM
     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);
@@ -610,7 +611,7 @@ namespace ParaMEDMEM
            PyList_SetItem(res,2,SWIG_From_int(tmp2));
            return res;
          }
-
+         
          int getCellContainingPoint(PyObject *p, double eps) const throw(INTERP_KERNEL::Exception)
          {
            double val;
@@ -976,6 +977,102 @@ namespace ParaMEDMEM
              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)
          {
@@ -1704,7 +1801,13 @@ namespace ParaMEDMEM
       {
         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();
@@ -2672,6 +2775,16 @@ namespace ParaMEDMEM
       {
         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)
       {
@@ -2762,6 +2875,11 @@ namespace ParaMEDMEM
     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);
@@ -2772,6 +2890,11 @@ namespace ParaMEDMEM
         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();
@@ -2825,6 +2948,10 @@ namespace ParaMEDMEM
     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);
@@ -2835,6 +2962,11 @@ namespace ParaMEDMEM
         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();
@@ -3177,6 +3309,11 @@ namespace ParaMEDMEM
       {
         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();
@@ -3217,6 +3354,10 @@ namespace ParaMEDMEM
       {
         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();
@@ -3294,6 +3435,11 @@ namespace ParaMEDMEM
         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;
@@ -4659,6 +4805,160 @@ namespace ParaMEDMEM
         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);
+      }
     }
   };
 
index 05722176c5b5e84b42d4d73ab3e315643a754e84..21f462ba01bb3545ef0dfef7d64f182813dac29b 100644 (file)
@@ -82,7 +82,7 @@ void numarrdeal(void *pt, void *wron)
     {
       Py_XINCREF(obj);
       PyArrayObject *objC=reinterpret_cast<PyArrayObject *>(obj);
-      objC->flags|=NPY_OWNDATA;
+      objC->flags|=NPY_ARRAY_OWNDATA;
       Py_XDECREF(weakRefOnOwner);
       Py_XDECREF(obj);
     }
@@ -282,24 +282,36 @@ MCData *BuildNewInstance(PyObject *elt0, int npyObjectType, PyTypeObject *pytype
   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)
@@ -363,7 +375,7 @@ int NumpyArrSetBaseObjectExt(PyArrayObject *arr, PyObject *obj)
  
 
         /* 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;
         }   
 
index 26097c097a68dc38dca4be4e60662a7a33076025..393dec9c81df98bc70e7c9c18d40a159c9f80962 100644 (file)
 //
 
 %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
@@ -51,6 +54,17 @@ DataArrayIntTuple.__imod__=ParaMEDMEMDataArrayIntTupleImod
 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
@@ -60,6 +74,7 @@ del ParaMEDMEMMEDCouplingFieldDoubleIsub
 del ParaMEDMEMMEDCouplingFieldDoubleImul
 del ParaMEDMEMMEDCouplingFieldDoubleIdiv
 del ParaMEDMEMMEDCouplingFieldDoubleIpow
+del ParaMEDMEMDataArrayIntnew
 del ParaMEDMEMDataArrayIntIadd
 del ParaMEDMEMDataArrayIntIsub
 del ParaMEDMEMDataArrayIntImul
@@ -76,4 +91,12 @@ del ParaMEDMEMDataArrayIntTupleIdiv
 del ParaMEDMEMDataArrayIntTupleImod
 del ParaMEDMEMDenseMatrixIadd
 del ParaMEDMEMDenseMatrixIsub
+del ParaMEDMEMMEDCouplingUMeshnew
+del ParaMEDMEMMEDCoupling1DGTUMeshnew
+del ParaMEDMEMMEDCoupling1SGTUMeshnew
+del ParaMEDMEMMEDCouplingCurveLinearMeshnew
+del ParaMEDMEMMEDCouplingCMeshnew
+del ParaMEDMEMMEDCouplingIMeshnew
+del ParaMEDMEMMEDCouplingExtrudedMeshnew
+del ParaMEDMEMMEDCouplingFieldDoublenew
 %}
index 104f463044bfac3bbec58a5c627f1c99ce33df1a..cbf759e945755fe6064eab5c4539f43502cd33de 100644 (file)
@@ -476,6 +476,41 @@ namespace ParaMEDMEM
         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);
+      }
     }
   };
   
@@ -2174,6 +2209,59 @@ namespace ParaMEDMEM
         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
+      }
     }
   };
 
@@ -4478,6 +4566,59 @@ namespace ParaMEDMEM
         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
+      }
     }
   };
 
diff --git a/src/MEDCoupling_Swig/MEDCouplingPickleTest.py b/src/MEDCoupling_Swig/MEDCouplingPickleTest.py
new file mode 100644 (file)
index 0000000..677b110
--- /dev/null
@@ -0,0 +1,300 @@
+#  -*- 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()
index 75881f9a4d1de34c4ed68550fe72c514e2ab8782..48003ef559df723474de5192f32e7276d27e03c7 100644 (file)
@@ -29,9 +29,9 @@ namespace INTERP_KERNEL
     %extend
     {
       std::string __str__() const
-        {
-          return std::string(self->what());
-        }
+      {
+        return std::string(self->what());
+      }
     }
   };
 }
@@ -157,3 +157,12 @@ namespace ParaMEDMEM
     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(),))
+%}
index e9ad002c8e190de8f30c161cfb2e047bd207acbc..135958b8814de52a8c8e87ffe1cf24d09f591476 100644 (file)
@@ -103,6 +103,9 @@ namespace ParaMEDMEM
 }
 
 %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)
@@ -118,6 +121,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(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)
@@ -133,6 +139,12 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -184,6 +196,27 @@ def ParaMEDMEMDenseMatrixIadd(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"
index ce6eed11c83f3df2070312bcfafe66408ad51484..94bed84df8a9289072946894b2b795c386c1dd06 100644 (file)
@@ -427,3 +427,31 @@ ParaMEDMEM::MEDCouplingFieldDouble *ParaMEDMEM_MEDCouplingFieldDouble___rdiv__Im
       { 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;
+}
index 546c67b9a9917506444b24a5e1c08457de5a69ee..ab8d676ed77f572cce5382babdd9efe36837879b 100644 (file)
@@ -21,6 +21,9 @@
 %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)
@@ -36,6 +39,9 @@ def ParaMEDMEMDataArrayDoubleIdiv(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)
@@ -51,6 +57,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
@@ -102,6 +111,27 @@ def ParaMEDMEMDenseMatrixIadd(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"
index 9b4396395feea6adf770f7a2ba03160b364639f4..38f4c475184231744c8ff2cba79f3f8ee411d362 100644 (file)
@@ -259,6 +259,9 @@ int MPI_Finalize();
   %}
 
 %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)
@@ -286,6 +289,9 @@ def ParaMEDMEMDataArrayDoubleTupleImul(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)
@@ -301,6 +307,9 @@ def ParaMEDMEMMEDCouplingFieldDoubleIdiv(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)
index 23cc5ea139f95c32ce4456c558812cc41fa6c81c..9ba28d27448cc65be466c25135a1552a2aec36e7 100644 (file)
 %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
@@ -107,10 +117,13 @@ DataArrayIntTuple.__imul__=ParaMEDMEMDataArrayIntTupleImul
 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