1 // Copyright (C) 2007-2012 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.
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 #ifndef __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__
23 #include "MEDCoupling.hxx"
24 #include "MEDCouplingTimeLabel.hxx"
25 #include "InterpolationOptions.hxx"
26 #include "MEDCouplingNatureOfField.hxx"
27 #include "InterpKernelException.hxx"
34 class MEDCouplingMesh;
35 class MEDCouplingUMesh;
36 class MEDCouplingFieldDouble;
37 class MEDCouplingFieldTemplate;
42 class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
45 MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper();
46 MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper();
47 MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception);
48 MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
49 MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
50 MEDCOUPLINGREMAPPER_EXPORT void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
51 MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
52 MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
53 MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
54 MEDCOUPLINGREMAPPER_EXPORT bool setOptionInt(const std::string& key, int value);
55 MEDCOUPLINGREMAPPER_EXPORT bool setOptionDouble(const std::string& key, double value);
56 MEDCOUPLINGREMAPPER_EXPORT bool setOptionString(const std::string& key, const std::string& value);
58 MEDCOUPLINGREMAPPER_EXPORT const std::vector<std::map<int,double> >& getCrudeMatrix() const;
59 MEDCOUPLINGREMAPPER_EXPORT static void PrintMatrix(const std::vector<std::map<int,double> >& m);
61 int prepareUU(const char *method) throw(INTERP_KERNEL::Exception);
62 int prepareEE(const char *method) throw(INTERP_KERNEL::Exception);
63 void updateTime() const;
64 void releaseData(bool matrixSuppression);
65 void transferUnderground(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, bool isDftVal, double dftValue) throw(INTERP_KERNEL::Exception);
66 void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField);
67 void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception);
68 void computeProduct(const double *inputPointer, int inputNbOfCompo, bool isDftVal, double dftValue, double *resPointer);
69 void computeReverseProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer);
70 void buildFinalInterpolationMatrixByConvolution(const std::vector< std::map<int,double> >& m1D,
71 const std::vector< std::map<int,double> >& m2D,
72 const int *corrCellIdSrc, int nbOf2DCellsSrc, int nbOf1DCellsSrc,
73 const int *corrCellIdTrg);
74 static void reverseMatrix(const std::vector<std::map<int,double> >& matIn, int nbColsMatIn,
75 std::vector<std::map<int,double> >& matOut);
76 static void computeRowSumAndColSum(const std::vector<std::map<int,double> >& matrixDeno,
77 std::vector<std::map<int,double> >& deno, std::vector<std::map<int,double> >& denoReverse);
78 static void computeColSumAndRowSum(const std::vector<std::map<int,double> >& matrixDeno,
79 std::vector<std::map<int,double> >& deno, std::vector<std::map<int,double> >& denoReverse);
81 MEDCouplingMesh *_src_mesh;
82 MEDCouplingMesh *_target_mesh;
83 std::string _src_method;
84 std::string _target_method;
85 NatureOfField _nature_of_deno;
86 unsigned int _time_deno_update;
87 std::vector<std::map<int,double> > _matrix;
88 std::vector<std::map<int,double> > _deno_multiply;
89 std::vector<std::map<int,double> > _deno_reverse_multiply;