include/deal.II/lac/relaxation_block.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: relaxation_block.h 25378 2012-04-03 20:24:22Z kanschat @f$
00003 //
00004 //    Copyright (C) 2010, 2011, 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__relaxation_block_h
00013 #define __deal2__relaxation_block_h
00014 
00015 #include <deal.II/base/subscriptor.h>
00016 #include <deal.II/base/smartpointer.h>
00017 #include <deal.II/lac/vector.h>
00018 #include <deal.II/lac/precondition_block_base.h>
00019 #include <deal.II/lac/block_list.h>
00020 
00021 #include <vector>
00022 #include <set>
00023 
00024 DEAL_II_NAMESPACE_OPEN
00025 
00050 template <class MATRIX, typename inverse_type=typename MATRIX::value_type>
00051 class RelaxationBlock :
00052   protected PreconditionBlockBase<inverse_type>
00053 {
00054   private:
00058     typedef typename MATRIX::value_type number;
00059 
00063     typedef inverse_type value_type;
00064 
00065   public:
00070     class AdditionalData : public Subscriptor
00071     {
00072       public:
00076         AdditionalData (const double relaxation = 1.,
00077                         const bool invert_diagonal = true,
00078                         const bool same_diagonal = false);
00079 
00089         AdditionalData (const BlockList& block_list,
00090                         const double relaxation = 1.,
00091                         const bool invert_diagonal = true,
00092                         const bool same_diagonal = false);
00093 
00094 
00099         SparsityPattern block_list;
00100 
00104         double relaxation;
00105 
00109         bool invert_diagonal;
00110 
00115         bool same_diagonal;
00120         typename PreconditionBlockBase<inverse_type>::Inversion inversion;
00121 
00131         double threshold;
00132 
00166         std::vector<std::vector<unsigned int> > order;
00167     };
00168 
00182     void initialize (const MATRIX& A,
00183                      const AdditionalData& parameters);
00184 
00193     void clear();
00194 
00198     bool empty () const;
00199 
00206     value_type el(unsigned int i,
00207                   unsigned int j) const;
00208 
00236     void invert_diagblocks();
00237 
00238   protected:
00252     template <typename number2>
00253     void do_step (
00254       Vector<number2>       &dst,
00255       const Vector<number2> &prev,
00256       const Vector<number2> &src,
00257       const bool backward) const;
00270     SmartPointer<const MATRIX,RelaxationBlock<MATRIX,inverse_type> > A;
00271 
00275     SmartPointer<const AdditionalData, RelaxationBlock<MATRIX,inverse_type> > additional_data;
00276 };
00277 
00278 
00294 template<class MATRIX, typename inverse_type = typename MATRIX::value_type>
00295 class RelaxationBlockJacobi : public virtual Subscriptor,
00296                              protected RelaxationBlock<MATRIX, inverse_type>
00297 {
00298   public:
00302 //    RelaxationBlockJacobi();
00303 
00307     typedef typename MATRIX::value_type number;
00308 
00312     using typename RelaxationBlock<MATRIX,inverse_type>::AdditionalData;
00313 
00318     using RelaxationBlock<MATRIX, inverse_type>::initialize;
00319 
00323     using RelaxationBlock<MATRIX, inverse_type>::clear;
00324 
00328     using RelaxationBlock<MATRIX, inverse_type>::empty;
00332     using RelaxationBlock<MATRIX, inverse_type>::size;
00336     using RelaxationBlock<MATRIX, inverse_type>::inverse;
00340     using RelaxationBlock<MATRIX, inverse_type>::inverse_householder;
00344     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
00345     using PreconditionBlockBase<inverse_type>::log_statistics;
00350     template <typename number2>
00351     void step (Vector<number2>& dst, const Vector<number2>& rhs) const;
00352 
00357     template <typename number2>
00358     void Tstep (Vector<number2>& dst, const Vector<number2>& rhs) const;
00359 };
00360 
00361 
00377 template<class MATRIX, typename inverse_type = typename MATRIX::value_type>
00378 class RelaxationBlockSOR : public virtual Subscriptor,
00379                              protected RelaxationBlock<MATRIX, inverse_type>
00380 {
00381   public:
00385 //    RelaxationBlockSOR();
00386 
00390     typedef typename MATRIX::value_type number;
00391 
00395     using typename RelaxationBlock<MATRIX,inverse_type>::AdditionalData;
00396 
00401     using RelaxationBlock<MATRIX, inverse_type>::initialize;
00402 
00406     using RelaxationBlock<MATRIX, inverse_type>::clear;
00407 
00411     using RelaxationBlock<MATRIX, inverse_type>::empty;
00415     using RelaxationBlock<MATRIX, inverse_type>::size;
00419     using RelaxationBlock<MATRIX, inverse_type>::inverse;
00423     using RelaxationBlock<MATRIX, inverse_type>::inverse_householder;
00427     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
00428     using PreconditionBlockBase<inverse_type>::log_statistics;
00433     template <typename number2>
00434     void step (Vector<number2>& dst, const Vector<number2>& rhs) const;
00435 
00440     template <typename number2>
00441     void Tstep (Vector<number2>& dst, const Vector<number2>& rhs) const;
00442 };
00443 
00444 
00461 template<class MATRIX, typename inverse_type = typename MATRIX::value_type>
00462 class RelaxationBlockSSOR : public virtual Subscriptor,
00463                             protected RelaxationBlock<MATRIX, inverse_type>
00464 {
00465   public:
00469     typedef typename MATRIX::value_type number;
00470 
00474     using typename RelaxationBlock<MATRIX,inverse_type>::AdditionalData;
00475 
00480     using RelaxationBlock<MATRIX, inverse_type>::initialize;
00481 
00485     using RelaxationBlock<MATRIX, inverse_type>::clear;
00486 
00490     using RelaxationBlock<MATRIX, inverse_type>::empty;
00491 
00495     using RelaxationBlock<MATRIX, inverse_type>::size;
00499     using RelaxationBlock<MATRIX, inverse_type>::inverse;
00503     using RelaxationBlock<MATRIX, inverse_type>::inverse_householder;
00507     using RelaxationBlock<MATRIX, inverse_type>::inverse_svd;
00508     using PreconditionBlockBase<inverse_type>::log_statistics;
00513     template <typename number2>
00514     void step (Vector<number2>& dst, const Vector<number2>& rhs) const;
00515 
00520     template <typename number2>
00521     void Tstep (Vector<number2>& dst, const Vector<number2>& rhs) const;
00522 };
00523 
00524 
00525 DEAL_II_NAMESPACE_CLOSE
00526 
00527 #endif
00528 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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