From: eap Date: Wed, 17 Dec 2008 10:51:44 +0000 (+0000) Subject: rename X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2946c8db2723cda69a6fe60f1fe42ec5dbddd230;p=tools%2Fmedcoupling.git rename --- diff --git a/src/ParaMEDMEM_Swig/Makefile.am b/src/ParaMEDMEM_Swig/Makefile.am index 1bcc2a00a..e5a53f832 100644 --- a/src/ParaMEDMEM_Swig/Makefile.am +++ b/src/ParaMEDMEM_Swig/Makefile.am @@ -22,39 +22,39 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am -lib_LTLIBRARIES = _libParaMED_Swig.la +lib_LTLIBRARIES = _libParaMEDMEM_Swig.la salomeinclude_HEADERS = \ - libParaMED_Swig.i + libParaMEDMEM_Swig.i -SWIG_DEF = libParaMED_Swig.i +SWIG_DEF = libParaMEDMEM_Swig.i SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) $(MPI_INCLUDES) -I$(srcdir)/../MEDMEM_SWIG -dist__libParaMED_Swig_la_SOURCES = libParaMED_Swig.i -nodist__libParaMED_Swig_la_SOURCES = libParaMED_Swig_wrap.cxx -libParaMED_Swig.py: libParaMED_Swig_wrap.cxx +dist__libParaMEDMEM_Swig_la_SOURCES = libParaMEDMEM_Swig.i +nodist__libParaMEDMEM_Swig_la_SOURCES = libParaMEDMEM_Swig_wrap.cxx +libParaMEDMEM_Swig.py: libParaMEDMEM_Swig_wrap.cxx -libParaMED_Swig_wrap.cxx: $(SWIG_DEF) +libParaMEDMEM_Swig_wrap.cxx: $(SWIG_DEF) $(SWIG) $(SWIG_FLAGS) -o $@ $< -_libParaMED_Swig_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) $(PYTHON_INCLUDES) \ +_libParaMEDMEM_Swig_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) $(PYTHON_INCLUDES) \ $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../INTERP_KERNEL \ $(MPI_INCLUDES) -I$(srcdir)/../ParaMEDMEM -I$(srcdir)/../MEDMEM_SWIG -_libParaMED_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \ +_libParaMEDMEM_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \ ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la \ ../ParaMEDMEM/libparamedmem.la if MED_ENABLE_KERNEL - _libParaMED_Swig_la_CPPFLAGS += ${KERNEL_CXXFLAGS} - _libParaMED_Swig_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace + _libParaMEDMEM_Swig_la_CPPFLAGS += ${KERNEL_CXXFLAGS} + _libParaMEDMEM_Swig_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace endif -CLEANFILES = libParaMED_Swig_wrap.cxx libParaMED_Swig.py +CLEANFILES = libParaMEDMEM_Swig_wrap.cxx libParaMEDMEM_Swig.py -nodist_salomescript_DATA= libParaMED_Swig.py +nodist_salomescript_DATA= libParaMEDMEM_Swig.py dist_salomescript_DATA= test_intersectiondec.py \ test_noncoincidentdec.py \ diff --git a/src/ParaMEDMEM_Swig/ParaMEDMEM.py b/src/ParaMEDMEM_Swig/ParaMEDMEM.py index 57bb0b4e3..a265e71c6 100644 --- a/src/ParaMEDMEM_Swig/ParaMEDMEM.py +++ b/src/ParaMEDMEM_Swig/ParaMEDMEM.py @@ -17,4 +17,4 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -from libParaMED_Swig import * +from libParaMEDMEM_Swig import * diff --git a/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i b/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i new file mode 100644 index 000000000..3cf0573c7 --- /dev/null +++ b/src/ParaMEDMEM_Swig/libParaMEDMEM_Swig.i @@ -0,0 +1,328 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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 +// +%module libParaMEDMEM_Swig + +%include "libParaMEDMEM_Swig.typemap" +%include "../MEDMEM_SWIG/libMEDMEM_Swig.i" + +%{ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace ParaMEDMEM; +using namespace ICoCo; +%} + + +class CommInterface { +public: + CommInterface(); +}; + +class ProcessorGroup { +public: + %extend { + // avoid error when SWIG creates a default constructor of an abstract class + ProcessorGroup() { return NULL; } + } +}; + +class MPIProcessorGroup: public ProcessorGroup { +public: + MPIProcessorGroup(const CommInterface& interface); + MPIProcessorGroup(const CommInterface& interface, set proc_ids); + MPIProcessorGroup(const CommInterface& interface,int pstart, int pend); + + int translateRank(const ProcessorGroup* group, int rank) const; + ProcessorGroup* createComplementProcGroup() const; + ProcessorGroup* fuse (const ProcessorGroup&) const; + + bool containsMyRank() const; + int myRank() const; +}; + +%rename(ICoCo_MEDField) ICoCo::MEDField; +namespace ICoCo { +class Field { +}; + +class MEDField: public Field { +public: + MEDField(ParaMESH* mesh, ParaFIELD* field); +}; +} + +class DEC { +public: + %extend { + // avoid error when SWIG creates a default constructor of an abstract class + DEC() { return NULL; }; + } + void recvData(); + void sendData(); + void synchronize(); + + void attachLocalField(FIELD* field, const char* method="P0"); + void attachLocalField(const ParaFIELD* field, const char* method="P0"); + void attachLocalField(const ICoCo::Field* field, const char* method="P0"); + + void renormalizeTargetField(); +}; + + +typedef enum{WithoutTimeInterp,LinearTimeInterp} TimeInterpolationMethod; + +typedef enum{Native,PointToPoint} AllToAllMethod; + +class IntersectionDEC: public DEC { +public: + + IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); + + void recvData(); + void recvData( double time ); + + void sendData(); + void sendData( double time, double deltatime ); + + void setTimeInterpolationMethod(TimeInterpolationMethod it); + TimeInterpolationMethod getTimeInterpolationMethod(); + + void setAsynchronous( bool dr); + bool getAsynchronous(); + + AllToAllMethod getAllToAllMethod(); + void setAllToAllMethod(AllToAllMethod sp); + + bool getForcedRenormalization(); + void setForcedRenormalization( bool dr); +}; + + + +/* 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 + + +class StructuredCoincidentDEC: public DEC { +public: + StructuredCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target); + void prepareSourceDE(); + void prepareTargetDE(); +}; + + +class ParaMESH { +public: + ParaMESH(driverTypes driver_type, const char* file_name, const ProcessorGroup& group); + ParaMESH(MESH& subdomain_mesh, const ProcessorGroup& proc_group, const char* name); + + void write(driverTypes driverType, const char* fileName=""); + MESH* getMesh() const; +}; + + + +class ParaSUPPORT { +public: + %extend { + // avoid error when SWIG creates a default constructor of an abstract class + ParaSUPPORT() { return NULL; } + + PyObject* getGlobalNumbering() { + const int * numIndex = self->getGlobalNumbering(); + int aSize = self->getSupport()->getNumberOfElements(999); + TYPEMAP_OUTPUT_ARRAY(numIndex, aSize, PyInt_FromLong, ParaSUPPORT::getGlobalNumbering); + } + } +}; + + +class UnstructuredParaSUPPORT: public ParaSUPPORT { +public: + UnstructuredParaSUPPORT(const ParaMESH* const mesh, const SUPPORT* support ); + UnstructuredParaSUPPORT(const ParaMESH* const mesh, const medEntityMesh entity); + UnstructuredParaSUPPORT(const SUPPORT* support, const ProcessorGroup& group); +}; + +class StructuredParaSUPPORT: public ParaSUPPORT { +public: + StructuredParaSUPPORT(const ParaGRID* const grid, const medEntityMesh entity); + StructuredParaSUPPORT(const ParaMESH* const mesh, const medEntityMesh entity); +}; + +class ComponentTopology { +public: + ComponentTopology(); + ComponentTopology(int nb_comp); + ComponentTopology(int nb_comp, int nb_blocks); + ComponentTopology(int nb_comp, ProcessorGroup* group); + + int nbComponents(); + int nbLocalComponents(); +}; + + +class ParaFIELD { +public: + ParaFIELD(const ParaSUPPORT* support, + const ComponentTopology& component_topology); + + ParaFIELD(driverTypes driver_type, + const char* file_name, + const char* driver_name, + const ComponentTopology& component_topology); + + ParaFIELD(FIELDDOUBLE* field, const ProcessorGroup& group); + + void write(driverTypes driverType, + const char* fileName="", + const char* meshName=""); + + FIELDDOUBLE* getField() const; + + double getVolumeIntegral(int icomp) const; +}; + + +// MPI realization specific definition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +//#ifdef MPICH2 +// MPICH2 +typedef int MPI_Datatype; +typedef int MPI_Comm; +#define MPI_COMM_WORLD 0x44000000 +#define MPI_COMM_SELF 0x44000001 +#define MPI_DOUBLE 0x4c00080b +#define MPI_INT 0x4c000405 + +//#endif +// END OF MPI realization specific definition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +// ============== +// 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(); + +// ========== +// MPI_Bcast +// ========== + +%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 ) { + PyErr_SetString(PyExc_ValueError, MEDMEM::STRING("buffer is expected to be of size ")< C++ object */ +%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE ) +{ + /* typemap in for set */ + /* Check if is a list */ + if (PyList_Check($input)) + { + int size = PyList_Size($input); + set< TYPE > tmpSet; + + for (int i=0; i < size; i++) + { + PyObject * tmp = PyList_GetItem($input,i); + TYPE elem = PyInt_AsLong(tmp); + tmpSet.insert(elem); + } + $1 = tmpSet; + } + else + { + PyErr_SetString(PyExc_TypeError,"not a list"); + return NULL; + } +} +%enddef + +%typemap(in) set +{ + TYPEMAP_INPUT_SET_BY_VALUE( int ) +} +%typecheck(SWIG_TYPECHECK_POINTER) set { + $1 = PyList_Check($input) ? 1 : 0; +} diff --git a/src/ParaMEDMEM_Swig/libParaMED_Swig.i b/src/ParaMEDMEM_Swig/libParaMED_Swig.i deleted file mode 100644 index 119de1bca..000000000 --- a/src/ParaMEDMEM_Swig/libParaMED_Swig.i +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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 -// -%module libParaMED_Swig - -%include "libParaMED_Swig.typemap" -%include "../MEDMEM_SWIG/libMEDMEM_Swig.i" - -%{ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace ParaMEDMEM; -using namespace ICoCo; -%} - - -class CommInterface { -public: - CommInterface(); -}; - -class ProcessorGroup { -public: - %extend { - // avoid error when SWIG creates a default constructor of an abstract class - ProcessorGroup() { return NULL; } - } -}; - -class MPIProcessorGroup: public ProcessorGroup { -public: - MPIProcessorGroup(const CommInterface& interface); - MPIProcessorGroup(const CommInterface& interface, set proc_ids); - MPIProcessorGroup(const CommInterface& interface,int pstart, int pend); - - int translateRank(const ProcessorGroup* group, int rank) const; - ProcessorGroup* createComplementProcGroup() const; - ProcessorGroup* fuse (const ProcessorGroup&) const; - - bool containsMyRank() const; - int myRank() const; -}; - -%rename(ICoCo_MEDField) ICoCo::MEDField; -namespace ICoCo { -class Field { -}; - -class MEDField: public Field { -public: - MEDField(ParaMESH* mesh, ParaFIELD* field); -}; -} - -class DEC { -public: - %extend { - // avoid error when SWIG creates a default constructor of an abstract class - DEC() { return NULL; }; - } - void recvData(); - void sendData(); - void synchronize(); - - void attachLocalField(FIELD* field, const char* method="P0"); - void attachLocalField(const ParaFIELD* field, const char* method="P0"); - void attachLocalField(const ICoCo::Field* field, const char* method="P0"); - - void renormalizeTargetField(); -}; - - -typedef enum{WithoutTimeInterp,LinearTimeInterp} TimeInterpolationMethod; - -typedef enum{Native,PointToPoint} AllToAllMethod; - -class IntersectionDEC: public DEC { -public: - - IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group); - - void recvData(); - void recvData( double time ); - - void sendData(); - void sendData( double time, double deltatime ); - - void setTimeInterpolationMethod(TimeInterpolationMethod it); - TimeInterpolationMethod getTimeInterpolationMethod(); - - void setAsynchronous( bool dr); - bool getAsynchronous(); - - AllToAllMethod getAllToAllMethod(); - void setAllToAllMethod(AllToAllMethod sp); - - bool getForcedRenormalization(); - void setForcedRenormalization( bool dr); -}; - - - -/* 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 - - -class StructuredCoincidentDEC: public DEC { -public: - StructuredCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target); - void prepareSourceDE(); - void prepareTargetDE(); -}; - - -class ParaMESH { -public: - ParaMESH(driverTypes driver_type, const char* file_name, const ProcessorGroup& group); - ParaMESH(MESH& subdomain_mesh, const ProcessorGroup& proc_group, const char* name); - - void write(driverTypes driverType, const char* fileName=""); - MESH* getMesh() const; -}; - - - -class ParaSUPPORT { -public: - %extend { - // avoid error when SWIG creates a default constructor of an abstract class - ParaSUPPORT() { return NULL; } - - PyObject* getGlobalNumbering() { - const int * numIndex = self->getGlobalNumbering(); - int aSize = self->getSupport()->getNumberOfElements(999); - TYPEMAP_OUTPUT_ARRAY(numIndex, aSize, PyInt_FromLong, ParaSUPPORT::getGlobalNumbering); - } - } -}; - - -class UnstructuredParaSUPPORT: public ParaSUPPORT { -public: - UnstructuredParaSUPPORT(const ParaMESH* const mesh, const SUPPORT* support ); - UnstructuredParaSUPPORT(const ParaMESH* const mesh, const medEntityMesh entity); - UnstructuredParaSUPPORT(const SUPPORT* support, const ProcessorGroup& group); -}; - -class StructuredParaSUPPORT: public ParaSUPPORT { -public: - StructuredParaSUPPORT(const ParaGRID* const grid, const medEntityMesh entity); - StructuredParaSUPPORT(const ParaMESH* const mesh, const medEntityMesh entity); -}; - -class ComponentTopology { -public: - ComponentTopology(); - ComponentTopology(int nb_comp); - ComponentTopology(int nb_comp, int nb_blocks); - ComponentTopology(int nb_comp, ProcessorGroup* group); - - int nbComponents(); - int nbLocalComponents(); -}; - - -class ParaFIELD { -public: - ParaFIELD(const ParaSUPPORT* support, - const ComponentTopology& component_topology); - - ParaFIELD(driverTypes driver_type, - const char* file_name, - const char* driver_name, - const ComponentTopology& component_topology); - - ParaFIELD(FIELDDOUBLE* field, const ProcessorGroup& group); - - void write(driverTypes driverType, - const char* fileName="", - const char* meshName=""); - - FIELDDOUBLE* getField() const; - - double getVolumeIntegral(int icomp) const; -}; - - -// MPI realization specific definition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -//#ifdef MPICH2 -// MPICH2 -typedef int MPI_Datatype; -typedef int MPI_Comm; -#define MPI_COMM_WORLD 0x44000000 -#define MPI_COMM_SELF 0x44000001 -#define MPI_DOUBLE 0x4c00080b -#define MPI_INT 0x4c000405 - -//#endif -// END OF MPI realization specific definition !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - -// ============== -// 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(); - -// ========== -// MPI_Bcast -// ========== - -%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 ) { - PyErr_SetString(PyExc_ValueError, MEDMEM::STRING("buffer is expected to be of size ")< C++ object */ -%define TYPEMAP_INPUT_SET_BY_VALUE( TYPE ) -{ - /* typemap in for set */ - /* Check if is a list */ - if (PyList_Check($input)) - { - int size = PyList_Size($input); - set< TYPE > tmpSet; - - for (int i=0; i < size; i++) - { - PyObject * tmp = PyList_GetItem($input,i); - TYPE elem = PyInt_AsLong(tmp); - tmpSet.insert(elem); - } - $1 = tmpSet; - } - else - { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} -%enddef - -%typemap(in) set -{ - TYPEMAP_INPUT_SET_BY_VALUE( int ) -} -%typecheck(SWIG_TYPECHECK_POINTER) set { - $1 = PyList_Check($input) ? 1 : 0; -}