X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParaMEDMEM_Swig%2FParaMEDMEM.i;h=5ba926d7fc34034ecfa478a1c857eaae75413c58;hb=8411b13fec372c7635bf04d2bb81a869dc038fdd;hp=abead8842665b80d785692ed036ce86b9e875049;hpb=6f69c981454686d6602cff78f55bed6d3cfaff9e;p=tools%2Fmedcoupling.git diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.i b/src/ParaMEDMEM_Swig/ParaMEDMEM.i index abead8842..5ba926d7f 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEM.i +++ b/src/ParaMEDMEM_Swig/ParaMEDMEM.i @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 @@ -17,251 +17,18 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -%module ParaMEDMEM - -%include "ParaMEDMEM.typemap" -%include "MEDCouplingCommon.i" - -%{ -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "Topology.hxx" -#include "MPIProcessorGroup.hxx" -#include "DEC.hxx" -#include "InterpKernelDEC.hxx" -#include "NonCoincidentDEC.hxx" -#include "StructuredCoincidentDEC.hxx" -#include "ParaMESH.hxx" -#include "ParaFIELD.hxx" -#include "ICoCoMEDField.hxx" -#include "ComponentTopology.hxx" - -#include - -using namespace MEDCoupling; -using namespace ICoCo; - -enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int }; -%} - -%include "CommInterface.hxx" -%include "ProcessorGroup.hxx" -%include "DECOptions.hxx" -%include "ParaMESH.hxx" -%include "ParaFIELD.hxx" -%include "MPIProcessorGroup.hxx" -%include "ComponentTopology.hxx" -%include "DEC.hxx" -%include "InterpKernelDEC.hxx" -%include "StructuredCoincidentDEC.hxx" - -%rename(ICoCoMEDField) ICoCo::MEDField; -%include "ICoCoMEDField.hxx" - -%nodefaultctor; - -/* This object can be used only if MED_ENABLE_FVM is defined*/ -#ifdef MED_ENABLE_FVM -class NonCoincidentDEC : public DEC -{ -public: - NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target); -}; -#endif - -%extend MEDCoupling::ParaMESH -{ - PyObject *getGlobalNumberingCell2() const - { - const int *tmp=self->getGlobalNumberingCell(); - int size=self->getCellMesh()->getNumberOfCells(); - PyObject *ret=PyList_New(size); - for(int i=0;igetGlobalNumberingFace(); - int size=self->getFaceMesh()->getNumberOfCells(); - PyObject *ret=PyList_New(size); - for(int i=0;igetGlobalNumberingNode(); - int size=self->getCellMesh()->getNumberOfNodes(); - PyObject *ret=PyList_New(size); - for(int i=0;i MPI_COMM_WORLD and MPI_COMM_SELF -%typemap(in) MPI_Comm -{ - switch (PyInt_AsLong($input)) - { - case mpi_comm_world: $1 = MPI_COMM_WORLD; break; - case mpi_comm_self: $1 = MPI_COMM_SELF; break; - default: - PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Comm"); - return NULL; - } -} -// Map mpi_double and mpi_int -> MPI_DOUBLE and MPI_INT -%typemap(in) MPI_Datatype -{ - switch (PyInt_AsLong($input)) - { - case mpi_double: $1 = MPI_DOUBLE; break; - case mpi_int: $1 = MPI_INT; break; - default: - PyErr_SetString(PyExc_TypeError,"unexpected value of MPI_Datatype"); - return NULL; - } -} -// The following code gets inserted into the result python file: -// create needed python symbols -%pythoncode %{ -MPI_COMM_WORLD = mpi_comm_world -MPI_COMM_SELF = mpi_comm_self -MPI_DOUBLE = mpi_double -MPI_INT = mpi_int -%} -//============================================================================================= - -// ============== -// MPI_Comm_size -// ============== -%inline %{ PyObject* MPI_Comm_size(MPI_Comm comm) - { - int res = 0; - int err = MPI_Comm_size(comm, &res); - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_size()"); - return NULL; - } - return PyInt_FromLong( res ); - } %} - -// ============== -// MPI_Comm_rank -// ============== -%inline %{ PyObject* MPI_Comm_rank(MPI_Comm comm) - { - int res = 0; - int err = MPI_Comm_rank(comm, &res); - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Comm_rank()"); - return NULL; - } - return PyInt_FromLong( res ); - } - %} - -int MPI_Init(int *argc, char ***argv ); -int MPI_Barrier(MPI_Comm comm); -int MPI_Finalize(); +%module ParaMEDMEM -// ========== -// MPI_Bcast -// ========== +#define MEDCOUPLING_EXPORT +#define INTERPKERNEL_EXPORT -%inline %{ PyObject* MPI_Bcast(PyObject* buffer, int nb, MPI_Datatype type, int root, MPI_Comm c) - { - // buffer must be a list - if (!PyList_Check(buffer)) - { - PyErr_SetString(PyExc_TypeError, "buffer is expected to be a list"); - return NULL; - } - // check list size - int aSize = PyList_Size(buffer); - if ( aSize != nb ) - { - std::ostringstream stream; stream << "buffer is expected to be of size " << nb; - PyErr_SetString(PyExc_ValueError, stream.str().c_str()); - return NULL; - } - // allocate and fill a buffer - void* aBuf = 0; - int* intBuf = 0; - double* dblBuf = 0; - if ( type == MPI_DOUBLE ) - { - aBuf = (void*) ( dblBuf = new double[ nb ] ); - for ( int i = 0; i < aSize; ++i ) - dblBuf[i] = PyFloat_AS_DOUBLE( PyList_GetItem( buffer, i )); - } - else if ( type == MPI_INT ) - { - aBuf = (void*) ( intBuf = new int[ nb ] ); - for ( int i = 0; i < aSize; ++i ) - intBuf[i] = int( PyInt_AS_LONG( PyList_GetItem( buffer, i ))); - } - else - { - PyErr_SetString(PyExc_TypeError, "Only MPI_DOUBLE and MPI_INT supported"); - return NULL; - } - // call MPI_Bcast - int err = MPI_Bcast(aBuf, nb, type, root, c); - // treat error - if ( err != MPI_SUCCESS ) - { - PyErr_SetString(PyExc_RuntimeError,"Erorr in MPI_Bcast()"); - delete [] intBuf; delete [] dblBuf; - return NULL; - } - // put recieved data into the list - int pyerr = 0; - if ( type == MPI_DOUBLE ) - { - for ( int i = 0; i < aSize && !pyerr; ++i ) - pyerr = PyList_SetItem(buffer, i, PyFloat_FromDouble( dblBuf[i] )); - delete [] dblBuf; - } - else - { - for ( int i = 0; i < aSize && !pyerr; ++i ) - pyerr = PyList_SetItem(buffer, i, PyInt_FromLong( intBuf[i] )); - delete [] intBuf; - } - if ( pyerr ) - { - PyErr_SetString(PyExc_RuntimeError, "Error of PyList_SetItem()"); - return NULL; - } - return PyInt_FromLong( err ); +%include "MEDCouplingCommon.i" - } - %} +%include "ParaMEDMEMCommon.i" %pythoncode %{ -def MEDCouplingDataArrayDoublenew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.DataArrayDouble____new___(cls,args) def MEDCouplingDataArrayDoubleIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayDouble____iadd___(self, self, *args) @@ -277,9 +44,6 @@ def MEDCouplingDataArrayDoubleIdiv(self,*args): def MEDCouplingDataArrayDoubleIpow(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayDouble____ipow___(self, self, *args) -def MEDCouplingFieldDoublenew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingFieldDouble____new___(cls,args) def MEDCouplingFieldDoubleIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.MEDCouplingFieldDouble____iadd___(self, self, *args) @@ -295,15 +59,6 @@ def MEDCouplingFieldDoubleIdiv(self,*args): def MEDCouplingFieldDoubleIpow(self,*args): import _ParaMEDMEM return _ParaMEDMEM.MEDCouplingFieldDouble____ipow___(self, self, *args) -def MEDCouplingFieldIntnew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingFieldInt____new___(cls,args) -def MEDCouplingFieldFloatnew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingFieldFloat____new___(cls,args) -def MEDCouplingDataArrayIntnew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.DataArrayInt____new___(cls,args) def MEDCouplingDataArrayIntIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayInt____iadd___(self, self, *args) @@ -322,12 +77,42 @@ def MEDCouplingDataArrayIntImod(self,*args): def MEDCouplingDataArrayIntIpow(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayInt____ipow___(self, self, *args) -def MEDCouplingDataArrayBytenew(cls,*args): +def MEDCouplingDataArrayInt32Iadd(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt32____iadd___(self, self, *args) +def MEDCouplingDataArrayInt32Isub(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt32____isub___(self, self, *args) +def MEDCouplingDataArrayInt32Imul(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt32____imul___(self, self, *args) +def MEDCouplingDataArrayInt32Idiv(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt32____idiv___(self, self, *args) +def MEDCouplingDataArrayInt32Imod(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt32____imod___(self, self, *args) +def MEDCouplingDataArrayInt32Ipow(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayByte____new___(cls,args) -def MEDCouplingDataArrayFloatnew(cls,*args): + return _ParaMEDMEM.DataArrayInt32____ipow___(self, self, *args) +def MEDCouplingDataArrayInt64Iadd(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayFloat____new___(cls,args) + return _ParaMEDMEM.DataArrayInt64____iadd___(self, self, *args) +def MEDCouplingDataArrayInt64Isub(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt64____isub___(self, self, *args) +def MEDCouplingDataArrayInt64Imul(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt64____imul___(self, self, *args) +def MEDCouplingDataArrayInt64Idiv(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt64____idiv___(self, self, *args) +def MEDCouplingDataArrayInt64Imod(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt64____imod___(self, self, *args) +def MEDCouplingDataArrayInt64Ipow(self,*args): + import _ParaMEDMEM + return _ParaMEDMEM.DataArrayInt64____ipow___(self, self, *args) def MEDCouplingDataArrayFloatIadd(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayFloat____iadd___(self, self, *args) @@ -352,48 +137,42 @@ def MEDCouplingDataArrayDoubleTupleImul(self,*args): def MEDCouplingDataArrayDoubleTupleIdiv(self,*args): import _ParaMEDMEM return _ParaMEDMEM.DataArrayDoubleTuple____idiv___(self, self, *args) -def MEDCouplingDataArrayIntTupleIadd(self,*args): +def MEDCouplingDataArrayInt32TupleIadd(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayIntTuple____iadd___(self, self, *args) -def MEDCouplingDataArrayIntTupleIsub(self,*args): + return _ParaMEDMEM.DataArrayInt32Tuple____iadd___(self, self, *args) +def MEDCouplingDataArrayInt32TupleIsub(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayIntTuple____isub___(self, self, *args) -def MEDCouplingDataArrayIntTupleImul(self,*args): + return _ParaMEDMEM.DataArrayInt32Tuple____isub___(self, self, *args) +def MEDCouplingDataArrayInt32TupleImul(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayIntTuple____imul___(self, self, *args) -def MEDCouplingDataArrayIntTupleIdiv(self,*args): + return _ParaMEDMEM.DataArrayInt32Tuple____imul___(self, self, *args) +def MEDCouplingDataArrayInt32TupleIdiv(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayIntTuple____idiv___(self, self, *args) -def MEDCouplingDataArrayIntTupleImod(self,*args): + return _ParaMEDMEM.DataArrayInt32Tuple____idiv___(self, self, *args) +def MEDCouplingDataArrayInt32TupleImod(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DataArrayIntTuple____imod___(self, self, *args) -def ParaMEDMEMDenseMatrixIadd(self,*args): + return _ParaMEDMEM.DataArrayInt32Tuple____imod___(self, self, *args) +def MEDCouplingDataArrayInt64TupleIadd(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DenseMatrix____iadd___(self, self, *args) -def ParaMEDMEMDenseMatrixIsub(self,*args): + return _ParaMEDMEM.DataArrayInt64Tuple____iadd___(self, self, *args) +def MEDCouplingDataArrayInt64TupleIsub(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.DenseMatrix____isub___(self, self, *args) -def MEDCouplingUMeshnew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingUMesh____new___(cls,args) -def MEDCoupling1DGTUMeshnew(cls,*args): - import _ParaMEDMEM - return _ParaMEDMEM.MEDCoupling1DGTUMesh____new___(cls,args) -def MEDCoupling1SGTUMeshnew(cls,*args): + return _ParaMEDMEM.DataArrayInt64Tuple____isub___(self, self, *args) +def MEDCouplingDataArrayInt64TupleImul(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.MEDCoupling1SGTUMesh____new___(cls,args) -def MEDCouplingCurveLinearMeshnew(cls,*args): + return _ParaMEDMEM.DataArrayInt64Tuple____imul___(self, self, *args) +def MEDCouplingDataArrayInt64TupleIdiv(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingCurveLinearMesh____new___(cls,args) -def MEDCouplingCMeshnew(cls,*args): + return _ParaMEDMEM.DataArrayInt64Tuple____idiv___(self, self, *args) +def MEDCouplingDataArrayInt64TupleImod(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingCMesh____new___(cls,args) -def MEDCouplingIMeshnew(cls,*args): + return _ParaMEDMEM.DataArrayInt64Tuple____imod___(self, self, *args) +def MEDCouplingDenseMatrixIadd(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingIMesh____new___(cls,args) -def MEDCouplingExtrudedMeshnew(cls,*args): + return _ParaMEDMEM.DenseMatrix____iadd___(self, self, *args) +def MEDCouplingDenseMatrixIsub(self,*args): import _ParaMEDMEM - return _ParaMEDMEM.MEDCouplingMappedExtrudedMesh____new___(cls,args) + return _ParaMEDMEM.DenseMatrix____isub___(self, self, *args) %} %include "MEDCouplingFinalize.i"