1 // Copyright (C) 2017 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 #define MEDCOUPLING_EXPORT
21 #define INTERPKERNEL_EXPORT
22 #define MEDCOUPLINGREMAPPER_EXPORT
24 %newobject MEDCoupling::MEDCouplingRemapper::transferField;
25 %newobject MEDCoupling::MEDCouplingRemapper::reverseTransferField;
28 #include "MEDCouplingRemapper.hxx"
31 %include "InterpolationOptions.hxx"
38 NOT_IK_ONLY_PREFERED = 1,
41 } InterpolationMatrixPolicy;
43 class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
46 void updateTime() const;
48 MEDCouplingRemapper();
49 ~MEDCouplingRemapper();
50 int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method) throw(INTERP_KERNEL::Exception);
51 int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
52 void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
53 void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
54 void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
55 MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
56 MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
57 bool setOptionInt(const std::string& key, int value) throw(INTERP_KERNEL::Exception);
58 bool setOptionDouble(const std::string& key, double value) throw(INTERP_KERNEL::Exception);
59 bool setOptionString(const std::string& key, const std::string& value) throw(INTERP_KERNEL::Exception);
60 int getInterpolationMatrixPolicy() const throw(INTERP_KERNEL::Exception);
61 void setInterpolationMatrixPolicy(int newInterpMatPol) throw(INTERP_KERNEL::Exception);
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 int getNumberOfColsOfMatrix() const throw(INTERP_KERNEL::Exception);
67 static std::string BuildMethodFrom(const std::string& meth1, const std::string& meth2) throw(INTERP_KERNEL::Exception);
70 PyObject *getCrudeMatrix() const throw(INTERP_KERNEL::Exception)
72 const std::vector<std::map<int,double> >& m=self->getCrudeMatrix();
73 std::size_t sz=m.size();
74 PyObject *ret=PyList_New(sz);
75 for(std::size_t i=0;i<sz;i++)
77 const std::map<int,double>& row=m[i];
78 PyObject *ret0=PyDict_New();
79 for(std::map<int,double>::const_iterator it=row.begin();it!=row.end();it++)
80 PyDict_SetItem(ret0,PyInt_FromLong((*it).first),PyFloat_FromDouble((*it).second));
81 PyList_SetItem(ret,i,ret0);
85 #if defined(WITH_NUMPY) && defined(WITH_SCIPY)
86 PyObject *getCrudeCSRMatrix() const throw(INTERP_KERNEL::Exception)
88 return ToCSRMatrix(self->getCrudeMatrix(),self->getNumberOfColsOfMatrix());
91 void setMatrix(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const std::string& method, PyObject *m) throw(INTERP_KERNEL::Exception)
93 std::vector<std::map<int,double> > mCpp;
94 convertToVectMapIntDouble(m,mCpp);
95 self->setMatrix(srcMesh,targetMesh,mCpp);