Back to index

salome-med  6.5.0
OverlapInterpolationMatrix.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 __OVERLAPINTERPOLATIONMATRIX_HXX__
00021 #define __OVERLAPINTERPOLATIONMATRIX_HXX__
00022 
00023 #include "MPIAccessDEC.hxx"
00024 #include "OverlapMapping.hxx"
00025 #include "InterpolationOptions.hxx"
00026 #include "DECOptions.hxx"
00027 
00028 namespace ParaMEDMEM
00029 {
00030   class ParaFIELD;
00031   class MEDCouplingPointSet;
00032 
00033   class OverlapInterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
00034                                      public DECOptions
00035   {
00036   public:
00037     
00038     OverlapInterpolationMatrix(ParaFIELD *source_field,
00039                                ParaFIELD *target_field,
00040                                const ProcessorGroup& group,
00041                                const DECOptions& dec_opt,
00042                                const InterpolationOptions& i_opt);
00043 
00044     void keepTracksOfSourceIds(int procId, DataArrayInt *ids);
00045 
00046     void keepTracksOfTargetIds(int procId, DataArrayInt *ids);
00047 
00048     void addContribution(const MEDCouplingPointSet *src, const DataArrayInt *srcIds, const std::string& srcMeth, int srcProcId,
00049                          const MEDCouplingPointSet *trg, const DataArrayInt *trgIds, const std::string& trgMeth, int trgProcId);
00050 
00051     void prepare(const std::vector< std::vector<int> >& procsInInteraction);
00052     
00053     void computeDeno();
00054 
00055     void multiply();
00056 
00057     void transposeMultiply();
00058     
00059     virtual ~OverlapInterpolationMatrix();
00060 #if 0
00061     void addContribution(MEDCouplingPointSet& distant_support, int iproc_distant,
00062                          const int* distant_elems, const std::string& srcMeth, const std::string& targetMeth);
00063     void finishContributionW(ElementLocator& elementLocator);
00064     void finishContributionL(ElementLocator& elementLocator);
00065     void multiply(MEDCouplingFieldDouble& field) const;
00066     void transposeMultiply(MEDCouplingFieldDouble& field)const;
00067     void prepare();
00068     int getNbRows() const { return _row_offsets.size(); }
00069     MPIAccessDEC* getAccessDEC() { return _mapping.getAccessDEC(); }
00070   private:
00071     void computeConservVolDenoW(ElementLocator& elementLocator);
00072     void computeIntegralDenoW(ElementLocator& elementLocator);
00073     void computeRevIntegralDenoW(ElementLocator& elementLocator);
00074     void computeGlobConstraintDenoW(ElementLocator& elementLocator);
00075     void computeConservVolDenoL(ElementLocator& elementLocator);
00076     void computeIntegralDenoL(ElementLocator& elementLocator);
00077     void computeRevIntegralDenoL(ElementLocator& elementLocator);
00078     
00079     void computeLocalColSum(std::vector<double>& res) const;
00080     void computeLocalRowSum(const std::vector<int>& distantProcs, std::vector<std::vector<int> >& resPerProcI,
00081                             std::vector<std::vector<double> >& resPerProcD) const;
00082     void computeGlobalRowSum(ElementLocator& elementLocator, std::vector<std::vector<double> >& denoStrorage, std::vector<std::vector<double> >& denoStrorageInv);
00083     void computeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
00084     void resizeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
00085     void fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map<int,double> >& values, MEDCouplingFieldDouble *surf);
00086     void serializeMe(std::vector< std::vector< std::map<int,double> > >& data1, std::vector<int>& data2) const;
00087     void initialize();
00088     void findAdditionnalElements(ElementLocator& elementLocator, std::vector<std::vector<int> >& elementsToAdd,
00089                                  const std::vector<std::vector<int> >& resPerProcI, const std::vector<std::vector<int> >& globalIdsPartial);
00090     void addGhostElements(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& elementsToAdd);
00091     int mergePolicies(const std::vector<int>& policyPartial);
00092     void mergeRowSum(const std::vector< std::vector<double> >& rowsPartialSumD, const std::vector< std::vector<int> >& globalIdsPartial,
00093                      std::vector<int>& globalIdsLazySideInteraction, std::vector<double>& sumCorresponding);
00094     void mergeRowSum2(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD,
00095                       const std::vector<int>& globalIdsLazySideInteraction, const std::vector<double>& sumCorresponding);
00096     void mergeRowSum3(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD);
00097     void mergeCoeffs(const std::vector<int>& procsInInteraction, const std::vector< std::vector<int> >& rowsPartialSumI,
00098                      const std::vector<std::vector<int> >& globalIdsPartial, std::vector<std::vector<double> >& denoStrorageInv);
00099     void divideByGlobalRowSum(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& resPerProcI,
00100                               const std::vector<std::vector<double> >& resPerProcD, std::vector<std::vector<double> >& deno);
00101 #endif
00102   private:
00103     bool isSurfaceComputationNeeded(const std::string& method) const;
00104     void fillDistributedMatrix(const std::vector< std::map<int,double> >& res,
00105                                const DataArrayInt *srcIds, int srcProc,
00106                                const DataArrayInt *trgIds, int trgProc);
00107     static void TransposeMatrix(const std::vector<std::map<int,double> >& matIn, int nbColsMatIn, std::vector<std::map<int,double> >& matOut);
00108   private:
00109     ParaMEDMEM::ParaFIELD *_source_field;
00110     ParaMEDMEM::ParaFIELD *_target_field;
00111     std::vector<int> _row_offsets;
00112     std::map<std::pair<int,int>, int > _col_offsets;
00113     MEDCouplingPointSet *_source_support;
00114     MEDCouplingPointSet *_target_support;
00115     OverlapMapping _mapping;
00116  
00117     const ProcessorGroup& _group;
00118     std::vector< std::vector<double> > _target_volume;
00119     std::vector<std::vector<std::pair<int,double> > > _coeffs;
00120     std::vector<std::vector<double> > _deno_multiply;
00121     std::vector<std::vector<double> > _deno_reverse_multiply;
00122   };
00123 }
00124 
00125 #endif