hp \
aniso \
$(shell if test "$(USE_CONTRIB_PETSC)" = yes ; then echo petsc ; fi) \
+ $(shell if test "$(USE_CONTRIB_TRILINOS)" = yes ; then echo trilinos ; fi) \
$(shell if test "$(USE_CONTRIB_UMFPACK)" = yes ; then echo umfpack ; fi) \
$(shell if grep -q 'define HAVE_LIBLAPACK' $D/base/include/base/config.h ;\
then echo umfpack ; fi)
--- /dev/null
+//---------------------------- trilinos_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_01.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using
+// TrilinosWrappers::SparseMatrix::set()
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_02.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using
+// TrilinosWrappers::SparseMatrix::add()
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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.add (i,j, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_03.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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)
+ {
+ if (i*j % 2 == 0)
+ m.set (i,j, i*j*.5+.5);
+ else
+ m.add (i,j, i*j*.5+.5);
+ }
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("03/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_03a.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_03a.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+//
+// in contrast to trilinos_03, we set and add the same elements here twice, to
+// get double the original value
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+
+ // 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 ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+ Assert (m.el(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("03a/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_03b.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_03b.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+//
+// in contrast to trilinos_03a, we set and add the same elements here twice, then
+// overwrite them again to get the original value back
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+ // 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);
+ // and overwrite everything 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.set (i,j, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("03b/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_04.cc ---------------------------
+
+
+// check querying matrix sizes
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::SparseMatrix &m)
+{
+ Assert (m.m() == 5, ExcInternalError());
+ Assert (m.n() == 5, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_05.cc ---------------------------
+
+
+// check querying the number of nonzero elements in
+// TrilinosWrappers::SparseMatrix
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::SparseMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ unsigned int counter = 0;
+ 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, i*j*.5+.5);
+ ++counter;
+ }
+
+ m.compress ();
+
+ deallog << m.n_nonzero_elements() << std::endl;
+ Assert (m.n_nonzero_elements() == counter,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("05/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::8
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_06.cc ---------------------------
+
+
+// check TrilinosWrappers::SparseMatrix::l1_norm
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::SparseMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ 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, i*j*.5+.5);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // l1-norm (max col-sum)
+ deallog << m.l1_norm() << std::endl;
+ Assert (m.l1_norm() == 7, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("06/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.00000
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_07.cc ---------------------------
+
+
+// check TrilinosWrappers::SparseMatrix::linfty_norm
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::SparseMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ 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, i*j*.5+.5);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // linfty-norm (max row-sum)
+ deallog << m.linfty_norm() << std::endl;
+ Assert (m.linfty_norm() == 8.5, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("07/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::8.50000
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_08.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_08.cc ---------------------------
+
+
+// check TrilinosWrappers::SparseMatrix::frobenius_norm
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::SparseMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ PetscScalar norm = 0;
+ 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, i*j*.5+.5);
+ norm += (i*j*.5+.5)*(i*j*.5+.5);
+ }
+ norm = std::sqrt(norm);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // l2-norm (max row-sum)
+ deallog << m.frobenius_norm() << std::endl;
+ Assert (m.frobenius_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("08/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::9.04157
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_09.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_09.cc ---------------------------
+
+
+// check TrilinosWrappers::SparseMatrix::operator *=
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then multiply everything by 1.25 and
+ // make sure we retrieve the values we
+ // expect
+ m *= 1.25;
+
+ 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)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("09/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_10.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_10.cc ---------------------------
+
+
+// check TrilinosWrappers::SparseMatrix::operator /=
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then divide everything by 4/3 and
+ // make sure we retrieve the values we
+ // expect
+ m /= 4./3.;
+
+ 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)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("10/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_11.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_11.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::size()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the vector
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) = i;
+
+ v.compress ();
+
+ Assert (v.size() == 100, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("11/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_12.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_12.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set-mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("12/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_13.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_13.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in add-mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("13/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_14.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_14.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set/add-mode alternatingly
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ bool flag = false;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ if (flag == true)
+ v(i) += i;
+ else
+ v(i) = i;
+ flag = !flag;
+
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("14/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_15.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_15.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set/add-mode alternatingly, but
+// writing to the same elements
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) += i;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("15/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_16.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_16.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set/add-mode alternatingly, but
+// writing and overwriting the same elements
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) += i;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) = i;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("16/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_17.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_17.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::l1_norm()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.l1_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("17/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_18.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_18.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::l2_norm()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ PetscScalar norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (fabs(v.l2_norm()-std::sqrt(norm))<eps, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("18/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_19.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_19.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::linfty_norm()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm = std::max(norm,fabs(i));
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.linfty_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("19/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_20.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_20.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator *=
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 5/4
+ v *= 5./4.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*5./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("20/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_21.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_21.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator /=
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 3/4
+ v /= 4./3.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*3./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("21/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_22.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_22.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator*(Vector) on two vectors that are
+// orthogonal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector, but disjoint sets of elements
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i;
+ else
+ w(i) = i;
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("22/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_23.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_23.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator*(Vector) on two vectors that are
+// not orthogonal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector, and record the expected scalar
+ // product
+ double product = 0;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ {
+ w(i) = i+1.;
+ product += i*(i+1);
+ }
+ }
+
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == product, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("23/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_24.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_24.cc ---------------------------
+
+
+// this test used to check for TrilinosWrappers::Vector::clear(). However, this
+// function has since been removed, so we test for v=0 instead, although that
+// may be covered by one of the other tests
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v = 0;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("24/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_25.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_25.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator = (PetscScalar) with setting to zero
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v = 0;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("25/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_26.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_26.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator = (PetscScalar) with setting to a
+// nonzero value
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ const unsigned int sz = v.size();
+ v = 2;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == std::sqrt(4.*sz), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("26/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_27.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_27.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator = (Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it
+ TrilinosWrappers::Vector w (v.size());
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < eps*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("27/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_28.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_28.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator = (Vector), except that we don't
+// resize the vector to be copied to beforehand
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it to a vector of different
+ // size
+ TrilinosWrappers::Vector w (1);
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < eps*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("28/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_29.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_29.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::reinit(fast)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ v.reinit (13, true);
+
+ Assert (v.size() == 13, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("29/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_30.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_30.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::reinit(!fast)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then resize with setting to zero
+ v.reinit (13, false);
+
+ Assert (v.size() == 13, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("30/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_31.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_31.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::l2_norm()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ PetscScalar norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (std::fabs(v.norm_sqr() - norm) < eps*norm,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("31/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_32.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004, 2005, 2007 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_32.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::mean_value()
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ PetscScalar sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i;
+ }
+ v.compress ();
+
+ // then check the norm
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (std::fabs(v.mean_value() - sum/v.size()) < eps*sum/v.size(),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("32/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_33.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_33.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::lp_norm(3)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ PetscScalar sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // then check the norm
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ const double true_value=std::pow(sum, static_cast<PetscScalar> (1./3.));
+ Assert (std::fabs(v.lp_norm(3) - true_value) < eps*true_value,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("33/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_34.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_34.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::all_zero
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // set them to zero again
+ v = 0;
+
+ // then check all_zero
+ Assert (v.all_zero() == true, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("34/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_35.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_35.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator+=(Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v += w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+i+1., ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("35/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_36.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_36.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator-=(Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v -= w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i-(i+1.), ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("36/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_37.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_37.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::add (scalar)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ v.compress ();
+
+ v.add (1.);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (v(i) == i+1., ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("37/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_38.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_38.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::add(Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("38/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_39.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_39.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::add(scalar, Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("39/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_40.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_40.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::add(s,V,s,V)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.add (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("40/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_41.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_41.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::sadd(s, Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("41/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_42.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_42.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::sadd(scalar, scalar, Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (3, 2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 3*i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("42/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_43.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_43.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::sadd(s,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.sadd (1.5, 2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("43/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_44.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_44.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::sadd(s,s,V,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x,
+ TrilinosWrappers::Vector &y)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ y(i) = i+3.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+ y.compress ();
+
+ v.sadd (1.5, 2, w, 3, x, 4, y);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (y(i) == i+3., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.)+4*(i+3), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("44/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ TrilinosWrappers::Vector y (100);
+ test (v,w,x,y);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_45.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_45.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::scale
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.scale (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("45/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_46.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_46.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::equ (s,V)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.equ (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("46/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_47.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_47.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::equ (s,V,s,V)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.equ (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("47/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_48.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_48.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::ratio
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.ratio (w, x);
+
+ // make sure we get the expected result
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (std::fabs(v(i) - (i+1.)/(i+2.)) < eps*v(i),
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("48/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_49.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_49.cc ---------------------------
+
+
+// check TrilinosWrappers::operator = (Vector<PetscVector>)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ Vector<PetscScalar> w (v.size());
+
+ for (unsigned int i=0; i<w.size(); ++i)
+ w(i) = i;
+
+ v = w;
+
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("49/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_50.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_50.cc ---------------------------
+
+
+// check TrilinosWrappers::operator = (Vector<T>) with T!=PetscScalar
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ Vector<double> w (v.size());
+ Vector<float> x (v.size());
+
+ for (unsigned int i=0; i<w.size(); ++i)
+ {
+ w(i) = i;
+ x(i) = i+1;
+ }
+
+ // first copy from w and make sure we get
+ // the expected result. then copy from x
+ // and do the same. in at least one of the
+ // two cases, the template argument to
+ // Vector<T> must be different from
+ // PetscScalar
+ v = w;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ Assert (x(i) == i+1, ExcInternalError());
+ }
+
+ v = x;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i, ExcInternalError());
+ Assert (v(i) == i+1, ExcInternalError());
+ Assert (x(i) == i+1, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("50/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_51.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_51.cc ---------------------------
+
+
+// check copy constructor TrilinosWrappers::Vector::Vector(Vector)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it
+ TrilinosWrappers::Vector w (v);
+ w.compress ();
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps=typeid(PetscScalar)==typeid(double) ? 1e-14 : 1e-5;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < eps*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("51/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_52.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_52.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using
+// TrilinosWrappers::SparseMatrix::set(). like trilinos_01, but use a different
+// constructor for the sparse matrix
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("52/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ std::vector<unsigned int> row_lengths (5, 3U);
+ row_lengths.back() = 2;
+ TrilinosWrappers::SparseMatrix m (5,5,row_lengths);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_53.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_53.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set, and later in add-mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) += i;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("53/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_54.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_54.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set, and later in -= mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = 2*i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) -= i;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("54/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_55.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_55.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set, and later in *= mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) *= 2;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("55/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_56.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_56.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator() in set, and later in /= mode
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = 2*i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) /= 2;
+
+ v.compress ();
+
+ // 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)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("56/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_57.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_57.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::is_non_zero
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. they are all positive
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // check that the vector is really
+ // non-negative
+ Assert (v.is_non_negative() == true, ExcInternalError());
+
+ // then set a single element to a negative
+ // value and check again
+ v(v.size()/2) = -1;
+ Assert (v.is_non_negative() == false, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("57/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_58.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_58.cc ---------------------------
+
+
+// check ::Vector (const TrilinosWrappers::Vector &) copy constructor
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector.
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ Vector<double> w (v);
+ Vector<float> x (v);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == w(i), ExcInternalError());
+ Assert (v(i) == x(i), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("58/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_59.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_59.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector (const ::Vector &) copy constructor
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector.
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ Vector<double> w (v);
+ Vector<float> x (v);
+
+ TrilinosWrappers::Vector w1 (w);
+ TrilinosWrappers::Vector x1 (x);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w1(i) == w(i), ExcInternalError());
+ Assert (x1(i) == x(i), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("59/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_60.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_60.cc ---------------------------
+
+
+// check ::Vector::operator = (const TrilinosWrappers::Vector &)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector.
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ Vector<double> w; w=v;
+ Vector<float> x; x=v;
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == w(i), ExcInternalError());
+ Assert (v(i) == x(i), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("60/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_61.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_61.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator = (const ::Vector &)
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector.
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ Vector<double> w; w=v;
+ Vector<float> x; x=v;
+
+ TrilinosWrappers::Vector w1; w1=w;
+ TrilinosWrappers::Vector x1; x1=x;
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w1(i) == w(i), ExcInternalError());
+ Assert (x1(i) == x(i), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("61/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_62.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_62.cc ---------------------------
+
+
+// check TrilinosWrappers::MatrixBase::clear ()
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() != 0, ExcInternalError());
+ Assert (m.n() != 0, ExcInternalError());
+
+ m.clear ();
+
+ Assert (m.m() == 0, ExcInternalError());
+ Assert (m.n() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("62/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (100,100,5);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_63.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_63.cc ---------------------------
+
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() == 100, ExcInternalError());
+ Assert (m.n() == 100, ExcInternalError());
+
+ m = 0;
+
+ Assert (m.m() == 100, ExcInternalError());
+ Assert (m.n() == 100, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("63/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (100,100,5);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_64.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- 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=
+
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/trilinos_parallel_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+template<typename MatrixType>
+void test (MatrixType &m)
+{
+ m.add(0,0,1);
+ m = 0;
+ m.compress();
+
+ Assert(fabs(m.frobenius_norm())<1e-15, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("64/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ const unsigned int n_dofs=420;
+ // check
+ // TrilinosWrappers::SparseMatrix
+ TrilinosWrappers::SparseMatrix
+ v1 (n_dofs, n_dofs, 5);
+ test (v1);
+
+ // check
+ // TrilinosWrappers::MPI::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::MPI::SparseMatrix
+ v2 (mpi_communicator, n_dofs, n_dofs, n_local_dofs, n_local_dofs, 5);
+ test (v2);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_65.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_65.cc ---------------------------
+
+
+// This test used to fail after upgrading to petsc 2.2.1
+
+
+#include "../tests.h"
+#include <lac/trilinos_parallel_vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test ()
+{
+ TrilinosWrappers::MPI::Vector v(PETSC_COMM_WORLD, 100, 100);
+ v(0) = 1;
+ v = 0;
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("65/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_66.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_66.cc ---------------------------
+
+
+// check TrilinosWrappers::MatrixBase::clear_row ()
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() != 0, ExcInternalError());
+ Assert (m.n() != 0, ExcInternalError());
+
+ // build a tri-diagonal pattern
+ double norm_sqr = 0;
+ unsigned int nnz = 0;
+ const unsigned int N = m.m();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ if (i>=5)
+ {
+ const double s = rand();
+ m.add (i,i-5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ if (i<N-5)
+ {
+ const double s = rand();
+ m.add (i,i+5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ const double s = rand();
+ m.add (i,i,s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+ m.compress ();
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+ Assert (m.n_nonzero_elements()-nnz == 0, ExcInternalError());
+
+ // now remove the entries of row N/2
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/2,i);
+ norm_sqr -= s*s;
+ }
+ m.clear_row (N/2);
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+
+ // make sure that zeroing out rows does at
+ // least not add new nonzero entries (it
+ // may remove some, though)
+ Assert (m.n_nonzero_elements() <= nnz, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("66/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (14,14,3);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.84337e+09 6.84337e+09
+DEAL::30 32
+DEAL::OK
--- /dev/null
+
+DEAL::6.88709e+09 6.88709e+09
+DEAL::32 32
+DEAL::6.68404e+09 6.68404e+09
+DEAL::29 32
+DEAL::OK
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.84337e+09 6.84337e+09
+DEAL::29 32
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_67.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_67.cc ---------------------------
+
+
+// check TrilinosWrappers::MatrixBase::clear_rows ()
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() != 0, ExcInternalError());
+ Assert (m.n() != 0, ExcInternalError());
+
+ // build a tri-diagonal pattern
+ double norm_sqr = 0;
+ unsigned int nnz = 0;
+ const unsigned int N = m.m();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ if (i>=5)
+ {
+ const double s = rand();
+ m.add (i,i-5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ if (i<N-5)
+ {
+ const double s = rand();
+ m.add (i,i+5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ const double s = rand();
+ m.add (i,i,s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+ m.compress ();
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+ Assert (m.n_nonzero_elements()-nnz == 0, ExcInternalError());
+
+ // now remove the entries of rows N/2 and N/3
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/2,i);
+ norm_sqr -= s*s;
+ }
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/3,i);
+ norm_sqr -= s*s;
+ }
+ const unsigned int rows[2] = { N/3, N/2 };
+ m.clear_rows (std::vector<unsigned int>(&rows[0], &rows[2]));
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+
+ // make sure that zeroing out rows does at
+ // least not add new nonzero entries (it
+ // may remove some, though)
+ Assert (m.n_nonzero_elements() <= nnz, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("67/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (14,14,3);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.71272e+09 6.71272e+09
+DEAL::29 32
+DEAL::OK
--- /dev/null
+
+DEAL::6.88709e+09 6.88709e+09
+DEAL::32 32
+DEAL::6.20640e+09 6.20640e+09
+DEAL::27 32
+DEAL::OK
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.71272e+09 6.71272e+09
+DEAL::27 32
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_68.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_68.cc ---------------------------
+
+
+// check TrilinosWrappers::MatrixBase::clear_row () with used second argument
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() != 0, ExcInternalError());
+ Assert (m.n() != 0, ExcInternalError());
+
+ // build a tri-diagonal pattern
+ double norm_sqr = 0;
+ unsigned int nnz = 0;
+ const unsigned int N = m.m();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ if (i>=5)
+ {
+ const double s = rand();
+ m.add (i,i-5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ if (i<N-5)
+ {
+ const double s = rand();
+ m.add (i,i+5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ const double s = rand();
+ m.add (i,i,s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+ m.compress ();
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+ Assert (m.n_nonzero_elements()-nnz == 0, ExcInternalError());
+
+ // now remove the entries of row N/2. set
+ // diagonal entries to rnd
+ const double rnd = rand();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/2,i);
+ norm_sqr -= s*s;
+ }
+ norm_sqr += rnd*rnd;
+
+ m.clear_row (N/2, rnd);
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+
+ // make sure that zeroing out rows does at
+ // least not add new nonzero entries (it
+ // may remove some, though)
+ Assert (m.n_nonzero_elements() <= nnz, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("68/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (14,14,3);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.96869e+09 6.96869e+09
+DEAL::30 32
+DEAL::OK
--- /dev/null
+
+DEAL::6.88709e+09 6.88709e+09
+DEAL::32 32
+DEAL::6.70776e+09 6.70776e+09
+DEAL::30 32
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_69.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_69.cc ---------------------------
+
+
+// check TrilinosWrappers::MatrixBase::clear_rows () with used second argument
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/vector.h>
+
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::MatrixBase &m)
+{
+ Assert (m.m() != 0, ExcInternalError());
+ Assert (m.n() != 0, ExcInternalError());
+
+ // build a tri-diagonal pattern
+ double norm_sqr = 0;
+ unsigned int nnz = 0;
+ const unsigned int N = m.m();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ if (i>=5)
+ {
+ const double s = rand();
+ m.add (i,i-5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ if (i<N-5)
+ {
+ const double s = rand();
+ m.add (i,i+5, s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+
+ const double s = rand();
+ m.add (i,i,s);
+ norm_sqr += s*s;
+ ++nnz;
+ }
+ m.compress ();
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+ Assert (m.n_nonzero_elements()-nnz == 0, ExcInternalError());
+
+ // now remove the entries of rows N/2 and
+ // N/3. set diagonal entries to rnd
+ const double rnd = rand();
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/2,i);
+ norm_sqr -= s*s;
+ }
+ for (unsigned int i=0; i<N; ++i)
+ {
+ const double s = m.el(N/3,i);
+ norm_sqr -= s*s;
+ }
+ norm_sqr += 2*rnd*rnd;
+
+ const unsigned int rows[2] = { N/3, N/2 };
+ m.clear_rows (std::vector<unsigned int>(&rows[0], &rows[2]), rnd);
+
+ deallog << m.frobenius_norm() << ' ' << std::sqrt (norm_sqr)
+ << std::endl;
+ deallog << m.n_nonzero_elements() << ' ' << nnz << std::endl;
+
+ Assert (std::fabs (m.frobenius_norm() - std::sqrt(norm_sqr))
+ < std::fabs (std::sqrt (norm_sqr)),
+ ExcInternalError());
+
+ // make sure that zeroing out rows does at
+ // least not add new nonzero entries (it
+ // may remove some, though)
+ Assert (m.n_nonzero_elements() <= nnz, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("69/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::SparseMatrix v (14,14,3);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.15267e+09 7.15267e+09
+DEAL::32 32
+DEAL::6.96580e+09 6.96580e+09
+DEAL::29 32
+DEAL::OK
--- /dev/null
+
+DEAL::6.88709e+09 6.88709e+09
+DEAL::32 32
+DEAL::6.25737e+09 6.25737e+09
+DEAL::29 32
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_70.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_70.cc ---------------------------
+
+
+// check PetscScalar
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/trilinos_vector.h>
+
+#include <fstream>
+
+int main ()
+{
+ std::ofstream logfile("70/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ if (typeid(PetscScalar)==typeid(double))
+ deallog << "double" << std::endl;
+ else if (typeid(PetscScalar)==typeid(float))
+ deallog << "float" << std::endl;
+ else
+ Assert(false, ExcNotImplemented());
+}
--- /dev/null
+
+DEAL::double
--- /dev/null
+############################################################
+# $Id$
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors
+############################################################
+
+############################################################
+# Include general settings for including DEAL libraries
+############################################################
+
+include ../Makefile.paths
+include $D/common/Make.global_options
+debug-mode = on
+
+libraries = $(lib-lac.g) \
+ $(lib-base.g)
+libraries_o = $(lib-lac.o) \
+ $(lib-base.o)
+
+default: run-tests
+
+############################################################
+
+tests_x = *
+
+
+# from above list of regular expressions, generate the real set of
+# tests
+expand = $(shell echo $(addsuffix .cc,$(1)) \
+ | $(PERL) -pi -e 's/\.cc//g;')
+tests = $(call expand,$(tests_x))
+
+############################################################
+
+
+include ../Makefile.rules
+include Makefile.depend
+include Makefile.tests
+
+.PHONY: default
\ No newline at end of file
--- /dev/null
+//---------------------------- trilinos_block_vector_iterator_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_block_vector_iterator_01.cc ---------------------------
+
+
+// make sure that block vector iterator allows reading and writing correctly
+
+#include "../tests.h"
+#include <lac/trilinos_block_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ TrilinosWrappers::BlockVector v(2,1);
+ v(0) = 1;
+ v(1) = 2;
+
+ // first check reading through a const
+ // iterator
+ {
+ TrilinosWrappers::BlockVector::const_iterator i=v.begin();
+ Assert (*i == 1, ExcInternalError());
+ ++i;
+ Assert (*i == 2, ExcInternalError());
+ }
+
+ // same, but create iterator in a different
+ // way
+ {
+ TrilinosWrappers::BlockVector::const_iterator
+ i=const_cast<const TrilinosWrappers::BlockVector&>(v).begin();
+ Assert (*i == 1, ExcInternalError());
+ ++i;
+ Assert (*i == 2, ExcInternalError());
+ }
+
+ // read through a read-write iterator
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+ Assert (*i == 1, ExcInternalError());
+ ++i;
+ Assert (*i == 2, ExcInternalError());
+ }
+
+ // write through a read-write iterator
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+
+ *i = 2;
+ ++i;
+ *i = 3;
+ }
+
+ // and read again
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+ Assert (*i == 2, ExcInternalError());
+ ++i;
+ Assert (*i == 3, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("block_vector_iterator_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_block_vector_iterator_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_block_vector_iterator_02.cc ---------------------------
+
+
+// like _01, except that we use operator[] instead of operator*
+
+#include "../tests.h"
+#include <lac/trilinos_block_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ TrilinosWrappers::BlockVector v(2,1);
+ v(0) = 1;
+ v(1) = 2;
+
+ // first check reading through a const
+ // iterator
+ {
+ TrilinosWrappers::BlockVector::const_iterator i=v.begin();
+ Assert (i[0] == 1, ExcInternalError());
+ Assert (i[1] == 2, ExcInternalError());
+ }
+
+ // same, but create iterator in a different
+ // way
+ {
+ TrilinosWrappers::BlockVector::const_iterator
+ i=const_cast<const TrilinosWrappers::BlockVector&>(v).begin();
+ Assert (i[0] == 1, ExcInternalError());
+ Assert (i[1] == 2, ExcInternalError());
+ }
+
+ // read through a read-write iterator
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+ Assert (i[0] == 1, ExcInternalError());
+ Assert (i[1] == 2, ExcInternalError());
+ }
+
+ // write through a read-write iterator
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+ i[0] = 2;
+ i[1] = 3;
+ }
+
+ // and read again
+ {
+ TrilinosWrappers::BlockVector::iterator i = v.begin();
+ Assert (i[0] == 2, ExcInternalError());
+ Assert (i[1] == 3, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("block_vector_iterator_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//--------------------------------------------------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2000, 2001, 2002, 2003, 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//--------------------------------------------------------------------
+
+// this test is an adaptation of lac/block_vector_iterator for PETSc block
+// vectors
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/trilinos_block_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include <numeric>
+#include <utility>
+#include <cmath>
+
+template <typename number>
+bool operator == (const TrilinosWrappers::BlockVector &v1,
+ const TrilinosWrappers::BlockVector &v2)
+{
+ if (v1.size() != v2.size())
+ return false;
+ for (unsigned int i=0; i<v1.size(); ++i)
+ if (v1(i) != v2(i))
+ return false;
+ return true;
+}
+
+
+void test ()
+{
+ std::vector<unsigned int> ivector(4);
+ ivector[0] = 2;
+ ivector[1] = 4;
+ ivector[2] = 3;
+ ivector[3] = 5;
+
+ // Check 1: initialization via
+ // iterators
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ TrilinosWrappers::BlockVector v2(ivector);
+
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+ // initialize other vector
+ // through iterators
+ TrilinosWrappers::BlockVector::iterator p2 = v2.begin();
+ for (unsigned int i=0; i<v1.size(); ++i, ++p2)
+ *p2 = i;
+ Assert (p2==v2.end(), ExcInternalError());
+
+ // check that the two vectors are equal
+ deallog << "Check 1: " << (v1==v2 ? "true" : "false") << std::endl;
+ };
+
+ // Check 1: initialization via
+ // iterators
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+ // initialize other vector
+ // through iterators into first
+ // vector
+ TrilinosWrappers::BlockVector v2(ivector, v1.begin(), v1.end());
+ // check that the two vectors are equal
+ deallog << "Check 2: " << (v1==v2 ? "true" : "false") << std::endl;
+ };
+
+ // Check 3: loop forward and back
+ // and check that things are the
+ // same
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ TrilinosWrappers::BlockVector::iterator p1 = v1.begin();
+ for (unsigned int i=0; i<v1.size(); ++i, ++p1)
+ Assert (*p1 == i, ExcInternalError());
+
+ Assert (p1 == v1.end(), ExcInternalError());
+
+ // move back into allowable
+ // region
+ --p1;
+
+ // check backwards
+ for (unsigned int i=0; i<v1.size(); ++i, --p1)
+ Assert (*p1 == v1.size()-i-1, ExcInternalError());
+
+ // if we came thus far,
+ // everything is alright
+ deallog << "Check 3: true" << std::endl;
+ };
+
+
+ // Check 4: same, but this time
+ // with const iterators
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ TrilinosWrappers::BlockVector::const_iterator p1 = v1.begin();
+ for (unsigned int i=0; i<v1.size(); ++i, ++p1)
+ Assert (*p1 == i, ExcInternalError());
+
+ Assert (p1 == v1.end(), ExcInternalError());
+
+ // move back into allowable
+ // region
+ --p1;
+
+ // check backwards
+ for (unsigned int i=0; i<v1.size(); ++i, --p1)
+ {
+ const double val = *p1;
+ const double ref = v1.size()-i-1;
+ Assert (val==ref, ExcInternalError());
+ };
+
+ // if we came thus far,
+ // everything is alright
+ deallog << "Check 4: true" << std::endl;
+ };
+
+ // Checks 5-14: use some standard
+ // algorithms
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ // check std::distance
+ // algorithm
+ deallog << "Check 5: "
+ << (std::distance (v1.begin(), v1.end()) ==
+ static_cast<signed int>(v1.size()) ?
+ "true" : "false")
+ << std::endl;
+
+ // check std::copy
+ TrilinosWrappers::BlockVector v2(ivector);
+ std::copy (v1.begin(), v1.end(), v2.begin());
+ deallog << "Check 6: " << (v1 == v2 ? "true" : "false") << std::endl;
+
+ // check std::transform
+ std::transform (v1.begin(), v1.end(), v2.begin(),
+ std::bind2nd (std::multiplies<double>(),
+ 2.0));
+ v2 *= 1./2.;
+ deallog << "Check 7: " << (v1 == v2 ? "true" : "false") << std::endl;
+
+
+ // check operators +/-, +=/-=
+ deallog << "Check 8: "
+ << (std::distance(v1.begin(), v1.begin()+3) == 3 ?
+ "true" : "false")
+ << std::endl;
+ deallog << "Check 9: "
+ << (std::distance(v1.end()-6, v1.end()) == 6 ?
+ "true" : "false")
+ << std::endl;
+ deallog << "Check 10: "
+ << (std::distance(v1.begin(), v1.end()) == (signed)v1.size() ?
+ "true" : "false")
+ << std::endl;
+ deallog << "Check 11: "
+ << (std::distance(v1.begin(), (v1.begin()+=7)) == 7 ?
+ "true" : "false")
+ << std::endl;
+ deallog << "Check 12: "
+ << (std::distance((v1.end()-=4), v1.end()) == 4 ?
+ "true" : "false")
+ << std::endl;
+
+ // check advance
+ TrilinosWrappers::BlockVector::iterator p2 = v1.begin();
+ std::advance (p2, v1.size());
+ deallog << "Check 13: " << (p2 == v1.end() ? "true" : "false") << std::endl;
+
+ TrilinosWrappers::BlockVector::const_iterator p3 = v1.begin();
+ std::advance (p3, v1.size());
+ deallog << "Check 14: " << (p3 == v1.end() ? "true" : "false") << std::endl;
+ };
+
+ // Check 15: initialization through
+ // iterators
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ // initialize a normal vector
+ // from it
+ Vector<double> v2(v1.begin(), v1.end());
+
+ // and reverse way
+ TrilinosWrappers::BlockVector v3(ivector, v2.begin(), v2.end());
+ deallog << "Check 15: " << (v1==v3 ? "true" : "false") << std::endl;
+ };
+
+ // Check 16: initialization through
+ // iterators. variant with one
+ // constant object
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ // initialize a normal vector
+ // from it
+ const Vector<double> v2(v1.begin(), v1.end());
+
+ // and reverse way
+ TrilinosWrappers::BlockVector v3(ivector, v2.begin(), v2.end());
+ deallog << "Check 16: " << (v1==v3 ? "true" : "false") << std::endl;
+ };
+
+ // Check 17: initialization through
+ // iterators. variant with two
+ // constant object
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ // initialize a normal vector
+ // from it
+ const Vector<double> v2(v1.begin(), v1.end());
+
+ // and reverse way
+ const TrilinosWrappers::BlockVector v3(ivector, v2.begin(), v2.end());
+ deallog << "Check 17: " << (v1==v3 ? "true" : "false") << std::endl;
+ };
+
+ // Check 18: initialization through
+ // iterators. variant with three
+ // constant object
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v0(ivector);
+ // initialize first vector with
+ // simple loop
+ for (unsigned int i=0; i<v0.size(); ++i)
+ v0(i) = i;
+
+ const TrilinosWrappers::BlockVector v1 = v0;
+
+ // initialize a normal vector
+ // from it
+ const Vector<double> v2(v1.begin(), v1.end());
+
+ // and reverse way
+ const TrilinosWrappers::BlockVector v3(ivector, v2.begin(), v2.end());
+ deallog << "Check 18: " << (v1==v3 ? "true" : "false") << std::endl;
+ };
+
+ // Check 19: operator[]
+ if (true)
+ {
+ TrilinosWrappers::BlockVector v1(ivector);
+ for (unsigned int i=0; i<v1.size(); ++i)
+ v1(i) = i;
+
+ for (unsigned int i=0; i<v1.size(); ++i)
+ {
+ const TrilinosWrappers::BlockVector::iterator p = (v1.begin()+i);
+ for (unsigned int j=0; j<v1.size(); ++j)
+ Assert (p[(signed)j-(signed)i] == j, ExcInternalError());
+ };
+
+ // if we came thus far,
+ // everything is alright
+ deallog << "Check 19: true" << std::endl;
+ };
+}
+
+
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("block_vector_iterator_03/output");
+ logfile.setf(std::ios::fixed);
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &e)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << e.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ // abort
+ return 2;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ // abort
+ return 3;
+ };
+
+
+ return 0;
+}
+
--- /dev/null
+
+DEAL::Check 1: true
+DEAL::Check 2: true
+DEAL::Check 3: true
+DEAL::Check 4: true
+DEAL::Check 5: true
+DEAL::Check 6: true
+DEAL::Check 7: true
+DEAL::Check 8: true
+DEAL::Check 9: true
+DEAL::Check 10: true
+DEAL::Check 11: true
+DEAL::Check 12: true
+DEAL::Check 13: true
+DEAL::Check 14: true
+DEAL::Check 15: true
+DEAL::Check 16: true
+DEAL::Check 17: true
+DEAL::Check 18: true
+DEAL::Check 19: true
--- /dev/null
+//---------------------------- trilinos_deal_solver_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_01.cc ---------------------------
+
+// test the CG solver using the PETSc matrix and vector classes
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/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("deal_solver_01/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverCG<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii8SolverCGINS_13PETScWrappers6VectorEEE
+DEAL:cg::Starting value 31.00
+DEAL:cg::Convergence step 43 value 0.0008189
+DEAL::Solver stopped after 43 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 4
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 4
--- /dev/null
+//---------------------------- trilinos_deal_solver_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_02.cc ---------------------------
+
+// test the BiCGStab solver using the PETSc matrix and vector classes
+
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/solver.h>
+#include <lac/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("deal_solver_02/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverBicgstab<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii14SolverBicgstabINS_13PETScWrappers6VectorEEE
+DEAL:Bicgstab::Starting value 31.00
+DEAL:Bicgstab::Convergence step 29 value 0.0008735
+DEAL::Solver stopped after 29 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 8
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 8
--- /dev/null
+//---------------------------- trilinos_deal_solver_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_03.cc ---------------------------
+
+// test the GMRES solver using the PETSc matrix and vector classes
+
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/solver.h>
+#include <lac/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("deal_solver_03/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverGMRES<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii11SolverGMRESINS_13PETScWrappers6VectorEEE
+DEAL:GMRES::Starting value 31.00
+DEAL:GMRES::Convergence step 75 value 0.0008096
+DEAL::Solver stopped after 75 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 30
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 30
--- /dev/null
+//---------------------------- trilinos_deal_solver_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_04.cc ---------------------------
+
+// test the MINRES solver using the PETSc matrix and vector classes
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/solver_minres.h>
+#include <lac/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("deal_solver_04/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverMinRes<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii12SolverMinResINS_13PETScWrappers6VectorEEE
+DEAL:minres::Starting value 31.00
+DEAL:minres::Convergence step 43 value 0.0006916
+DEAL::Solver stopped after 43 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 7
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 7
--- /dev/null
+//---------------------------- trilinos_deal_solver_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_05.cc ---------------------------
+
+// test the QMRS solver using the PETSc matrix and vector classes
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/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("deal_solver_05/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverQMRS<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii10SolverQMRSINS_13PETScWrappers6VectorEEE
+DEAL:QMRS::Starting value 31.00
+DEAL:QMRS::Convergence step 46 value 0.0009063
+DEAL::Solver stopped after 46 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 5
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 5
--- /dev/null
+//---------------------------- trilinos_deal_solver_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_deal_solver_06.cc ---------------------------
+
+// test the Richardson solver using the PETSc matrix and vector classes
+
+
+#include "../tests.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/solver_control.h>
+#include <lac/solver_cg.h>
+#include <lac/solver_gmres.h>
+#include <lac/solver_bicgstab.h>
+#include <lac/solver_richardson.h>
+#include <lac/solver_qmrs.h>
+#include <lac/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;
+ }
+
+ deallog << "Solver stopped after " << solver.control().last_step()
+ << " iterations" << std::endl;
+}
+
+
+int main(int argc, char **argv)
+{
+ std::ofstream logfile("deal_solver_06/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ const unsigned int size = 32;
+ unsigned int dim = (size-1)*(size-1);
+ SolverControl control(10000, 1.e-3);
+
+ 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 ();
+
+ GrowingVectorMemory<TrilinosWrappers::Vector> mem;
+ SolverRichardson<TrilinosWrappers::Vector> solver(control,mem);
+ PreconditionIdentity preconditioner;
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii16SolverRichardsonINS_13PETScWrappers6VectorEEE
+DEAL:Richardson::Starting value 31.00
+DEAL:Richardson::Failure step 372 value nan
+DEAL::Iterative method reported convergence failure in step 372 with residual nan
+DEAL::Solver stopped after 372 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 2
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 2
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii16SolverRichardsonINS_13PETScWrappers6VectorEEE
+DEAL:Richardson::Starting value 31.00
+DEAL:Richardson::Failure step 10000 value nan
+DEAL::Iterative method reported convergence failure in step 10000 with residual nan
+DEAL::Solver stopped after 10000 iterations
+DEAL::GrowingVectorMemory:Overall allocated vectors: 2
+DEAL::GrowingVectorMemory:Maximum allocated vectors: 2
--- /dev/null
+//---------------------------- trilinos_full_matrix_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_01.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using
+// TrilinosWrappers::FullMatrix::set()
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_02.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using
+// TrilinosWrappers::FullMatrix::add()
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &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.add (i,j, i*j*.5+.5);
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_03.cc ---------------------------
+
+
+// check setting elements in a petsc matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &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)
+ {
+ if (i*j % 2 == 0)
+ m.set (i,j, i*j*.5+.5);
+ else
+ m.add (i,j, i*j*.5+.5);
+ }
+
+ m.compress ();
+
+ // then make sure we retrieve the same ones
+ 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)
+ {
+ Assert (m(i,j) == i*j*.5+.5, ExcInternalError());
+ Assert (m.el(i,j) == i*j*.5+.5, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_03/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_04.cc ---------------------------
+
+
+// check querying matrix sizes
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &m)
+{
+ Assert (m.m() == 5, ExcInternalError());
+ Assert (m.n() == 5, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004, 2005, 2007 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_full_matrix_05.cc ---------------------------
+
+
+// check querying the number of nonzero elements in
+// TrilinosWrappers::FullMatrix
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ unsigned int counter = 0;
+ 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, i*j*.5+.5);
+ ++counter;
+ }
+
+ m.compress ();
+
+ // prior to and including PETSc 2.3.0,
+ // n_nonzero_elements returns the actual
+ // number of nonzeros. after that, PETSc
+ // returns the *total* number of entries of
+ // this matrix. check both (in the case
+ // post 2.3.0, output a dummy number
+#if (DEAL_II_PETSC_VERSION_MAJOR == 2) &&\
+ ((DEAL_II_PETSC_VERSION_MINOR < 3) \
+ ||\
+ ((DEAL_II_PETSC_VERSION_MINOR == 3) &&\
+ (DEAL_II_PETSC_VERSION_SUBMINOR == 0)))
+ deallog << m.n_nonzero_elements() << std::endl;
+ Assert (m.n_nonzero_elements() == counter,
+ ExcInternalError());
+#else
+ deallog << counter << std::endl;
+ Assert (m.m() * m.m(), ExcInternalError());
+#endif
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_05/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::8
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_06.cc ---------------------------
+
+
+// check TrilinosWrappers::FullMatrix::l1_norm
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ 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, i*j*.5+.5);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // l1-norm (max col-sum)
+ deallog << m.l1_norm() << std::endl;
+ Assert (m.l1_norm() == 7, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_06/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::7.00000
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_07.cc ---------------------------
+
+
+// check TrilinosWrappers::FullMatrix::linfty_norm
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ 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, i*j*.5+.5);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // linfty-norm (max row-sum)
+ deallog << m.linfty_norm() << std::endl;
+ Assert (m.linfty_norm() == 8.5, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_07/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::8.50000
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_08.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_08.cc ---------------------------
+
+
+// check TrilinosWrappers::FullMatrix::frobenius_norm
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &m)
+{
+ // first set a few entries. count how many
+ // entries we have
+ PetscScalar norm = 0;
+ 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, i*j*.5+.5);
+ norm += (i*j*.5+.5)*(i*j*.5+.5);
+ }
+ norm = std::sqrt(norm);
+
+ m.compress ();
+
+ // compare against the exact value of the
+ // l2-norm (max row-sum)
+ deallog << m.frobenius_norm() << std::endl;
+ Assert (m.frobenius_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_08/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::9.04157
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_09.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_09.cc ---------------------------
+
+
+// check TrilinosWrappers::FullMatrix::operator *=
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then multiply everything by 1.25 and
+ // make sure we retrieve the values we
+ // expect
+ m *= 1.25;
+
+ 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)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_09/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_10.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_10.cc ---------------------------
+
+
+// check TrilinosWrappers::FullMatrix::operator /=
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (TrilinosWrappers::FullMatrix &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, i*j*.5+.5);
+
+ m.compress ();
+
+ // then divide everything by 4/3 and
+ // make sure we retrieve the values we
+ // expect
+ m /= 4./3.;
+
+ 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)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_10/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::FullMatrix m (5,5);
+ test (m);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_iterator_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_iterator_01.cc ---------------------------
+
+
+// test TrilinosWrappers::MatrixBase::const_iterator
+
+#include "../tests.h"
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ TrilinosWrappers::FullMatrix m(5,5);
+ m.set (0,0,1);
+ m.set (1,1,2);
+ m.set (1,2,3);
+ m.compress ();
+ TrilinosWrappers::FullMatrix::const_iterator i = m.begin();
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+ ++i;
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+ i++;
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("full_matrix_iterator_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::0 0 1.00000
+DEAL::0 1 0
+DEAL::0 2 0
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_01.cc ---------------------------
+
+
+// check FullMatrix::vmult
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.vmult (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j;
+ Assert (w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_02.cc ---------------------------
+
+
+// check FullMatrix::Tvmult
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.Tvmult (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (j+2*i)*j;
+ Assert (w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_03.cc ---------------------------
+
+
+// check FullMatrix::vmult_add
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.vmult_add (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j;
+ Assert (w(i) == i+result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_03/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_04.cc ---------------------------
+
+
+// check FullMatrix::Tvmult_add
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.Tvmult_add (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (j+2*i)*j;
+ Assert (w(i) == i+result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_05.cc ---------------------------
+
+
+// check FullMatrix::matrix_scalar_product
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // <w,Mv>
+ const PetscScalar s = m.matrix_scalar_product (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+ Assert (w(i) == i+1, ExcInternalError());
+ }
+
+ PetscScalar result = 0;
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j*(i+1);
+
+ Assert (s == result, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_05/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_06.cc ---------------------------
+
+
+// check FullMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+
+ // <w,Mv>
+ const PetscScalar s = m.matrix_norm_square (v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (v(i) == i, ExcInternalError());
+
+ PetscScalar result = 0;
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j*i;
+
+ Assert (s == result, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_06/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (30);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_full_matrix_vector_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_full_matrix_vector_07.cc ---------------------------
+
+
+// check FullMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_full_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ TrilinosWrappers::FullMatrix m(v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // x=w-Mv
+ const double s = m.residual (x, v, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+ Assert (w(i) == i+1, ExcInternalError());
+
+ double result = i+1;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result -= (i+2*j)*j;
+
+ Assert (x(i) == result, ExcInternalError());
+ }
+
+ Assert (s == x.l2_norm(), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("full_matrix_vector_07/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_parallel_sparse_matrix_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_parallel_sparse_matrix_01.cc ---------------------------
+
+
+// TrilinosWrappers::MPI::SparseMatrix::reinit(CompressedSparsityPattern) should
+// create a matrix that, when filled with elements that match the sparsity
+// pattern, doesn't require any more memory allocation any more. This is
+// tricky to get right, though, and took a while until it worked.
+//
+// the test itself can only check this when run in parallel, but we can add it
+// anyway to the testsuite. in order to check that the library actually does
+// what it is supposed to do, run this program with more than one MPI process
+// and with the option -log_info. All the output should say that no additional
+// malloc calls have been performed
+
+#include "../tests.h"
+#include <lac/trilinos_parallel_sparse_matrix.h>
+#include <lac/compressed_sparsity_pattern.h>
+#include <fstream>
+#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)
+ {
+ N += (i+1)*10;
+ local_rows_per_process[i] = (i+1)*10;
+ start_row[i] += i*10;
+ }
+
+ // here is a sparsity pattern for which we
+ // used to allocate additional memory for 2
+ // processes. note that only one of the
+ // four blocks uses Inodes
+ CompressedSparsityPattern csp (N,N);
+ for (unsigned int i=0; i<N; ++i)
+ for (unsigned int j=0; j<N; ++j)
+ {
+ csp.add (i,i);
+ if (i+local_rows_per_process.back() < N)
+ csp.add (i,i+local_rows_per_process.back());
+ if (i > local_rows_per_process.back())
+ csp.add (i,i-local_rows_per_process.back());
+ }
+
+ // here is a sparsity pattern for which no
+ // Inodes are used, but it doesn't allocate
+ // additional memory
+// for (unsigned int bi=0; bi<get_n_mpi_processes(); ++bi)
+// for (unsigned int bj=0; bj<get_n_mpi_processes(); ++bj)
+// for (unsigned int i=0; i<local_rows_per_process[bi]; ++i)
+// for (unsigned int k=0; k<6; ++k)
+// csp.add (start_row[bi] + i,
+// start_row[bj] + (i+2*k) % local_rows_per_process[bj]);
+
+
+
+ // now create a matrix with this sparsity
+ // pattern
+ TrilinosWrappers::MPI::SparseMatrix m;
+ m.reinit (MPI_COMM_WORLD, csp, local_rows_per_process,
+ local_rows_per_process, get_this_mpi_process());
+
+ // no write into the exact same matrix
+ // entries as have been created by the
+ // sparsity pattern above
+ for (unsigned int i=0; i<N; ++i)
+ for (unsigned int j=0; j<csp.row_length(i); ++j)
+ m.add (i, csp.column_number(i,j), 1.);
+
+ m.compress ();
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("parallel_sparse_matrix_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ test ();
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_slowness_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005 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_slowness_01.cc ---------------------------
+
+
+// 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
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ const unsigned int N = 200;
+
+ // first build the sparsity pattern
+ SparsityPattern sparsity (N*N, N*N, 5);
+ for(unsigned int i=0; i<N; i++)
+ for(unsigned int j=0; j<N; j++)
+ {
+ const unsigned int global = i*N+j;
+ sparsity.add(global, global);
+ if (j>0)
+ {
+ sparsity.add(global-1, global);
+ sparsity.add(global, global-1);
+ }
+ if (j<N-1)
+ {
+ sparsity.add(global+1, global);
+ sparsity.add(global, global+1);
+ }
+ if (i>0)
+ {
+ sparsity.add(global-N, global);
+ sparsity.add(global, global-N);
+ }
+ if (i<N-1)
+ {
+ sparsity.add(global+N, global);
+ sparsity.add(global, global+N);
+ }
+ }
+ sparsity.compress();
+
+
+ // next build the sparse matrix itself
+ SparseMatrix<double> matrix (sparsity);
+ 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);
+ if (j>0)
+ {
+ matrix.add(global-1, global, -1);
+ matrix.add(global, global-1, -1);
+ }
+ if (j<N-1)
+ {
+ matrix.add(global+1, global, -1);
+ matrix.add(global, global+1, -1);
+ }
+ if (i>0)
+ {
+ matrix.add(global-N, global, -1);
+ matrix.add(global, global-N, -1);
+ }
+ if (i<N-1)
+ {
+ matrix.add(global+N, global, -1);
+ matrix.add(global, global+N, -1);
+ }
+ }
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ Vector<double> v1(N*N), v2(N*N);
+ for (unsigned int i=0; i<N*N; ++i)
+ v1(i) = i;
+ matrix.vmult (v2, v1);
+
+ deallog << v1*v2 << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("slowness_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+//---------------------------- trilinos_slowness_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005 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_slowness_02.cc ---------------------------
+
+
+// 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
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ const unsigned int N = 200;
+
+ // build the sparse matrix
+ TrilinosWrappers::SparseMatrix matrix (N*N, N*N, 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);
+ if (j>0)
+ {
+ matrix.add(global-1, global, -1);
+ matrix.add(global, global-1, -1);
+ }
+ if (j<N-1)
+ {
+ matrix.add(global+1, global, -1);
+ matrix.add(global, global+1, -1);
+ }
+ if (i>0)
+ {
+ matrix.add(global-N, global, -1);
+ matrix.add(global, global-N, -1);
+ }
+ if (i<N-1)
+ {
+ matrix.add(global+N, global, -1);
+ matrix.add(global, global+N, -1);
+ }
+ }
+ matrix.compress ();
+
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ TrilinosWrappers::Vector v1(N*N), v2(N*N);
+ for (unsigned int i=0; i<N*N; ++i)
+ v1(i) = i;
+ matrix.vmult (v2, v1);
+
+ deallog << v1*v2 << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("slowness_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+//---------------------------- trilinos_slowness_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005 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_slowness_03.cc ---------------------------
+
+
+// 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
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <lac/trilinos_parallel_sparse_matrix.h>
+#include <lac/trilinos_parallel_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ const unsigned int N = 200;
+
+ // build the sparse matrix
+ TrilinosWrappers::MPI::SparseMatrix matrix (PETSC_COMM_WORLD,
+ N*N, N*N,
+ N*N, N*N,
+ 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);
+ if (j>0)
+ {
+ matrix.add(global-1, global, -1);
+ matrix.add(global, global-1, -1);
+ }
+ if (j<N-1)
+ {
+ matrix.add(global+1, global, -1);
+ matrix.add(global, global+1, -1);
+ }
+ if (i>0)
+ {
+ matrix.add(global-N, global, -1);
+ matrix.add(global, global-N, -1);
+ }
+ if (i<N-1)
+ {
+ matrix.add(global+N, global, -1);
+ matrix.add(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);
+ for (unsigned int i=0; i<N*N; ++i)
+ v1(i) = i;
+ matrix.vmult (v2, v1);
+
+ deallog << v1*v2 << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("slowness_03/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+//---------------------------- trilinos_slowness_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005 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_slowness_03.cc ---------------------------
+
+
+// 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
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+//
+// this test does the same as the _03 test, except that it does not allocate
+// the entries in consecutive order, but in pseudo-random order. the reason is
+// that in usual finite element programs, we do not write to the elements of a
+// matrix in a consecutive fashion, but rather according to the order of
+// degrees of freedom in the sequence of cells that we traverse
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <lac/trilinos_parallel_sparse_matrix.h>
+#include <lac/trilinos_parallel_vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ const unsigned int N = 200;
+
+ // first find a random permutation of the
+ // indices
+ std::vector<unsigned int> permutation (N);
+ {
+ std::vector<unsigned int> unused_indices (N);
+ for (unsigned int i=0; i<N; i++)
+ unused_indices[i] = i;
+
+ for (unsigned int i=0; i<N; i++)
+ {
+ // pick a random element among the
+ // unused indices
+ const unsigned int k = rand() % (N-i);
+ permutation[i] = unused_indices[k];
+
+ // then swap this used element to the
+ // end where we won't consider it any
+ // more
+ std::swap (unused_indices[k], unused_indices[N-i-1]);
+ }
+ }
+
+ // build the sparse matrix
+ TrilinosWrappers::MPI::SparseMatrix matrix (PETSC_COMM_WORLD,
+ N*N, N*N,
+ N*N, N*N,
+ 5);
+ for(unsigned int i_=0; i_<N; i_++)
+ for(unsigned int j_=0; j_<N; j_++)
+ {
+ const unsigned int i=permutation[i_];
+ const unsigned int j=permutation[j_];
+
+ const unsigned int global = i*N+j;
+ matrix.add(global, global, rand());
+ if (j>0)
+ {
+ matrix.add(global-1, global, rand());
+ matrix.add(global, global-1, rand());
+ }
+ if (j<N-1)
+ {
+ matrix.add(global+1, global, rand());
+ matrix.add(global, global+1, rand());
+ }
+ if (i>0)
+ {
+ matrix.add(global-N, global, rand());
+ matrix.add(global, global-N, rand());
+ }
+ if (i<N-1)
+ {
+ matrix.add(global+N, global, rand());
+ matrix.add(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);
+ for (unsigned int i=0; i<N*N; ++i)
+ v1(i) = i;
+ matrix.vmult (v2, v1);
+
+ deallog << v1*v2 << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("slowness_04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::2.04928e+23
--- /dev/null
+
+DEAL::2.04862e+23
--- /dev/null
+//---------------------------- trilinos_solver_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_01.cc ---------------------------
+
+// test the PETSc Richardson solver
+
+
+#include "../tests.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);
+
+ {
+ 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 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 PETSc Chebychev solver
+
+
+#include "../tests.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);
+
+ {
+ 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
--- /dev/null
+//---------------------------- trilinos_solver_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_03.cc ---------------------------
+
+// test the PETSc CG solver
+
+
+#include "../tests.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_03/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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::SolverCG solver(control);
+ TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers8SolverCGE
+DEAL::Starting value 7.750
+DEAL::Convergence step 41 value 0.0006730
+DEAL::Solver stopped after 41 iterations
--- /dev/null
+//---------------------------- trilinos_solver_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_04.cc ---------------------------
+
+// test the PETSc BiCG solver
+
+
+#include "../tests.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);
+
+ {
+ 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
--- /dev/null
+//---------------------------- trilinos_solver_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_05.cc ---------------------------
+
+// test the PETSc GMRES solver
+
+
+#include "../tests.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_05/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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::SolverGMRES solver(control);
+ TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers11SolverGMRESE
+DEAL::Starting value 7.750
+DEAL::Convergence step 48 value 0.0009841
+DEAL::Solver stopped after 48 iterations
--- /dev/null
+//---------------------------- trilinos_solver_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_06.cc ---------------------------
+
+// test the PETSc Bicgstab solver
+
+
+#include "../tests.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_06/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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::SolverBicgstab solver(control);
+ TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers14SolverBicgstabE
+DEAL::Starting value 7.750
+DEAL::Convergence step 33 value 0.0005745
+DEAL::Solver stopped after 33 iterations
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers14SolverBicgstabE
+DEAL::Starting value 7.750
+DEAL::Convergence step 33 value 0.0005777
+DEAL::Solver stopped after 33 iterations
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers14SolverBicgstabE
+DEAL::Starting value 7.750
+DEAL::Convergence step 33 value 0.0005766
+DEAL::Solver stopped after 33 iterations
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers14SolverBicgstabE
+DEAL::Starting value 7.750
+DEAL::Convergence step 33 value 0.0005777
+DEAL::Solver stopped after 33 iterations
--- /dev/null
+//---------------------------- trilinos_solver_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_07.cc ---------------------------
+
+// test the PETSc CGS solver
+
+
+#include "../tests.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_07/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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::SolverCGS solver(control);
+ TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers9SolverCGSE
+DEAL::Starting value 7.750
+DEAL::Convergence step 40 value 0.0007519
+DEAL::Solver stopped after 40 iterations
--- /dev/null
+//---------------------------- trilinos_solver_08.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_08.cc ---------------------------
+
+// test the PETSc TFQMR solver
+
+
+#include "../tests.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_08/output");
+ logfile.precision(4);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ {
+ 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::SolverTFQMR solver(control);
+ TrilinosWrappers::PreconditionJacobi preconditioner(A);
+ check_solve (solver, A,u,f, preconditioner);
+ }
+}
+
--- /dev/null
+
+DEAL::Size 32 Unknowns 961
+DEAL::Solver type: N6dealii13PETScWrappers11SolverTFQMRE
+DEAL::Starting value 7.750
+DEAL::Convergence step 40 value 0.0008680
+DEAL::Solver stopped after 40 iterations
--- /dev/null
+//---------------------------- trilinos_solver_09.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_solver_09.cc ---------------------------
+
+// test the PETSc TCQMR solver
+//
+// note that this test fails on PETSc 2.1.6 due to a bug in the TCQMR
+// implementation. this is reported and should be fixed soonish
+
+
+
+#include "../tests.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);
+
+ {
+ 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 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 PETSc CR solver
+
+
+#include "../tests.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);
+
+ {
+ 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 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 PETSc LSQR solver
+
+
+#include "../tests.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);
+
+ {
+ 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
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_iterator_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_iterator_01.cc ---------------------------
+
+
+// test TrilinosWrappers::MatrixBase::const_iterator
+
+#include "../tests.h"
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ TrilinosWrappers::SparseMatrix m(5,5,5);
+ m.set (0,0,1);
+ m.set (1,1,2);
+ m.set (1,2,3);
+ m.compress ();
+ TrilinosWrappers::SparseMatrix::const_iterator i = m.begin();
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+ ++i;
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+ i++;
+ deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("sparse_matrix_iterator_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ test ();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::0 0 1.00000
+DEAL::1 1 2.00000
+DEAL::1 2 3.00000
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_01.cc ---------------------------
+
+
+// check SparseMatrix::vmult
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.vmult (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j;
+ Assert (w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_02.cc ---------------------------
+
+
+// check SparseMatrix::Tvmult
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.Tvmult (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (j+2*i)*j;
+ Assert (w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_03.cc ---------------------------
+
+
+// check SparseMatrix::vmult_add
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.vmult_add (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j;
+ Assert (w(i) == i+result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_03/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_04.cc ---------------------------
+
+
+// check SparseMatrix::Tvmult_add
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // w:=Mv
+ m.Tvmult_add (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (j+2*i)*j;
+ Assert (w(i) == i+result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_04/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_05.cc ---------------------------
+
+
+// check SparseMatrix::matrix_scalar_product
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // <w,Mv>
+ const PetscScalar s = m.matrix_scalar_product (w,v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+ Assert (w(i) == i+1, ExcInternalError());
+ }
+
+ PetscScalar result = 0;
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j*(i+1);
+
+ Assert (s == result, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_05/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_06.cc ---------------------------
+
+
+// check SparseMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ m.compress ();
+ v.compress ();
+
+ // <w,Mv>
+ const PetscScalar s = m.matrix_norm_square (v);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (v(i) == i, ExcInternalError());
+
+ PetscScalar result = 0;
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ result += (i+2*j)*j*i;
+
+ Assert (s == result, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_06/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (30);
+ test (v);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_sparse_matrix_vector_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_sparse_matrix_vector_07.cc ---------------------------
+
+
+// check SparseMatrix::matrix_norm_square
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <lac/trilinos_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w,
+ TrilinosWrappers::Vector &x)
+{
+ TrilinosWrappers::SparseMatrix m(v.size(),v.size(),v.size());
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ m.set (i,j, i+2*j);
+
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1;
+ }
+
+ m.compress ();
+ v.compress ();
+ w.compress ();
+
+ // x=w-Mv
+ const double s = m.residual (x, v, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (v(i) == i, ExcInternalError());
+ Assert (w(i) == i+1, ExcInternalError());
+
+ double result = i+1;
+ for (unsigned int j=0; j<m.m(); ++j)
+ result -= (i+2*j)*j;
+
+ Assert (x(i) == result, ExcInternalError());
+ }
+
+ Assert (s == x.l2_norm(), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("sparse_matrix_vector_07/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ TrilinosWrappers::Vector x (100);
+ test (v,w,x);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_assign_01.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_assign_01.cc ---------------------------
+
+
+// when calling TrilinosWrappers::Vector::operator() (), the return type is a
+// reference object, not a reference to the actual element. this leads to the
+// funny situation that an assignment like v2(i)=v1(i) isn't really what it
+// looks like: it tries to copy the reference objects, not the values they
+// point to, as one would expect
+//
+// this was fixed 2004-04-05, and this test checks that it works
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set the first vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ // copy elements by reference
+ for (unsigned int i=0; i<v.size(); ++i)
+ w(i) = v(i);
+
+ // check that they're equal
+ Assert (v==w, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_assign_01/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_assign_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_assign_02.cc ---------------------------
+
+
+// this is equivalent to the trilinos_vector_assign_02 test, except that we use
+// operator+= instead of operator=. Now, this does not present a problem,
+// since the compiler does not automatically generate a version of this
+// operator, but simply performs the conversion to PetscScalar, i.e. the
+// argument to the user-defined operator+=. This is not exciting, but since I
+// wrote the test to make sure it works this way, let's keep it then...
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set the first vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ // add elements by reference
+ for (unsigned int i=0; i<v.size(); ++i)
+ w(i) += v(i);
+
+ // check that they're equal
+ Assert (v==w, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_assign_02/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_equality_1.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_equality_1.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator==(TrilinosWrappers::Vector) for vectors that are not
+// equal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ Assert (!(v==w), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_equality_1/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_equality_2.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_equality_2.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator==(TrilinosWrappers::Vector) for vectors that are
+// equal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+ // but then copy elements and make sure the
+ // vectors are actually equal
+ v = w;
+ Assert (v==w, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_equality_2/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_equality_3.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_equality_3.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator!=(TrilinosWrappers::Vector) for vectors that are not
+// equal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ Assert (v!=w, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_equality_3/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+//---------------------------- trilinos_vector_equality_4.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// 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
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- trilinos_vector_equality_4.cc ---------------------------
+
+
+// check TrilinosWrappers::Vector::operator!=(TrilinosWrappers::Vector) for vectors that are
+// equal
+
+#include "../tests.h"
+#include <lac/trilinos_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (TrilinosWrappers::Vector &v,
+ TrilinosWrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+ // but then copy elements and make sure the
+ // vectors are actually equal
+ v = w;
+ Assert (! (v!=w), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("vector_equality_4/output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ try
+ {
+ {
+ TrilinosWrappers::Vector v (100);
+ TrilinosWrappers::Vector w (100);
+ test (v,w);
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK