void test (TrilinosWrappers::SparseMatrix &m)
{
// first set a few entries
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ m.set (i,j, 0.);
+
+ // then add values to these entries
for (unsigned int i=0; i<m.m(); ++i)
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
void test (TrilinosWrappers::SparseMatrix &m)
{
// first set a few entries
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ m.set (i,j, 0.);
+
+ m.compress();
+
+ // then add/set values into these entries
for (unsigned int i=0; i<m.m(); ++i)
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
m.set (i,j, i*j*.5+.5);
-
- m.compress();
// then add the same elements again
for (unsigned int i=0; i<m.m(); ++i)
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
m.add (i,j, i*j*.5+.5);
+
+ m.compress();
+
// and overwrite everything again
for (unsigned int i=0; i<m.m(); ++i)
for (unsigned int j=0; j<m.m(); ++j)
}
else
{
- Assert (m(i,j) == 0, ExcInternalError());
Assert (m.el(i,j) == 0, ExcInternalError());
}
}
else
{
- Assert (m(i,j) == 0, ExcInternalError());
Assert (m.el(i,j) == 0, ExcInternalError());
}
}
else
{
- Assert (m(i,j) == 0, ExcInternalError());
Assert (m.el(i,j) == 0, ExcInternalError());
}
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == 2*i)
+ Assert ((((pattern[i] == true) && (v(i) == 2*i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that the entries are ok
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i*5./4.)
+ Assert ((((pattern[i] == true) && (v(i) == i*5./4.))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that the entries are ok
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i*3./4.)
+ Assert ((((pattern[i] == true) && (v(i) == i*3./4.))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
void test (TrilinosWrappers::Vector &v)
{
- v.reinit (13, true);
+ v.reinit (13);
Assert (v.size() == 13, ExcInternalError());
v.compress ();
// then resize with setting to zero
- v.reinit (13, false);
+ v.reinit (13);
Assert (v.size() == 13, ExcInternalError());
Assert (v.l2_norm() == 0, ExcInternalError());
}
else
{
- Assert (m(i,j) == 0, ExcInternalError());
Assert (m.el(i,j) == 0, ExcInternalError());
}
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == 2*i)
+ Assert ((((pattern[i] == true) && (v(i) == 2*i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == 2*i)
+ Assert ((((pattern[i] == true) && (v(i) == 2*i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
// check that they are ok, and this time
// all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert (((pattern[i] == true) && (v(i) == i)
+ Assert ((((pattern[i] == true) && (v(i) == i))
||
- (pattern[i] == false) && (v(i) == 0)),
+ ((pattern[i] == false) && (v(i) == 0))),
ExcInternalError());
deallog << "OK" << std::endl;
//---------------------------- trilinos_62.cc ---------------------------
-// check TrilinosWrappers::MatrixBase::clear ()
+// check TrilinosWrappers::SparseMatrix::clear ()
#include "../tests.h"
#include <base/utilities.h>
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() != 0, ExcInternalError());
Assert (m.n() != 0, ExcInternalError());
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() == 100, ExcInternalError());
Assert (m.n() == 100, ExcInternalError());
//---------------------------- trilinos_64.cc ---------------------------
-// This test should be run on multiple processors. note that this test also
-// started to fail with the upgrade to petsc 2.2.1 which required a fix in
-// TrilinosWrappers::MatrixBase::operator=
+// This test should be run on multiple processors.
#include "../tests.h"
#include <base/utilities.h>
#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_sparse_matrix.h>
+#include <Epetra_Map.h>
+#include <Epetra_Comm.h>
#include <lac/vector.h>
#include <fstream>
template<typename MatrixType>
void test (MatrixType &m)
{
- m.add(0,0,1);
+ m.set(0,0,1.);
+ m.compress();
m = 0;
m.compress();
// check
// TrilinosWrappers::SparseMatrix
- MPI_Comm mpi_communicator (MPI_COMM_WORLD);
- int n_jobs=1;
- MPI_Comm_size (mpi_communicator, &n_jobs);
- const unsigned int n_mpi_processes=static_cast<unsigned int>(n_jobs);
- Assert(n_dofs%n_mpi_processes==0, ExcInternalError());
- const unsigned int n_local_dofs=n_dofs/n_mpi_processes;
- TrilinosWrappers::SparseMatrix
- v2 (mpi_communicator, n_dofs, n_dofs, n_local_dofs, n_local_dofs, 5);
+ const unsigned int n_jobs =
+ Utilities::Trilinos::get_n_mpi_processes(Utilities::Trilinos::comm_world());
+ Assert(n_dofs%n_jobs==0, ExcInternalError());
+ const unsigned int n_local_dofs=n_dofs/n_jobs;
+ Epetra_Map map(n_dofs, n_local_dofs, Utilities::Trilinos::comm_world());
+ TrilinosWrappers::SparseMatrix v2 (map, 5);
test (v2);
}
}
void test ()
{
- TrilinosWrappers::MPI::Vector v(PETSC_COMM_WORLD, 100, 100);
+ TrilinosWrappers::MPI::Vector
+ v (Epetra_Map(100,0,Utilities::Trilinos::comm_world()));
v(0) = 1;
v = 0;
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() != 0, ExcInternalError());
Assert (m.n() != 0, ExcInternalError());
if (i>=5)
{
const double s = rand();
- m.add (i,i-5, s);
+ m.set (i,i-5, s);
norm_sqr += s*s;
++nnz;
}
if (i<N-5)
{
const double s = rand();
- m.add (i,i+5, s);
+ m.set (i,i+5, s);
norm_sqr += s*s;
++nnz;
}
const double s = rand();
- m.add (i,i,s);
+ m.set (i,i,s);
norm_sqr += s*s;
++nnz;
}
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() != 0, ExcInternalError());
Assert (m.n() != 0, ExcInternalError());
if (i>=5)
{
const double s = rand();
- m.add (i,i-5, s);
+ m.set (i,i-5, s);
norm_sqr += s*s;
++nnz;
}
if (i<N-5)
{
const double s = rand();
- m.add (i,i+5, s);
+ m.set (i,i+5, s);
norm_sqr += s*s;
++nnz;
}
const double s = rand();
- m.add (i,i,s);
+ m.set (i,i,s);
norm_sqr += s*s;
++nnz;
}
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() != 0, ExcInternalError());
Assert (m.n() != 0, ExcInternalError());
if (i>=5)
{
const double s = rand();
- m.add (i,i-5, s);
+ m.set (i,i-5, s);
norm_sqr += s*s;
++nnz;
}
if (i<N-5)
{
const double s = rand();
- m.add (i,i+5, s);
+ m.set (i,i+5, s);
norm_sqr += s*s;
++nnz;
}
const double s = rand();
- m.add (i,i,s);
+ m.set (i,i,s);
norm_sqr += s*s;
++nnz;
}
#include <vector>
-void test (TrilinosWrappers::MatrixBase &m)
+void test (TrilinosWrappers::SparseMatrix &m)
{
Assert (m.m() != 0, ExcInternalError());
Assert (m.n() != 0, ExcInternalError());
if (i>=5)
{
const double s = rand();
- m.add (i,i-5, s);
+ m.set (i,i-5, s);
norm_sqr += s*s;
++nnz;
}
if (i<N-5)
{
const double s = rand();
- m.add (i,i+5, s);
+ m.set (i,i+5, s);
norm_sqr += s*s;
++nnz;
}
const double s = rand();
- m.add (i,i,s);
+ m.set (i,i,s);
norm_sqr += s*s;
++nnz;
}
#include <fstream>
-int main ()
+int main (int argc, char** argv)
{
std::ofstream logfile("70/output");
deallog.attach(logfile);
void test ()
{
- TrilinosWrappers::BlockVector v(2,1);
+ TrilinosWrappers::BlockVector v(2);
+ for (unsigned int i=0; i<v.n_blocks(); ++i)
+ v.block(i).reinit(1);
+ v.collect_sizes();
+
v(0) = 1;
v(1) = 2;
void test ()
{
- TrilinosWrappers::BlockVector v(2,1);
+ TrilinosWrappers::BlockVector v(2);
+ for (unsigned int i=0; i<v.n_blocks(); ++i)
+ v.block(i).reinit(1);
+ v.collect_sizes();
+
v(0) = 1;
v(1) = 2;
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
u.compress ();
GrowingVectorMemory<TrilinosWrappers::Vector> mem;
- SolverCG<TrilinosWrappers::Vector> solver(control,mem);
+ SolverCG<TrilinosWrappers::Vector> solver(control, mem);
PreconditionIdentity preconditioner;
check_solve (solver, A,u,f, preconditioner);
}
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(2000, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
#include <cstdlib>
-unsigned int
-get_n_mpi_processes ()
-{
- int n_jobs;
- MPI_Comm_size (MPI_COMM_WORLD, &n_jobs);
-
- return n_jobs;
-}
-
-
-
-unsigned int
-get_this_mpi_process ()
-{
- int rank;
- MPI_Comm_rank (MPI_COMM_WORLD, &rank);
-
- return rank;
-}
-
-
void test ()
{
// create a parallel matrix where the first
// process has 10 rows, the second one 20,
// the third one 30, and so on
unsigned int N = 0;
- std::vector<unsigned int> local_rows_per_process (get_n_mpi_processes());
- std::vector<unsigned int> start_row (get_n_mpi_processes());
- for (unsigned int i=0; i<get_n_mpi_processes(); ++i)
+ std::vector<unsigned int> local_rows_per_process
+ (Utilities::Trilinos::get_n_mpi_processes(Utilities::Trilinos::comm_world()));
+ std::vector<unsigned int> start_row
+ (Utilities::Trilinos::get_n_mpi_processes(Utilities::Trilinos::comm_world()));
+ for (unsigned int i=0;
+ i<Utilities::Trilinos::get_n_mpi_processes(Utilities::Trilinos::comm_world());
+ ++i)
{
N += (i+1)*10;
local_rows_per_process[i] = (i+1)*10;
// now create a matrix with this sparsity
// pattern
- TrilinosWrappers::SparseMatrix m;
- m.reinit (MPI_COMM_WORLD, csp, local_rows_per_process,
- local_rows_per_process, get_this_mpi_process());
+ Epetra_Map map (-1, local_rows_per_process[Utilities::Trilinos::get_this_mpi_process
+ (Utilities::Trilinos::comm_world())],
+ 0, Utilities::Trilinos::comm_world());
- // no write into the exact same matrix
+ TrilinosWrappers::SparseMatrix m;
+ m.reinit (map, csp);
+ // now write into the exact same matrix
// entries as have been created by the
// sparsity pattern above
for (unsigned int i=0; i<N; ++i)
// this is part of a whole suite of tests that checks the relative speed of
-// using PETSc for sparse matrices as compared to the speed of our own
-// library. the tests therefore may not all actually use PETSc, but they are
+// using Trilinos for sparse matrices as compared to the speed of our own
+// library. the tests therefore may not all actually use Trilinos, but they are
// meant to compare it
//
// the tests build the 5-point stencil matrix for a uniform grid of size N*N
deallog.attach(logfile);
deallog.depth_console(0);
+ Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
+
try
{
{
<< std::endl;
return 1;
};
+ return 0;
}
for(unsigned int j=0; j<N; j++)
{
const unsigned int global = i*N+j;
- matrix.add(global, global, 4);
+ matrix.set(global, global, 4);
if (j>0)
{
- matrix.add(global-1, global, -1);
- matrix.add(global, global-1, -1);
+ matrix.set(global-1, global, -1);
+ matrix.set(global, global-1, -1);
}
if (j<N-1)
{
- matrix.add(global+1, global, -1);
- matrix.add(global, global+1, -1);
+ matrix.set(global+1, global, -1);
+ matrix.set(global, global+1, -1);
}
if (i>0)
{
- matrix.add(global-N, global, -1);
- matrix.add(global, global-N, -1);
+ matrix.set(global-N, global, -1);
+ matrix.set(global, global-N, -1);
}
if (i<N-1)
{
- matrix.add(global+N, global, -1);
- matrix.add(global, global+N, -1);
+ matrix.set(global+N, global, -1);
+ matrix.set(global, global+N, -1);
}
}
matrix.compress ();
deallog.attach(logfile);
deallog.depth_console(0);
+ Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
+
try
{
{
<< std::endl;
return 1;
};
+ return 0;
}
const unsigned int N = 200;
// build the sparse matrix
- TrilinosWrappers::SparseMatrix matrix (PETSC_COMM_WORLD,
- N*N, N*N,
- N*N, N*N,
- 5);
+ Epetra_Map map (N*N, 0, Utilities::Trilinos::comm_world());
+ TrilinosWrappers::SparseMatrix matrix (map, 5);
for(unsigned int i=0; i<N; i++)
for(unsigned int j=0; j<N; j++)
{
const unsigned int global = i*N+j;
- matrix.add(global, global, 4);
+ matrix.set(global, global, 4);
if (j>0)
{
- matrix.add(global-1, global, -1);
- matrix.add(global, global-1, -1);
+ matrix.set(global-1, global, -1);
+ matrix.set(global, global-1, -1);
}
if (j<N-1)
{
- matrix.add(global+1, global, -1);
- matrix.add(global, global+1, -1);
+ matrix.set(global+1, global, -1);
+ matrix.set(global, global+1, -1);
}
if (i>0)
{
- matrix.add(global-N, global, -1);
- matrix.add(global, global-N, -1);
+ matrix.set(global-N, global, -1);
+ matrix.set(global, global-N, -1);
}
if (i<N-1)
{
- matrix.add(global+N, global, -1);
- matrix.add(global, global+N, -1);
+ matrix.set(global+N, global, -1);
+ matrix.set(global, global+N, -1);
}
}
matrix.compress ();
// then do a single matrix-vector
// multiplication with subsequent formation
// of the matrix norm
- TrilinosWrappers::MPI::Vector v1(PETSC_COMM_WORLD, N*N, N*N);
- TrilinosWrappers::MPI::Vector v2(PETSC_COMM_WORLD, N*N, N*N);
+ TrilinosWrappers::MPI::Vector v1(map);
+ TrilinosWrappers::MPI::Vector v2(map);
for (unsigned int i=0; i<N*N; ++i)
v1(i) = i;
matrix.vmult (v2, v1);
deallog.attach(logfile);
deallog.depth_console(0);
+ Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
+
try
{
{
<< std::endl;
return 1;
};
+
+ return 0;
}
}
// build the sparse matrix
- TrilinosWrappers::SparseMatrix matrix (PETSC_COMM_WORLD,
- N*N, N*N,
- N*N, N*N,
- 5);
+ Epetra_Map map (N*N, 0, Utilities::Trilinos::comm_world());
+ TrilinosWrappers::SparseMatrix matrix (map, 5);
for(unsigned int i_=0; i_<N; i_++)
for(unsigned int j_=0; j_<N; j_++)
{
const unsigned int j=permutation[j_];
const unsigned int global = i*N+j;
- matrix.add(global, global, rand());
+ matrix.set(global, global, rand());
if (j>0)
{
- matrix.add(global-1, global, rand());
- matrix.add(global, global-1, rand());
+ matrix.set(global-1, global, rand());
+ matrix.set(global, global-1, rand());
}
if (j<N-1)
{
- matrix.add(global+1, global, rand());
- matrix.add(global, global+1, rand());
+ matrix.set(global+1, global, rand());
+ matrix.set(global, global+1, rand());
}
if (i>0)
{
- matrix.add(global-N, global, rand());
- matrix.add(global, global-N, rand());
+ matrix.set(global-N, global, rand());
+ matrix.set(global, global-N, rand());
}
if (i<N-1)
{
- matrix.add(global+N, global, rand());
- matrix.add(global, global+N, rand());
+ matrix.set(global+N, global, rand());
+ matrix.set(global, global+N, rand());
}
}
matrix.compress ();
// then do a single matrix-vector
// multiplication with subsequent formation
// of the matrix norm
- TrilinosWrappers::MPI::Vector v1(PETSC_COMM_WORLD, N*N, N*N);
- TrilinosWrappers::MPI::Vector v2(PETSC_COMM_WORLD, N*N, N*N);
+ TrilinosWrappers::MPI::Vector v1(map);
+ TrilinosWrappers::MPI::Vector v2(map);
for (unsigned int i=0; i<N*N; ++i)
v1(i) = i;
matrix.vmult (v2, v1);
deallog.attach(logfile);
deallog.depth_console(0);
+ Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
+
try
{
{
<< std::endl;
return 1;
};
+ return 0;
}
+++ /dev/null
-//---------------------------- trilinos_solver_01.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_01.cc ---------------------------
-
-// test the Trilinos Richardson solver
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- // it needs to be expected for the
- // richardson solver that we end up
- // here, so don't abort
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_01/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverRichardson solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers16SolverRichardsonE
-DEAL::Starting value 7.750
-DEAL::Failure step 100 value 4.004
-DEAL::Iterative method reported convergence failure in step 100 with residual 4.00437
-DEAL::Solver stopped after 100 iterations
+++ /dev/null
-//---------------------------- trilinos_solver_02.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_02.cc ---------------------------
-
-// test the Trilinos Chebychev solver
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- // just like for Richardson: we end up
- // here normally for this solver
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_02/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverChebychev solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers15SolverChebychevE
-DEAL::Starting value 7.745
-DEAL::Failure step 100 value 3.885
-DEAL::Iterative method reported convergence failure in step 100 with residual 3.88526
-DEAL::Solver stopped after 100 iterations
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
u.compress ();
TrilinosWrappers::SolverCG solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ TrilinosWrappers::PreconditionJacobi preconditioner;
+ preconditioner.initialize(A);
check_solve (solver, A,u,f, preconditioner);
}
}
+++ /dev/null
-//---------------------------- trilinos_solver_04.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_04.cc ---------------------------
-
-// test the Trilinos BiCG solver
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_04/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverBiCG solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverBiCGE
-DEAL::Starting value 7.750
-DEAL::Convergence step 41 value 0.0006730
-DEAL::Solver stopped after 41 iterations
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
u.compress ();
TrilinosWrappers::SolverGMRES solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ TrilinosWrappers::PreconditionJacobi preconditioner;
+ preconditioner.initialize(A);
check_solve (solver, A,u,f, preconditioner);
}
}
u.compress ();
TrilinosWrappers::SolverBicgstab solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ TrilinosWrappers::PreconditionJacobi preconditioner;
+ preconditioner.initialize(A);
check_solve (solver, A,u,f, preconditioner);
}
}
//---------------------------- trilinos_solver_07.cc ---------------------------
-// $Id$
+// $Id: solver_07.cc 17307 2008-10-23 01:52:20Z bangerth $
// Version: $Name$
//
-// Copyright (C) 2004, 2005, 2008 by the deal.II authors
+// Copyright (C) 2004, 2005 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// test the Trilinos CGS solver
-#include "../tests.h"
-#include <base/utilities.h>
+#include "../tests.h"
#include "../lac/testmatrix.h"
#include <cmath>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <base/logstream.h>
+#include <base/utilities.h>
#include <lac/trilinos_sparse_matrix.h>
#include <lac/trilinos_vector.h>
#include <lac/trilinos_solver.h>
logfile.precision(4);
deallog.attach(logfile);
deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
+ deallog.threshold_double(1.e-10);
+ Utilities::System::MPI_InitFinalize mpi_initialization(argc, argv);
{
- SolverControl control(100, 1.e-3);
+ SolverControl control(200, 1.e-3);
const unsigned int size = 32;
unsigned int dim = (size-1)*(size-1);
u.compress ();
TrilinosWrappers::SolverCGS solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ TrilinosWrappers::PreconditionJacobi preconditioner;
+ preconditioner.initialize(A);
check_solve (solver, A,u,f, preconditioner);
}
+
}
u.compress ();
TrilinosWrappers::SolverTFQMR solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ TrilinosWrappers::PreconditionJacobi preconditioner;
+ preconditioner.initialize(A);
check_solve (solver, A,u,f, preconditioner);
}
}
+++ /dev/null
-//---------------------------- trilinos_solver_09.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_09.cc ---------------------------
-
-// test the Trilinos TCQMR solver
-//
-// note that this test fails on Trilinos 2.1.6 due to a bug in the TCQMR
-// implementation. this is reported and should be fixed soonish
-
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_09/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverTCQMR solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers11SolverTCQMRE
-DEAL::Starting value 7.750
-DEAL::Starting value 7.750
-DEAL::Convergence step 44 value 0.0007016
-DEAL::Solver stopped after 44 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers11SolverTCQMRE
-DEAL::Starting value 7.750
-DEAL::Starting value 7.750
-DEAL::Convergence step 44 value 0.0007012
-DEAL::Solver stopped after 44 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers11SolverTCQMRE
-DEAL::Starting value 7.750
-DEAL::Starting value 7.750
-DEAL::Convergence step 44 value 0.0007011
-DEAL::Solver stopped after 44 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers11SolverTCQMRE
-DEAL::Starting value 7.750
-DEAL::Starting value 7.750
-DEAL::Convergence step 44 value 0.0007008
-DEAL::Solver stopped after 44 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers11SolverTCQMRE
-DEAL::Starting value 7.750
-DEAL::Starting value 7.750
-DEAL::Convergence step 44 value 0.0007010
-DEAL::Solver stopped after 44 iterations
+++ /dev/null
-//---------------------------- trilinos_solver_10.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_10.cc ---------------------------
-
-// test the Trilinos CR solver
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- abort ();
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_10/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverCR solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers8SolverCRE
-DEAL::Starting value 7.750
-DEAL::Convergence step 41 value 0.0005700
-DEAL::Solver stopped after 41 iterations
+++ /dev/null
-//---------------------------- trilinos_solver_11.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2004, 2005, 2008 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.
-//
-//---------------------------- trilinos_solver_11.cc ---------------------------
-
-// test the Trilinos LSQR solver
-
-
-#include "../tests.h"
-#include <base/utilities.h>
-#include "../lac/testmatrix.h"
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <base/logstream.h>
-#include <lac/trilinos_sparse_matrix.h>
-#include <lac/trilinos_vector.h>
-#include <lac/trilinos_solver.h>
-#include <lac/trilinos_precondition.h>
-#include <lac/vector_memory.h>
-#include <typeinfo>
-
-template<class SOLVER, class MATRIX, class VECTOR, class PRECONDITION>
-void
-check_solve( SOLVER& solver, const MATRIX& A,
- VECTOR& u, VECTOR& f, const PRECONDITION& P)
-{
- deallog << "Solver type: " << typeid(solver).name() << std::endl;
-
- u = 0.;
- f = 1.;
- try
- {
- solver.solve(A,u,f,P);
- }
- catch (std::exception& e)
- {
- deallog << e.what() << std::endl;
- // just like for Richardson: expect to
- // get here, don't abort the program
- }
-
- deallog << "Solver stopped after " << solver.control().last_step()
- << " iterations" << std::endl;
-}
-
-
-int main(int argc, char **argv)
-{
- std::ofstream logfile("solver_11/output");
- logfile.precision(4);
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
-
-
- {
- SolverControl control(100, 1.e-3);
-
- const unsigned int size = 32;
- unsigned int dim = (size-1)*(size-1);
-
- deallog << "Size " << size << " Unknowns " << dim << std::endl;
-
- // Make matrix
- FDMatrix testproblem(size, size);
- TrilinosWrappers::SparseMatrix A(dim, dim, 5);
- testproblem.five_point(A);
-
- TrilinosWrappers::Vector f(dim);
- TrilinosWrappers::Vector u(dim);
- f = 1.;
- A.compress ();
- f.compress ();
- u.compress ();
-
- TrilinosWrappers::SolverLSQR solver(control);
- TrilinosWrappers::PreconditionJacobi preconditioner(A);
- check_solve (solver, A,u,f, preconditioner);
- }
-}
-
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Starting value 31.00
-DEAL::Failure step 100 value 24.01
-DEAL::Iterative method reported convergence failure in step 100 with residual 24.0098
-DEAL::Solver stopped after 100 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Starting value 31.00
-DEAL::Failure step 100 value 24.02
-DEAL::Iterative method reported convergence failure in step 100 with residual 24.0185
-DEAL::Solver stopped after 100 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Starting value 31.00
-DEAL::Failure step 100 value 24.02
-DEAL::Iterative method reported convergence failure in step 100 with residual 24.0199
-DEAL::Solver stopped after 100 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Starting value 31.00
-DEAL::Failure step 100 value 24.02
-DEAL::Iterative method reported convergence failure in step 100 with residual 24.0219
-DEAL::Solver stopped after 100 iterations
+++ /dev/null
-
-DEAL::Size 32 Unknowns 961
-DEAL::Solver type: N6dealii13PETScWrappers10SolverLSQRE
-DEAL::Starting value 31.00
-DEAL::Failure step 100 value 24.02
-DEAL::Iterative method reported convergence failure in step 100 with residual 24.0221
-DEAL::Solver stopped after 100 iterations