Salome HOME
[EDF21149] : Improvements for // spliter
[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 #include "ParaSkyLineArray.hxx"
39
40 using namespace INTERP_KERNEL;
41 using namespace MEDCoupling;
42 using namespace ICoCo;
43 %}
44
45 %include "InterpolationOptions.hxx"
46 %include "ProcessorGroup.hxx"
47 %include "DECOptions.hxx"
48 %include "ParaMESH.hxx"
49 %include "ParaFIELD.hxx"
50 %include "MPIProcessorGroup.hxx"
51 %include "ComponentTopology.hxx"
52 %include "DEC.hxx"
53 %include "DisjointDEC.hxx"
54 %include "InterpKernelDEC.hxx"
55 %include "StructuredCoincidentDEC.hxx"
56
57 %include "ICoCoField.hxx"
58 %rename(ICoCoMEDField) ICoCo::MEDField;
59 %include "ICoCoMEDField.hxx"
60
61 %newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes;
62 %newobject MEDCoupling::ParaSkyLineArray::equiRedistribute;
63 %newobject MEDCoupling::ParaSkyLineArray::getSkyLineArray;
64 %newobject MEDCoupling::ParaSkyLineArray::getGlobalIdsArray;
65
66 %feature("unref") ParaSkyLineArray "$this->decrRef();"
67
68 %nodefaultctor;
69
70 namespace MEDCoupling
71 {
72   class CommInterface
73   {
74   public:
75     CommInterface();
76     virtual ~CommInterface();
77     int worldSize() const;
78     int commSize(MPI_Comm comm, int* size) const;
79     int commRank(MPI_Comm comm, int* rank) const;
80     int commGroup(MPI_Comm comm, MPI_Group* group) const;
81     int groupIncl(MPI_Group group, int size, int* ranks, MPI_Group* group_output) const;
82     int commCreate(MPI_Comm comm, MPI_Group group, MPI_Comm* comm_output) const;
83     int groupFree(MPI_Group* group) const;
84     int commFree(MPI_Comm* comm) const;
85
86     int send(void* buffer, int count, MPI_Datatype datatype, int target, int tag, MPI_Comm comm) const;
87     int recv(void* buffer, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status* status) const;
88     int sendRecv(void* sendbuf, int sendcount, MPI_Datatype sendtype, 
89                  int dest, int sendtag, void* recvbuf, int recvcount, 
90                  MPI_Datatype recvtype, int source, int recvtag, MPI_Comm comm,
91                  MPI_Status* status);
92
93     int Isend(void* buffer, int count, MPI_Datatype datatype, int target,
94               int tag, MPI_Comm comm, MPI_Request *request) const;
95     int Irecv(void* buffer, int count, MPI_Datatype datatype, int source,
96               int tag, MPI_Comm comm, MPI_Request* request) const;
97
98     int wait(MPI_Request *request, MPI_Status *status) const;
99     int test(MPI_Request *request, int *flag, MPI_Status *status) const;
100     int requestFree(MPI_Request *request) const;
101     int waitany(int count, MPI_Request *array_of_requests, int *index, MPI_Status *status) const;
102     int testany(int count, MPI_Request *array_of_requests, int *index, int *flag, MPI_Status *status) const;
103     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); }
104     int testall(int count, MPI_Request *array_of_requests, int *flag, MPI_Status *array_of_status) const;
105     int waitsome(int incount, MPI_Request *array_of_requests,int *outcount, int *array_of_indices, MPI_Status *array_of_status) const;
106     int testsome(int incount, MPI_Request *array_of_requests, int *outcount,
107                  int *array_of_indices, MPI_Status *array_of_status) const;
108     int probe(int source, int tag, MPI_Comm comm, MPI_Status *status) const;
109     int Iprobe(int source, int tag, MPI_Comm comm, int *flag, MPI_Status *status) const;
110     int cancel(MPI_Request *request) const;
111     int testCancelled(MPI_Status *status, int *flag) const;
112     int barrier(MPI_Comm comm) const;
113     int errorString(int errorcode, char *string, int *resultlen) const;
114     int getCount(MPI_Status *status, MPI_Datatype datatype, int *count) const;
115
116     int broadcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm) const;
117     int allGather(void* sendbuf, int sendcount, MPI_Datatype sendtype,
118                   void* recvbuf, int recvcount, MPI_Datatype recvtype,
119                   MPI_Comm comm) const;
120     int allToAll(void* sendbuf, int sendcount, MPI_Datatype sendtype,
121                  void* recvbuf, int recvcount, MPI_Datatype recvtype,
122                  MPI_Comm comm) const;
123     int allToAllV(void* sendbuf, int* sendcounts, int* senddispls,
124                   MPI_Datatype sendtype, void* recvbuf, int* recvcounts,
125                   int* recvdispls, MPI_Datatype recvtype, 
126                   MPI_Comm comm) const;
127
128     int reduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm) const;
129     int allReduce(void* sendbuf, void* recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) const;
130   };
131
132   class ParaUMesh
133   {
134   public:
135     ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
136     %extend
137     {
138       DataArrayIdType *getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const
139       { 
140         MCAuto<DataArrayIdType> ret(self->getCellIdsLyingOnNodes(globalNodeIds,fullyIn));
141         return ret.retn();
142       }
143     }
144   };
145
146   class ParaSkyLineArray : public RefCountObject
147   {
148   public:
149     static ParaSkyLineArray *New(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds);
150     %extend
151     {
152       ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds)
153       {
154         return ParaSkyLineArray::New(ska,globalIds);
155       }
156
157       ParaSkyLineArray *equiRedistribute(mcIdType nbOfEntities) const
158       {
159         MCAuto<ParaSkyLineArray> ret(self->equiRedistribute(nbOfEntities));
160         return ret.retn();
161       }
162
163       MEDCouplingSkyLineArray *getSkyLineArray() const
164       {
165         MEDCouplingSkyLineArray *ret(self->getSkyLineArray());
166         if(ret)
167           ret->incrRef();
168         return ret;
169       }
170       
171       DataArrayIdType *getGlobalIdsArray() const
172       {
173         DataArrayIdType *ret(self->getGlobalIdsArray());
174         if(ret)
175           ret->incrRef();
176         return ret;
177       }
178     }
179   };
180 }
181
182 /* This object can be used only if MED_ENABLE_FVM is defined*/
183 #ifdef MED_ENABLE_FVM
184 class NonCoincidentDEC : public DEC
185 {
186 public:
187   NonCoincidentDEC(ProcessorGroup& source, ProcessorGroup& target);
188 };
189 #endif
190
191 %extend MEDCoupling::ParaMESH
192 {
193   PyObject *getGlobalNumberingCell2() const
194   {
195     const mcIdType *tmp=self->getGlobalNumberingCell();
196     mcIdType size=self->getCellMesh()->getNumberOfCells();
197     PyObject *ret=PyList_New(size);
198     for(mcIdType i=0;i<size;i++)
199       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
200     return ret;
201   }
202
203   PyObject *getGlobalNumberingFace2() const
204   {
205     const mcIdType *tmp=self->getGlobalNumberingFace();
206     mcIdType size=self->getFaceMesh()->getNumberOfCells();
207     PyObject *ret=PyList_New(size);
208     for(mcIdType i=0;i<size;i++)
209       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
210     return ret;
211   }
212
213   PyObject *getGlobalNumberingNode2() const
214   {
215     const mcIdType *tmp=self->getGlobalNumberingNode();
216     mcIdType size=self->getCellMesh()->getNumberOfNodes();
217     PyObject *ret=PyList_New(size);
218     for(mcIdType i=0;i<size;i++)
219       PyList_SetItem(ret,i,PyInt_FromLong(tmp[i])); 
220     return ret;
221   }
222 }