matrix_out \
pointer_matrix \
pointer_matrix_vector \
- solver solver_selector_* \
+ solver solver_selector_* solver_relaxation_* \
eigen \
filtered_matrix \
sparse_ilu* \
// $Id$
// Version: $Name$
//
-// Copyright (C) 2007 by the deal.II authors
+// Copyright (C) 2007, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
{
std::ofstream logfile("filtered_matrix/output");
deallog.attach(logfile);
- deallog.depth_console(10);
+ deallog.depth_console(0);
PreconditionIdentity identity;
ScaledMatrix<Vector<double> > s(identity, 3.);
-//---------------------------- full_matrix.cc,v ---------------------------
+//----------------------------------------------------------------------
// $Id$
-// Version: $Name$
//
// Copyright (C) 2005 by the deal.II authors
//
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
-//---------------------------- full_matrix.cc,v ---------------------------
+//----------------------------------------------------------------------
// Test copying between matrices (copy_from and fill)
--- /dev/null
+//----------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2010 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//----------------------------------------------------------------------
+
+#include <base/logstream.h>
+#include <lac/matrix_block.h>
+#include <lac/sparse_matrix.h>
+#include <lac/full_matrix.h>
+#include <lac/block_sparsity_pattern.h>
+
+#include <iostream>
+#include <fstream>
+
+using namespace dealii;
+
+void test_sparse()
+{
+ MatrixBlockVector<SparseMatrix<float> > v;
+// v.add(0, 0, "A",
+}
+
+
+int main(int argc, char** argv)
+{
+ std::cerr << argv[0] << std::endl;
+
+ std::ofstream logfile("matrices/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+}
--- /dev/null
+
+DEAL::FullMatrix<float>::copy_from SparseMatrixEZ<double>
+2. ~ 3. 4.
+5. 6. ~ 7.
+8. 9. 10. 11.
+~ ~ ~ ~
+12. ~ 13. 14.
+DEAL::LAPACKFullMatrix<double>::copy_from SparseMatrixEZ<double>
+2. ~ 3. 4.
+5. 6. ~ 7.
+8. 9. 10. 11.
+~ ~ ~ ~
+12. ~ 13. 14.
+DEAL::LAPACKFullMatrix<double>::fill SparseMatrixEZ<double>
+9. 10. 11.
+~ ~ ~
+DEAL::LAPACKFullMatrix<double>::fill SparseMatrixEZ<double>
+9. 10. 11.
+~ 13. 14.
-//---------------------------- solver.cc ---------------------------
+//----------------------------------------------------------------------
// $Id$
-// Version: $Name$
//
-// Copyright (C) 1998 - 2005 by the deal.II authors
+// Copyright (C) 1998 - 2005, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
-//---------------------------- solver.cc ---------------------------
+//----------------------------------------------------------------------
#include "../tests.h"
+#include "testmatrix.h"
#include <cmath>
#include <fstream>
#include <iomanip>
-#include <iomanip>
-#include "testmatrix.h"
#include <base/logstream.h>
#include <lac/sparse_matrix.h>
#include <lac/vector.h>
DEAL:rich:QMRS::Starting value 3.000
DEAL:rich:QMRS::Convergence step 3 value 0
DEAL:ssor:RichardsonT::Starting value 3.000
-DEAL:ssor:RichardsonT::Convergence step 10 value 0.0004418
+DEAL:ssor:RichardsonT::Convergence step 7 value 0.0006128
DEAL:ssor:Richardson::Starting value 3.000
-DEAL:ssor:Richardson::Convergence step 10 value 0.0004418
+DEAL:ssor:Richardson::Convergence step 7 value 0.0006128
DEAL:ssor:cg::Starting value 3.000
DEAL:ssor:cg::Convergence step 4 value 6.018e-05
DEAL:ssor:Bicgstab::Starting value 3.000
DEAL:ssor:Bicgstab::Convergence step 2 value 0.0003670
-DEAL:ssor:GMRES::Starting value 1.600
-DEAL:ssor:GMRES::Convergence step 3 value 0.0002978
-DEAL:ssor:GMRES::Starting value 1.600
-DEAL:ssor:GMRES::Convergence step 3 value 0.0002978
+DEAL:ssor:GMRES::Starting value 1.920
+DEAL:ssor:GMRES::Convergence step 3 value 0.0003574
+DEAL:ssor:GMRES::Starting value 1.920
+DEAL:ssor:GMRES::Convergence step 3 value 0.0003574
DEAL:ssor:QMRS::Starting value 3.000
DEAL:ssor:QMRS::Convergence step 4 value 0.0001345
DEAL:sor:RichardsonT::Starting value 3.000
DEAL:rich:QMRS::Starting value 11.00
DEAL:rich:QMRS::Convergence step 16 value 0.0002583
DEAL:ssor:RichardsonT::Starting value 11.00
-DEAL:ssor:RichardsonT::Convergence step 59 value 0.0008892
+DEAL:ssor:RichardsonT::Convergence step 48 value 0.0009502
DEAL:ssor:Richardson::Starting value 11.00
-DEAL:ssor:Richardson::Convergence step 59 value 0.0008892
+DEAL:ssor:Richardson::Convergence step 48 value 0.0009502
DEAL:ssor:cg::Starting value 11.00
DEAL:ssor:cg::Convergence step 8 value 0.0005816
DEAL:ssor:Bicgstab::Starting value 11.00
DEAL:ssor:Bicgstab::Convergence step 4 value 0.0003834
-DEAL:ssor:GMRES::Starting value 11.05
-DEAL:ssor:GMRES::Convergence step 7 value 0.0006838
-DEAL:ssor:GMRES::Starting value 11.05
-DEAL:ssor:GMRES::Convergence step 7 value 0.0006838
+DEAL:ssor:GMRES::Starting value 13.27
+DEAL:ssor:GMRES::Convergence step 7 value 0.0008206
+DEAL:ssor:GMRES::Starting value 13.27
+DEAL:ssor:GMRES::Convergence step 7 value 0.0008206
DEAL:ssor:QMRS::Starting value 11.00
DEAL:ssor:QMRS::Convergence step 9 value 0.0004140
DEAL:sor:RichardsonT::Starting value 11.00
--- /dev/null
+//----------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2005, 2010 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//----------------------------------------------------------------------
+
+// Compare preconditioned Richardson with relaxation. All output diffs
+// should be zero.
+
+#include "../tests.h"
+#include "testmatrix.h"
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+#include <base/logstream.h>
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <lac/vector_memory.h>
+#include <lac/solver_control.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_relaxation.h>
+#include <lac/precondition.h>
+
+template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
+double
+check_solve( SOLVER& solver, const MATRIX& A,
+ VECTOR& u, VECTOR& f, const PRECONDITION& P)
+{
+ double result = 0.;
+ u = 0.;
+ f = 1.;
+ try
+ {
+ solver.solve(A,u,f,P);
+ }
+ catch (SolverControl::NoConvergence& e)
+ {
+ result = e.last_residual;
+ }
+ return result;
+}
+
+int main()
+{
+ std::ofstream logfile("solver_relaxation_01/output");
+// logfile.setf(std::ios::fixed);
+ deallog << std::setprecision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ SolverControl control(10, 1.e-3);
+ SolverRichardson<> rich(control);
+ SolverRelaxation<> relax(control);
+
+ for (unsigned int size=7; size <= 30; size *= 3)
+ {
+ unsigned int dim = (size-1)*(size-1);
+
+ deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+ // Make matrix
+ FDMatrix testproblem(size, size);
+ SparsityPattern structure(dim, dim, 5);
+ testproblem.five_point_structure(structure);
+ structure.compress();
+ SparseMatrix<double> A(structure);
+ testproblem.five_point(A);
+
+ PreconditionJacobi<> prec_jacobi;
+ prec_jacobi.initialize(A, 0.6);
+ PreconditionSOR<> prec_sor;
+ prec_sor.initialize(A, 1.2);
+ PreconditionSSOR<> prec_ssor1;
+ prec_ssor1.initialize(A, 1.);
+ PreconditionSSOR<> prec_ssor2;
+ prec_ssor2.initialize(A, 1.2);
+
+ Vector<double> f(dim);
+ Vector<double> u(dim);
+ Vector<double> res(dim);
+
+ f = 1.;
+ u = 1.;
+
+ try
+ {
+ double r1, r2;
+
+ r1 = check_solve(rich,A,u,f,prec_jacobi);
+ r2 = check_solve(relax,A,u,f,prec_jacobi);
+ deallog << "Jacobi diff " << std::fabs(r1-r2)/r1 << std::endl;
+
+ r1 = check_solve(rich,A,u,f,prec_sor);
+ r2 = check_solve(relax,A,u,f,prec_sor);
+ deallog << "SOR diff " << std::fabs(r1-r2)/r1 << std::endl;
+
+ r1 = check_solve(rich,A,u,f,prec_ssor1);
+ r2 = check_solve(relax,A,u,f,prec_ssor1);
+ deallog << "SSOR1 diff " << std::fabs(r1-r2)/r1 << std::endl;
+
+ r1 = check_solve(rich,A,u,f,prec_ssor2);
+ r2 = check_solve(relax,A,u,f,prec_ssor2);
+ deallog << "SSOR1.2 diff " << std::fabs(r1-r2)/r1 << std::endl;
+ }
+ catch (std::exception& e)
+ {
+ std::cerr << "Exception: " << e.what() << std::endl;
+ }
+ };
+
+ // Solve advection problem
+ for (unsigned int size=4; size <= 3; size *= 3)
+ {
+ unsigned int dim = (size-1)*(size-1);
+
+ deallog << "Size " << size << " Unknowns " << dim << std::endl;
+
+ // Make matrix
+ FDMatrix testproblem(size, size);
+ SparsityPattern structure(dim, dim, 5);
+ testproblem.five_point_structure(structure);
+ structure.compress();
+ SparseMatrix<double> A(structure);
+ testproblem.upwind(A, true);
+
+ PreconditionSOR<> prec_sor;
+ prec_sor.initialize(A, 1.);
+
+ std::vector<unsigned int> permutation(dim);
+ std::vector<unsigned int> inverse_permutation(dim);
+
+ // Create a permutation: Blocks
+ // backwards and every second
+ // block backwards
+ unsigned int k = 0;
+ for (unsigned int i=0;i<size-1;++i)
+ for (unsigned int j=0;j<size-1;++j)
+ {
+ permutation[k++] = i * (size-1) + size-j-2;
+ }
+
+ for (unsigned int i=0;i<permutation.size();++i)
+ std::cerr << ' ' << permutation[i];
+ std::cerr << std::endl;
+
+ for (unsigned int i=0;i<permutation.size();++i)
+ inverse_permutation[permutation[i]] = i;
+
+ for (unsigned int i=0;i<permutation.size();++i)
+ std::cerr << ' ' << inverse_permutation[i];
+ std::cerr << std::endl;
+
+ PreconditionPSOR<> prec_psor;
+ prec_psor.initialize(A, permutation, inverse_permutation, 1.);
+
+ Vector<double> f(dim);
+ Vector<double> u(dim);
+ f = 1.;
+ u = 1.;
+
+ std::cerr << "******************************" << std::endl;
+
+ check_solve(rich,A,u,f,prec_sor);
+ check_solve(rich,A,u,f,prec_psor);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 7 Unknowns 36
+DEAL:Richardson::Starting value 6.000
+DEAL:Richardson::Failure step 10 value 2.974
+DEAL:Relaxation::Starting value 6.000
+DEAL:Relaxation::Failure step 10 value 2.974
+DEAL::Jacobi diff 0
+DEAL:Richardson::Starting value 6.000
+DEAL:Richardson::Failure step 10 value 0.3010
+DEAL:Relaxation::Starting value 6.000
+DEAL:Relaxation::Failure step 10 value 0.3010
+DEAL::SOR diff 0
+DEAL:Richardson::Starting value 6.000
+DEAL:Richardson::Failure step 10 value 0.1343
+DEAL:Relaxation::Starting value 6.000
+DEAL:Relaxation::Failure step 10 value 0.1343
+DEAL::SSOR1 diff 0
+DEAL:Richardson::Starting value 6.000
+DEAL:Richardson::Failure step 10 value 0.03379
+DEAL:Relaxation::Starting value 6.000
+DEAL:Relaxation::Failure step 10 value 0.03379
+DEAL::SSOR1.2 diff 0
+DEAL::Size 21 Unknowns 400
+DEAL:Richardson::Starting value 20.00
+DEAL:Richardson::Failure step 10 value 16.98
+DEAL:Relaxation::Starting value 20.00
+DEAL:Relaxation::Failure step 10 value 16.98
+DEAL::Jacobi diff 0
+DEAL:Richardson::Starting value 20.00
+DEAL:Richardson::Failure step 10 value 12.36
+DEAL:Relaxation::Starting value 20.00
+DEAL:Relaxation::Failure step 10 value 12.36
+DEAL::SOR diff 0
+DEAL:Richardson::Starting value 20.00
+DEAL:Richardson::Failure step 10 value 10.93
+DEAL:Relaxation::Starting value 20.00
+DEAL:Relaxation::Failure step 10 value 10.93
+DEAL::SSOR1 diff 0
+DEAL:Richardson::Starting value 20.00
+DEAL:Richardson::Failure step 10 value 8.814
+DEAL:Relaxation::Starting value 20.00
+DEAL:Relaxation::Failure step 10 value 8.814
+DEAL::SSOR1.2 diff 0
DEAL:5-SparseMatrix<double>:jacobi:Richardson::Starting value 4.00
DEAL:5-SparseMatrix<double>:jacobi:Richardson::Failure step 10 value 1.34
DEAL:5-SparseMatrix<double>:ssor:Richardson::Starting value 4.00
-DEAL:5-SparseMatrix<double>:ssor:Richardson::Failure step 10 value 0.00218
+DEAL:5-SparseMatrix<double>:ssor:Richardson::Failure step 10 value 0.000169
DEAL:5-SparseMatrix<double>:sor:Richardson::Starting value 4.00
DEAL:5-SparseMatrix<double>:sor:Richardson::Failure step 10 value 0.00188
DEAL:5-SparseMatrix<double>:block_jacobi:Richardson::Starting value 4.00
DEAL:5-SparseMatrix<double>:jacobi:RichardsonT::Starting value 4.00
DEAL:5-SparseMatrix<double>:jacobi:RichardsonT::Failure step 10 value 1.34
DEAL:5-SparseMatrix<double>:ssor:RichardsonT::Starting value 4.00
-DEAL:5-SparseMatrix<double>:ssor:RichardsonT::Failure step 10 value 0.0180
+DEAL:5-SparseMatrix<double>:ssor:RichardsonT::Failure step 10 value 0.00836
DEAL:5-SparseMatrix<double>:sor:RichardsonT::Starting value 4.00
DEAL:5-SparseMatrix<double>:sor:RichardsonT::Failure step 10 value 0.230
DEAL:5-SparseMatrix<double>:block_jacobi:RichardsonT::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:jacobi:Richardson::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:jacobi:Richardson::Failure step 10 value 1.34
DEAL:5-SparseMatrixEZ<double>:ssor:Richardson::Starting value 4.00
-DEAL:5-SparseMatrixEZ<double>:ssor:Richardson::Failure step 10 value 0.00218
+DEAL:5-SparseMatrixEZ<double>:ssor:Richardson::Failure step 10 value 0.000169
DEAL:5-SparseMatrixEZ<double>:sor:Richardson::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:sor:Richardson::Failure step 10 value 0.00188
DEAL:5-SparseMatrixEZ<double>:block_jacobi:Richardson::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:jacobi:RichardsonT::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:jacobi:RichardsonT::Failure step 10 value 1.34
DEAL:5-SparseMatrixEZ<double>:ssor:RichardsonT::Starting value 4.00
-DEAL:5-SparseMatrixEZ<double>:ssor:RichardsonT::Failure step 10 value 0.0180
+DEAL:5-SparseMatrixEZ<double>:ssor:RichardsonT::Failure step 10 value 0.00836
DEAL:5-SparseMatrixEZ<double>:sor:RichardsonT::Starting value 4.00
DEAL:5-SparseMatrixEZ<double>:sor:RichardsonT::Failure step 10 value 0.230
DEAL:5-SparseMatrixEZ<double>:block_jacobi:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrix<double>:jacobi:Richardson::Starting value 4.00
DEAL:9-SparseMatrix<double>:jacobi:Richardson::Failure step 10 value 1.17
DEAL:9-SparseMatrix<double>:ssor:Richardson::Starting value 4.00
-DEAL:9-SparseMatrix<double>:ssor:Richardson::Failure step 10 value 0.00174
+DEAL:9-SparseMatrix<double>:ssor:Richardson::Failure step 10 value 0.000124
DEAL:9-SparseMatrix<double>:sor:Richardson::Starting value 4.00
DEAL:9-SparseMatrix<double>:sor:Richardson::Failure step 10 value 0.00112
DEAL:9-SparseMatrix<double>:block_jacobi:Richardson::Starting value 4.00
DEAL:9-SparseMatrix<double>:jacobi:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrix<double>:jacobi:RichardsonT::Failure step 10 value 1.17
DEAL:9-SparseMatrix<double>:ssor:RichardsonT::Starting value 4.00
-DEAL:9-SparseMatrix<double>:ssor:RichardsonT::Failure step 10 value 0.00174
+DEAL:9-SparseMatrix<double>:ssor:RichardsonT::Failure step 10 value 0.000124
DEAL:9-SparseMatrix<double>:sor:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrix<double>:sor:RichardsonT::Failure step 10 value 0.00112
DEAL:9-SparseMatrix<double>:block_jacobi:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:jacobi:Richardson::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:jacobi:Richardson::Failure step 10 value 1.17
DEAL:9-SparseMatrixEZ<double>:ssor:Richardson::Starting value 4.00
-DEAL:9-SparseMatrixEZ<double>:ssor:Richardson::Failure step 10 value 0.00174
+DEAL:9-SparseMatrixEZ<double>:ssor:Richardson::Failure step 10 value 0.000124
DEAL:9-SparseMatrixEZ<double>:sor:Richardson::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:sor:Richardson::Failure step 10 value 0.00112
DEAL:9-SparseMatrixEZ<double>:block_jacobi:Richardson::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:jacobi:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:jacobi:RichardsonT::Failure step 10 value 1.17
DEAL:9-SparseMatrixEZ<double>:ssor:RichardsonT::Starting value 4.00
-DEAL:9-SparseMatrixEZ<double>:ssor:RichardsonT::Failure step 10 value 0.00174
+DEAL:9-SparseMatrixEZ<double>:ssor:RichardsonT::Failure step 10 value 0.000124
DEAL:9-SparseMatrixEZ<double>:sor:RichardsonT::Starting value 4.00
DEAL:9-SparseMatrixEZ<double>:sor:RichardsonT::Failure step 10 value 0.00112
DEAL:9-SparseMatrixEZ<double>:block_jacobi:RichardsonT::Starting value 4.00