include/deal.II/lac/iterative_inverse.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: iterative_inverse.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 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__iterative_inverse_h
00013 #define __deal2__iterative_inverse_h
00014 
00015 #include <deal.II/base/config.h>
00016 #include <deal.II/base/smartpointer.h>
00017 //#include <deal.II/base/template_constraints.h>
00018 //#include <deal.II/lac/tridiagonal_matrix.h>
00019 #include <deal.II/lac/solver_selector.h>
00020 #include <deal.II/lac/vector_memory.h>
00021 #include <deal.II/lac/pointer_matrix.h>
00022 
00023 DEAL_II_NAMESPACE_OPEN
00024 
00025 
00075 template <class VECTOR>
00076 class IterativeInverse : public Subscriptor
00077 {
00078   public:
00085     template <class MATRIX, class PRECONDITION>
00086     void initialize (const MATRIX&, const PRECONDITION&);
00087 
00092     void clear();
00093 
00097     void vmult (VECTOR& dst, const VECTOR& src) const;
00098 
00104 //    void Tvmult (VECTOR& dst, const VECTOR& src) const;
00105 
00112     SolverSelector<VECTOR> solver;
00113 
00114   private:
00118     std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > matrix;
00119 
00123     std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > preconditioner;
00127     std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > transpose_matrix;
00128 
00132     std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > transpose_preconditioner;
00133 };
00134 
00135 
00136 template <class VECTOR>
00137 template <class MATRIX, class PRECONDITION>
00138 inline
00139 void
00140 IterativeInverse<VECTOR>::initialize(const MATRIX& m, const PRECONDITION& p)
00141 {
00142                                    // dummy variable
00143   VECTOR* v = 0;
00144   matrix = std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > (new_pointer_matrix_base(m, *v));
00145   preconditioner = std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > (new_pointer_matrix_base(p, *v));
00146 }
00147 
00148 
00149 template <class VECTOR>
00150 inline
00151 void
00152 IterativeInverse<VECTOR>::clear()
00153 {
00154   matrix = 0;
00155   preconditioner = 0;
00156 }
00157 
00158 
00159 template <class VECTOR>
00160 inline void
00161 IterativeInverse<VECTOR>::vmult (VECTOR& dst, const VECTOR& src) const
00162 {
00163   Assert(matrix.get() != 0, ExcNotInitialized());
00164   Assert(preconditioner.get() != 0, ExcNotInitialized());
00165   solver.solve(*matrix, dst, src, *preconditioner);
00166 }
00167 
00168 
00169 // template <class VECTOR>
00170 // inline void
00171 // IterativeInverse<VECTOR>::Tvmult (VECTOR& dst, const VECTOR& src) const
00172 // {
00173 //   TransposeMatrix<
00174 //   solver.solve(*matrix, dst, src, *preconditioner);
00175 // }
00176 
00177 
00178 DEAL_II_NAMESPACE_CLOSE
00179 
00180 #endif
00181 
00182 
00183 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Tue May 22 2012 12:06:11 by doxygen 1.7.3