X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingFieldDiscretization.i;h=5394a2cc2f3324e3a6ab0d4ff95994d9d58efd5a;hb=378cb2ebe08f8f4543ef632b2bd5f77fe180f978;hp=cc872bafa493c2dc1b63e7b0053c993675ff08f9;hpb=a8ef1de17a4971fbdf462d30755fa7cb7062bdd4;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i old mode 100644 new mode 100755 index cc872bafa..5394a2cc2 --- a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 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. +// 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 @@ -28,6 +28,7 @@ %newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart; %newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOnMulti; %newobject ParaMEDMEM::MEDCouplingFieldDiscretization::computeTupleIdsToSelectFromCellIds; +%newobject ParaMEDMEM::MEDCouplingFieldDiscretizationKriging::PerformDriftOfVec; namespace ParaMEDMEM { @@ -37,7 +38,7 @@ namespace ParaMEDMEM static MEDCouplingFieldDiscretization *New(TypeOfField type) throw(INTERP_KERNEL::Exception); double getPrecision() const throw(INTERP_KERNEL::Exception); void setPrecision(double val) throw(INTERP_KERNEL::Exception); - static TypeOfField GetTypeOfFieldFromStringRepr(const char *repr) throw(INTERP_KERNEL::Exception); + static TypeOfField GetTypeOfFieldFromStringRepr(const std::string& repr) throw(INTERP_KERNEL::Exception); virtual TypeOfField getEnum() const throw(INTERP_KERNEL::Exception); virtual bool isEqual(const MEDCouplingFieldDiscretization *other, double eps) const throw(INTERP_KERNEL::Exception); virtual bool isEqualIfNotWhy(const MEDCouplingFieldDiscretization *other, double eps, std::string& reason) const throw(INTERP_KERNEL::Exception); @@ -89,13 +90,13 @@ namespace ParaMEDMEM return res; } - virtual int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, PyObject *code, PyObject *idsPerType) const throw(INTERP_KERNEL::Exception) + virtual int getNumberOfTuplesExpectedRegardingCode(PyObject *code, PyObject *idsPerType) const throw(INTERP_KERNEL::Exception) { std::vector inp0; convertPyToNewIntArr4(code,1,3,inp0); std::vector inp1; convertFromPyObjVectorOfObj(idsPerType,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",inp1); - return self->getNumberOfTuplesExpectedRegardingCode(mesh,inp0,inp1); + return self->getNumberOfTuplesExpectedRegardingCode(inp0,inp1); } virtual PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) @@ -345,11 +346,36 @@ namespace ParaMEDMEM class MEDCouplingFieldDiscretizationGaussNE : public MEDCouplingFieldDiscretization { + public: + %extend + { + static PyObject *GetWeightArrayFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception) + { + std::size_t sz(0); + const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetWeightArrayFromGeometricType(geoType,sz)); + return convertDblArrToPyList(ret,sz); + } + + static PyObject *GetRefCoordsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception) + { + std::size_t sz(0); + const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetRefCoordsFromGeometricType(geoType,sz)); + return convertDblArrToPyList(ret,sz); + } + + static PyObject *GetLocsFromGeometricType(INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception) + { + std::size_t sz(0); + const double *ret(MEDCouplingFieldDiscretizationGaussNE::GetLocsFromGeometricType(geoType,sz)); + return convertDblArrToPyList(ret,sz); + } + } }; class MEDCouplingFieldDiscretizationKriging : public MEDCouplingFieldDiscretizationOnNodes { public: + static DataArrayDouble *PerformDriftOfVec(const DataArrayDouble *arr, int isDrift) throw(INTERP_KERNEL::Exception); %extend { PyObject *computeVectorOfCoefficients(const MEDCouplingMesh *mesh, const DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) @@ -372,6 +398,17 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); return ret; } + + PyObject *computeMatrix(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + int ret1(-1),ret2(-1); + DataArrayDouble *ret0=self->computeMatrix(mesh,ret1,ret2); + PyObject *ret=PyTuple_New(3); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); + return ret; + } PyObject *computeEvaluationMatrixOnGivenPts(const MEDCouplingMesh *mesh, PyObject *locs) const throw(INTERP_KERNEL::Exception) { @@ -389,6 +426,47 @@ namespace ParaMEDMEM PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); return ret; } + + void operateOnDenseMatrix(int spaceDimension, DataArrayDouble *myMatrix) const throw(INTERP_KERNEL::Exception) + { + if(!myMatrix || !myMatrix->isAllocated() || myMatrix->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("Wrap of MEDCouplingFieldDiscretizationKriging::operateOnDenseMatrix : invalid input matrix as DataArrayDouble ! Must be allocated with one component !"); + self->operateOnDenseMatrix(spaceDimension,myMatrix->getNumberOfTuples(),myMatrix->getPointer()); + } + + PyObject *performDrift(const DataArrayDouble *matr, const DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + int ret1(-1); + DataArrayDouble *ret0(self->performDrift(matr,arr,ret1)); + PyObject *res(PyTuple_New(2)); + PyTuple_SetItem(res,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0)); + PyTuple_SetItem(res,1,PyInt_FromLong(ret1)); + return res; + } + + static PyObject *PerformDriftRect(const DataArrayDouble *matr, const DataArrayDouble *arr) throw(INTERP_KERNEL::Exception) + { + int ret1(-1); + DataArrayDouble *ret0(MEDCouplingFieldDiscretizationKriging::PerformDriftRect(matr,arr,ret1)); + PyObject *res(PyTuple_New(2)); + PyTuple_SetItem(res,0,SWIG_NewPointerObj((void*)ret0,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,SWIG_POINTER_OWN | 0)); + PyTuple_SetItem(res,1,PyInt_FromLong(ret1)); + return res; + } + + static void OperateOnDenseMatrixH3(DataArrayDouble *myMatrix) throw(INTERP_KERNEL::Exception) + { + if(!myMatrix || !myMatrix->isAllocated() || myMatrix->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("Wrap of MEDCouplingFieldDiscretizationKriging::OperateOnDenseMatrixH3 : invalid input matrix as DataArrayDouble ! Must be allocated with one component !"); + MEDCouplingFieldDiscretizationKriging::OperateOnDenseMatrixH3(myMatrix->getNumberOfTuples(),myMatrix->getPointer()); + } + + static void OperateOnDenseMatrixH2Ln(DataArrayDouble *myMatrix) throw(INTERP_KERNEL::Exception) + { + if(!myMatrix || !myMatrix->isAllocated() || myMatrix->getNumberOfComponents()!=1) + throw INTERP_KERNEL::Exception("Wrap of MEDCouplingFieldDiscretizationKriging::OperateOnDenseMatrixH2Ln : invalid input matrix as DataArrayDouble ! Must be allocated with one component !"); + MEDCouplingFieldDiscretizationKriging::OperateOnDenseMatrixH2Ln(myMatrix->getNumberOfTuples(),myMatrix->getPointer()); + } } }; }