Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / ParaMEDMEM_Swig / ParaMEDMEMCommon.i
1 // Copyright (C) 2017-2020  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 %include std_set.i
21
22 %template() std::set<int>;
23
24 %{
25 #include "CommInterface.hxx"
26 #include "ProcessorGroup.hxx"
27 #include "Topology.hxx"
28 #include "MPIProcessorGroup.hxx"
29 #include "DEC.hxx"
30 #include "InterpKernelDEC.hxx"
31 #include "NonCoincidentDEC.hxx"
32 #include "StructuredCoincidentDEC.hxx"
33 #include "ParaMESH.hxx"
34 #include "ParaFIELD.hxx"
35 #include "ICoCoMEDField.hxx"
36 #include "ComponentTopology.hxx"
37 #include "ParaUMesh.hxx"
38
39 using namespace INTERP_KERNEL;
40 using namespace MEDCoupling;
41 using namespace ICoCo;
42 %}
43
44 %include "InterpolationOptions.hxx"
45 %include "ProcessorGroup.hxx"
46 %include "DECOptions.hxx"
47 %include "ParaMESH.hxx"
48 %include "ParaFIELD.hxx"
49 %include "MPIProcessorGroup.hxx"
50 %include "ComponentTopology.hxx"
51 %include "DEC.hxx"
52 %include "DisjointDEC.hxx"
53 %include "InterpKernelDEC.hxx"
54 %include "StructuredCoincidentDEC.hxx"
55
56 %include "ICoCoField.hxx"
57 %rename(ICoCoMEDField) ICoCo::MEDField;
58 %include "ICoCoMEDField.hxx"
59
60 %newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes;
61
62 %nodefaultctor;
63
64 namespace MEDCoupling
65 {
66   class CommInterface
67   {
68   public:
69     CommInterface();
70     virtual ~CommInterface();
71     int worldSize() const;
72     int commSize(MPI_Comm comm, int* size) const;
73     int commRank(MPI_Comm comm, int* rank) const;
74     int commGroup(MPI_Comm comm, MPI_Group* group) const;
75     int groupIncl(MPI_Group group, int size, int* ranks, MPI_Group* group_output) const;
76     int commCreate(MPI_Comm comm, MPI_Group group, MPI_Comm* comm_output) const;
77     int groupFree(MPI_Group* group) const;
78     int commFree(MPI_Comm* comm) const;
79
80     int send(void* buffer, int count, MPI_Datatype datatype, int target, int tag, MPI_Comm comm) const;
81     int recv(void* buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status) const;
82     int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, 
83                  int dest, int sendtag, void* recvbuf, int recvcount, 
84                  MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm,
85                  MPI_Status* status);
86
87     int Isend(void* buffer, int count, MPI_Datatype datatype, int target,
88               int tag, MPI_Comm comm, MPI_Request *request) const;
89     int Irecv(void* buffer, int count, MPI_Datatype datatype, int source,
90               int tag, MPI_Comm comm, MPI_Request* request) const;
91
92     int wait(MPI_Request *request, MPI_Status *status) const;
93     int test(MPI_Request *request, int *flag, MPI_Status *status) const;
94     int requestFree(MPI_Request *request) const;
95     int waitany(int count, MPI_Request *array_of_requests, int *index, MPI_Status *status) const;
96     int testany(int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status) const;
97     int waitall(int count, MPI_Request *array_of_requests, MPI_Status *array_of_status) const { return MPI_Waitall(count, array_of_requests, array_of_status); }
98     int testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_status) const;
99     int waitsome(int incount, MPI_Request *array_of_requests,int *outcount, int *array_of_indices, MPI_Status *array_of_status) const;
100     int testsome(int incount, MPI_Request *array_of_requests, int *outcount,
101                  int *array_of_indices, MPI_Status *array_of_status) const;
102     int probe(int source, int tag, MPI_Comm comm, MPI_Status *status) const;
103     int Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status) const;
104     int cancel(MPI_Request *request) const;
105     int testCancelled(MPI_Status *status, int *flag) const;
106     int barrier(MPI_Comm comm) const;
107     int errorString(int errorcode, char *string, int *resultlen) const;
108     int getCount(MPI_Status *status, MPI_Datatype datatype, int *count) const;
109
110     int broadcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) const;
111     int allGather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
112                   void* recvbuf, int recvcount, MPI_Datatype recvtype,
113                   MPI_Comm comm) const;
114     int allToAll(void* sendbuf, int sendcount, MPI_Datatype sendtype,
115                  void* recvbuf, int recvcount, MPI_Datatype recvtype,
116                  MPI_Comm comm) const;
117     int allToAllV(void* sendbuf, int* sendcounts, int* senddispls,
118                   MPI_Datatype sendtype, void* recvbuf, int* recvcounts,
119                   int* recvdispls, MPI_Datatype recvtype, 
120                   MPI_Comm comm) const;
121
122     int reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) const;
123     int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const;
124   };
125
126   class ParaUMesh
127   {
128   public:
129     ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
130     %extend
131     {
132       DataArrayIdType *getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const
133       { 
134         MCAuto<DataArrayIdType> ret(self->getCellIdsLyingOnNodes(globalNodeIds,fullyIn));
135         return ret.retn();
136       }
137     }
138   };
139 }
140
141 /* This object can be used only if MED_ENABLE_FVM is defined*/
142 #ifdef MED_ENABLE_FVM
143 class NonCoincidentDEC : public DEC
144 {
145 public:
146   NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
147 };
148 #endif
149
150 %extend MEDCoupling::ParaMESH
151 {
152   PyObject *getGlobalNumberingCell2() const
153   {
154     const mcIdType *tmp=self->getGlobalNumberingCell();
155     mcIdType size=self->getCellMesh()->getNumberOfCells();
156     PyObject *ret=PyList_New(size);
157     for(mcIdType i=0;i<size;i++)
158       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
159     return ret;
160   }
161
162   PyObject *getGlobalNumberingFace2() const
163   {
164     const mcIdType *tmp=self->getGlobalNumberingFace();
165     mcIdType size=self->getFaceMesh()->getNumberOfCells();
166     PyObject *ret=PyList_New(size);
167     for(mcIdType i=0;i<size;i++)
168       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
169     return ret;
170   }
171
172   PyObject *getGlobalNumberingNode2() const
173   {
174     const mcIdType *tmp=self->getGlobalNumberingNode();
175     mcIdType size=self->getCellMesh()->getNumberOfNodes();
176     PyObject *ret=PyList_New(size);
177     for(mcIdType i=0;i<size;i++)
178       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
179     return ret;
180   }
181 }