00001
00002
00003
00004
00005
00006
00007
00008
00009
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
00018
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
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
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
00170
00171
00172
00173
00174
00175
00176
00177
00178 DEAL_II_NAMESPACE_CLOSE
00179
00180 #endif
00181
00182
00183