-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-%module ParaMEDMEM
-
-%include "ParaMEDMEM.typemap"
-%include "MEDLoaderCommon.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 <mpi.h>
-
-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;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-
- PyObject *getGlobalNumberingFace2() const
- {
- const int *tmp=self->getGlobalNumberingFace();
- int size=self->getFaceMesh()->getNumberOfCells();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-
- PyObject *getGlobalNumberingNode2() const
- {
- const int *tmp=self->getGlobalNumberingNode();
- int size=self->getCellMesh()->getNumberOfNodes();
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(tmp[i]));
- return ret;
- }
-}
-
-//=============================================================================================
-// Interface for MPI-realization-specific constants like MPI_COMM_WORLD.
-//
-// Type and values of constants like MPI_COMM_WORLD depends on MPI realization
-// and usually such constants actually are macros. To have such symbols in python
-// and translate them into correct values we use the following technique.
-// We define some constants (enum mpi_constants) and map them into real MPI values
-// using typemaps, and we create needed python symbols equal to 'mpi_constants'
-// via %pythoncode directive.
-
-// Constants corresponding to similar MPI definitions
-enum mpi_constants { mpi_comm_world, mpi_comm_self, mpi_double, mpi_int };
+// Author : Anthony Geay (EDF R&D)
-// Map mpi_comm_world and mpi_comm_self -> 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 "ICoCoMEDField.i"
- }
- %}
+%include "ParaMEDMEMCommon.i"
%pythoncode %{
-def ParaMEDMEMDataArrayDoublenew(cls,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayDouble____new___(cls,args)
-def ParaMEDMEMDataArrayDoubleIadd(self,*args):
+def MEDCouplingDataArrayDoubleIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____iadd___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleIsub(self,*args):
+def MEDCouplingDataArrayDoubleIsub(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____isub___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleImul(self,*args):
+def MEDCouplingDataArrayDoubleImul(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____imul___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleIdiv(self,*args):
+def MEDCouplingDataArrayDoubleIdiv(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____idiv___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleIpow(self,*args):
+def MEDCouplingDataArrayDoubleIpow(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayDouble____ipow___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayDoubleTuple____iadd___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayDoubleTuple____isub___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayDoubleTuple____imul___(self, self, *args)
-def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayDoubleTuple____idiv___(self, self, *args)
-def ParaMEDMEMMEDCouplingFieldDoublenew(cls,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.MEDCouplingFieldDouble____new___(cls,args)
-def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
+def MEDCouplingFieldDoubleIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____iadd___(self, self, *args)
-def ParaMEDMEMMEDCouplingFieldDoubleIsub(self,*args):
+def MEDCouplingFieldDoubleIsub(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____isub___(self, self, *args)
-def ParaMEDMEMMEDCouplingFieldDoubleImul(self,*args):
+def MEDCouplingFieldDoubleImul(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____imul___(self, self, *args)
-def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args):
+def MEDCouplingFieldDoubleIdiv(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____idiv___(self, self, *args)
-def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
+def MEDCouplingFieldDoubleIpow(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.MEDCouplingFieldDouble____ipow___(self, self, *args)
-def ParaMEDMEMDataArrayIntnew(cls,*args):
- import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayInt____new___(cls,args)
-def ParaMEDMEMDataArrayIntIadd(self,*args):
+def MEDCouplingDataArrayIntIadd(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____iadd___(self, self, *args)
-def ParaMEDMEMDataArrayIntIsub(self,*args):
+def MEDCouplingDataArrayIntIsub(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____isub___(self, self, *args)
-def ParaMEDMEMDataArrayIntImul(self,*args):
+def MEDCouplingDataArrayIntImul(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____imul___(self, self, *args)
-def ParaMEDMEMDataArrayIntIdiv(self,*args):
+def MEDCouplingDataArrayIntIdiv(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____idiv___(self, self, *args)
-def ParaMEDMEMDataArrayIntImod(self,*args):
+def MEDCouplingDataArrayIntImod(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____imod___(self, self, *args)
-def ParaMEDMEMDataArrayIntIpow(self,*args):
+def MEDCouplingDataArrayIntIpow(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DataArrayInt____ipow___(self, self, *args)
-def ParaMEDMEMDataArrayIntTupleIadd(self,*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.DataArrayInt32____ipow___(self, self, *args)
+def MEDCouplingDataArrayInt64Iadd(self,*args):
+ import _ParaMEDMEM
+ 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)
+def MEDCouplingDataArrayFloatIsub(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayFloat____isub___(self, self, *args)
+def MEDCouplingDataArrayFloatImul(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayFloat____imul___(self, self, *args)
+def MEDCouplingDataArrayFloatIdiv(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayFloat____idiv___(self, self, *args)
+def MEDCouplingDataArrayDoubleTupleIadd(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayDoubleTuple____iadd___(self, self, *args)
+def MEDCouplingDataArrayDoubleTupleIsub(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayDoubleTuple____isub___(self, self, *args)
+def MEDCouplingDataArrayDoubleTupleImul(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayDoubleTuple____imul___(self, self, *args)
+def MEDCouplingDataArrayDoubleTupleIdiv(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayDoubleTuple____idiv___(self, self, *args)
+def MEDCouplingDataArrayInt32TupleIadd(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt32Tuple____iadd___(self, self, *args)
+def MEDCouplingDataArrayInt32TupleIsub(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt32Tuple____isub___(self, self, *args)
+def MEDCouplingDataArrayInt32TupleImul(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt32Tuple____imul___(self, self, *args)
+def MEDCouplingDataArrayInt32TupleIdiv(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt32Tuple____idiv___(self, self, *args)
+def MEDCouplingDataArrayInt32TupleImod(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt32Tuple____imod___(self, self, *args)
+def MEDCouplingDataArrayInt64TupleIadd(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt64Tuple____iadd___(self, self, *args)
+def MEDCouplingDataArrayInt64TupleIsub(self,*args):
+ import _ParaMEDMEM
+ return _ParaMEDMEM.DataArrayInt64Tuple____isub___(self, self, *args)
+def MEDCouplingDataArrayInt64TupleImul(self,*args):
import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayIntTuple____iadd___(self, self, *args)
-def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
+ return _ParaMEDMEM.DataArrayInt64Tuple____imul___(self, self, *args)
+def MEDCouplingDataArrayInt64TupleIdiv(self,*args):
import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayIntTuple____isub___(self, self, *args)
-def ParaMEDMEMDataArrayIntTupleImul(self,*args):
+ return _ParaMEDMEM.DataArrayInt64Tuple____idiv___(self, self, *args)
+def MEDCouplingDataArrayInt64TupleImod(self,*args):
import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayIntTuple____imul___(self, self, *args)
-def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
+ return _ParaMEDMEM.DataArrayInt64Tuple____imod___(self, self, *args)
+def MEDCouplingDenseMatrixIadd(self,*args):
import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayIntTuple____idiv___(self, self, *args)
-def ParaMEDMEMDataArrayIntTupleImod(self,*args):
+ return _ParaMEDMEM.DenseMatrix____iadd___(self, self, *args)
+def MEDCouplingDenseMatrixIsub(self,*args):
import _ParaMEDMEM
- return _ParaMEDMEM.DataArrayIntTuple____imod___(self, self, *args)
+ return _ParaMEDMEM.DenseMatrix____isub___(self, self, *args)
%}
%include "MEDCouplingFinalize.i"