Back to index

salome-med  6.5.0
MEDCouplingRemapper.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #ifndef __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__
00021 #define __PARAMEDMEM_MEDCOUPLINGREMAPPER_HXX__
00022 
00023 #include "MEDCoupling.hxx"
00024 #include "MEDCouplingTimeLabel.hxx"
00025 #include "InterpolationOptions.hxx"
00026 #include "MEDCouplingNatureOfField.hxx"
00027 #include "InterpKernelException.hxx"
00028 
00029 #include <map>
00030 #include <vector>
00031 
00032 namespace ParaMEDMEM
00033 {
00034   class MEDCouplingMesh;
00035   class MEDCouplingUMesh;
00036   class MEDCouplingFieldDouble;
00037   class MEDCouplingFieldTemplate;
00038 }
00039 
00040 namespace ParaMEDMEM
00041 {
00042   class MEDCouplingRemapper : public TimeLabel, public INTERP_KERNEL::InterpolationOptions
00043   {
00044   public:
00045     MEDCOUPLINGREMAPPER_EXPORT MEDCouplingRemapper();
00046     MEDCOUPLINGREMAPPER_EXPORT ~MEDCouplingRemapper();
00047     MEDCOUPLINGREMAPPER_EXPORT int prepare(const MEDCouplingMesh *srcMesh, const MEDCouplingMesh *targetMesh, const char *method) throw(INTERP_KERNEL::Exception);
00048     MEDCOUPLINGREMAPPER_EXPORT int prepareEx(const MEDCouplingFieldTemplate *src, const MEDCouplingFieldTemplate *target) throw(INTERP_KERNEL::Exception);
00049     MEDCOUPLINGREMAPPER_EXPORT void transfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
00050     MEDCOUPLINGREMAPPER_EXPORT void partialTransfer(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField) throw(INTERP_KERNEL::Exception);
00051     MEDCOUPLINGREMAPPER_EXPORT void reverseTransfer(MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
00052     MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *transferField(const MEDCouplingFieldDouble *srcField, double dftValue) throw(INTERP_KERNEL::Exception);
00053     MEDCOUPLINGREMAPPER_EXPORT MEDCouplingFieldDouble *reverseTransferField(const MEDCouplingFieldDouble *targetField, double dftValue) throw(INTERP_KERNEL::Exception);
00054     MEDCOUPLINGREMAPPER_EXPORT bool setOptionInt(const std::string& key, int value);
00055     MEDCOUPLINGREMAPPER_EXPORT bool setOptionDouble(const std::string& key, double value);
00056     MEDCOUPLINGREMAPPER_EXPORT bool setOptionString(const std::string& key, const std::string& value);
00057   public:
00058     MEDCOUPLINGREMAPPER_EXPORT const std::vector<std::map<int,double> >& getCrudeMatrix() const;
00059     MEDCOUPLINGREMAPPER_EXPORT static void PrintMatrix(const std::vector<std::map<int,double> >& m);
00060   private:
00061     int prepareUU(const char *method) throw(INTERP_KERNEL::Exception);
00062     int prepareEE(const char *method) throw(INTERP_KERNEL::Exception);
00063     void updateTime() const;
00064     void releaseData(bool matrixSuppression);
00065     void transferUnderground(const MEDCouplingFieldDouble *srcField, MEDCouplingFieldDouble *targetField, bool isDftVal, double dftValue) throw(INTERP_KERNEL::Exception);
00066     void computeDeno(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField);
00067     void computeDenoFromScratch(NatureOfField nat, const MEDCouplingFieldDouble *srcField, const MEDCouplingFieldDouble *trgField) throw(INTERP_KERNEL::Exception);
00068     void computeProduct(const double *inputPointer, int inputNbOfCompo, bool isDftVal, double dftValue, double *resPointer);
00069     void computeReverseProduct(const double *inputPointer, int inputNbOfCompo, double dftValue, double *resPointer);
00070     void buildFinalInterpolationMatrixByConvolution(const std::vector< std::map<int,double> >& m1D,
00071                                                     const std::vector< std::map<int,double> >& m2D,
00072                                                     const int *corrCellIdSrc, int nbOf2DCellsSrc, int nbOf1DCellsSrc,
00073                                                     const int *corrCellIdTrg);
00074     static void reverseMatrix(const std::vector<std::map<int,double> >& matIn, int nbColsMatIn,
00075                               std::vector<std::map<int,double> >& matOut);
00076     static void computeRowSumAndColSum(const std::vector<std::map<int,double> >& matrixDeno,
00077                                        std::vector<std::map<int,double> >& deno, std::vector<std::map<int,double> >& denoReverse);
00078     static void computeColSumAndRowSum(const std::vector<std::map<int,double> >& matrixDeno,
00079                                        std::vector<std::map<int,double> >& deno, std::vector<std::map<int,double> >& denoReverse);
00080   private:
00081     MEDCouplingMesh *_src_mesh;
00082     MEDCouplingMesh *_target_mesh;
00083     std::string _src_method;
00084     std::string _target_method;
00085     NatureOfField _nature_of_deno;
00086     unsigned int _time_deno_update;
00087     std::vector<std::map<int,double> > _matrix;
00088     std::vector<std::map<int,double> > _deno_multiply;
00089     std::vector<std::map<int,double> > _deno_reverse_multiply;
00090   };
00091 }
00092 
00093 #endif