Back to index

salome-med  6.5.0
InterpolationMatrix.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 __INTERPOLATIONMATRIX_HXX__
00021 #define __INTERPOLATIONMATRIX_HXX__
00022 
00023 #include "MPIAccessDEC.hxx"
00024 #include "MxN_Mapping.hxx"
00025 #include "InterpolationOptions.hxx"
00026 #include "DECOptions.hxx"
00027 
00028 namespace ParaMEDMEM
00029 {
00030   class ElementLocator;
00031 
00032   class InterpolationMatrix : public INTERP_KERNEL::InterpolationOptions,
00033                               public DECOptions
00034   {
00035   public:
00036     
00037     InterpolationMatrix(const ParaMEDMEM::ParaFIELD *source_field, 
00038                         const ProcessorGroup& source_group,
00039                         const ProcessorGroup& target_group,
00040                         const DECOptions& dec_opt,
00041                         const InterpolationOptions& i_opt);
00042 
00043     
00044     virtual ~InterpolationMatrix();
00045     void addContribution(MEDCouplingPointSet& distant_support, int iproc_distant,
00046                          const int* distant_elems, const std::string& srcMeth, const std::string& targetMeth);
00047     void finishContributionW(ElementLocator& elementLocator);
00048     void finishContributionL(ElementLocator& elementLocator);
00049     void multiply(MEDCouplingFieldDouble& field) const;
00050     void transposeMultiply(MEDCouplingFieldDouble& field)const;
00051     void prepare();
00052     int getNbRows() const { return _row_offsets.size(); }
00053     MPIAccessDEC* getAccessDEC() { return _mapping.getAccessDEC(); }
00054   private:
00055     void computeConservVolDenoW(ElementLocator& elementLocator);
00056     void computeIntegralDenoW(ElementLocator& elementLocator);
00057     void computeRevIntegralDenoW(ElementLocator& elementLocator);
00058     void computeGlobConstraintDenoW(ElementLocator& elementLocator);
00059     void computeConservVolDenoL(ElementLocator& elementLocator);
00060     void computeIntegralDenoL(ElementLocator& elementLocator);
00061     void computeRevIntegralDenoL(ElementLocator& elementLocator);
00062     
00063     void computeLocalColSum(std::vector<double>& res) const;
00064     void computeLocalRowSum(const std::vector<int>& distantProcs, std::vector<std::vector<int> >& resPerProcI,
00065                             std::vector<std::vector<double> >& resPerProcD) const;
00066     void computeGlobalRowSum(ElementLocator& elementLocator, std::vector<std::vector<double> >& denoStrorage, std::vector<std::vector<double> >& denoStrorageInv);
00067     void computeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
00068     void resizeGlobalColSum(std::vector<std::vector<double> >& denoStrorage);
00069     void fillDSFromVM(int iproc_distant, const int* distant_elems, const std::vector< std::map<int,double> >& values, MEDCouplingFieldDouble *surf);
00070     void serializeMe(std::vector< std::vector< std::map<int,double> > >& data1, std::vector<int>& data2) const;
00071     void initialize();
00072     void findAdditionnalElements(ElementLocator& elementLocator, std::vector<std::vector<int> >& elementsToAdd,
00073                                  const std::vector<std::vector<int> >& resPerProcI, const std::vector<std::vector<int> >& globalIdsPartial);
00074     void addGhostElements(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& elementsToAdd);
00075     int mergePolicies(const std::vector<int>& policyPartial);
00076     void mergeRowSum(const std::vector< std::vector<double> >& rowsPartialSumD, const std::vector< std::vector<int> >& globalIdsPartial,
00077                      std::vector<int>& globalIdsLazySideInteraction, std::vector<double>& sumCorresponding);
00078     void mergeRowSum2(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD,
00079                       const std::vector<int>& globalIdsLazySideInteraction, const std::vector<double>& sumCorresponding);
00080     void mergeRowSum3(const std::vector< std::vector<int> >& globalIdsPartial, std::vector< std::vector<double> >& rowsPartialSumD);
00081     void mergeCoeffs(const std::vector<int>& procsInInteraction, const std::vector< std::vector<int> >& rowsPartialSumI,
00082                      const std::vector<std::vector<int> >& globalIdsPartial, std::vector<std::vector<double> >& denoStrorageInv);
00083     void divideByGlobalRowSum(const std::vector<int>& distantProcs, const std::vector<std::vector<int> >& resPerProcI,
00084                               const std::vector<std::vector<double> >& resPerProcD, std::vector<std::vector<double> >& deno);
00085   private:
00086     bool isSurfaceComputationNeeded(const std::string& method) const;
00087   private:
00088     const ParaMEDMEM::ParaFIELD *_source_field;
00089     std::vector<int> _row_offsets;
00090     std::map<std::pair<int,int>, int > _col_offsets;
00091     MEDCouplingPointSet *_source_support;
00092     MxN_Mapping _mapping;
00093  
00094     const ProcessorGroup& _source_group;
00095     const ProcessorGroup& _target_group;
00096     std::vector< std::vector<double> > _target_volume;
00097     std::vector<std::vector<std::pair<int,double> > > _coeffs;
00098     std::vector<std::vector<double> > _deno_multiply;
00099     std::vector<std::vector<double> > _deno_reverse_multiply;
00100   };
00101 }
00102 
00103 #endif