1 // Copyright (C) 2007-2015 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)
26 %include "MEDLoaderCommon.i"
29 #include "MEDCalculatorBrowserLiteStruct.hxx"
30 #include "MEDCalculatorBrowserField.hxx"
31 #include "MEDCalculatorDBField.hxx"
32 #include "MEDCalculatorTypemaps.i"
34 using namespace MEDCoupling;
35 using namespace INTERP_KERNEL;
38 %typemap(out) MEDCoupling::MEDCalculatorDBField*
40 $result=convertMEDCalculatorDBField($1,$owner);
43 %newobject MEDCoupling::MEDCalculatorDBField::operator+;
44 %newobject MEDCoupling::MEDCalculatorDBField::operator-;
45 %newobject MEDCoupling::MEDCalculatorDBField::operator*;
46 %newobject MEDCoupling::MEDCalculatorDBField::operator/;
47 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__radd__;
48 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__rsub__;
49 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__rmul__;
50 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__rdiv__;
51 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__getitem__;
52 %newobject MEDCoupling::MEDCalculatorDBFieldReal::__setitem__;
53 %newobject MEDCoupling::MEDCalculatorDBFieldReal::operator();
54 %newobject MEDCoupling::MEDCalculatorDBFieldReal::buildCstFieldFromThis;
55 %newobject MEDCoupling::MEDCalculatorDBFieldReal::dot;
56 %newobject MEDCoupling::MEDCalculatorDBFieldReal::operator^;
57 %newobject MEDCoupling::MEDCalculatorDBFieldReal::crossProduct;
58 %newobject MEDCoupling::MEDCalculatorDBFieldReal::doublyContractedProduct;
59 %newobject MEDCoupling::MEDCalculatorDBFieldReal::determinant;
60 %newobject MEDCoupling::MEDCalculatorDBFieldReal::eigenValues;
61 %newobject MEDCoupling::MEDCalculatorDBFieldReal::eigenVectors;
62 %newobject MEDCoupling::MEDCalculatorDBFieldReal::inverse;
63 %newobject MEDCoupling::MEDCalculatorDBFieldReal::trace;
64 %newobject MEDCoupling::MEDCalculatorDBFieldReal::deviator;
65 %newobject MEDCoupling::MEDCalculatorDBFieldReal::magnitude;
67 %feature("unref") MEDCalculatorDBField "$this->decrRef();"
71 class MEDCalculatorBrowserLiteStruct
74 MEDCalculatorBrowserLiteStruct(const char *);
75 const MEDCalculatorBrowserField& getField(int) const;
78 class MEDCalculatorDBField : public RefCountObject
81 virtual MEDCalculatorDBField *operator+(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
82 MEDCalculatorDBField *operator+(double val) const throw(INTERP_KERNEL::Exception);
83 virtual MEDCalculatorDBField *operator-(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
84 MEDCalculatorDBField *operator-(double val) const throw(INTERP_KERNEL::Exception);
85 virtual MEDCalculatorDBField *operator*(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
86 MEDCalculatorDBField *operator*(double val) const throw(INTERP_KERNEL::Exception);
87 virtual MEDCalculatorDBField *operator/(const MEDCalculatorDBField& other) const throw(INTERP_KERNEL::Exception);
88 MEDCalculatorDBField *operator/(double val) const throw(INTERP_KERNEL::Exception);
89 virtual bool isEqual(const MEDCalculatorDBField& other, double precM, double precF) const;
92 class MEDCalculatorDBFieldReal : public MEDCalculatorDBField
95 MEDCalculatorDBFieldReal(const MEDCalculatorBrowserField& ls);
96 ~MEDCalculatorDBFieldReal();
97 MEDCalculatorDBFieldReal *buildCstFieldFromThis(double val) const;
98 MEDCoupling::TypeOfField getType() const;
99 void fetchData() const throw(INTERP_KERNEL::Exception);
100 int getNumberOfSteps() const;
101 int getNumberOfFetchedSteps() const;
102 int getNumberOfComponents() const;
103 void setName(const char *name);
104 void setDescription(const char *descr);
105 std::string getInfoOnComponent(int i) const throw(INTERP_KERNEL::Exception);
106 void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception);
107 void write(const char *fName, bool writeFromScratch) const throw(INTERP_KERNEL::Exception);
108 void display() const throw(INTERP_KERNEL::Exception);
109 void applyFunc(const char *func) throw(INTERP_KERNEL::Exception);
110 MEDCalculatorDBField *operator^(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
111 MEDCalculatorDBField *dot(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
112 MEDCalculatorDBField *crossProduct(const MEDCalculatorDBFieldReal& other) const throw(INTERP_KERNEL::Exception);
113 MEDCalculatorDBField *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
114 MEDCalculatorDBField *determinant() const throw(INTERP_KERNEL::Exception);
115 MEDCalculatorDBField *eigenValues() const throw(INTERP_KERNEL::Exception);
116 MEDCalculatorDBField *eigenVectors() const throw(INTERP_KERNEL::Exception);
117 MEDCalculatorDBField *inverse() const throw(INTERP_KERNEL::Exception);
118 MEDCalculatorDBField *trace() const throw(INTERP_KERNEL::Exception);
119 MEDCalculatorDBField *deviator() const throw(INTERP_KERNEL::Exception);
120 MEDCalculatorDBField *magnitude() const throw(INTERP_KERNEL::Exception);
123 MEDCalculatorDBField *__radd__(double val)
125 MEDCalculatorDBFieldCst tmp(val);
129 MEDCalculatorDBField *__rsub__(double val)
131 MEDCalculatorDBFieldCst tmp(val);
135 MEDCalculatorDBField *__rmul__(double val)
137 MEDCalculatorDBFieldCst tmp(val);
141 MEDCalculatorDBField *__rdiv__(double val)
143 MEDCalculatorDBFieldCst tmp(val);
147 MEDCalculatorDBFieldReal *__getitem__(PyObject *obj) throw(INTERP_KERNEL::Exception)
149 if(!PyTuple_Check(obj))
150 throw INTERP_KERNEL::Exception("Unexpected type found : Tuple expected ! Should never happen !");
151 int sz=PyTuple_Size(obj);
153 throw INTERP_KERNEL::Exception("Unexpected nb of element in slice : 3 expected !\n1st is for time, 2nd for geometrical entities and 3rd for components of field !");
154 MEDCalculatorDBRangeSelection tr,pr,cr;
155 PyObject *obj0=PyTuple_GetItem(obj,0);
156 convertPyObjToRS2(obj0,tr,"for 1st tuple element for time");
157 PyObject *obj1=PyTuple_GetItem(obj,1);
158 convertPyObjToRS2(obj1,pr,"for 2nd tuple element for geometrical entities");
159 PyObject *obj2=PyTuple_GetItem(obj,2);
160 convertPyObjToRS2(obj2,cr,"for 3rd tuple element for components of field");
161 return self->operator()(tr,pr,cr);
164 MEDCalculatorDBFieldReal *__setitem__(PyObject *obj, PyObject *val) throw(INTERP_KERNEL::Exception)
166 MEDCalculatorDBRangeSelection tr,pr,cr;
167 if(!PyTuple_Check(obj))
169 const char msg[]="Unexpected type found : Tuple expected or [:] !";
170 if(!PySlice_Check(obj))
171 throw INTERP_KERNEL::Exception(msg);
172 Py_ssize_t strt,stp,step;
173 PySliceObject *oC=reinterpret_cast<PySliceObject *>(obj);
174 PySlice_GetIndices(oC,std::numeric_limits<int>::max(),&strt,&stp,&step);
175 if(strt!=0 || stp!=std::numeric_limits<int>::max() || step!=1)
176 throw INTERP_KERNEL::Exception(msg);
177 tr.setAll(); pr.setAll(); cr.setAll();
181 int sz=PyTuple_Size(obj);
183 throw INTERP_KERNEL::Exception("Unexpected nb of element in slice : 3 expected !\n1st is for time, 2nd for geometrical entities and 3rd for components of field !");
184 PyObject *obj0=PyTuple_GetItem(obj,0);
185 convertPyObjToRS2(obj0,tr,"for 1st tuple element for time");
186 PyObject *obj1=PyTuple_GetItem(obj,1);
187 convertPyObjToRS2(obj1,pr,"for 2nd tuple element for geometrical entities");
188 PyObject *obj2=PyTuple_GetItem(obj,2);
189 convertPyObjToRS2(obj2,cr,"for 3rd tuple element for components of field");
191 MEDCouplingAutoRefCountObjectPtr<MEDCalculatorDBFieldReal> ret=self->operator()(tr,pr,cr);
194 (*ret)=double(PyInt_AS_LONG(val));
198 if(PyFloat_Check(val))
200 (*ret)=PyFloat_AS_DOUBLE(val);
205 int status=SWIG_ConvertPtr(val,&argp,SWIGTYPE_p_MEDCoupling__MEDCalculatorDBFieldReal,0|0);
206 if(!SWIG_IsOK(status))
208 throw INTERP_KERNEL::Exception("For setting only float, int or DBFieldReal supported !");
210 const MEDCoupling::MEDCalculatorDBFieldReal *arg=reinterpret_cast< const MEDCoupling::MEDCalculatorDBFieldReal * >(argp);
216 MEDCalculatorDBFieldReal *operator()(PyObject *t, PyObject *p, PyObject *c) throw(INTERP_KERNEL::Exception)
218 MEDCalculatorDBRangeSelection tr,pr,cr;
219 convertPyObjToRS(t,tr);
220 convertPyObjToRS(p,pr);
221 convertPyObjToRS(c,cr);
222 return self->operator()(tr,pr,cr);
225 const MEDCalculatorDBFieldReal& assign(const MEDCalculatorDBFieldReal& other) throw(INTERP_KERNEL::Exception)
231 const MEDCalculatorDBFieldReal& assign(const MEDCalculatorDBFieldReal& other, const char *name) throw(INTERP_KERNEL::Exception)
238 const MEDCalculatorDBFieldReal& assign(double val) throw(INTERP_KERNEL::Exception)
244 const MEDCalculatorDBFieldReal& assign(double val, const char *name) throw(INTERP_KERNEL::Exception)
251 const MEDCalculatorDBFieldReal& assign(int val) throw(INTERP_KERNEL::Exception)
253 (*self)=(double) val;
257 const MEDCalculatorDBFieldReal& assign(int val, const char *name) throw(INTERP_KERNEL::Exception)
259 (*self)=(double) val;
264 PyObject *getFields() const throw(INTERP_KERNEL::Exception)
266 std::vector<MEDCouplingFieldDouble *> r=self->getFields();
267 PyObject *ret = PyList_New(r.size());
268 for(unsigned int i=0;i<r.size();i++)
270 MEDCouplingFieldDouble *tmp=r[i];
271 PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(tmp),SWIGTYPE_p_MEDCoupling__MEDCouplingFieldDouble, SWIG_POINTER_OWN | 0 ));
276 PyObject *getValues() const throw(INTERP_KERNEL::Exception)
278 std::vector<MEDCouplingFieldDouble *> r=self->getFields();
279 PyObject *ret = PyList_New(r.size());
280 for(unsigned int i=0;i<r.size();i++)
282 MEDCouplingFieldDouble *tmp=r[i];
283 const double *valtmp=tmp->getArray()->getConstPointer();
284 int nbvals=tmp->getNumberOfValues();
285 PyObject *ret2=PyList_New(nbvals);
286 for(int j=0;j<nbvals;j++)
287 PyList_SetItem(ret2,j,PyFloat_FromDouble(valtmp[j]));
288 PyList_SetItem(ret,i,ret2);
294 std::string __str__() const
296 return self->simpleRepr();
301 class MEDCalculatorDBFieldCst : public MEDCalculatorDBField
304 MEDCalculatorDBFieldCst(double val);
305 MEDCalculatorDBFieldCst(int val);
308 std::string __str__() const
310 std::ostringstream oss; oss << self->getValue();
318 def MEDCouplingDataArrayDoublenew(cls,*args):
319 import _MEDCalculator
320 return _MEDCalculator.DataArrayDouble____new___(cls,args)
321 def MEDCouplingDataArrayDoubleIadd(self,*args):
322 import _MEDCalculator
323 return _MEDCalculator.DataArrayDouble____iadd___(self, self, *args)
324 def MEDCouplingDataArrayDoubleIsub(self,*args):
325 import _MEDCalculator
326 return _MEDCalculator.DataArrayDouble____isub___(self, self, *args)
327 def MEDCouplingDataArrayDoubleImul(self,*args):
328 import _MEDCalculator
329 return _MEDCalculator.DataArrayDouble____imul___(self, self, *args)
330 def MEDCouplingDataArrayDoubleIdiv(self,*args):
331 import _MEDCalculator
332 return _MEDCalculator.DataArrayDouble____idiv___(self, self, *args)
333 def MEDCouplingDataArrayDoubleIpow(self,*args):
334 import _MEDCalculator
335 return _MEDCalculator.DataArrayDouble____ipow___(self, self, *args)
336 def MEDCouplingDataArrayDoubleTupleIadd(self,*args):
337 import _MEDCalculator
338 return _MEDCalculator.DataArrayDoubleTuple____iadd___(self, self, *args)
339 def MEDCouplingDataArrayDoubleTupleIsub(self,*args):
340 import _MEDCalculator
341 return _MEDCalculator.DataArrayDoubleTuple____isub___(self, self, *args)
342 def MEDCouplingDataArrayDoubleTupleImul(self,*args):
343 import _MEDCalculator
344 return _MEDCalculator.DataArrayDoubleTuple____imul___(self, self, *args)
345 def MEDCouplingDataArrayDoubleTupleIdiv(self,*args):
346 import _MEDCalculator
347 return _MEDCalculator.DataArrayDoubleTuple____idiv___(self, self, *args)
348 def MEDCouplingFieldDoublenew(cls,*args):
349 import _MEDCalculator
350 return _MEDCalculator.MEDCouplingFieldDouble____new___(cls,args)
351 def MEDCouplingFieldDoubleIadd(self,*args):
352 import _MEDCalculator
353 return _MEDCalculator.MEDCouplingFieldDouble____iadd___(self, self, *args)
354 def MEDCouplingFieldDoubleIsub(self,*args):
355 import _MEDCalculator
356 return _MEDCalculator.MEDCouplingFieldDouble____isub___(self, self, *args)
357 def MEDCouplingFieldDoubleImul(self,*args):
358 import _MEDCalculator
359 return _MEDCalculator.MEDCouplingFieldDouble____imul___(self, self, *args)
360 def MEDCouplingFieldDoubleIdiv(self,*args):
361 import _MEDCalculator
362 return _MEDCalculator.MEDCouplingFieldDouble____idiv___(self, self, *args)
363 def MEDCouplingFieldDoubleIpow(self,*args):
364 import _MEDCalculator
365 return _MEDCalculator.MEDCouplingFieldDouble____ipow___(self, self, *args)
366 def MEDCouplingDataArrayIntnew(cls,*args):
367 import _MEDCalculator
368 return _MEDCalculator.DataArrayInt____new___(cls,args)
369 def MEDCouplingDataArrayIntIadd(self,*args):
370 import _MEDCalculator
371 return _MEDCalculator.DataArrayInt____iadd___(self, self, *args)
372 def MEDCouplingDataArrayIntIsub(self,*args):
373 import _MEDCalculator
374 return _MEDCalculator.DataArrayInt____isub___(self, self, *args)
375 def MEDCouplingDataArrayIntImul(self,*args):
376 import _MEDCalculator
377 return _MEDCalculator.DataArrayInt____imul___(self, self, *args)
378 def MEDCouplingDataArrayIntIdiv(self,*args):
379 import _MEDCalculator
380 return _MEDCalculator.DataArrayInt____idiv___(self, self, *args)
381 def MEDCouplingDataArrayIntImod(self,*args):
382 import _MEDCalculator
383 return _MEDCalculator.DataArrayInt____imod___(self, self, *args)
384 def MEDCouplingDataArrayIntIpow(self,*args):
385 import _MEDCalculator
386 return _MEDCalculator.DataArrayInt____ipow___(self, self, *args)
387 def MEDCouplingDataArrayIntTupleIadd(self,*args):
388 import _MEDCalculator
389 return _MEDCalculator.DataArrayIntTuple____iadd___(self, self, *args)
390 def MEDCouplingDataArrayIntTupleIsub(self,*args):
391 import _MEDCalculator
392 return _MEDCalculator.DataArrayIntTuple____isub___(self, self, *args)
393 def MEDCouplingDataArrayIntTupleImul(self,*args):
394 import _MEDCalculator
395 return _MEDCalculator.DataArrayIntTuple____imul___(self, self, *args)
396 def MEDCouplingDataArrayIntTupleIdiv(self,*args):
397 import _MEDCalculator
398 return _MEDCalculator.DataArrayIntTuple____idiv___(self, self, *args)
399 def MEDCouplingDataArrayIntTupleImod(self,*args):
400 import _MEDCalculator
401 return _MEDCalculator.DataArrayIntTuple____imod___(self, self, *args)
402 def ParaMEDMEMDenseMatrixIadd(self,*args):
403 import _MEDCalculator
404 return _MEDCalculator.DenseMatrix____iadd___(self, self, *args)
405 def ParaMEDMEMDenseMatrixIsub(self,*args):
406 import _MEDCalculator
407 return _MEDCalculator.DenseMatrix____isub___(self, self, *args)
408 def MEDCouplingUMeshnew(cls,*args):
409 import _MEDCalculator
410 return _MEDCalculator.MEDCouplingUMesh____new___(cls,args)
411 def MEDCoupling1DGTUMeshnew(cls,*args):
412 import _MEDCalculator
413 return _MEDCalculator.MEDCoupling1DGTUMesh____new___(cls,args)
414 def MEDCoupling1SGTUMeshnew(cls,*args):
415 import _MEDCalculator
416 return _MEDCalculator.MEDCoupling1SGTUMesh____new___(cls,args)
417 def MEDCouplingCurveLinearMeshnew(cls,*args):
418 import _MEDCalculator
419 return _MEDCalculator.MEDCouplingCurveLinearMesh____new___(cls,args)
420 def MEDCouplingCMeshnew(cls,*args):
421 import _MEDCalculator
422 return _MEDCalculator.MEDCouplingCMesh____new___(cls,args)
423 def MEDCouplingIMeshnew(cls,*args):
424 import _MEDCalculator
425 return _MEDCalculator.MEDCouplingIMesh____new___(cls,args)
426 def MEDCouplingExtrudedMeshnew(cls,*args):
427 import _MEDCalculator
428 return _MEDCalculator.MEDCouplingExtrudedMesh____new___(cls,args)
432 def ParaMEDMEMMEDFileUMeshnew(cls,*args):
433 import _MEDCalculator
434 return _MEDCalculator.MEDFileUMesh____new___(cls,args)
437 %include "MEDCouplingFinalize.i"
440 MEDFileUMesh.__new__=classmethod(ParaMEDMEMMEDFileUMeshnew)
441 del ParaMEDMEMMEDFileUMeshnew