1 // Copyright (C) 2007-2014 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
20 %module MEDCouplingRemapper
22 #define MEDCOUPLING_EXPORT
23 #define INTERPKERNEL_EXPORT
24 #define MEDCOUPLINGREMAPPER_EXPORT
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCouplingUMesh.hxx"
29 #include "MEDCouplingField.hxx"
30 #include "MEDCouplingFieldDouble.hxx"
31 #include "MEDCouplingRemapper.hxx"
33 using namespace ParaMEDMEM;
34 using namespace INTERP_KERNEL;
37 %newobject ParaMEDMEM::MEDCouplingRemapper::transferField;
38 %newobject ParaMEDMEM::MEDCouplingRemapper::reverseTransferField;
40 %include "MEDCouplingCommon.i"
41 %include "InterpolationOptions.hxx"
48 NOT_IK_ONLY_PREFERED = 1,
51 } InterpolationMatrixPolicy;
53 class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
56 void updateTime() const;
58 MEDCouplingRemapper();
59 ~MEDCouplingRemapper();
60 int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method) throw(INTERP_KERNEL::Exception);
61 int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
62 void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
63 void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
64 void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
65 MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
66 MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
67 bool setOptionInt(const std::string& key, int value) throw(INTERP_KERNEL::Exception);
68 bool setOptionDouble(const std::string& key, double value) throw(INTERP_KERNEL::Exception);
69 bool setOptionString(const std::string& key, const std::string& value) throw(INTERP_KERNEL::Exception);
70 int getInterpolationMatrixPolicy() const throw(INTERP_KERNEL::Exception);
71 void setInterpolationMatrixPolicy(int newInterpMatPol) throw(INTERP_KERNEL::Exception);
73 int nullifiedTinyCoeffInCrudeMatrixAbs(double maxValAbs) throw(INTERP_KERNEL::Exception);
74 int nullifiedTinyCoeffInCrudeMatrix(double scaleFactor) throw(INTERP_KERNEL::Exception);
75 double getMaxValueInCrudeMatrix() const throw(INTERP_KERNEL::Exception);
76 int getNumberOfColsOfMatrix() const throw(INTERP_KERNEL::Exception);
77 static std::string BuildMethodFrom(const std::string& meth1, const std::string& meth2) throw(INTERP_KERNEL::Exception);
80 PyObject *getCrudeMatrix() const throw(INTERP_KERNEL::Exception)
82 const std::vector<std::map<int,double> >& m=self->getCrudeMatrix();
83 std::size_t sz=m.size();
84 PyObject *ret=PyList_New(sz);
85 for(std::size_t i=0;i<sz;i++)
87 const std::map<int,double>& row=m[i];
88 PyObject *ret0=PyDict_New();
89 for(std::map<int,double>::const_iterator it=row.begin();it!=row.end();it++)
90 PyDict_SetItem(ret0,PyInt_FromLong((*it).first),PyFloat_FromDouble((*it).second));
91 PyList_SetItem(ret,i,ret0);
95 #if defined(WITH_NUMPY) && defined(WITH_SCIPY)
96 PyObject *getCrudeCSRMatrix() const throw(INTERP_KERNEL::Exception)
98 return ToCSRMatrix(self->getCrudeMatrix(),self->getNumberOfColsOfMatrix());
106 def ParaMEDMEMDataArrayDoubleIadd(self,*args):
107 import _MEDCouplingRemapper
108 return _MEDCouplingRemapper.DataArrayDouble____iadd___(self, self, *args)
109 def ParaMEDMEMDataArrayDoubleIsub(self,*args):
110 import _MEDCouplingRemapper
111 return _MEDCouplingRemapper.DataArrayDouble____isub___(self, self, *args)
112 def ParaMEDMEMDataArrayDoubleImul(self,*args):
113 import _MEDCouplingRemapper
114 return _MEDCouplingRemapper.DataArrayDouble____imul___(self, self, *args)
115 def ParaMEDMEMDataArrayDoubleIdiv(self,*args):
116 import _MEDCouplingRemapper
117 return _MEDCouplingRemapper.DataArrayDouble____idiv___(self, self, *args)
118 def ParaMEDMEMDataArrayDoubleIpow(self,*args):
119 import _MEDCouplingRemapper
120 return _MEDCouplingRemapper.DataArrayDouble____ipow___(self, self, *args)
121 def ParaMEDMEMMEDCouplingFieldDoubleIadd(self,*args):
122 import _MEDCouplingRemapper
123 return _MEDCouplingRemapper.MEDCouplingFieldDouble____iadd___(self, self, *args)
124 def ParaMEDMEMMEDCouplingFieldDoubleIsub(self,*args):
125 import _MEDCouplingRemapper
126 return _MEDCouplingRemapper.MEDCouplingFieldDouble____isub___(self, self, *args)
127 def ParaMEDMEMMEDCouplingFieldDoubleImul(self,*args):
128 import _MEDCouplingRemapper
129 return _MEDCouplingRemapper.MEDCouplingFieldDouble____imul___(self, self, *args)
130 def ParaMEDMEMMEDCouplingFieldDoubleIdiv(self,*args):
131 import _MEDCouplingRemapper
132 return _MEDCouplingRemapper.MEDCouplingFieldDouble____idiv___(self, self, *args)
133 def ParaMEDMEMMEDCouplingFieldDoubleIpow(self,*args):
134 import _MEDCouplingRemapper
135 return _MEDCouplingRemapper.MEDCouplingFieldDouble____ipow___(self, self, *args)
136 def ParaMEDMEMDataArrayIntIadd(self,*args):
137 import _MEDCouplingRemapper
138 return _MEDCouplingRemapper.DataArrayInt____iadd___(self, self, *args)
139 def ParaMEDMEMDataArrayIntIsub(self,*args):
140 import _MEDCouplingRemapper
141 return _MEDCouplingRemapper.DataArrayInt____isub___(self, self, *args)
142 def ParaMEDMEMDataArrayIntImul(self,*args):
143 import _MEDCouplingRemapper
144 return _MEDCouplingRemapper.DataArrayInt____imul___(self, self, *args)
145 def ParaMEDMEMDataArrayIntIdiv(self,*args):
146 import _MEDCouplingRemapper
147 return _MEDCouplingRemapper.DataArrayInt____idiv___(self, self, *args)
148 def ParaMEDMEMDataArrayIntImod(self,*args):
149 import _MEDCouplingRemapper
150 return _MEDCouplingRemapper.DataArrayInt____imod___(self, self, *args)
151 def ParaMEDMEMDataArrayIntIpow(self,*args):
152 import _MEDCouplingRemapper
153 return _MEDCouplingRemapper.DataArrayInt____ipow___(self, self, *args)
154 def ParaMEDMEMDataArrayDoubleTupleIadd(self,*args):
155 import _MEDCouplingRemapper
156 return _MEDCouplingRemapper.DataArrayDoubleTuple____iadd___(self, self, *args)
157 def ParaMEDMEMDataArrayDoubleTupleIsub(self,*args):
158 import _MEDCouplingRemapper
159 return _MEDCouplingRemapper.DataArrayDoubleTuple____isub___(self, self, *args)
160 def ParaMEDMEMDataArrayDoubleTupleImul(self,*args):
161 import _MEDCouplingRemapper
162 return _MEDCouplingRemapper.DataArrayDoubleTuple____imul___(self, self, *args)
163 def ParaMEDMEMDataArrayDoubleTupleIdiv(self,*args):
164 import _MEDCouplingRemapper
165 return _MEDCouplingRemapper.DataArrayDoubleTuple____idiv___(self, self, *args)
166 def ParaMEDMEMDataArrayIntTupleIadd(self,*args):
167 import _MEDCouplingRemapper
168 return _MEDCouplingRemapper.DataArrayIntTuple____iadd___(self, self, *args)
169 def ParaMEDMEMDataArrayIntTupleIsub(self,*args):
170 import _MEDCouplingRemapper
171 return _MEDCouplingRemapper.DataArrayIntTuple____isub___(self, self, *args)
172 def ParaMEDMEMDataArrayIntTupleImul(self,*args):
173 import _MEDCouplingRemapper
174 return _MEDCouplingRemapper.DataArrayIntTuple____imul___(self, self, *args)
175 def ParaMEDMEMDataArrayIntTupleIdiv(self,*args):
176 import _MEDCouplingRemapper
177 return _MEDCouplingRemapper.DataArrayIntTuple____idiv___(self, self, *args)
178 def ParaMEDMEMDataArrayIntTupleImod(self,*args):
179 import _MEDCouplingRemapper
180 return _MEDCouplingRemapper.DataArrayIntTuple____imod___(self, self, *args)
181 def ParaMEDMEMDenseMatrixIadd(self,*args):
182 import _MEDCouplingRemapper
183 return _MEDCouplingRemapper.DenseMatrix____iadd___(self, self, *args)
184 def ParaMEDMEMDenseMatrixIsub(self,*args):
185 import _MEDCouplingRemapper
186 return _MEDCouplingRemapper.DenseMatrix____isub___(self, self, *args)
189 %include "MEDCouplingFinalize.i"