From b4ae996b174d68f4aafe9656cabb5eee839daf3c Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 20 Aug 2013 10:18:45 +0000 Subject: [PATCH] Cleanup swigging. --- src/MEDCoupling_Swig/CMakeLists.txt | 3 +- src/MEDCoupling_Swig/MEDCouplingCommon.i | 257 +----------- .../MEDCouplingFieldDiscretization.i | 394 ++++++++++++++++++ 3 files changed, 416 insertions(+), 238 deletions(-) create mode 100644 src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i diff --git a/src/MEDCoupling_Swig/CMakeLists.txt b/src/MEDCoupling_Swig/CMakeLists.txt index b948b0a74..ae3c2479b 100644 --- a/src/MEDCoupling_Swig/CMakeLists.txt +++ b/src/MEDCoupling_Swig/CMakeLists.txt @@ -28,6 +28,7 @@ ENDIF(NUMPY_FOUND) SET (MEDCoupling_SWIG_DPYS_FILES MEDCouplingCommon.i MEDCouplingMemArray.i + MEDCouplingFieldDiscretization.i MEDCouplingFinalize.i MEDCouplingTypemaps.i) @@ -77,7 +78,7 @@ INSTALL(TARGETS ${SWIG_MODULE_MEDCoupling_REAL_NAME} ${SWIG_MODULE_MEDCouplingRe SET(PYFILES_TO_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/MEDCoupling.py ${CMAKE_CURRENT_BINARY_DIR}/MEDCouplingRemapper.py) INSTALL_AND_COMPILE_PYTHON_FILE("${PYFILES_TO_INSTALL}" ${SALOME_INSTALL_SCRIPT_PYTHON}) -INSTALL(FILES MEDCoupling.i MEDCouplingCommon.i MEDCouplingMemArray.i MEDCouplingFinalize.i MEDCouplingRemapper.i MEDCouplingTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS}) +INSTALL(FILES MEDCoupling.i MEDCouplingCommon.i MEDCouplingMemArray.i MEDCouplingFieldDiscretization.i MEDCouplingFinalize.i MEDCouplingRemapper.i MEDCouplingTypemaps.i DESTINATION ${SALOME_INSTALL_HEADERS}) INSTALL(FILES MEDCouplingBasicsTest.py MEDCouplingRemapperTest.py MEDCouplingDataForTest.py MEDCouplingNumPyTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}) INSTALL(FILES MEDCouplingExamplesTest.py DESTINATION ${SALOME_INSTALL_SCRIPT_PYTHON}) diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 3da4c59fb..17b2548be 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -157,18 +157,6 @@ using namespace INTERP_KERNEL; %feature("autodoc", "1"); %feature("docstring"); -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::New; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::deepCpy; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clone; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::clonePartRange; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getOffsetArr; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getLocalizationOfDiscValues; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOnMulti; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::computeTupleIdsToSelectFromCellIds; -%newobject ParaMEDMEM::MEDCouplingFieldDiscretization::buildSubMeshData; %newobject ParaMEDMEM::MEDCouplingField::buildMeasureField; %newobject ParaMEDMEM::MEDCouplingField::getLocalizationOfDiscr; %newobject ParaMEDMEM::MEDCouplingField::computeTupleIdsToSelectFromCellIds; @@ -820,22 +808,10 @@ namespace ParaMEDMEM void renumberCells(PyObject *li, bool check=true) throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayInt, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); - self->renumberCells(tmp,check); - } - else - { - DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); - da2->checkAllocated(); - self->renumberCells(da2->getConstPointer(),check); - } + int sw,sz(-1); + int v0; std::vector v1; + const int *ids(convertObjToPossibleCpp1_Safe(li,sw,sz,v0,v1)); + self->renumberCells(ids,check); } PyObject *checkGeoEquivalWith(const MEDCouplingMesh *other, int levOfCheck, double prec) const throw(INTERP_KERNEL::Exception) @@ -1115,11 +1091,8 @@ namespace ParaMEDMEM %include "MEDCouplingNatureOfField.hxx" %include "MEDCouplingTimeDiscretization.hxx" %include "MEDCouplingGaussLocalization.hxx" -%include "MEDCouplingFieldDiscretization.hxx" -%ignore ParaMEDMEM::MEDCouplingFieldDiscretization::clonePart; -%ignore ParaMEDMEM::MEDCouplingFieldDiscretization::buildSubMeshDataRange; -%ignore ParaMEDMEM::MEDCouplingFieldDiscretizationPerCell::getArrayOfDiscIds; +%include "MEDCouplingFieldDiscretization.i" //== MEDCouplingPointSet @@ -3136,152 +3109,6 @@ namespace ParaMEDMEM //== MEDCouplingCurveLinearMesh End } -%extend ParaMEDMEM::MEDCouplingFieldDiscretization -{ - MEDCouplingFieldDiscretization *clonePart(PyObject *li) - { - int sz=0,sw=-1,val1=-1; - std::vector val2; - const int *inp=convertObjToPossibleCpp1_Safe(li,sw,sz,val1,val2); - return self->clonePart(inp,inp+sz); - } - - PyObject *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const throw(INTERP_KERNEL::Exception) - { - DataArrayInt *ret1=0; - int bb,ee,ss; - MEDCouplingMesh *ret0=self->buildSubMeshDataRange(mesh,begin,end,step,bb,ee,ss,ret1); - 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)); - else - { - PyObject *res1=PySlice_New(PyInt_FromLong(bb),PyInt_FromLong(ee),PyInt_FromLong(ss)); - PyTuple_SetItem(res,1,res1); - } - return res; - } - - PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) - { - std::vector vVal; int iVal=-1; - int sz=-1,sw=0; - const int *tupleIdsBg=convertObjToPossibleCpp1_Safe(tupleIds,sw,sz,iVal,vVal); - if(sw==0) - throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::computeMeshRestrictionFromTupleIds : none parameter in input !"); - 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 )); - return pyRet; - } - - int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, 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); - } -} - -%extend ParaMEDMEM::MEDCouplingFieldDiscretizationP0 -{ - PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) - { return ParaMEDMEM_MEDCouplingFieldDiscretization_computeMeshRestrictionFromTupleIds__SWIG_1(self,mesh,tupleIds); } -} - -%extend ParaMEDMEM::MEDCouplingFieldDiscretizationOnNodes -{ - PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) - { return ParaMEDMEM_MEDCouplingFieldDiscretization_computeMeshRestrictionFromTupleIds__SWIG_1(self,mesh,tupleIds); } -} - -%extend ParaMEDMEM::MEDCouplingFieldDiscretizationGauss -{ - PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) - { return ParaMEDMEM_MEDCouplingFieldDiscretization_computeMeshRestrictionFromTupleIds__SWIG_1(self,mesh,tupleIds); } -} - -%extend ParaMEDMEM::MEDCouplingFieldDiscretizationGaussNE -{ - PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) - { return ParaMEDMEM_MEDCouplingFieldDiscretization_computeMeshRestrictionFromTupleIds__SWIG_1(self,mesh,tupleIds); } -} - -%extend ParaMEDMEM::MEDCouplingFieldDiscretizationPerCell -{ - PyObject *getArrayOfDiscIds() const - { - 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 ); - } - - PyObject *splitIntoSingleGaussDicrPerCellType() const throw(INTERP_KERNEL::Exception) - { - std::vector ret1; - std::vector ret0=self->splitIntoSingleGaussDicrPerCellType(ret1); - std::size_t sz=ret0.size(); - PyObject *pyRet=PyTuple_New(2); - PyObject *pyRet0=PyList_New((int)sz); - 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,1,PyInt_FromLong(ret1)); - return ret; - } - - PyObject *computeInverseMatrix(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) - { - 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,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) - { - 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; - 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,1,PyInt_FromLong(ret1)); - return ret; - } -} - namespace ParaMEDMEM { class MEDCouplingField : public ParaMEDMEM::RefCountObject, public ParaMEDMEM::TimeLabel @@ -3391,31 +3218,12 @@ namespace ParaMEDMEM return res; } - DataArrayInt *computeTupleIdsToSelectFromCellIds(PyObject *li) const + DataArrayInt *computeTupleIdsToSelectFromCellIds(PyObject *cellIds) const { - int sw; - int pos1; - std::vector pos2; - DataArrayInt *pos3=0; - DataArrayIntTuple *pos4=0; - convertObjToPossibleCpp1(li,sw,pos1,pos2,pos3,pos4); - switch(sw) - { - case 1: - { - return self->computeTupleIdsToSelectFromCellIds(&pos1,&pos1+1); - } - case 2: - { - return self->computeTupleIdsToSelectFromCellIds(&pos2[0],&pos2[0]+pos2.size()); - } - case 3: - { - return self->computeTupleIdsToSelectFromCellIds(pos3->begin(),pos3->end()); - } - default: - throw INTERP_KERNEL::Exception("MEDCouplingField::computeTupleIdsToSelectFromCellIds : unexpected input array type recognized !"); - } + int sw,sz(-1); + int v0; std::vector v1; + const int *cellIdsBg(convertObjToPossibleCpp1_Safe(cellIds,sw,sz,v0,v1)); + return self->computeTupleIdsToSelectFromCellIds(cellIdsBg,cellIdsBg+sz); } void setGaussLocalizationOnCells(PyObject *li, const std::vector& refCoo, @@ -3684,42 +3492,17 @@ namespace ParaMEDMEM return convertDblArrToPyList(res,sz); } - DataArrayDouble *getValueOnMulti(PyObject *li) const throw(INTERP_KERNEL::Exception) + DataArrayDouble *getValueOnMulti(PyObject *locs) const throw(INTERP_KERNEL::Exception) { - void *da=0; - int res1=SWIG_ConvertPtr(li,&da,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, 0 | 0 ); - if (!SWIG_IsOK(res1)) - { - int size; - INTERP_KERNEL::AutoCPtr tmp=convertPyToNewDblArr2(li,&size); - const MEDCouplingMesh *mesh=self->getMesh(); - if(!mesh) - throw INTERP_KERNEL::Exception("Python wrap MEDCouplingFieldDouble::getValueOnMulti : lying on a null mesh !"); - int spaceDim=mesh->getSpaceDimension(); - int nbOfPoints=size/spaceDim; - if(size%spaceDim!=0) - { - throw INTERP_KERNEL::Exception("Invalid list length ! Must be a multiple of self.getMesh().getSpaceDimension() !"); - } - return self->getValueOnMulti(tmp,nbOfPoints); - } - else - { - DataArrayDouble *da2=reinterpret_cast< DataArrayDouble * >(da); - if(!da2) - throw INTERP_KERNEL::Exception("Not null DataArrayDouble instance expected !"); - da2->checkAllocated(); - int size=da2->getNumberOfTuples(); - int nbOfCompo=da2->getNumberOfComponents(); - const MEDCouplingMesh *mesh=self->getMesh(); - if(!mesh) - throw INTERP_KERNEL::Exception("Python wrap MEDCouplingFieldDouble::getValueOnMulti : lying on a null mesh !"); - if(nbOfCompo!=mesh->getSpaceDimension()) - { - throw INTERP_KERNEL::Exception("Invalid DataArrayDouble nb of components ! Expected same as self.getMesh().getSpaceDimension() !"); - } - return self->getValueOnMulti(da2->getConstPointer(),size); - } + const MEDCouplingMesh *mesh(self->getMesh()); + if(!mesh) + throw INTERP_KERNEL::Exception("Python wrap MEDCouplingFieldDouble::getValueOnMulti : lying on a null mesh !"); + // + int sw,nbPts; + double v0; ParaMEDMEM::DataArrayDouble *v1(0); ParaMEDMEM::DataArrayDoubleTuple *v2(0); std::vector v3; + const double *inp=convertObjToPossibleCpp5_Safe2(locs,sw,v0,v1,v2,v3,"wrap of MEDCouplingFieldDouble::getValueOnMulti", + mesh->getSpaceDimension(),true,nbPts); + return self->getValueOnMulti(inp,nbPts); } PyObject *getValueOn(PyObject *sl, double time) const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i new file mode 100644 index 000000000..cc872bafa --- /dev/null +++ b/src/MEDCoupling_Swig/MEDCouplingFieldDiscretization.i @@ -0,0 +1,394 @@ +// Copyright (C) 2007-2013 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. +// +// 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 +// +// 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; + +namespace ParaMEDMEM +{ + class MEDCouplingFieldDiscretization : public RefCountObject, public TimeLabel + { + public: + 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); + 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); + virtual bool isEqualWithoutConsideringStr(const MEDCouplingFieldDiscretization *other, double eps) const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDiscretization *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDiscretization *clone() const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDiscretization *clonePartRange(int beginCellIds, int endCellIds, int stepCellIds) const throw(INTERP_KERNEL::Exception); + virtual std::string getStringRepr() const throw(INTERP_KERNEL::Exception); + virtual const char *getRepr() const throw(INTERP_KERNEL::Exception); + virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + virtual int getNumberOfMeshPlaces(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + virtual DataArrayInt *getOffsetArr(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + virtual DataArrayDouble *getLocalizationOfDiscValues(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception); + virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception); + virtual double getIJK(const MEDCouplingMesh *mesh, const DataArrayDouble *da, int cellId, int nodeIdInCell, int compoId) const throw(INTERP_KERNEL::Exception); + virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArray *da) const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingFieldDouble *getMeasureField(const MEDCouplingMesh *mesh, bool isAbs) const throw(INTERP_KERNEL::Exception); + virtual void setGaussLocalizationOnType(const MEDCouplingMesh *m, INTERP_KERNEL::NormalizedCellType type, const std::vector& refCoo, + const std::vector& gsCoo, const std::vector& wg) throw(INTERP_KERNEL::Exception); + virtual void clearGaussLocalizations() throw(INTERP_KERNEL::Exception); + virtual MEDCouplingGaussLocalization& getGaussLocalization(int locId) throw(INTERP_KERNEL::Exception); + virtual int getNbOfGaussLocalization() const throw(INTERP_KERNEL::Exception); + virtual int getGaussLocalizationIdOfOneCell(int cellId) const throw(INTERP_KERNEL::Exception); + virtual int getGaussLocalizationIdOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception); + %extend + { + virtual MEDCouplingFieldDiscretization *clonePart(PyObject *li) + { + int sz=0,sw=-1,val1=-1; + std::vector val2; + const int *inp=convertObjToPossibleCpp1_Safe(li,sw,sz,val1,val2); + return self->clonePart(inp,inp+sz); + } + + virtual PyObject *buildSubMeshDataRange(const MEDCouplingMesh *mesh, int beginCellIds, int endCellIds, int stepCellIds, int& beginOut, int& endOut, int& stepOut, DataArrayInt *&di) const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *ret1=0; + int bb,ee,ss; + MEDCouplingMesh *ret0=self->buildSubMeshDataRange(mesh,beginCellIds,endCellIds,stepCellIds,bb,ee,ss,ret1); + 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)); + else + { + PyObject *res1=PySlice_New(PyInt_FromLong(bb),PyInt_FromLong(ee),PyInt_FromLong(ss)); + PyTuple_SetItem(res,1,res1); + } + return res; + } + + virtual int getNumberOfTuplesExpectedRegardingCode(const MEDCouplingMesh *mesh, 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); + } + + virtual PyObject *computeMeshRestrictionFromTupleIds(const MEDCouplingMesh *mesh, PyObject *tupleIds) const throw(INTERP_KERNEL::Exception) + { + std::vector vVal; int iVal=-1; + int sz=-1,sw=0; + const int *tupleIdsBg=convertObjToPossibleCpp1_Safe(tupleIds,sw,sz,iVal,vVal); + if(sw==0) + throw INTERP_KERNEL::Exception("MEDCouplingFieldDiscretization::computeMeshRestrictionFromTupleIds : none parameter in input !"); + 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 )); + return pyRet; + } + + virtual PyObject *normL1(const MEDCouplingMesh *mesh, const DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + if(!arr) + throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL1 : input array is null !"); + int sz(arr->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->normL1(mesh,arr,tmp); + return convertDblArrToPyList(tmp,sz); + } + + virtual PyObject *normL2(const MEDCouplingMesh *mesh, const DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + if(!arr) + throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::normL2 : input array is null !"); + int sz(arr->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->normL2(mesh,arr,tmp); + return convertDblArrToPyList(tmp,sz); + } + + virtual PyObject *integral(const MEDCouplingMesh *mesh, const DataArrayDouble *arr, bool isWAbs) const throw(INTERP_KERNEL::Exception) + { + if(!arr) + throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::integral : input array is null !"); + int sz(arr->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr tmp=new double[sz]; + self->integral(mesh,arr,isWAbs,tmp); + return convertDblArrToPyList(tmp,sz); + } + + virtual PyObject *getCellIdsHavingGaussLocalization(int locId) const throw(INTERP_KERNEL::Exception) + { + std::vector tmp; + self->getCellIdsHavingGaussLocalization(locId,tmp); + 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 ); + } + + 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 ); + if (!SWIG_IsOK(res1)) + { + int size; + INTERP_KERNEL::AutoPtr tmp=convertPyToNewIntArr2(li,&size); + self->setGaussLocalizationOnCells(m,tmp,((int *)tmp)+size,refCoo,gsCoo,wg); + } + else + { + DataArrayInt *da2=reinterpret_cast< DataArrayInt * >(da); + if(!da2) + throw INTERP_KERNEL::Exception("Not null DataArrayInt instance expected !"); + da2->checkAllocated(); + self->setGaussLocalizationOnCells(m,da2->getConstPointer(),da2->getConstPointer()+da2->getNbOfElems(),refCoo,gsCoo,wg); + } + } + + virtual PyObject *getGaussLocalizationIdsOfOneType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) + { + std::set ret=self->getGaussLocalizationIdsOfOneType(type); + return convertIntArrToPyList3(ret); + } + + virtual PyObject *getValueOn(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, PyObject *sl) const throw(INTERP_KERNEL::Exception) + { + double val; + DataArrayDouble *a; + DataArrayDoubleTuple *aa; + std::vector bb; + int sw; + if(!mesh) + throw INTERP_KERNEL::Exception("Python wrap of MEDCouplingFieldDiscretization::getValueOn : no underlying mesh !"); + int spaceDim=mesh->getSpaceDimension(); + const char msg[]="Python wrap of MEDCouplingFieldDiscretization::getValueOn : "; + const double *spaceLoc=convertObjToPossibleCpp5_Safe(sl,sw,val,a,aa,bb,msg,1,spaceDim,true); + // + INTERP_KERNEL::AutoPtr res(new double[spaceDim]); + self->getValueOn(arr,mesh,spaceLoc,res); + return convertDblArrToPyList(res,spaceDim); + } + + virtual PyObject *getValueOnPos(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, int i, int j, int k) const throw(INTERP_KERNEL::Exception) + { + if(!arr) + throw INTERP_KERNEL::Exception("wrap of MEDCouplingFieldDiscretization::getValueOnPos : input array is null !"); + int sz(arr->getNumberOfComponents()); + INTERP_KERNEL::AutoPtr res=new double[sz]; + self->getValueOnPos(arr,mesh,i,j,k,res); + return convertDblArrToPyList(res,sz); + } + + virtual DataArrayDouble *getValueOnMulti(const DataArrayDouble *arr, const MEDCouplingMesh *mesh, PyObject *loc) const throw(INTERP_KERNEL::Exception) + { + if(!mesh) + 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; + 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); + } + + virtual void renumberCells(PyObject *li, bool check=true) throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *ids(convertObjToPossibleCpp1_Safe(li,sw,sz,v0,v1)); + self->renumberCells(ids,check); + } + + virtual void renumberArraysForCell(const MEDCouplingMesh *mesh, PyObject *arrays, + PyObject *old2New, bool check) throw(INTERP_KERNEL::Exception) + { + std::vector input1; + convertFromPyObjVectorOfObj(arrays,SWIGTYPE_p_ParaMEDMEM__DataArray,"DataArray",input1); + // + int sw,sz(-1); + int v0; std::vector v1; + const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + // + self->renumberArraysForCell(mesh,input1,old2NewBg,check); + } + + virtual DataArrayInt *computeTupleIdsToSelectFromCellIds(const MEDCouplingMesh *mesh, PyObject *cellIds) const throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *cellIdsBg(convertObjToPossibleCpp1_Safe(cellIds,sw,sz,v0,v1)); + return self->computeTupleIdsToSelectFromCellIds(mesh,cellIdsBg,cellIdsBg+sz); + } + + virtual PyObject *buildSubMeshData(const MEDCouplingMesh *mesh, PyObject *ids) const throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *idsBg(convertObjToPossibleCpp1_Safe(ids,sw,sz,v0,v1)); + DataArrayInt *di(0); + 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 )); + return ret; + } + + virtual void renumberValuesOnNodes(double epsOnVals, PyObject *old2New, int newNbOfNodes, DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + self->renumberValuesOnNodes(epsOnVals,old2NewBg,newNbOfNodes,arr); + } + + virtual void renumberValuesOnCells(double epsOnVals, const MEDCouplingMesh *mesh, PyObject *old2New, int newSz, DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *old2NewBg(convertObjToPossibleCpp1_Safe(old2New,sw,sz,v0,v1)); + self->renumberValuesOnCells(epsOnVals,mesh,old2NewBg,newSz,arr); + } + + virtual void renumberValuesOnCellsR(const MEDCouplingMesh *mesh, PyObject *new2old, int newSz, DataArrayDouble *arr) const throw(INTERP_KERNEL::Exception) + { + int sw,sz(-1); + int v0; std::vector v1; + const int *new2oldBg(convertObjToPossibleCpp1_Safe(new2old,sw,sz,v0,v1)); + self->renumberValuesOnCellsR(mesh,new2oldBg,newSz,arr); + } + } + }; + + class MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization + { + }; + + class MEDCouplingFieldDiscretizationOnNodes : public MEDCouplingFieldDiscretization + { + }; + + class MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretizationOnNodes + { + }; + + class MEDCouplingFieldDiscretizationPerCell : public MEDCouplingFieldDiscretization + { + public: + void setArrayOfDiscIds(const DataArrayInt *adids) throw(INTERP_KERNEL::Exception); + void checkNoOrphanCells() const throw(INTERP_KERNEL::Exception); + %extend + { + PyObject *getArrayOfDiscIds() const + { + 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 ); + } + + PyObject *splitIntoSingleGaussDicrPerCellType() const throw(INTERP_KERNEL::Exception) + { + std::vector ret1; + std::vector ret0=self->splitIntoSingleGaussDicrPerCellType(ret1); + std::size_t sz=ret0.size(); + PyObject *pyRet=PyTuple_New(2); + PyObject *pyRet0=PyList_New((int)sz); + 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,1,PyInt_FromLong(ret1)); + return ret; + } + + PyObject *computeInverseMatrix(const MEDCouplingMesh *mesh) const throw(INTERP_KERNEL::Exception) + { + 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,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) + { + 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; + 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,1,PyInt_FromLong(ret1)); + return ret; + } + } + }; +} -- 2.39.2