include/deal.II/lac/sparse_vanka.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: sparse_vanka.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__sparse_vanka_h
00013 #define __deal2__sparse_vanka_h
00014 
00015 
00016 
00017 #include <deal.II/base/config.h>
00018 #include <deal.II/base/smartpointer.h>
00019 #include <deal.II/base/multithread_info.h>
00020 
00021 #include <vector>
00022 #include <map>
00023 
00024 DEAL_II_NAMESPACE_OPEN
00025 
00026 template <typename number> class FullMatrix;
00027 template <typename number> class SparseMatrix;
00028 template <typename number> class Vector;
00029 
00030 template <typename number> class SparseVanka;
00031 template <typename number> class SparseBlockVanka;
00032 
00128 template<typename number>
00129 class SparseVanka
00130 {
00131   public:
00187     SparseVanka(const SparseMatrix<number> &M,
00188                 const std::vector<bool>    &selected,
00189                 const bool                  conserve_memory = false,
00190                 const unsigned int          n_threads       = multithread_info.n_default_threads);
00191 
00196     ~SparseVanka();
00197 
00204     template<typename number2>
00205     void vmult (Vector<number2>       &dst,
00206                 const Vector<number2> &src) const;
00207 
00208   protected:
00250     template<typename number2>
00251     void apply_preconditioner (Vector<number2>         &dst,
00252                                const Vector<number2>   &src,
00253                                const std::vector<bool> * const dof_mask = 0) const;
00254 
00260     std::size_t memory_consumption () const;
00261 
00262   private:
00266     SmartPointer<const SparseMatrix<number>,SparseVanka<number> > matrix;
00267 
00271     const bool conserve_mem;
00272 
00277     const std::vector<bool> &selected;
00278 
00285     const unsigned int n_threads;
00286 
00293     mutable std::vector<SmartPointer<FullMatrix<float>,SparseVanka<number> > > inverses;
00294 
00299     void compute_inverses ();
00300 
00312     void compute_inverses (const unsigned int begin,
00313                            const unsigned int end);
00314 
00329     void compute_inverse (const unsigned int         row,
00330                           std::vector<unsigned int> &local_indices);
00331 
00357     template <typename T> friend class SparseBlockVanka;
00358 };
00359 
00360 
00361 
00509 template<typename number>
00510 class SparseBlockVanka : public SparseVanka<number>
00511 {
00512   public:
00519     enum BlockingStrategy {
00520           index_intervals, adaptive
00521     };
00522 
00528     SparseBlockVanka (const SparseMatrix<number> &M,
00529                       const std::vector<bool>    &selected,
00530                       const unsigned int          n_blocks,
00531                       const BlockingStrategy      blocking_strategy,
00532                       const bool                  conserve_memory = false,
00533                       const unsigned int          n_threads       = multithread_info.n_default_threads);
00534 
00538     template<typename number2>
00539     void vmult (Vector<number2>       &dst,
00540                      const Vector<number2> &src) const;
00541 
00547     std::size_t memory_consumption () const;
00548 
00549   private:
00553     const unsigned int n_blocks;
00554 
00569     std::vector<std::vector<bool> > dof_masks;
00570 
00577     void compute_dof_masks (const SparseMatrix<number> &M,
00578                             const std::vector<bool>    &selected,
00579                             const BlockingStrategy      blocking_strategy);
00580 };
00581 
00583 DEAL_II_NAMESPACE_CLOSE
00584 
00585 #endif
00586 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Wed May 23 2012 06:07:40 by doxygen 1.7.3