include/deal.II/lac/sparse_decomposition.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: sparse_decomposition.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2012 by the deal.II authors
00005 //    by the deal.II authors and Stephen "Cheffo" Kolaroff
00006 //
00007 //    This file is subject to QPL and may not be  distributed
00008 //    without copyright and license information. Please refer
00009 //    to the file deal.II/doc/license.html for the  text  and
00010 //    further information on this license.
00011 //
00012 //---------------------------------------------------------------------------
00013 #ifndef __deal2__sparse_decomposition_h
00014 #define __deal2__sparse_decomposition_h
00015 
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/lac/sparse_matrix.h>
00018 
00019 #include <cmath>
00020 
00021 DEAL_II_NAMESPACE_OPEN
00022 
00135 template <typename number>
00136 class SparseLUDecomposition : protected SparseMatrix<number>,
00137                               public virtual Subscriptor
00138 {
00139   protected:
00148     SparseLUDecomposition ();
00149 
00156     SparseLUDecomposition (const SparsityPattern& sparsity);
00157 
00158   public:
00166     virtual ~SparseLUDecomposition ()
00167 #ifndef DEAL_II_IMPLEMENTED_PURE_FUNCTION_BUG
00168       = 0
00169 #endif
00170     ;
00171 
00178     virtual void clear();
00179 
00184     class AdditionalData
00185     {
00186       public:
00192         AdditionalData (const double strengthen_diagonal=0,
00193                         const unsigned int extra_off_diagonals=0,
00194                         const bool use_previous_sparsity=false,
00195                         const SparsityPattern *use_this_sparsity=0);
00196 
00207         double strengthen_diagonal;
00208 
00229         unsigned int extra_off_diagonals;
00230 
00246         bool use_previous_sparsity;
00247 
00266         const SparsityPattern *use_this_sparsity;
00267     };
00268 
00297     template <typename somenumber>
00298     void initialize (const SparseMatrix<somenumber> &matrix,
00299                      const AdditionalData parameters);
00300 
00309     void reinit (const SparsityPattern &sparsity);
00310 
00319     template <typename somenumber>
00320     void decompose (const SparseMatrix<somenumber> &matrix,
00321                     const double                    strengthen_diagonal=0.);
00322 
00331     virtual bool is_decomposed () const;
00332 
00338     bool empty () const;
00339 
00345     virtual std::size_t memory_consumption () const;
00346 
00353     DeclException1 (ExcInvalidStrengthening,
00354                     double,
00355                     << "The strengthening parameter " << arg1
00356                     << " is not greater or equal than zero!");
00358   protected:
00365     template<typename somenumber>
00366     void copy_from (const SparseMatrix<somenumber>& matrix);
00367 
00378     virtual void strengthen_diagonal_impl ();
00379 
00393     virtual number get_strengthen_diagonal(const number rowsum, const unsigned int row) const;
00394 
00406     bool decomposed;
00407 
00413     double  strengthen_diagonal;
00414 
00425     std::vector<const unsigned int*> prebuilt_lower_bound;
00426 
00427   private:
00433     void prebuild_lower_bound ();
00434 
00452     SparsityPattern *own_sparsity;
00453 };
00454 
00456 //---------------------------------------------------------------------------
00457 
00458 #ifndef DOXYGEN
00459 
00460 template <typename number>
00461 inline number
00462 SparseLUDecomposition<number>::
00463 get_strengthen_diagonal(const number /*rowsum*/,
00464                         const unsigned int /*row*/) const
00465 {
00466   return strengthen_diagonal;
00467 }
00468 
00469 
00470 
00471 template <typename number>
00472 inline bool
00473 SparseLUDecomposition<number>::is_decomposed () const
00474 {
00475   return decomposed;
00476 }
00477 
00478 
00479 
00480 template <typename number>
00481 inline bool
00482 SparseLUDecomposition<number>::empty () const
00483 {
00484   return SparseMatrix<number>::empty();
00485 }
00486 
00487 
00488 
00489 //---------------------------------------------------------------------------
00490 
00491 
00492 template <typename number>
00493 SparseLUDecomposition<number>::AdditionalData::AdditionalData (
00494   const double strengthen_diag,
00495   const unsigned int extra_off_diag,
00496   const bool use_prev_sparsity,
00497   const SparsityPattern *use_this_spars):
00498                 strengthen_diagonal(strengthen_diag),
00499                 extra_off_diagonals(extra_off_diag),
00500                 use_previous_sparsity(use_prev_sparsity),
00501                 use_this_sparsity(use_this_spars)
00502 {}
00503 
00504 
00505 #endif // DOXYGEN
00506 
00507 DEAL_II_NAMESPACE_CLOSE
00508 
00509 #endif // __deal2__sparse_decomposition_h
00510 
 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