X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling_Swig%2FMEDCouplingFieldDiscretization.i;h=ced6d8b499ba99e7933112968f09f3ef030f42ca;hb=0b187729ac99d3e9e9bb9d2be8cb8600a783be6c;hp=6c6858cc424917c91fdbb7da1d0bb65811149ba5;hpb=e1c9bf0e2aad8bb4e3fbd99e6f7a6409aa4f20ea;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i index 6c6858cc4..ced6d8b49 100644 --- 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-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. +// 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 @@ -18,18 +18,19 @@ // // Author : Anthony Geay (CEA/DEN) -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::New; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::deepCpy; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clone; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePartRange; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getLocalizationOfDiscValues; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOnMulti; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::computeTupleIdsToSelectFromCellIds; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::New; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::deepCpy; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::clone; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::clonePartRange; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::getOffsetArr; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::getLocalizationOfDiscValues; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::getMeasureField; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::clonePart; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::getValueOnMulti; +%newobject MEDCoupling::MEDCouplingFieldDiscretization::computeTupleIdsToSelectFromCellIds; +%newobject MEDCoupling::MEDCouplingFieldDiscretizationKriging::PerformDriftOfVec; -namespace ParaMEDMEM +namespace MEDCoupling { class MEDCouplingFieldDiscretization : public RefCountObject, public TimeLabel { @@ -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); @@ -80,7 +81,7 @@ namespace ParaMEDMEM PyObject *res=PyTuple_New(2); PyTuple_SetItem(res,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 )); if(ret1) - PyTuple_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,SWIG_POINTER_OWN | 0)); + PyTuple_SetItem(res,1,SWIG_NewPointerObj((void*)ret1,SWIGTYPE_p_MEDCoupling__DataArrayInt,SWIG_POINTER_OWN | 0)); else { PyObject *res1=PySlice_New(PyInt_FromLong(bb),PyInt_FromLong(ee),PyInt_FromLong(ss)); @@ -94,7 +95,7 @@ namespace ParaMEDMEM std::vector inp0; convertPyToNewIntArr4(code,1,3,inp0); std::vector inp1; - convertFromPyObjVectorOfObj(idsPerType,SWIGTYPE_p_ParaMEDMEM__DataArrayInt,"DataArrayInt",inp1); + convertFromPyObjVectorOfObj(idsPerType,SWIGTYPE_p_MEDCoupling__DataArrayInt,"DataArrayInt",inp1); return self->getNumberOfTuplesExpectedRegardingCode(inp0,inp1); } @@ -108,8 +109,8 @@ namespace ParaMEDMEM DataArrayInt *ret0=0,*ret1=0; self->computeMeshRestrictionFromTupleIds(mesh,tupleIdsBg,tupleIdsBg+sz,ret0,ret1); PyObject *pyRet=PyTuple_New(2); - PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(pyRet,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(pyRet,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); return pyRet; } @@ -150,14 +151,14 @@ namespace ParaMEDMEM DataArrayInt *ret=DataArrayInt::New(); ret->alloc((int)tmp.size(),1); std::copy(tmp.begin(),tmp.end(),ret->getPointer()); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); } virtual void setGaussLocalizationOnCells(const MEDCouplingMesh *m, PyObject *li, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception) { void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); + int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_MEDCoupling__DataArrayInt, 0 | 0 ); if (!SWIG_IsOK(res1)) { int size; @@ -214,7 +215,7 @@ namespace ParaMEDMEM throw INTERP_KERNEL::Exception("Python wrap MEDCouplingFieldDiscretization::getValueOnMulti : null input mesh !"); // int sw,nbPts; - double v0; ParaMEDMEM::DataArrayDouble *v1(0); ParaMEDMEM::DataArrayDoubleTuple *v2(0); std::vector v3; + double v0; MEDCoupling::DataArrayDouble *v1(0); MEDCoupling::DataArrayDoubleTuple *v2(0); std::vector v3; const double *inp=convertObjToPossibleCpp5_Safe2(loc,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDouble::getValueOnMulti", mesh->getSpaceDimension(),true,nbPts); return self->getValueOnMulti(arr,mesh,inp,nbPts); @@ -232,7 +233,7 @@ namespace ParaMEDMEM PyObject *old2New, bool check) throw(INTERP_KERNEL::Exception) { std::vector input1; - convertFromPyObjVectorOfObj(arrays,SWIGTYPE_p_ParaMEDMEM__DataArray,"DataArray",input1); + convertFromPyObjVectorOfObj(arrays,SWIGTYPE_p_MEDCoupling__DataArray,"DataArray",input1); // int sw,sz(-1); int v0; std::vector v1; @@ -258,7 +259,7 @@ namespace ParaMEDMEM MEDCouplingMesh *ret0=self->buildSubMeshData(mesh,idsBg,idsBg+sz,di); PyObject *ret=PyTuple_New(2); PyTuple_SetItem(ret,0,convertMesh(ret0, SWIG_POINTER_OWN | 0 )); - PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(di),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(di),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 )); return ret; } @@ -312,7 +313,7 @@ namespace ParaMEDMEM DataArrayInt *ret=const_cast(self->getArrayOfDiscIds()); if(ret) ret->incrRef(); - return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ); + return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_MEDCoupling__DataArrayInt, SWIG_POINTER_OWN | 0 ); } PyObject *splitIntoSingleGaussDicrPerCellType() const throw(INTERP_KERNEL::Exception) @@ -325,7 +326,7 @@ namespace ParaMEDMEM PyObject *pyRet1=PyList_New((int)sz); for(std::size_t i=0;icomputeVectorOfCoefficients(mesh,arr,ret1); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); return ret; } @@ -391,7 +393,18 @@ namespace ParaMEDMEM int ret1(-1),ret2(-1); DataArrayDouble *ret0=self->computeInverseMatrix(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,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); + 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_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); PyTuple_SetItem(ret,1,PyInt_FromLong(ret1)); PyTuple_SetItem(ret,2,PyInt_FromLong(ret2)); return ret; @@ -402,17 +415,58 @@ namespace ParaMEDMEM if(!mesh) throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretizationKriging::computeEvaluationMatrixOnGivenPts : input mesh is empty !"); int sw,nbPts; - double v0; ParaMEDMEM::DataArrayDouble *v1(0); ParaMEDMEM::DataArrayDoubleTuple *v2(0); std::vector v3; + double v0; MEDCoupling::DataArrayDouble *v1(0); MEDCoupling::DataArrayDoubleTuple *v2(0); std::vector v3; const double *inp=convertObjToPossibleCpp5_Safe2(locs,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDiscretizationKriging::computeEvaluationMatrixOnGivenPts", mesh->getSpaceDimension(),true,nbPts); // int ret1(-1); DataArrayDouble *ret0=self->computeEvaluationMatrixOnGivenPts(mesh,inp,nbPts,ret1); PyObject *ret=PyTuple_New(2); - PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_MEDCoupling__DataArrayDouble, SWIG_POINTER_OWN | 0 )); 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_MEDCoupling__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_MEDCoupling__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()); + } } }; }