Salome HOME
Merge from V6_main (04/10/2012)
[modules/med.git] / src / MEDCoupling_Swig / MEDCouplingRemapper.i
1 // Copyright (C) 2007-2012  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.
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 %module MEDCouplingRemapper
21
22 #define MEDCOUPLING_EXPORT
23 #define INTERPKERNEL_EXPORT
24 #define MEDCOUPLINGREMAPPER_EXPORT
25
26 %{
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCouplingUMesh.hxx"
29 #include "MEDCouplingField.hxx"
30 #include "MEDCouplingFieldDouble.hxx"
31 #include "MEDCouplingRemapper.hxx"
32
33 using namespace ParaMEDMEM;
34 using namespace INTERP_KERNEL;
35 %}
36
37 %newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
38 %newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
39
40 %include "MEDCouplingCommon.i"
41 %include "InterpolationOptions.hxx"
42
43 namespace ParaMEDMEM
44 {
45   class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
46     {
47     private:
48       void updateTime() const;
49     public:
50       MEDCouplingRemapper();
51       ~MEDCouplingRemapper();
52       int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception);
53       int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
54       void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
55       void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
56       void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
57       MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
58       MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
59       bool setOptionInt(const std::string& key, int value);
60       bool setOptionDouble(const std::string& key, double value);
61       bool setOptionString(const std::string& key, const std::string& value);
62       //
63       int nullifiedTinyCoeffInCrudeMatrixAbs(double maxValAbs) throw(INTERP_KERNEL::Exception);
64       int nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) throw(INTERP_KERNEL::Exception);
65       double getMaxValueInCrudeMatrix() const throw(INTERP_KERNEL::Exception);
66       %extend
67          {
68            PyObject *getCrudeMatrix() const
69            {
70              const std::vector<std::map<int,double> >& m=self->getCrudeMatrix();
71              std::size_t sz=m.size();
72              PyObject *ret=PyList_New(sz);
73              for(std::size_t i=0;i<sz;i++)
74                {
75                  const std::map<int,double>& row=m[i];
76                  PyObject *ret0=PyDict_New();
77                  for(std::map<int,double>::const_iterator it=row.begin();it!=row.end();it++)
78                    PyDict_SetItem(ret0,PyInt_FromLong((*it).first),PyFloat_FromDouble((*it).second));
79                  PyList_SetItem(ret,i,ret0);
80                }
81              return ret;
82            }
83          }
84     };
85 }
86
87 %pythoncode %{
88 def ParaMEDMEMDataArrayDoubleIadd(self,*args):
89     import _MEDCouplingRemapper
90     return _MEDCouplingRemapper.DataArrayDouble____iadd___(self, self, *args)
91 def ParaMEDMEMDataArrayDoubleIsub(self,*args):
92     import _MEDCouplingRemapper
93     return _MEDCouplingRemapper.DataArrayDouble____isub___(self, self, *args)
94 def ParaMEDMEMDataArrayDoubleImul(self,*args):
95     import _MEDCouplingRemapper
96     return _MEDCouplingRemapper.DataArrayDouble____imul___(self, self, *args)
97 def ParaMEDMEMDataArrayDoubleIdiv(self,*args):
98     import _MEDCouplingRemapper
99     return _MEDCouplingRemapper.DataArrayDouble____idiv___(self, self, *args)
100 def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
101     import _MEDCouplingRemapper
102     return _MEDCouplingRemapper.MEDCouplingFieldDouble____iadd___(self, self, *args)
103 def ParaMEDMEMMEDCouplingFieldDoubleIsub(self,*args):
104     import _MEDCouplingRemapper
105     return _MEDCouplingRemapper.MEDCouplingFieldDouble____isub___(self, self, *args)
106 def ParaMEDMEMMEDCouplingFieldDoubleImul(self,*args):
107     import _MEDCouplingRemapper
108     return _MEDCouplingRemapper.MEDCouplingFieldDouble____imul___(self, self, *args)
109 def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args):
110     import _MEDCouplingRemapper
111     return _MEDCouplingRemapper.MEDCouplingFieldDouble____idiv___(self, self, *args)
112 def ParaMEDMEMDataArrayIntIadd(self,*args):
113     import _MEDCouplingRemapper
114     return _MEDCouplingRemapper.DataArrayInt____iadd___(self, self, *args)
115 def ParaMEDMEMDataArrayIntIsub(self,*args):
116     import _MEDCouplingRemapper
117     return _MEDCouplingRemapper.DataArrayInt____isub___(self, self, *args)
118 def ParaMEDMEMDataArrayIntImul(self,*args):
119     import _MEDCouplingRemapper
120     return _MEDCouplingRemapper.DataArrayInt____imul___(self, self, *args)
121 def ParaMEDMEMDataArrayIntIdiv(self,*args):
122     import _MEDCouplingRemapper
123     return _MEDCouplingRemapper.DataArrayInt____idiv___(self, self, *args)
124 def ParaMEDMEMDataArrayIntImod(self,*args):
125     import _MEDCouplingRemapper
126     return _MEDCouplingRemapper.DataArrayInt____imod___(self, self, *args)
127 def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
128     import _MEDCouplingRemapper
129     return _MEDCouplingRemapper.DataArrayDoubleTuple____iadd___(self, self, *args)
130 def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
131     import _MEDCouplingRemapper
132     return _MEDCouplingRemapper.DataArrayDoubleTuple____isub___(self, self, *args)
133 def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
134     import _MEDCouplingRemapper
135     return _MEDCouplingRemapper.DataArrayDoubleTuple____imul___(self, self, *args)
136 def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
137     import _MEDCouplingRemapper
138     return _MEDCouplingRemapper.DataArrayDoubleTuple____idiv___(self, self, *args)
139 def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
140     import _MEDCouplingRemapper
141     return _MEDCouplingRemapper.DataArrayIntTuple____iadd___(self, self, *args)
142 def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
143     import _MEDCouplingRemapper
144     return _MEDCouplingRemapper.DataArrayIntTuple____isub___(self, self, *args)
145 def ParaMEDMEMDataArrayIntTupleImul(self,*args):
146     import _MEDCouplingRemapper
147     return _MEDCouplingRemapper.DataArrayIntTuple____imul___(self, self, *args)
148 def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
149     import _MEDCouplingRemapper
150     return _MEDCouplingRemapper.DataArrayIntTuple____idiv___(self, self, *args)
151 def ParaMEDMEMDataArrayIntTupleImod(self,*args):
152     import _MEDCouplingRemapper
153     return _MEDCouplingRemapper.DataArrayIntTuple____imod___(self, self, *args)
154 %}
155
156 %include "MEDCouplingFinalize.i"