1 // Copyright (C) 2007-2015 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
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __OVERLAPINTERPOLATIONMATRIX_HXX__
22 #define __OVERLAPINTERPOLATIONMATRIX_HXX__
24 #include "MPIAccessDEC.hxx"
25 #include "OverlapMapping.hxx"
26 #include "InterpolationOptions.hxx"
27 #include "DECOptions.hxx"
32 class MEDCouplingPointSet;
34 class OverlapInterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
39 OverlapInterpolationMatrix(ParaFIELD *source_field,
40 ParaFIELD *target_field,
41 const ProcessorGroup& group,
42 const DECOptions& dec_opt,
43 const InterpolationOptions& i_opt);
45 void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
47 void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
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);
52 void prepare(const std::vector< std::vector<int> >& procsInInteraction);
58 void transposeMultiply();
60 virtual ~OverlapInterpolationMatrix();
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;
69 int getNbRows() const { return _row_offsets.size(); }
70 MPIAccessDEC* getAccessDEC() { return _mapping.getAccessDEC(); }
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);
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;
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);
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);
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;
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;