*/
//void MEDCouplingFieldDouble::setArrays(const std::vector<DataArrayDouble *>& arrs)
-void MEDCouplingFieldDouble::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
-{
- tinyInfo.clear();
- timeDiscr()->getTinySerializationStrInformation(tinyInfo);
- tinyInfo.push_back(_name);
- tinyInfo.push_back(_desc);
- tinyInfo.push_back(getTimeUnit());
-}
-
-/*!
- * This method retrieves some critical values to resize and prepare remote instance.
- * The first two elements returned in tinyInfo correspond to the parameters to give in constructor.
- * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
- */
-void MEDCouplingFieldDouble::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationIntInformation !");
- tinyInfo.clear();
- tinyInfo.push_back((int)_type->getEnum());
- tinyInfo.push_back((int)timeDiscr()->getEnum());
- tinyInfo.push_back((int)_nature);
- timeDiscr()->getTinySerializationIntInformation(tinyInfo);
- std::vector<int> tinyInfo2;
- _type->getTinySerializationIntInformation(tinyInfo2);
- tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
- tinyInfo.push_back((int)tinyInfo2.size());
-}
-
-/*!
- * This method retrieves some critical values to resize and prepare remote instance.
- * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
- */
-void MEDCouplingFieldDouble::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationDbleInformation !");
- tinyInfo.clear();
- timeDiscr()->getTinySerializationDbleInformation(tinyInfo);
- std::vector<double> tinyInfo2;
- _type->getTinySerializationDbleInformation(tinyInfo2);
- tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
- tinyInfo.push_back((int)tinyInfo2.size());//very bad, lack of time to improve it
-}
-
-/*!
- * This method has to be called to the new instance filled by CORBA, MPI, File...
- * @param tinyInfoI is the value retrieves from distant result of getTinySerializationIntInformation on source instance to be copied.
- * @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)
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !");
- dataInt=0;
- 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());
- timeDiscr()->resizeForUnserialization(tinyInfoI2,arrays);
- std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
- _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(_type.isNull())
- 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());
- timeDiscr()->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(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform finishUnserialization !");
- std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
- //
- std::vector<double> tmp(tinyInfoD);
- int sz=(int)tinyInfoD.back();//very bad, lack of time to improve it
- tmp.pop_back();
- std::vector<double> tmp1(tmp.begin(),tmp.end()-sz);
- std::vector<double> tmp2(tmp.end()-sz,tmp.end());
- //
- timeDiscr()->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
- _nature=(NatureOfField)tinyInfoI[2];
- _type->finishUnserialization(tmp2);
- int nbOfElemS=(int)tinyInfoS.size();
- _name=tinyInfoS[nbOfElemS-3];
- _desc=tinyInfoS[nbOfElemS-2];
- setTimeUnit(tinyInfoS[nbOfElemS-1]);
-}
-
-/*!
- * Contrary to MEDCouplingPointSet class the returned arrays are \b not the responsabilities of the caller.
- * The values returned must be consulted only in readonly mode.
- */
-void MEDCouplingFieldDouble::serialize(DataArrayInt *&dataInt, std::vector<DataArrayDouble *>& arrays) const
-{
- if(_type.isNull())
- throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform serialize !");
- timeDiscr()->getArrays(arrays);
- _type->getSerializationIntArray(dataInt);
-}
-
/*!
* Tries to set an \a other mesh as the support of \a this field. An attempt fails, if
* a current and the \a other meshes are different with use of specified equality
MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
//
- MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- 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;
- //
MEDCOUPLING_EXPORT void changeUnderlyingMesh(const MEDCouplingMesh *other, int levOfCheck, double precOnMesh, double eps=1e-15);
MEDCOUPLING_EXPORT void substractInPlaceDM(const MEDCouplingFieldDouble *f, int levOfCheck, double precOnMesh, double eps=1e-15);
MEDCOUPLING_EXPORT bool mergeNodes(double eps, double epsOnVals=1e-15);
MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const;
MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldT<T> *other);
MEDCOUPLING_EXPORT void copyAllTinyAttrFrom(const MEDCouplingFieldT<T> *other);
+ //
+ MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+ 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<typename Traits<T>::ArrayType *>& arrays);
+ MEDCOUPLING_EXPORT void checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<typename Traits<T>::ArrayType *>& 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<typename Traits<T>::ArrayType *>& arrays) const;
protected:
const MEDCouplingTimeDiscretizationTemplate<T> *timeDiscrSafe() const;
MEDCouplingTimeDiscretizationTemplate<T> *timeDiscrSafe();
throw INTERP_KERNEL::Exception("const FieldT : Null type of time discr !");
return ret;
}
+
+ template<class T>
+ void MEDCouplingFieldT<T>::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+ {
+ tinyInfo.clear();
+ timeDiscrSafe()->getTinySerializationStrInformation(tinyInfo);
+ tinyInfo.push_back(_name);
+ tinyInfo.push_back(_desc);
+ tinyInfo.push_back(getTimeUnit());
+ }
+
+ /*!
+ * This method retrieves some critical values to resize and prepare remote instance.
+ * The first two elements returned in tinyInfo correspond to the parameters to give in constructor.
+ * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+ {
+ if(_type.isNull())
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationIntInformation !");
+ tinyInfo.clear();
+ tinyInfo.push_back((int)_type->getEnum());
+ tinyInfo.push_back((int)timeDiscrSafe()->getEnum());
+ tinyInfo.push_back((int)_nature);
+ timeDiscrSafe()->getTinySerializationIntInformation(tinyInfo);
+ std::vector<int> tinyInfo2;
+ _type->getTinySerializationIntInformation(tinyInfo2);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.push_back((int)tinyInfo2.size());
+ }
+
+ /*!
+ * This method retrieves some critical values to resize and prepare remote instance.
+ * @param tinyInfo out parameter resized correctly after the call. The length of this vector is tiny.
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+ {
+ if(_type.isNull())
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform getTinySerializationDbleInformation !");
+ tinyInfo.clear();
+ timeDiscrSafe()->getTinySerializationDbleInformation(tinyInfo);
+ std::vector<double> tinyInfo2;
+ _type->getTinySerializationDbleInformation(tinyInfo2);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.push_back((int)tinyInfo2.size());//very bad, lack of time to improve it
+ }
+
+ /*!
+ * This method has to be called to the new instance filled by CORBA, MPI, File...
+ * @param tinyInfoI is the value retrieves from distant result of getTinySerializationIntInformation on source instance to be copied.
+ * @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
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::resizeForUnserialization(const std::vector<int>& tinyInfoI, DataArrayInt *&dataInt, std::vector<typename Traits<T>::ArrayType *>& arrays)
+ {
+ if(_type.isNull())
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform resizeForUnserialization !");
+ dataInt=0;
+ 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());
+ timeDiscrSafe()->resizeForUnserialization(tinyInfoI2,arrays);
+ std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
+ _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
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::checkForUnserialization(const std::vector<int>& tinyInfoI, const DataArrayInt *dataInt, const std::vector<typename Traits<T>::ArrayType *>& arrays)
+ {
+ if(_type.isNull())
+ 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());
+ timeDiscrSafe()->checkForUnserialization(tinyInfoI2,arrays);
+ std::vector<int> tinyInfoITmp3(tinyInfoITmp.end()-sz,tinyInfoITmp.end());
+ _type->checkForUnserialization(tinyInfoITmp3,dataInt);
+ }
+
+ template<class T>
+ void MEDCouplingFieldT<T>::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+ {
+ if(_type.isNull())
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform finishUnserialization !");
+ std::vector<int> tinyInfoI2(tinyInfoI.begin()+3,tinyInfoI.end());
+ //
+ std::vector<double> tmp(tinyInfoD);
+ int sz=(int)tinyInfoD.back();//very bad, lack of time to improve it
+ tmp.pop_back();
+ std::vector<double> tmp1(tmp.begin(),tmp.end()-sz);
+ std::vector<double> tmp2(tmp.end()-sz,tmp.end());
+ //
+ timeDiscrSafe()->finishUnserialization(tinyInfoI2,tmp1,tinyInfoS);
+ _nature=(NatureOfField)tinyInfoI[2];
+ _type->finishUnserialization(tmp2);
+ int nbOfElemS=(int)tinyInfoS.size();
+ _name=tinyInfoS[nbOfElemS-3];
+ _desc=tinyInfoS[nbOfElemS-2];
+ setTimeUnit(tinyInfoS[nbOfElemS-1]);
+ }
+
+ /*!
+ * Contrary to MEDCouplingPointSet class the returned arrays are \b not the responsabilities of the caller.
+ * The values returned must be consulted only in readonly mode.
+ */
+ template<class T>
+ void MEDCouplingFieldT<T>::serialize(DataArrayInt *&dataInt, std::vector<typename Traits<T>::ArrayType *>& arrays) const
+ {
+ if(_type.isNull())
+ throw INTERP_KERNEL::Exception("No spatial discretization underlying this field to perform serialize !");
+ timeDiscrSafe()->getArrays(arrays);
+ _type->getSerializationIntArray(dataInt);
+ }
}
#endif
return ret.retn();
}
-/*!
- * Returns a new DataArrayDouble by aggregating two given arrays, so that (1) the number
- * of components in the result array is a sum of the number of components of given arrays
- * and (2) the number of tuples in the result array is same as that of each of given
- * arrays. In other words the i-th tuple of result array includes all components of
- * i-th tuples of all given arrays.
- * Number of tuples in the given arrays must be the same.
- * \param [in] a1 - an array to include in the result array.
- * \param [in] a2 - another array to include in the result array.
- * \return DataArrayDouble * - the new instance of DataArrayDouble.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If both \a a1 and \a a2 are NULL.
- * \throw If any given array is not allocated.
- * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
- */
-DataArrayDouble *DataArrayDouble::Meld(const DataArrayDouble *a1, const DataArrayDouble *a2)
-{
- std::vector<const DataArrayDouble *> arr(2);
- arr[0]=a1; arr[1]=a2;
- return Meld(arr);
-}
-
-/*!
- * Returns a new DataArrayDouble by aggregating all given arrays, so that (1) the number
- * of components in the result array is a sum of the number of components of given arrays
- * and (2) the number of tuples in the result array is same as that of each of given
- * arrays. In other words the i-th tuple of result array includes all components of
- * i-th tuples of all given arrays.
- * Number of tuples in the given arrays must be the same.
- * \param [in] arr - a sequence of arrays to include in the result array.
- * \return DataArrayDouble * - the new instance of DataArrayDouble.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If all arrays within \a arr are NULL.
- * \throw If any given array is not allocated.
- * \throw If getNumberOfTuples() of arrays within \a arr is different.
- */
-DataArrayDouble *DataArrayDouble::Meld(const std::vector<const DataArrayDouble *>& arr)
-{
- std::vector<const DataArrayDouble *> a;
- for(std::vector<const DataArrayDouble *>::const_iterator it4=arr.begin();it4!=arr.end();it4++)
- if(*it4)
- a.push_back(*it4);
- if(a.empty())
- throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : input list must contain at least one NON EMPTY DataArrayDouble !");
- std::vector<const DataArrayDouble *>::const_iterator it;
- for(it=a.begin();it!=a.end();it++)
- (*it)->checkAllocated();
- it=a.begin();
- int nbOfTuples=(*it)->getNumberOfTuples();
- std::vector<int> nbc(a.size());
- std::vector<const double *> pts(a.size());
- nbc[0]=(*it)->getNumberOfComponents();
- pts[0]=(*it++)->getConstPointer();
- for(int i=1;it!=a.end();it++,i++)
- {
- if(nbOfTuples!=(*it)->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !");
- nbc[i]=(*it)->getNumberOfComponents();
- pts[i]=(*it)->getConstPointer();
- }
- int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->alloc(nbOfTuples,totalNbOfComp);
- double *retPtr=ret->getPointer();
- for(int i=0;i<nbOfTuples;i++)
- for(int j=0;j<(int)a.size();j++)
- {
- retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
- pts[j]+=nbc[j];
- }
- int k=0;
- for(int i=0;i<(int)a.size();i++)
- for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
- return ret;
-}
-
/*!
* Returns a new DataArrayDouble containing a dot product of two given arrays, so that
* the i-th tuple of the result array is a sum of products of j-th components of i-th
declareAsNew();
}
-/*!
- * Returns a new DataArrayInt by aggregating two given arrays, so that (1) the number
- * of components in the result array is a sum of the number of components of given arrays
- * and (2) the number of tuples in the result array is same as that of each of given
- * arrays. In other words the i-th tuple of result array includes all components of
- * i-th tuples of all given arrays.
- * Number of tuples in the given arrays must be the same.
- * \param [in] a1 - an array to include in the result array.
- * \param [in] a2 - another array to include in the result array.
- * \return DataArrayInt * - the new instance of DataArrayInt.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If both \a a1 and \a a2 are NULL.
- * \throw If any given array is not allocated.
- * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
- */
-DataArrayInt *DataArrayInt::Meld(const DataArrayInt *a1, const DataArrayInt *a2)
-{
- std::vector<const DataArrayInt *> arr(2);
- arr[0]=a1; arr[1]=a2;
- return Meld(arr);
-}
-
-/*!
- * Returns a new DataArrayInt by aggregating all given arrays, so that (1) the number
- * of components in the result array is a sum of the number of components of given arrays
- * and (2) the number of tuples in the result array is same as that of each of given
- * arrays. In other words the i-th tuple of result array includes all components of
- * i-th tuples of all given arrays.
- * Number of tuples in the given arrays must be the same.
- * \param [in] arr - a sequence of arrays to include in the result array.
- * \return DataArrayInt * - the new instance of DataArrayInt.
- * The caller is to delete this result array using decrRef() as it is no more
- * needed.
- * \throw If all arrays within \a arr are NULL.
- * \throw If any given array is not allocated.
- * \throw If getNumberOfTuples() of arrays within \a arr is different.
- */
-DataArrayInt *DataArrayInt::Meld(const std::vector<const DataArrayInt *>& arr)
-{
- std::vector<const DataArrayInt *> a;
- for(std::vector<const DataArrayInt *>::const_iterator it4=arr.begin();it4!=arr.end();it4++)
- if(*it4)
- a.push_back(*it4);
- if(a.empty())
- throw INTERP_KERNEL::Exception("DataArrayInt::Meld : array must be NON empty !");
- std::vector<const DataArrayInt *>::const_iterator it;
- for(it=a.begin();it!=a.end();it++)
- (*it)->checkAllocated();
- it=a.begin();
- int nbOfTuples=(*it)->getNumberOfTuples();
- std::vector<int> nbc(a.size());
- std::vector<const int *> pts(a.size());
- nbc[0]=(*it)->getNumberOfComponents();
- pts[0]=(*it++)->getConstPointer();
- for(int i=1;it!=a.end();it++,i++)
- {
- if(nbOfTuples!=(*it)->getNumberOfTuples())
- throw INTERP_KERNEL::Exception("DataArrayInt::meld : mismatch of number of tuples !");
- nbc[i]=(*it)->getNumberOfComponents();
- pts[i]=(*it)->getConstPointer();
- }
- int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(nbOfTuples,totalNbOfComp);
- int *retPtr=ret->getPointer();
- for(int i=0;i<nbOfTuples;i++)
- for(int j=0;j<(int)a.size();j++)
- {
- retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
- pts[j]+=nbc[j];
- }
- int k=0;
- for(int i=0;i<(int)a.size();i++)
- for(int j=0;j<nbc[i];j++,k++)
- ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
- return ret;
-}
-
/*!
* Returns a new DataArrayInt which is a minimal partition of elements of \a groups.
* The i-th item of the result array is an ID of a set of elements belonging to a
MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Divide(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Add(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Multiply(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
+ MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Meld(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2);
+ MEDCOUPLING_EXPORT static typename Traits<T>::ArrayType *Meld(const std::vector<const typename Traits<T>::ArrayType *>& arr);
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsGreaterOrEqualTo(T val) const;
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsGreaterThan(T val) const;
MEDCOUPLING_EXPORT MCAuto<DataArrayInt> findIdsLowerOrEqualTo(T val) const;
MEDCOUPLING_EXPORT DataArrayInt *findIdsNotInRange(double vmin, double vmax) const;
MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const DataArrayDouble *a1, const DataArrayDouble *a2);
MEDCOUPLING_EXPORT static DataArrayDouble *Aggregate(const std::vector<const DataArrayDouble *>& arr);
- MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const DataArrayDouble *a1, const DataArrayDouble *a2);
- MEDCOUPLING_EXPORT static DataArrayDouble *Meld(const std::vector<const DataArrayDouble *>& arr);
MEDCOUPLING_EXPORT static DataArrayDouble *Dot(const DataArrayDouble *a1, const DataArrayDouble *a2);
MEDCOUPLING_EXPORT static DataArrayDouble *CrossProduct(const DataArrayDouble *a1, const DataArrayDouble *a2);
MEDCOUPLING_EXPORT static DataArrayDouble *Max(const DataArrayDouble *a1, const DataArrayDouble *a2);
MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const DataArrayInt *a1, const DataArrayInt *a2, int offsetA2);
MEDCOUPLING_EXPORT static DataArrayInt *Aggregate(const std::vector<const DataArrayInt *>& arr);
MEDCOUPLING_EXPORT static DataArrayInt *AggregateIndexes(const std::vector<const DataArrayInt *>& arrs);
- MEDCOUPLING_EXPORT static DataArrayInt *Meld(const DataArrayInt *a1, const DataArrayInt *a2);
- MEDCOUPLING_EXPORT static DataArrayInt *Meld(const std::vector<const DataArrayInt *>& arr);
MEDCOUPLING_EXPORT static DataArrayInt *MakePartition(const std::vector<const DataArrayInt *>& groups, int newNb, std::vector< std::vector<int> >& fidsOfGroups);
MEDCOUPLING_EXPORT static DataArrayInt *BuildUnion(const std::vector<const DataArrayInt *>& arr);
MEDCOUPLING_EXPORT static DataArrayInt *BuildIntersection(const std::vector<const DataArrayInt *>& arr);
LowerThan<T> lt(val);
return findIdsAdv(lt);
}
+
+ /*!
+ * Returns a new DataArrayDouble by aggregating two given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] a1 - an array to include in the result array.
+ * \param [in] a2 - another array to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If both \a a1 and \a a2 are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If \a a1->getNumberOfTuples() != \a a2->getNumberOfTuples()
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::Meld(const typename Traits<T>::ArrayType *a1, const typename Traits<T>::ArrayType *a2)
+ {
+ std::vector<const typename Traits<T>::ArrayType *> arr(2);
+ arr[0]=a1; arr[1]=a2;
+ return Meld(arr);
+ }
+
+ /*!
+ * Returns a new DataArrayDouble by aggregating all given arrays, so that (1) the number
+ * of components in the result array is a sum of the number of components of given arrays
+ * and (2) the number of tuples in the result array is same as that of each of given
+ * arrays. In other words the i-th tuple of result array includes all components of
+ * i-th tuples of all given arrays.
+ * Number of tuples in the given arrays must be the same.
+ * \param [in] arr - a sequence of arrays to include in the result array.
+ * \return DataArrayDouble * - the new instance of DataArrayDouble.
+ * The caller is to delete this result array using decrRef() as it is no more
+ * needed.
+ * \throw If all arrays within \a arr are NULL.
+ * \throw If any given array is not allocated.
+ * \throw If getNumberOfTuples() of arrays within \a arr is different.
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::Meld(const std::vector<const typename Traits<T>::ArrayType *>& arr)
+ {
+ std::vector<const typename Traits<T>::ArrayType *> a;
+ for(typename std::vector<const typename Traits<T>::ArrayType *>::const_iterator it4=arr.begin();it4!=arr.end();it4++)
+ if(*it4)
+ a.push_back(*it4);
+ if(a.empty())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : input list must contain at least one NON EMPTY DataArrayDouble !");
+ typename std::vector<const typename Traits<T>::ArrayType *>::const_iterator it;
+ for(it=a.begin();it!=a.end();it++)
+ (*it)->checkAllocated();
+ it=a.begin();
+ int nbOfTuples((*it)->getNumberOfTuples());
+ std::vector<int> nbc(a.size());
+ std::vector<const T *> pts(a.size());
+ nbc[0]=(*it)->getNumberOfComponents();
+ pts[0]=(*it++)->getConstPointer();
+ for(int i=1;it!=a.end();it++,i++)
+ {
+ if(nbOfTuples!=(*it)->getNumberOfTuples())
+ throw INTERP_KERNEL::Exception("DataArrayDouble::Meld : mismatch of number of tuples !");
+ nbc[i]=(*it)->getNumberOfComponents();
+ pts[i]=(*it)->getConstPointer();
+ }
+ int totalNbOfComp=std::accumulate(nbc.begin(),nbc.end(),0);
+ typename Traits<T>::ArrayType *ret(Traits<T>::ArrayType::New());
+ ret->alloc(nbOfTuples,totalNbOfComp);
+ T *retPtr(ret->getPointer());
+ for(int i=0;i<nbOfTuples;i++)
+ for(int j=0;j<(int)a.size();j++)
+ {
+ retPtr=std::copy(pts[j],pts[j]+nbc[j],retPtr);
+ pts[j]+=nbc[j];
+ }
+ int k=0;
+ for(int i=0;i<(int)a.size();i++)
+ for(int j=0;j<nbc[i];j++,k++)
+ ret->setInfoOnComponent(k,a[i]->getInfoOnComponent(j));
+ return ret;
+ }
/*!
* Checks if all values in \a this array are equal to \a val at precision \a eps.
return ret;
}
-void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
- if(_array)
- {
- tinyInfo.push_back(_array->getNumberOfTuples());
- tinyInfo.push_back(_array->getNumberOfComponents());
- }
- else
- {
- tinyInfo.push_back(-1);
- tinyInfo.push_back(-1);
- }
-}
-
-void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
-{
- arrays.resize(1);
- if(_array!=0)
- _array->decrRef();
- DataArrayDouble *arr=0;
- if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
- {
- arr=DataArrayDouble::New();
- arr->alloc(tinyInfoI[0],tinyInfoI[1]);
- }
- _array=arr;
- 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];
- int nbOfCompo=_array->getNumberOfComponents();
- for(int i=0;i<nbOfCompo;i++)
- _array->setInfoOnComponent(i,tinyInfoS[i]);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
- tinyInfo.push_back(_time_tolerance);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
-{
- int nbOfCompo=_array->getNumberOfComponents();
- for(int i=0;i<nbOfCompo;i++)
- tinyInfo.push_back(_array->getInfoOnComponent(i));
-}
-
bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const
{
int iteration,order;
MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
MEDCOUPLING_EXPORT virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretizationTemplate<T> *other) const;
MEDCOUPLING_EXPORT virtual ~MEDCouplingTimeDiscretizationTemplate();
+ MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
+ 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<typename Traits<T>::ArrayType *>& arrays);
+ MEDCOUPLING_EXPORT virtual void checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<typename Traits<T>::ArrayType *>& arrays);
+ MEDCOUPLING_EXPORT virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
protected:
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate();
MEDCOUPLING_EXPORT MEDCouplingTimeDiscretizationTemplate(const MEDCouplingTimeDiscretizationTemplate<T>& other, bool deepCopy);
MEDCOUPLING_EXPORT virtual void divideEqual(const MEDCouplingTimeDiscretization *other) = 0;
MEDCOUPLING_EXPORT virtual MEDCouplingTimeDiscretization *pow(const MEDCouplingTimeDiscretization *other) const = 0;
MEDCOUPLING_EXPORT virtual void powEqual(const MEDCouplingTimeDiscretization *other) = 0;
- MEDCOUPLING_EXPORT virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- 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 virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
#define __MEDCOUPLINGTIMEDISCRETIZATION_TXX__
#include "MEDCouplingTimeDiscretization.hxx"
+#include "MEDCouplingMemArray.txx"
#include <cmath>
#include <sstream>
arrays[0]=_array;
}
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
+ {
+ if(_array)
+ {
+ tinyInfo.push_back(_array->getNumberOfTuples());
+ tinyInfo.push_back(_array->getNumberOfComponents());
+ }
+ else
+ {
+ tinyInfo.push_back(-1);
+ tinyInfo.push_back(-1);
+ }
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
+ {
+ tinyInfo.push_back(_time_tolerance);
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
+ {
+ int nbOfCompo(_array->getNumberOfComponents());
+ for(int i=0;i<nbOfCompo;i++)
+ tinyInfo.push_back(_array->getInfoOnComponent(i));
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<typename Traits<T>::ArrayType *>& arrays)
+ {
+ arrays.resize(1);
+ if(_array!=0)
+ _array->decrRef();
+ typename Traits<T>::ArrayType *arr=0;
+ if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
+ {
+ arr=Traits<T>::ArrayType::New();
+ arr->alloc(tinyInfoI[0],tinyInfoI[1]);
+ }
+ _array=arr;
+ arrays[0]=arr;
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::checkForUnserialization(const std::vector<int>& tinyInfoI, const std::vector<typename Traits<T>::ArrayType *>& 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();
+ }
+ }
+
+ template<class T>
+ void MEDCouplingTimeDiscretizationTemplate<T>::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
+ {
+ _time_tolerance=tinyInfoD[0];
+ int nbOfCompo=_array->getNumberOfComponents();
+ for(int i=0;i<nbOfCompo;i++)
+ _array->setInfoOnComponent(i,tinyInfoS[i]);
+ }
+
+ /////////////////////////
+
template<class T>
std::string MEDCouplingTimeDiscretizationSimple<T>::getStringRepr() const
{
def MEDCouplingFieldDoubleIpow(self,*args):
import _MEDCoupling
return _MEDCoupling.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def MEDCouplingFieldIntnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingFieldInt____new___(cls,args)
+def MEDCouplingFieldFloatnew(cls,*args):
+ import _MEDCoupling
+ return _MEDCoupling.MEDCouplingFieldFloat____new___(cls,args)
def MEDCouplingDataArrayIntnew(cls,*args):
import _MEDCoupling
return _MEDCoupling.DataArrayInt____new___(cls,args)
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;
+ return field_getTinySerializationInformation<MEDCouplingFieldDouble>(self);
}
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_MEDCoupling__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_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
- }
- PyTuple_SetItem(ret,1,ret1Py);
- return ret;
+ return field_serialize<double>(self);
}
static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
{// put an empty dict in input to say to __new__ to call __init__...
- self->checkConsistencyLight();
- 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;
+ return field__getnewargs__<MEDCouplingFieldDouble>(self);
}
PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
{
- self->checkConsistencyLight();
- PyObject *ret0(MEDCoupling_MEDCouplingFieldDouble_getTinySerializationInformation(self));
- PyObject *ret1(MEDCoupling_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;
+ return field__getstate__<MEDCouplingFieldDouble>(self,MEDCoupling_MEDCouplingFieldDouble_getTinySerializationInformation,MEDCoupling_MEDCouplingFieldDouble_serialize);
}
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_MEDCoupling__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_MEDCoupling__DataArrayInt,0|0));
- if(!SWIG_IsOK(status))
- throw INTERP_KERNEL::Exception(MSG);
- b0=reinterpret_cast<DataArrayInt *>(argp);
- convertFromPyObjVectorOfObj<MEDCoupling::DataArrayDouble *>(b1py,SWIGTYPE_p_MEDCoupling__DataArrayDouble,"DataArrayDouble",b1);
- }
- self->checkForUnserialization(a1,b0,b1);
- // useless here to call resizeForUnserialization because arrays are well resized.
- self->finishUnserialization(a1,a0,a2);
+ field__setstate__<double>(self,inp);
}
}
};
PyList_SetItem(res,2,SWIG_From_int(tmp2));
return res;
}
+
+ PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception)
+ {
+ return field_getTinySerializationInformation<MEDCouplingFieldInt>(self);
+ }
+
+ PyObject *serialize() const throw(INTERP_KERNEL::Exception)
+ {
+ return field_serialize<int>(self);
+ }
+
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjExpectToBeAListOfSz2>(cls,args,"MEDCouplingFieldInt");
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {// put an empty dict in input to say to __new__ to call __init__...
+ return field__getnewargs__<MEDCouplingFieldInt>(self);
+ }
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ return field__getstate__<MEDCouplingFieldInt>(self,MEDCoupling_MEDCouplingFieldInt_getTinySerializationInformation,MEDCoupling_MEDCouplingFieldInt_serialize);
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ field__setstate__<int>(self,inp);
+ }
}
};
}
PyObject *getTime() throw(INTERP_KERNEL::Exception)
- {
+ {
int tmp1,tmp2;
double tmp0=self->getTime(tmp1,tmp2);
PyObject *res = PyList_New(3);
PyList_SetItem(res,1,SWIG_From_int(tmp1));
PyList_SetItem(res,2,SWIG_From_int(tmp2));
return res;
- }
+ }
+
+ PyObject *getTinySerializationInformation() const throw(INTERP_KERNEL::Exception)
+ {
+ return field_getTinySerializationInformation<MEDCouplingFieldFloat>(self);
+ }
+
+ PyObject *serialize() const throw(INTERP_KERNEL::Exception)
+ {
+ return field_serialize<float>(self);
+ }
+
+ static PyObject *___new___(PyObject *cls, PyObject *args) throw(INTERP_KERNEL::Exception)
+ {
+ return NewMethWrapCallInitOnlyIfDictWithSingleEltInInputGeneral<SinglePyObjExpectToBeAListOfSz2>(cls,args,"MEDCouplingFieldFloat");
+ }
+
+ PyObject *__getnewargs__() throw(INTERP_KERNEL::Exception)
+ {// put an empty dict in input to say to __new__ to call __init__...
+ return field__getnewargs__<MEDCouplingFieldFloat>(self);
+ }
+
+ PyObject *__getstate__() const throw(INTERP_KERNEL::Exception)
+ {
+ return field__getstate__<MEDCouplingFieldFloat>(self,MEDCoupling_MEDCouplingFieldFloat_getTinySerializationInformation,MEDCoupling_MEDCouplingFieldFloat_serialize);
+ }
+
+ void __setstate__(PyObject *inp) throw(INTERP_KERNEL::Exception)
+ {
+ field__setstate__<float>(self,inp);
+ }
}
};
#include <sstream>
+static PyObject *convertArray(MEDCoupling::DataArray *array, int owner)
+{
+ PyObject *ret(NULL);
+ if(!array)
+ {
+ Py_XINCREF(Py_None);
+ return Py_None;
+ }
+ if(dynamic_cast<MEDCoupling::DataArrayDouble *>(array))
+ ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayDouble,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayInt *>(array))
+ ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayInt,owner);
+ if(dynamic_cast<MEDCoupling::DataArrayFloat *>(array))
+ ret=SWIG_NewPointerObj((void*)array,SWIGTYPE_p_MEDCoupling__DataArrayFloat,owner);
+ if(!ret)
+ throw INTERP_KERNEL::Exception("Not recognized type of array on downcast !");
+ return ret;
+}
+
/*!
* This method is an extention of PySlice_GetIndices but less
* open than PySlice_GetIndicesEx that accepts too many situations.
MEDCouplingFieldDouble.__idiv__=MEDCouplingFieldDoubleIdiv
MEDCouplingFieldDouble.__ipow__=MEDCouplingFieldDoubleIpow
+MEDCouplingFieldInt.__new__=classmethod(MEDCouplingFieldIntnew)
+
+MEDCouplingFieldFloat.__new__=classmethod(MEDCouplingFieldFloatnew)
+
DataArrayDoubleTuple.__iadd__=MEDCouplingDataArrayDoubleTupleIadd
DataArrayDoubleTuple.__isub__=MEDCouplingDataArrayDoubleTupleIsub
DataArrayDoubleTuple.__imul__=MEDCouplingDataArrayDoubleTupleImul
%newobject MEDCoupling::DataArrayFloat::New;
%newobject MEDCoupling::DataArrayFloat::iterator;
%newobject MEDCoupling::DataArrayFloat::__iter__;
+%newobject MEDCoupling::DataArrayFloat::Meld;
%newobject MEDCoupling::DataArrayInt::New;
%newobject MEDCoupling::DataArrayInt::__iter__;
%newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef;
void iota(float init=0.) throw(INTERP_KERNEL::Exception);
DataArrayFloatIterator *iterator() throw(INTERP_KERNEL::Exception);
MCAuto<DataArrayDouble> convertToDblArr() const throw(INTERP_KERNEL::Exception);
+ static DataArrayFloat *Meld(const DataArrayFloat *a1, const DataArrayFloat *a2) throw(INTERP_KERNEL::Exception);
%extend
{
DataArrayFloat() throw(INTERP_KERNEL::Exception)
self.assertTrue(x2.isEqual(x,1e-7))
pass
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test16(self):
+ """ Test of MEDCouplingFieldInt 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=f.convertToIntField()
+ self.assertTrue(isinstance(f,MEDCouplingFieldInt))
+ f.setName("aname")
+ a=f.getArray()
+ b=a[:] ; b.iota(7000)
+ f.setArray(DataArrayInt.Meld(a,b))
+ f.getArray().setInfoOnComponents(["u1","vv2"])
+ f.checkConsistencyLight();
+ #
+ st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
+ f2=cPickle.loads(st)
+ self.assertTrue(f2.isEqual(f,1e-16,0))
+ self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
+ pass
+
+ @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ def test17(self):
+ """ Test of MEDCouplingFieldInt 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)
+ f2=m.getMeasureField(True)
+ f=MEDCouplingFieldFloat(ON_CELLS)
+ f.setMesh(m) ; f.setArray(f2.getArray().convertToFloatArr())
+ self.assertTrue(isinstance(f,MEDCouplingFieldFloat))
+ f.setName("aname")
+ a=f.getArray()
+ b=a[:] ; b.iota(7000.)
+ f.setArray(DataArrayFloat.Meld(a,b))
+ f.getArray().setInfoOnComponents(["u1","vv2"])
+ f.checkConsistencyLight();
+ #
+ st=cPickle.dumps(f,cPickle.HIGHEST_PROTOCOL)
+ f2=cPickle.loads(st)
+ self.assertTrue(f2.isEqual(f,1e-16,0))
+ self.assertTrue(f2.getMesh().isEqual(f.getMesh(),1e-16))
+ pass
+
def setUp(self):
pass
pass
def MEDCouplingFieldDoubleIpow(self,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def MEDCouplingFieldIntnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingFieldInt____new___(cls,args)
+def MEDCouplingFieldFloatnew(cls,*args):
+ import _MEDCouplingRemapper
+ return _MEDCouplingRemapper.MEDCouplingFieldFloat____new___(cls,args)
def MEDCouplingDataArrayBytenew(cls,*args):
import _MEDCouplingRemapper
return _MEDCouplingRemapper.DataArrayByte____new___(cls,args)
#include "MEDCouplingPartDefinition.hxx"
#include "MEDCouplingCartesianAMRMesh.hxx"
-static PyObject *convertMesh(MEDCoupling::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertMesh(MEDCoupling::MEDCouplingMesh *mesh, int owner)
{
PyObject *ret=0;
if(!mesh)
return ret;
}
-static PyObject *convertFieldDiscretization(MEDCoupling::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertFieldDiscretization(MEDCoupling::MEDCouplingFieldDiscretization *fd, int owner)
{
PyObject *ret=0;
if(!fd)
return ret;
}
-static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner)
{
PyObject *ret=0;
if(!mfs)
return ret;
}
-static PyObject *convertCartesianAMRMesh(MEDCoupling::MEDCouplingCartesianAMRMeshGen *mesh, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertCartesianAMRMesh(MEDCoupling::MEDCouplingCartesianAMRMeshGen *mesh, int owner)
{
if(!mesh)
{
throw INTERP_KERNEL::Exception("convertCartesianAMRMesh wrap : unrecognized type of cartesian AMR mesh !");
}
-static PyObject *convertDataForGodFather(MEDCoupling::MEDCouplingDataForGodFather *data, int owner) throw(INTERP_KERNEL::Exception)
+static PyObject *convertDataForGodFather(MEDCoupling::MEDCouplingDataForGodFather *data, int owner)
{
if(!data)
{
return fieldT_buildSubPart<T>(self,li);
}
+template<class FIELDT>
+PyObject *field_getTinySerializationInformation(const FIELDT *self)
+{
+ 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;
+}
+
+template<class T>
+PyObject *field_serialize(const typename MEDCoupling::Traits<T>::FieldType *self)
+{
+ MEDCoupling::DataArrayInt *ret0(0);
+ std::vector<typename MEDCoupling::Traits<T>::ArrayType *> 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_MEDCoupling__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,convertArray(ret1[i],SWIG_POINTER_OWN | 0));
+ }
+ PyTuple_SetItem(ret,1,ret1Py);
+ return ret;
+}
+
+template<class FIELDT>
+PyObject *field__getnewargs__(FIELDT *self)
+{
+ self->checkConsistencyLight();
+ 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;
+}
+
+template<class FIELDT>
+PyObject *field__getstate__(const FIELDT *self, PyObject *(*tinyserial)(const FIELDT *), PyObject *(*bigserial)(const FIELDT *))
+{
+ self->checkConsistencyLight();
+ PyObject *ret0(tinyserial(self));
+ PyObject *ret1(bigserial(self));
+ const MEDCoupling::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<MEDCoupling::MEDCouplingMesh *>(mesh),SWIG_POINTER_OWN | 0 ));
+ return ret;
+}
+
+template<class T>
+void field__setstate__(typename MEDCoupling::Traits<T>::FieldType *self, PyObject *inp)
+{
+ 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_MEDCoupling__MEDCouplingMesh,0|0));
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ self->setMesh(reinterpret_cast< const MEDCoupling::MEDCouplingMesh * >(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;
+ MEDCoupling::DataArrayInt *b0(0);
+ std::vector<typename MEDCoupling::Traits<T>::ArrayType *>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_MEDCoupling__DataArrayInt,0|0));
+ if(!SWIG_IsOK(status))
+ throw INTERP_KERNEL::Exception(MSG);
+ b0=reinterpret_cast<MEDCoupling::DataArrayInt *>(argp);
+ convertFromPyObjVectorOfObj<typename MEDCoupling::Traits<T>::ArrayType *>(b1py,SWIGTITraits<T>::TI,MEDCoupling::Traits<T>::ArrayTypeName,b1);
+ }
+ self->checkForUnserialization(a1,b0,b1);
+ // useless here to call resizeForUnserialization because arrays are well resized.
+ self->finishUnserialization(a1,a0,a2);
+}
#endif
def MEDCouplingFieldDoubleIpow(self,*args):
import _MEDLoader
return _MEDLoader.MEDCouplingFieldDouble____ipow___(self, self, *args)
+def MEDCouplingFieldIntnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingFieldInt____new___(cls,args)
+def MEDCouplingFieldFloatnew(cls,*args):
+ import _MEDLoader
+ return _MEDLoader.MEDCouplingFieldFloat____new___(cls,args)
def MEDCouplingDataArrayBytenew(cls,*args):
import _MEDLoader
return _MEDLoader.DataArrayByte____new___(cls,args)