]> SALOME platform Git repositories - modules/med.git/blob - src/ParaMEDMEM/OverlapInterpolationMatrix.hxx
Salome HOME
Merge from V6_main 01/04/2013
[modules/med.git] / src / ParaMEDMEM / OverlapInterpolationMatrix.hxx
1 // Copyright (C) 2007-2013  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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __OVERLAPINTERPOLATIONMATRIX_HXX__
22 #define __OVERLAPINTERPOLATIONMATRIX_HXX__
23
24 #include "MPIAccessDEC.hxx"
25 #include "OverlapMapping.hxx"
26 #include "InterpolationOptions.hxx"
27 #include "DECOptions.hxx"
28
29 namespace ParaMEDMEM
30 {
31   class ParaFIELD;
32   class MEDCouplingPointSet;
33
34   class OverlapInterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
35                                      public DECOptions
36   {
37   public:
38     
39     OverlapInterpolationMatrix(ParaFIELD *source_field,
40                                ParaFIELD *target_field,
41                                const ProcessorGroup& group,
42                                const DECOptions& dec_opt,
43                                const InterpolationOptions& i_opt);
44
45     void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
46
47     void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
48
49     void addContribution(const MEDCouplingPointSet *src, const DataArrayInt *srcIds, const std::string& srcMeth, int srcProcId,
50                          const MEDCouplingPointSet *trg, const DataArrayInt *trgIds, const std::string& trgMeth, int trgProcId);
51
52     void prepare(const std::vector< std::vector<int> >& procsInInteraction);
53     
54     void computeDeno();
55
56     void multiply();
57
58     void transposeMultiply();
59     
60     virtual ~OverlapInterpolationMatrix();
61 #if 0
62     void addContribution(MEDCouplingPointSet& distant_support, int iproc_distant,
63                          const int* distant_elems, const std::string& srcMeth, const std::string& targetMeth);
64     void finishContributionW(ElementLocator& elementLocator);
65     void finishContributionL(ElementLocator& elementLocator);
66     void multiply(MEDCouplingFieldDouble& field) const;
67     void transposeMultiply(MEDCouplingFieldDouble& field)const;
68     void prepare();
69     int getNbRows() const { return _row_offsets.size(); }
70     MPIAccessDEC* getAccessDEC() { return _mapping.getAccessDEC(); }
71   private:
72     void computeConservVolDenoW(ElementLocator& elementLocator);
73     void computeIntegralDenoW(ElementLocator& elementLocator);
74     void computeRevIntegralDenoW(ElementLocator& elementLocator);
75     void computeGlobConstraintDenoW(ElementLocator& elementLocator);
76     void computeConservVolDenoL(ElementLocator& elementLocator);
77     void computeIntegralDenoL(ElementLocator& elementLocator);
78     void computeRevIntegralDenoL(ElementLocator& elementLocator);
79     
80     void computeLocalColSum(std::vector<double>& res) const;
81     void computeLocalRowSum(const std::vector<int>& distantProcs, std::vector<std::vector<int> >& resPerProcI,
82                             std::vector<std::vector<double> >& resPerProcD) const;
83     void computeGlobalRowSum(ElementLocator& elementLocator, std::vector<std::vector<double> >& denoStrorage, std::vector<std::vector<double> >& denoStrorageInv);
84     void computeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
85     void resizeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
86     void fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map<int,double> >& values, MEDCouplingFieldDouble *surf);
87     void serializeMe(std::vector< std::vector< std::map<int,double> > >& data1, std::vector<int>& data2) const;
88     void initialize();
89     void findAdditionnalElements(ElementLocator& elementLocator, std::vector<std::vector<int> >& elementsToAdd,
90                                  const std::vector<std::vector<int> >& resPerProcI, const std::vector<std::vector<int> >& globalIdsPartial);
91     void addGhostElements(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& elementsToAdd);
92     int mergePolicies(const std::vector<int>& policyPartial);
93     void mergeRowSum(const std::vector< std::vector<double> >& rowsPartialSumD, const std::vector< std::vector<int> >& globalIdsPartial,
94                      std::vector<int>& globalIdsLazySideInteraction, std::vector<double>& sumCorresponding);
95     void mergeRowSum2(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD,
96                       const std::vector<int>& globalIdsLazySideInteraction, const std::vector<double>& sumCorresponding);
97     void mergeRowSum3(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD);
98     void mergeCoeffs(const std::vector<int>& procsInInteraction, const std::vector< std::vector<int> >& rowsPartialSumI,
99                      const std::vector<std::vector<int> >& globalIdsPartial, std::vector<std::vector<double> >& denoStrorageInv);
100     void divideByGlobalRowSum(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& resPerProcI,
101                               const std::vector<std::vector<double> >& resPerProcD, std::vector<std::vector<double> >& deno);
102 #endif
103   private:
104     bool isSurfaceComputationNeeded(const std::string& method) const;
105     void fillDistributedMatrix(const std::vector< std::map<int,double> >& res,
106                                const DataArrayInt *srcIds, int srcProc,
107                                const DataArrayInt *trgIds, int trgProc);
108     static void TransposeMatrix(const std::vector<std::map<int,double> >& matIn, int nbColsMatIn, std::vector<std::map<int,double> >& matOut);
109   private:
110     ParaMEDMEM::ParaFIELD *_source_field;
111     ParaMEDMEM::ParaFIELD *_target_field;
112     std::vector<int> _row_offsets;
113     std::map<std::pair<int,int>, int > _col_offsets;
114     MEDCouplingPointSet *_source_support;
115     MEDCouplingPointSet *_target_support;
116     OverlapMapping _mapping;
117  
118     const ProcessorGroup& _group;
119     std::vector< std::vector<double> > _target_volume;
120     std::vector<std::vector<std::pair<int,double> > > _coeffs;
121     std::vector<std::vector<double> > _deno_multiply;
122     std::vector<std::vector<double> > _deno_reverse_multiply;
123   };
124 }
125
126 #endif