// ---------------------------------------------------------------------
-// $Id:
+// $Id: 00.cc$
//
// Copyright (C) 2013 by the deal.II authors
//
// PetscSclar=complex. They check that std::complex<double> and
// PetscScalar complex are compatible without explicitly casting.
//
-// These tests look archaic - they are the original tests used by the
-// authors to figure out how PetscScalar complex works...
+// These tests look archaic - they are the original tests used to
+// figure out how PetscScalar complex works...
// Multiply a PETSc complex number by a complex number.
void multiply_petsc_complex_by_a_number ()
deallog << "OK" << std::endl;
}
-
// Divide a PETSc complex number by a real number.
void divide_petsc_complex_by_a_number ()
{
deallog << "OK" << std::endl;
}
-
// Initialize a PETSc complex number directly only, check he is
// initialised to 0+0i.
void init_petsc_complex ()
{
PetscInitialize (&argc, &argv, (char*) 0, (char*) 0);
{
- // check initialisation (zero and nonzero)
+ // initialisation (zero and nonzero)
init_petsc_complex ();
make_petsc_complex ();
- // check initialisation from std::complex (and vice versa)
+ // initialisation from std::complex (and vice versa)
make_petsc_complex_from_std_complex ();
make_std_complex_from_petsc_complex ();
- // Check some operators
+ // some operators
divide_petsc_complex_by_a_number ();
multiply_petsc_complex_by_a_number ();
}
PetscFinalize ();
}
-
catch (std::exception &exc)
{
std::cerr << std::endl << std::endl
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 01.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <iostream>
-void test_real (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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) == std::complex<double> (i*j*.5+.5,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (i*j*.5+.5,0.), ExcInternalError());
- }
- else
- {
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- }
-
- deallog << "OK" << std::endl;
-}
-
-void test_complex (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Complex test" << std::endl;
-
// 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, std::complex<double> (0.,i*j*.5+.5));
-
+
m.compress (VectorOperation::add);
-
+
// 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)
Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
-
+
deallog << "OK" << std::endl;
}
deallog.attach(logfile);
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
-
+
try
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m (5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 02.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// ---------------------------------------------------------------------
-
// check setting elements in a petsc matrix using
// PETScWrappers::SparseMatrix::add()
+
#include "../tests.h"
#include <deal.II/lac/petsc_sparse_matrix.h>
#include <fstream>
#include <iostream>
-void test_real (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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) == std::complex<double> (i*j*.5+.5,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (i*j*.5+.5,0.), ExcInternalError());
- }
- else
- {
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- }
-
- deallog << "OK" << std::endl;
-}
-
-
-void test_complex (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Complex test" << std::endl;
-
// 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, std::complex<double> (0.,i*j*.5+.5));
-
+
m.compress (VectorOperation::add);
-
+
// 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)
Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
-
+
deallog << "OK" << std::endl;
}
-
int main (int argc,char **argv)
{
std::ofstream logfile("output");
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $Id: 04.cc 30045 2013-07-18 19:18:00Z maier $
+// $Id: 04.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// ---------------------------------------------------------------------
-
// check querying matrix sizes
#include "../tests.h"
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 05.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-
// check querying the number of nonzero elements in
// PETScWrappers::SparseMatrix
#include <iostream>
-void test_real (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- deallog << m.n_nonzero_elements() << std::endl;
- Assert (m.n_nonzero_elements() == counter,
- ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-
-void test_complex (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Complex test" << std::endl;
-
// first set a few entries. count how many entries we have
unsigned int counter = 0;
for (unsigned int i=0; i<m.m(); ++i)
}
m.compress (VectorOperation::add);
-
+
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("output");
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
PETScWrappers::SparseMatrix m (5,5,3);
- test_real (m);
-
- PETScWrappers::SparseMatrix n (5,5,3);
- test_complex (n);
+ test (m);
- // this last bit is unnecessarry fun...
- deallog << "Compare real-complex test" << std::endl;
- Assert (m.n_nonzero_elements() == n.n_nonzero_elements(),
- ExcInternalError());
deallog << "OK" << std::endl;
}
// ---------------------------------------------------------------------
-// $Id: 06.cc 30045 2013-07-18 19:18:00Z maier $
+// $Id: 06.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// ---------------------------------------------------------------------
-
// check PETScWrappers::SparseMatrix::l1_norm
#include "../tests.h"
#include <iostream>
-void test_real (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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;
-}
-
-
-void test_complex (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Complex test" << std::endl;
-
// 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)
}
-
int main (int argc,char **argv)
{
std::ofstream logfile("output");
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 07.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <iostream>
-void test_real (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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;
-}
-
-void test_complex (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Complex test" << std::endl;
-
// 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, std::complex<double> (0.,i*j*.5+.5));
-
+
m.compress (VectorOperation::add);
-
+
// 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("output");
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 08.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <iostream>
-
-void test_real (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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;
-}
-
-void test_complex (PETScWrappers::SparseMatrix &m)
+void test (PETScWrappers::SparseMatrix &m)
{
- deallog << "Complex test" << std::endl;
-
// first set a few entries. count how many entries we have
PetscScalar norm = 0;
for (unsigned int i=0; i<m.m(); ++i)
norm += (i*j*.5+.5)*(i*j*.5+.5);
}
norm = std::sqrt(norm);
-
+
m.compress (VectorOperation::add);
-
+
// 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;
}
deallog.attach(logfile);
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
-
+
try
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
-
}
catch (std::exception &exc)
{
// ---------------------------------------------------------------------
-// $Id: 09.cc 30045 2013-07-18 19:18:00Z maier $
+// $Id: 09.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
#include <iostream>
-
-void test_real (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Real test" << std::endl;
-
- // 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)
- {
- // put like this, ie. just adding real numbers, imaginary
- // entries are automagically zero
- m.set (i,j, i*j*.5+.5);
- }
-
- m.compress (VectorOperation::add);
-
- // then multiply everything by 1.25
- m *= 1.25;
-
- // and make sure we retrieve the values we expect
- 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) == std::complex<double> ((i*j*.5+.5)*1.25,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,0.), ExcInternalError());
- }
- else
- {
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- }
-
- deallog << "OK" << std::endl;
-}
-
void test_complex (PETScWrappers::SparseMatrix &m)
{
- deallog << "Complex test" << std::endl;
-
// 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)
- {
- // put like this, matrix enteries had better be imaginary
- m.set (i,j, std::complex<double> (i*j*.5+.5,i*j*.5));
- }
-
+ m.set (i,j, std::complex<double> (i*j*.5+.5,i*j*.5));
+
m.compress (VectorOperation::add);
-
+
// then multiply everything by 1.25
m *= 1.25;
Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
-
+
deallog << "OK" << std::endl;
}
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $id:
+// $id: 10.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
-void test_real (PETScWrappers::SparseMatrix &m)
-{
- deallog << "Real test" << std::endl;
-
- // 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 (VectorOperation::add);
-
- // 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) == std::complex<double> ((i*j*.5+.5)/4*3, 0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> ((i*j*.5+.5)/4*3, 0.), ExcInternalError());
- }
- else
- {
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- }
-
- deallog << "OK" << std::endl;
-}
-
-
void test_complex (PETScWrappers::SparseMatrix &m)
{
- deallog << "Complex test" << std::endl;
-
// 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, std::complex<double> (0.,i*j*.5+.5));
-
+
m.compress (VectorOperation::add);
-
+
// 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) == std::complex<double> (0.,0.), ExcInternalError());
Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
-
+
deallog << "OK" << std::endl;
}
deallog.attach(logfile);
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
-
+
try
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::SparseMatrix m;
-
- m.reinit (5,5,3);
- test_real (m);
-
- m.reinit (5,5,3);
- test_complex (m);
+ PETScWrappers::SparseMatrix m(5,5,3);
+ test (m);
}
}
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 11.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <iostream>
-void test_real (PETScWrappers::Vector &v)
+void test (PETScWrappers::Vector &v)
{
- deallog << "Real test" << std::endl;
-
- // set only certain elements of the vector
- for (unsigned int k=0; k<v.size(); k+=1+k)
- v(k) = k;
-
- v.compress (VectorOperation::add);
-
- Assert (v.size() == 100, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-void test_complex (PETScWrappers::Vector &v)
-{
- deallog << "Complex test" << std::endl;
-
// set only certain elements of the vector
for (unsigned int k=0; k<v.size(); k+=1+k)
v(k) = std::complex<double> (k,.5*k);
-
+
v.compress (VectorOperation::add);
-
+
Assert (v.size() == 100, ExcInternalError());
-
+
deallog << "OK" << std::endl;
}
-
int main (int argc,char **argv)
{
std::ofstream logfile("output");
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::Vector v;
-
- v.reinit (100);
- test_real (v);
-
- v.reinit (100);
- test_complex (v);
+ PETScWrappers::Vector v(100);
+ test (v);
}
-
}
catch (std::exception &exc)
{
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 12.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <vector>
-void test_real (PETScWrappers::Vector &v)
-{
- deallog << "Real test" << std::endl;
-
- // 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 k=0; k<v.size(); k+=1+k)
- {
- v(k) = k;
- pattern[k] = true;
- }
-
- v.compress (VectorOperation::add);
- // check that they are ok, and this time all of them
- //
- // Note the use of a copy constructor to "el". This is done here
- // because, at the time of writing, we don't have a method to expand
- // the macro PetscXXXPart (v(i)). This should be fixed by the next
- // test. Let's leave it as it is for this one... ;-)
- for (unsigned int k=0; k<v.size(); ++k)
- {
- const PetscScalar el = v(k);
- Assert ( ( (pattern[k] == true) && (PetscRealPart(el) == k) && (PetscImaginaryPart(el) == 0.) )
- ||
- ( (pattern[k] == false) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == 0.)),
- ExcInternalError());
- }
-
- deallog << "OK" << std::endl;
-}
-
-
-void test_complex (PETScWrappers::Vector &v)
+void test (PETScWrappers::Vector &v)
{
deallog << "Complex test" << std::endl;
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
{
- PETScWrappers::Vector v;
-
- v.reinit (100);
- test_real (v);
-
- v.reinit (100);
- test_complex (v);
+ PETScWrappers::Vector v(100);
+ test (v);
}
-
}
catch (std::exception &exc)
{
// ---------------------------------------------------------------------
-// $Id:
+// $Id: 13.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-// $Id: 17.cc
+// $Id: 17.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
}
-
int main (int argc,char **argv)
{
std::ofstream logfile("output");
PETScWrappers::Vector v (100);
test (v);
}
-
}
catch (std::exception &exc)
{
// ---------------------------------------------------------------------
-// $Id: 18.cc 30045 2013-07-18 19:18:00Z maier $
+// $Id: 18.cc $
//
-// Copyright (C) 2004 - 2013 by the deal.II authors
+// Copyright (C) 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
PETScWrappers::Vector v (100);
test (v);
}
-
}
catch (std::exception &exc)
{
// ---------------------------------------------------------------------
-// $Id: 19.cc
+// $Id: 19.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
+++ /dev/null
-Some (if not most) of these tests were ported from the petsc
-directory. They fall into three categories:
-
-(*) Ported - Reason: Check a similar real-number functionality with
-complex numbers. In this case various modifications are made to
-facilitate two-dimensional numbers; eg sd::complex<double> and
-PetscScalar.
-
-(*) Cloned - Reason: Check the correct (expected) behaviour is
-obtained for petsc-scalar=complex is obtained as was for
-petsc-scalar=real. In this case the .cc file is (almost) identical to
-the original and the expected output (cmp/generic) is copied from the
-original without modification.
-
-(*) New - Reason: Obvious.
\ No newline at end of file
// ---------------------------------------------------------------------
-// $Id: solver_real_01.cc
+// $Id: solver_real_01.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
PETScWrappers::PreconditionJacobi preconditioner(A);
check_solve (solver, A,u,f, preconditioner);
}
-
}
// ---------------------------------------------------------------------
-// $Id: solver_real_02.cc
+// $Id: solver_real_02.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-// $Id: solver_real_03.cc
+// $Id: solver_real_03.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-// $Id: solver_03_mf.cc
+// $Id: solver_03_mf.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// into this directory and
// play with it, but, by
// using *that* file
- // directly is itself a test
- // of syntax compatibility
+ // directly is instead
+ // represents a test of
+ // syntax compatibility
// between petsc-scalar=real
- // and petsc-scalar=complex.
+ // and assigning real
+ // numbers to a possibly
+ // complex matrix where
+ // petsc-scalar=complex.
#include <cmath>
#include <fstream>
#include <iostream>
// ---------------------------------------------------------------------
-// $Id: solver_real_04.cc
+// $Id: solver_real_04.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-// $Id sparse_matrix_01.cc
+// $Id sparse_matrix_01.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-
// check SparseMatrix::add(other, factor)
#include "../tests.h"
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
- test ();
+ try
+ {
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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
-// ---------------------------------------------------------------------
-// $Id sparse_matrix_01.cc
-//
-// Copyright (C) 2013 by the deal.II authors
-//
-// This file is part of the deal.II library.
-//
-// The deal.II library is free software; you can use it, redistribute
-// it, and/or modify it under the terms of the GNU Lesser General
-// Public License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// The full text of the license can be found in the file LICENSE at
-// the top level of the deal.II distribution.
-//
-// ---------------------------------------------------------------------
-
-
-
-// check SparseMatrix::add(other, factor)
-
-// This is in general the same as sparse_matrix_02.cc, but uses
-// integer input to complex numbers. Since it was done, make a note of
-// a generic failure / annoyance
-
-#include "../tests.h"
-#include <deal.II/lac/petsc_vector.h>
-#include <deal.II/lac/petsc_sparse_matrix.h>
-#include <fstream>
-#include <iostream>
-#include <vector>
-
-
-void test ()
-{
- const unsigned int s = 10;
- PETScWrappers::SparseMatrix m(s,s,s);
- for (unsigned int k=0; k<m.m(); ++k)
- for (unsigned int l=0; l<=k; ++l)
- m.set (k,l, k+2*l);
-
- m.compress (VectorOperation::add);
-
- PETScWrappers::SparseMatrix m2(s,s,s);
- m2.set(0,1,5.0);
- for (unsigned int k=0; k<m2.m(); ++k)
- {
- // This fails
- // m2.set(k,k,PetscScalar(k,-k));
- // This is ok
- m2.set(k,k,PetscScalar(k,-1.0*k));
- }
- m2.compress(VectorOperation::add);
-
- // we now print the matrix m, it is all real. Then print after
- // adding m2 which is complex, and then subtract m2 again to get the
- // original matrix back.
-
- deallog << "before: " << m(0,1) << std::endl;
- for (unsigned int k=0; k<s; ++k)
- deallog << m(k,k) << " ";
- deallog << std::endl;
-
- m.add(m2,1.0);
-
- deallog << "after: " << m(0,1) << std::endl;
- for (unsigned int k=0; k<s; ++k)
- deallog << m(k,k) << " ";
- deallog << std::endl;
-
- m.add(m2,-1.0);
-
- deallog << "back to original: " << m(0,1) << std::endl;
- for (unsigned int k=0; k<s; ++k)
- deallog << m(k,k) << " ";
- deallog << std::endl;
-
- deallog << "OK" << std::endl;
-}
-
-
-
-int main (int argc, char **argv)
-{
- std::ofstream logfile("output");
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
- test ();
-
-}
// ---------------------------------------------------------------------
-// $Id sparse_matrix_01.cc
+// $Id vector_02.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
-// check Vector, make a note of a generic failure / annoyance
+// check assignment of elements in Vector
#include "../tests.h"
#include <deal.II/lac/petsc_vector.h>
deallog.depth_console(0);
deallog.threshold_double(1.e-10);
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
- test ();
+ try
+ {
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ 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;
+ };
}
// ---------------------------------------------------------------------
-// $Id: vector_assign_01.cc
+// $Id: vector_assign_01.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
-// when calling PETScWrappers::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
-
+// See notes in petsc/vector_assign_01.cc
#include "../tests.h"
#include <deal.II/lac/petsc_vector.h>
#include <fstream>
// ---------------------------------------------------------------------
-// $Id: vector_assign_02.cc
+// $Id: vector_assign_02.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <vector>
-void test_real (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
+void test (PETScWrappers::Vector &v,
+ PETScWrappers::Vector &w)
{
- deallog << "Real test" << std::endl;
-
- // set the first vector
- for (unsigned int k=0; k<v.size(); ++k)
- v(k) = k;
-
- // add elements by reference
- for (unsigned int k=0; k<v.size(); ++k)
- w(k) += v(k);
-
- // check that they're equal
- Assert (v==w, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-
-void test_complex (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
-{
- deallog << "Complex test" << std::endl;
-
// set the first vector
for (unsigned int k=0; k<v.size(); ++k)
v(k) = PetscScalar (k,k*k);
{
PETScWrappers::Vector v (20);
PETScWrappers::Vector w (20);
- test_real (v,w);
-
- v.reinit (20);
- w.reinit (20);
- test_complex (v,w);
+ test (v,w);
- // We are really only interested in checking that assignment
- // of the complex part is correct.
+ // Some output
deallog << "Complex vectors: " << std::endl;
deallog << "v: " << std::flush;
v.print (logfile, 0, false, true);
// ---------------------------------------------------------------------
-// $Id: vector_equality_1.cc
+// $Id: vector_equality_1.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <vector>
-void test_real (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
+void test (PETScWrappers::Vector &v,
+ PETScWrappers::Vector &w)
{
- deallog << "Real test" << std::endl;
-
- // set only certain elements of each vector
- for (unsigned int k=0; k<v.size(); ++k)
- {
- v(k) = k;
- if (k%3 == 0)
- w(k) = k+1.;
- }
-
- Assert (!(v==w), ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-void test_complex (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
-{
- deallog << "Complex test" << std::endl;
-
// set only certain elements of each vector
for (unsigned int k=0; k<v.size(); ++k)
{
{
PETScWrappers::Vector v (20);
PETScWrappers::Vector w (20);
- test_real (v,w);
-
- // Just incase, *read* these vectors are correct.
- deallog << "Real vectors: " << std::endl;
- v.print (logfile, 0, false, true);
- w.print (logfile, 0, false, true);
- deallog << "OK" << std::endl;
-
- v.reinit (20);
- w.reinit (20);
- test_complex (v,w);
+ test (v,w);
- // Just incase, *read* these vectors are correct.
+ // SOme output
deallog << "Complex vectors: " << std::endl;
v.print (logfile, 0, false, true);
w.print (logfile, 0, false, true);
// ---------------------------------------------------------------------
-// $Id: vector_equality_2.cc
+// $Id: vector_equality_2.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <vector>
-void test_real (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
-{
- // set only certain elements of each vector where, on the "master
- // vector", some elements are complex and the other is real.
- for (unsigned int k=0; k<v.size(); ++k)
- {
- v(k) = k;
- if (k%3 == 0)
- w(k) = std::complex<double> (k+1.,k+1);
- }
-
- // then copy elements and make sure the vectors are actually equal
- v = w;
- Assert (v==w, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-void test_complex (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
+void test (PETScWrappers::Vector &v,
+ PETScWrappers::Vector &w)
{
// set only certain elements of each vector
for (unsigned int k=0; k<v.size(); ++k)
if (k%3 == 0)
w(k) = std::complex<double> (k+1.,k+1);
}
-
+
// then copy elements and make sure the vectors are actually equal
v = w;
Assert (v==w, ExcInternalError());
-
+
deallog << "OK" << std::endl;
}
+++ /dev/null
-// ---------------------------------------------------------------------
-// $Id: vector_equality_5.cc
-//
-// Copyright (C) 2013 by the deal.II authors
-//
-// This file is part of the deal.II library.
-//
-// The deal.II library is free software; you can use it, redistribute
-// it, and/or modify it under the terms of the GNU Lesser General
-// Public License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-// The full text of the license can be found in the file LICENSE at
-// the top level of the deal.II distribution.
-//
-// ---------------------------------------------------------------------
-
-
-
-// check PETScWrappers::Vector::operator=(PETScWrappers::Vector) for vectors that are
-// equal and initialised from PETScWrappers::Vector (PETScWrappers::Vector)
-
-#include "../tests.h"
-#include <deal.II/lac/petsc_vector.h>
-#include <fstream>
-#include <iostream>
-#include <vector>
-
-
-void test_real (PETScWrappers::Vector &v)
-{
- deallog << "Real test" << std::endl;
-
- // set only certain elements of vector
- for (unsigned int k=0; k<v.size(); ++k)
- if (k%3 == 0)
- v(k) = k;
-
- PETScWrappers::Vector w (v);
-
- Assert (v==w, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-
-void test_complex (PETScWrappers::Vector &v)
-{
- deallog << "Complex test" << std::endl;
-
- // set only certain elements of vector
- for (unsigned int k=0; k<v.size(); ++k)
- if (k%3 == 0)
- v(k) = std::complex<double> (k,k+1.);
-
- PETScWrappers::Vector w (v);
-
- Assert (v==w, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-
-
-int main (int argc, char **argv)
-{
- std::ofstream logfile("output");
- deallog.attach(logfile);
- deallog.depth_console(0);
- deallog.threshold_double(1.e-10);
-
- try
- {
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
- {
- PETScWrappers::Vector v (100);
- test_real (v);
-
- v.reinit (100);
- test_complex (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;
- };
-}
// ---------------------------------------------------------------------
-// $Id: vector_print.cc
+// $Id: vector_print.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
// ---------------------------------------------------------------------
-// $Id: vector_wrap_01.cc
+// $Id: vector_wrap_01.cc $
//
// Copyright (C) 2013 by the deal.II authors
//
#include <vector>
-void test_01 (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
+void test (PETScWrappers::Vector &v,
+ PETScWrappers::Vector &w)
{
// set the first vector
for (unsigned int k=0; k<v.size(); ++k)
}
-void test_02 (PETScWrappers::Vector &v,
- PETScWrappers::Vector &w)
-{
- // copy
- v=w;
-
- // check that they're still equal
- Assert (v==w, ExcInternalError());
-
- deallog << "OK" << std::endl;
-}
-
-
-
int main (int argc, char **argv)
{
std::ofstream logfile("output");
{
PETScWrappers::Vector v (vpetsc);
PETScWrappers::Vector w (100);
- test_01 (v,w);
-
- w.reinit (100);
- test_01 (v,w);
+ test (v,w);
}
#if DEAL_II_PETSC_VERSION_LT(3,2,0)