Salome HOME
c0c6984a869a0ecd05c5fb1efd121caf5ac3e678
[tools/medcoupling.git] / src / ParaMEDMEM / InterpolationMatrix.hxx
1 //  Copyright (C) 2007-2008  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 #ifndef __INTERPOLATIONMATRIX_HXX__
20 #define __INTERPOLATIONMATRIX_HXX__
21
22 #include "MPIAccessDEC.hxx"
23 #include "MxN_Mapping.hxx"
24 #include "InterpolationOptions.hxx"
25 #include "DECOptions.hxx"
26
27 namespace ParaMEDMEM
28 {
29   class InterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
30                               public DECOptions
31   {
32   public:
33     
34     InterpolationMatrix(ParaMEDMEM::ParaMESH *source_support, 
35                         const ProcessorGroup& source_group,
36                         const ProcessorGroup& target_group,
37                         const DECOptions& dec_opt,
38                         const InterpolationOptions& i_opt);
39
40     
41     virtual ~InterpolationMatrix();
42     void addContribution(MEDCouplingUMesh& distant_support, int iproc_distant,
43                          int* distant_elems, const std::string& srcMeth, const std::string& targetMeth);
44     void multiply(MEDCouplingFieldDouble& field) const;
45     void transposeMultiply(MEDCouplingFieldDouble& field)const;
46     void prepare();
47     int getNbRows() const {return _row_offsets.size();}
48     MPIAccessDEC* getAccessDEC(){return _mapping.getAccessDEC();}
49
50     static MEDCouplingFieldDouble *getSupportVolumes(MEDCouplingMesh *field);
51     static MEDCouplingFieldDouble *getSupportUnstructuredVolumes(MEDCouplingUMesh *field);
52   private:
53     std::vector<int> _row_offsets;
54     std::vector<std::pair<int,int> > _col_offsets;
55     MEDCouplingUMesh *_source_support; 
56     MxN_Mapping _mapping;
57  
58     const ProcessorGroup& _source_group;
59     const ProcessorGroup& _target_group;
60     std::vector<double> _target_volume;
61     std::vector<double> _source_volume;
62     std::vector<std::vector<std::pair<int,double> > > _coeffs;
63   };
64 }
65
66 #endif