From: schrage Date: Mon, 7 Jun 1999 09:03:34 +0000 (+0000) Subject: Added SolverCG. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=621832817b51f140301c7c32f34ea5c91eb5f4b1;p=dealii-svn.git Added SolverCG. git-svn-id: https://svn.dealii.org/trunk@1372 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/tutorial/chapter-1.elements/solve.html b/deal.II/doc/tutorial/chapter-1.elements/solve.html index a8dde4a6e6..27b55543f4 100644 --- a/deal.II/doc/tutorial/chapter-1.elements/solve.html +++ b/deal.II/doc/tutorial/chapter-1.elements/solve.html @@ -86,7 +86,7 @@ It is initialized by

Example:We initialize a Bicgstab-solver for the problem Au=f, using the solver control -explained above. A shall be a spare matrix and the vectors +explained above. A shall be a sparse matrix and the vectors u and f shall be vectors of doubles. Next, we solve the problem.

@@ -96,7 +96,7 @@ we solve the problem. // Include files for solver control, solver and preconditioner #include <lac/solver_control.h> #include <lac/solver_bicgstab.h> -#include <lac/precondition.h> +#include <lac/precondition_selector.h> // Include files for matrices and vectors #include <lac/sparsematrix.h> @@ -116,12 +116,69 @@ SolverBicgstab<SparseMatrix,Vector<double> > solver(control,vectorme SparseMatrix<double> A; Vector<double> u,f; -// NEED TO DEFINE A PRECONDITIONER -solver.solve(A,u,f,precondition); +// Generate a Jacobi preconditioner with the damping parameter 1 +PreconditionSelector<SparseMatrix<double>, Vector<double> > preconditioning("jacobi",1.); + +// Use the matrix of the linear equation system for preconditioning +// (this is the usual case). +preconditioning.use_matrix(A); + +solver.solve(A,u,f,preconditioning); +

SolverCG

+ +

+This class implements the preconditioned cg-method. +It is initialized by
+SolverCG (SolverControl &cn, VectorMemory &mem). +

+

+Example:We initialize a CG-solver for +the problem Au=f, using the solver control +explained above. A shall be a sparse matrix and the vectors +u and f shall be vectors of doubles. Next, +we solve the problem. +

+ +
+
+// Include files for solver control, solver and preconditioner
+#include <lac/solver_control.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/precondition_selector.h>
+
+// Include files for matrices and vectors
+#include <lac/sparsematrix.h>
+#include <lac/vector.h>
+
+// Initialize the solver control and the solver
+
+SolverControl control(1000,1e-6);
+VectorMemory<Vector<double> > vectormem;
+SolverCG<SparseMatrix,Vector<double> > solver(control,vectormem);
+
+// Initialize the problem matrices. Well...they shouldn't only be
+// initialized but also contain the problem, so this is just an example
+// to get the definitions and types and everything right. 
+// To make it clear: This code as it is will not do anything because
+// it does not contain any mathematical problem ! 
+
+SparseMatrix<double> A;
+Vector<double> u,f;
+
+// Generate a Jacobi preconditioner with the damping parameter 1
+PreconditionSelector<SparseMatrix<double>, Vector<double> > preconditioning("jacobi",1.);
+
+// Use the matrix of the linear equation system for preconditioning
+// (this is the usual case).
+preconditioning.use_matrix(A);
+
+solver.solve(A,u,f,preconditioning);
+
+