1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDCOUPLINGTYPEMAPS_I__
22 #define __MEDCOUPLINGTYPEMAPS_I__
24 #include "MEDCouplingDataArrayTypemaps.i"
25 #include "MEDCouplingUMesh.hxx"
26 #include "MEDCouplingCMesh.hxx"
27 #include "MEDCouplingIMesh.hxx"
28 #include "MEDCouplingCurveLinearMesh.hxx"
29 #include "MEDCouplingMappedExtrudedMesh.hxx"
30 #include "MEDCoupling1GTUMesh.hxx"
31 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "MEDCouplingMultiFields.hxx"
33 #include "MEDCouplingPartDefinition.hxx"
34 #include "MEDCouplingCartesianAMRMesh.hxx"
36 static PyObject *convertMesh(MEDCoupling::MEDCouplingMesh *mesh, int owner) throw(INTERP_KERNEL::Exception)
44 if(dynamic_cast<MEDCoupling::MEDCouplingUMesh *>(mesh))
45 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingUMesh,owner);
46 if(dynamic_cast<MEDCoupling::MEDCoupling1SGTUMesh *>(mesh))
47 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1SGTUMesh,owner);
48 if(dynamic_cast<MEDCoupling::MEDCoupling1DGTUMesh *>(mesh))
49 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCoupling1DGTUMesh,owner);
50 if(dynamic_cast<MEDCoupling::MEDCouplingMappedExtrudedMesh *>(mesh))
51 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingMappedExtrudedMesh,owner);
52 if(dynamic_cast<MEDCoupling::MEDCouplingCMesh *>(mesh))
53 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCMesh,owner);
54 if(dynamic_cast<MEDCoupling::MEDCouplingCurveLinearMesh *>(mesh))
55 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingCurveLinearMesh,owner);
56 if(dynamic_cast<MEDCoupling::MEDCouplingIMesh *>(mesh))
57 ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_MEDCoupling__MEDCouplingIMesh,owner);
59 throw INTERP_KERNEL::Exception("Not recognized type of mesh on downcast !");
63 static PyObject *convertFieldDiscretization(MEDCoupling::MEDCouplingFieldDiscretization *fd, int owner) throw(INTERP_KERNEL::Exception)
71 if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP0 *>(fd))
72 ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP0,owner);
73 if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationP1 *>(fd))
74 ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationP1,owner);
75 if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGauss *>(fd))
76 ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGauss,owner);
77 if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationGaussNE *>(fd))
78 ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationGaussNE,owner);
79 if(dynamic_cast<MEDCoupling::MEDCouplingFieldDiscretizationKriging *>(fd))
80 ret=SWIG_NewPointerObj(reinterpret_cast<void*>(fd),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDiscretizationKriging,owner);
82 throw INTERP_KERNEL::Exception("Not recognized type of field discretization on downcast !");
86 static PyObject* convertMultiFields(MEDCoupling::MEDCouplingMultiFields *mfs, int owner) throw(INTERP_KERNEL::Exception)
94 if(dynamic_cast<MEDCoupling::MEDCouplingFieldOverTime *>(mfs))
95 ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldOverTime,owner);
97 ret=SWIG_NewPointerObj((void*)mfs,SWIGTYPE_p_MEDCoupling__MEDCouplingMultiFields,owner);
101 static PyObject *convertCartesianAMRMesh(MEDCoupling::MEDCouplingCartesianAMRMeshGen *mesh, int owner) throw(INTERP_KERNEL::Exception)
108 if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMeshSub *>(mesh))
110 return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMeshSub,owner);
112 if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRMesh *>(mesh))
114 return SWIG_NewPointerObj(reinterpret_cast<void*>(mesh),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRMesh,owner);
116 throw INTERP_KERNEL::Exception("convertCartesianAMRMesh wrap : unrecognized type of cartesian AMR mesh !");
119 static PyObject *convertDataForGodFather(MEDCoupling::MEDCouplingDataForGodFather *data, int owner) throw(INTERP_KERNEL::Exception)
126 if(dynamic_cast<MEDCoupling::MEDCouplingAMRAttribute *>(data))
128 return SWIG_NewPointerObj(reinterpret_cast<void*>(data),SWIGTYPE_p_MEDCoupling__MEDCouplingAMRAttribute,owner);
130 throw INTERP_KERNEL::Exception("convertDataForGodFather wrap : unrecognized data type for AMR !");
133 static PyObject *convertCartesianAMRPatch(MEDCoupling::MEDCouplingCartesianAMRPatchGen *patch, int owner) throw(INTERP_KERNEL::Exception)
140 if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatchGF *>(patch))
142 return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatchGF,owner);
144 if(dynamic_cast<MEDCoupling::MEDCouplingCartesianAMRPatch *>(patch))
146 return SWIG_NewPointerObj(reinterpret_cast<void*>(patch),SWIGTYPE_p_MEDCoupling__MEDCouplingCartesianAMRPatch,owner);
148 throw INTERP_KERNEL::Exception("convertCartesianAMRPatch wrap : unrecognized type of cartesian AMR patch !");
151 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___add__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
153 const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__add__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
154 const char msg2[]="in MEDCouplingFieldDouble.__add__ : self field has no Array of values set !";
157 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
159 MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
161 return (*self)+(*other);
163 throw INTERP_KERNEL::Exception(msg);
167 MEDCoupling::DataArrayDouble *a;
168 MEDCoupling::DataArrayDoubleTuple *aa;
169 std::vector<double> bb;
171 convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
176 if(!self->getArray())
177 throw INTERP_KERNEL::Exception(msg2);
178 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
179 ret->applyLin(1.,val);
180 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
186 if(!self->getArray())
187 throw INTERP_KERNEL::Exception(msg2);
188 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),a);
189 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
195 if(!self->getArray())
196 throw INTERP_KERNEL::Exception(msg2);
197 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
198 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
199 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
205 if(!self->getArray())
206 throw INTERP_KERNEL::Exception(msg2);
207 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
208 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Add(self->getArray(),aaa);
209 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
214 { throw INTERP_KERNEL::Exception(msg); }
218 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___radd__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
220 return MEDCoupling_MEDCouplingFieldDouble___add__Impl(self,obj);
223 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rsub__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
225 const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rsub__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
226 const char msg2[]="in MEDCouplingFieldDouble.__rsub__ : self field has no Array of values set !";
229 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
231 MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
233 return (*other)-(*self);
235 throw INTERP_KERNEL::Exception(msg);
239 MEDCoupling::DataArrayDouble *a;
240 MEDCoupling::DataArrayDoubleTuple *aa;
241 std::vector<double> bb;
243 convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
248 if(!self->getArray())
249 throw INTERP_KERNEL::Exception(msg2);
250 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
251 ret->applyLin(-1.,val);
252 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
258 if(!self->getArray())
259 throw INTERP_KERNEL::Exception(msg2);
260 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(a,self->getArray());
261 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
267 if(!self->getArray())
268 throw INTERP_KERNEL::Exception(msg2);
269 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
270 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
271 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
277 if(!self->getArray())
278 throw INTERP_KERNEL::Exception(msg2);
279 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
280 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Substract(aaa,self->getArray());
281 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
286 { throw INTERP_KERNEL::Exception(msg); }
290 static MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___mul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
292 const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__mul__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
293 const char msg2[]="in MEDCouplingFieldDouble.__mul__ : self field has no Array of values set !";
296 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
298 MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
300 return (*self)*(*other);
302 throw INTERP_KERNEL::Exception(msg);
306 MEDCoupling::DataArrayDouble *a;
307 MEDCoupling::DataArrayDoubleTuple *aa;
308 std::vector<double> bb;
310 convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
315 if(!self->getArray())
316 throw INTERP_KERNEL::Exception(msg2);
317 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
318 ret->applyLin(val,0.);
319 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
325 if(!self->getArray())
326 throw INTERP_KERNEL::Exception(msg2);
327 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),a);
328 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
334 if(!self->getArray())
335 throw INTERP_KERNEL::Exception(msg2);
336 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
337 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
338 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
344 if(!self->getArray())
345 throw INTERP_KERNEL::Exception(msg2);
346 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
347 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Multiply(self->getArray(),aaa);
348 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
353 { throw INTERP_KERNEL::Exception(msg); }
357 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rmul__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
359 return MEDCoupling_MEDCouplingFieldDouble___mul__Impl(self,obj);
362 MEDCoupling::MEDCouplingFieldDouble *MEDCoupling_MEDCouplingFieldDouble___rdiv__Impl(MEDCoupling::MEDCouplingFieldDouble *self, PyObject *obj) throw(INTERP_KERNEL::Exception)
364 const char msg[]="Unexpected situation in MEDCouplingFieldDouble.__rdiv__ ! Expecting a not null MEDCouplingFieldDouble or DataArrayDouble or DataArrayDoubleTuple instance, or a list of double, or a double.";
365 const char msg2[]="in MEDCouplingFieldDouble.__div__ : self field has no Array of values set !";
368 if(SWIG_IsOK(SWIG_ConvertPtr(obj,&argp,SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble,0|0)))
370 MEDCoupling::MEDCouplingFieldDouble *other=reinterpret_cast< MEDCoupling::MEDCouplingFieldDouble * >(argp);
372 return (*other)/(*self);
374 throw INTERP_KERNEL::Exception(msg);
378 MEDCoupling::DataArrayDouble *a;
379 MEDCoupling::DataArrayDoubleTuple *aa;
380 std::vector<double> bb;
382 convertObjToPossibleCpp5(obj,sw,val,a,aa,bb);
387 if(!self->getArray())
388 throw INTERP_KERNEL::Exception(msg2);
389 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=self->getArray()->deepCopy();
391 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
397 if(!self->getArray())
398 throw INTERP_KERNEL::Exception(msg2);
399 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(a,self->getArray());
400 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
406 if(!self->getArray())
407 throw INTERP_KERNEL::Exception(msg2);
408 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=aa->buildDADouble(1,self->getNumberOfComponents());
409 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
410 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
416 if(!self->getArray())
417 throw INTERP_KERNEL::Exception(msg2);
418 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> aaa=MEDCoupling::DataArrayDouble::New(); aaa->useArray(&bb[0],false,MEDCoupling::CPP_DEALLOC,1,(int)bb.size());
419 MEDCoupling::MCAuto<MEDCoupling::DataArrayDouble> ret=MEDCoupling::DataArrayDouble::Divide(aaa,self->getArray());
420 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingFieldDouble> ret2=self->clone(false);
425 { throw INTERP_KERNEL::Exception(msg); }