From 991a7b57f6b83998f7fce2be1db821383242fc47 Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Sun, 6 Mar 2016 18:20:23 +0100 Subject: [PATCH] fix petsc_complex test --- tests/petsc_complex/00.cc | 25 +++---------------- tests/petsc_complex/00.output | 1 - tests/petsc_complex/01.cc | 5 ++-- tests/petsc_complex/02.cc | 3 +-- tests/petsc_complex/04.cc | 3 +-- tests/petsc_complex/05.cc | 5 ++-- tests/petsc_complex/06.cc | 5 ++-- tests/petsc_complex/07.cc | 5 ++-- tests/petsc_complex/08.cc | 5 ++-- tests/petsc_complex/09.cc | 5 ++-- tests/petsc_complex/10.cc | 5 ++-- tests/petsc_complex/11.cc | 5 ++-- tests/petsc_complex/12.cc | 5 ++-- tests/petsc_complex/13.cc | 3 +-- tests/petsc_complex/17.cc | 5 ++-- tests/petsc_complex/18.cc | 5 ++-- tests/petsc_complex/19.cc | 5 ++-- tests/petsc_complex/20.cc | 7 +++--- tests/petsc_complex/element_access_00.cc | 9 +++---- tests/petsc_complex/element_access_01.cc | 9 +++---- tests/petsc_complex/element_access_02.cc | 9 +++---- tests/petsc_complex/element_access_03.cc | 9 +++---- tests/petsc_complex/fe_get_function_values.cc | 13 +++++----- .../parallel_sparse_matrix_01.cc | 19 +++++++------- tests/petsc_complex/solver_real_01.cc | 9 +++---- tests/petsc_complex/solver_real_02.cc | 9 +++---- tests/petsc_complex/solver_real_03.cc | 9 +++---- tests/petsc_complex/solver_real_03_mf.cc | 9 +++---- tests/petsc_complex/solver_real_04.cc | 9 +++---- tests/petsc_complex/sparse_matrix_01.cc | 7 +++--- tests/petsc_complex/vector_02.cc | 7 +++--- tests/petsc_complex/vector_assign_01.cc | 3 +-- tests/petsc_complex/vector_assign_02.cc | 3 +-- tests/petsc_complex/vector_equality_1.cc | 3 +-- tests/petsc_complex/vector_equality_2.cc | 3 +-- tests/petsc_complex/vector_print.cc | 3 +-- tests/petsc_complex/vector_wrap_01.cc | 3 +-- 37 files changed, 92 insertions(+), 155 deletions(-) diff --git a/tests/petsc_complex/00.cc b/tests/petsc_complex/00.cc index f00cdb481b..17781e5d09 100644 --- a/tests/petsc_complex/00.cc +++ b/tests/petsc_complex/00.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 00.cc$ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -14,21 +13,6 @@ // // --------------------------------------------------------------------- - -// PETSc includes: We would like to do this cleanly -// -#include -#include -#include -// -// though a horrible warning message -// -// warning: imaginary constants are a GCC extension [enabled by default] -// -// appears. This seems to be related to the direct useage of -// PetscScalar in accordance with gcc.gnu.org bug 7263. - -// deal.II includes #include "../tests.h" #include @@ -159,16 +143,16 @@ void init_petsc_complex () deallog << "OK" << std::endl; } + int main (int argc, char **argv) { std::ofstream logfile ("output"); dealii::deallog.attach (logfile); - dealii::deallog.depth_console (0); deallog.threshold_double(1.e-10); try { - PetscInitialize (&argc, &argv, (char *) 0, (char *) 0); + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1); { // initialisation (zero and nonzero) init_petsc_complex (); @@ -182,7 +166,6 @@ int main (int argc, char **argv) divide_petsc_complex_by_a_number (); multiply_petsc_complex_by_a_number (); } - PetscFinalize (); } catch (std::exception &exc) @@ -210,8 +193,6 @@ int main (int argc, char **argv) return 1; } - logfile << std::endl; - return 0; } diff --git a/tests/petsc_complex/00.output b/tests/petsc_complex/00.output index 8fc890b1ae..a7cb78f5fb 100644 --- a/tests/petsc_complex/00.output +++ b/tests/petsc_complex/00.output @@ -11,4 +11,3 @@ DEAL::Check PetscScalar division DEAL::OK DEAL::Check PetscScalar multiply DEAL::OK - diff --git a/tests/petsc_complex/01.cc b/tests/petsc_complex/01.cc index 4dbcfec56c..61a78e9054 100644 --- a/tests/petsc_complex/01.cc +++ b/tests/petsc_complex/01.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 01.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -31,7 +30,7 @@ void test (PETScWrappers::SparseMatrix &m) if ((i+2*j+1) % 3 == 0) m.set (i,j, std::complex (0.,i*j*.5+.5)); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // then make sure we retrieve the same ones for (unsigned int i=0; i (0.,i*j*.5+.5)); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // compare against the exact value of the l1-norm (max col-sum) deallog << m.l1_norm() << std::endl; diff --git a/tests/petsc_complex/07.cc b/tests/petsc_complex/07.cc index 3a1cafb1a9..75b106ebd4 100644 --- a/tests/petsc_complex/07.cc +++ b/tests/petsc_complex/07.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 07.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -32,7 +31,7 @@ void test (PETScWrappers::SparseMatrix &m) if ((i+2*j+1) % 3 == 0) m.set (i,j, std::complex (0.,i*j*.5+.5)); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // compare against the exact value of the linfty-norm (max row-sum). deallog << m.linfty_norm() << std::endl; diff --git a/tests/petsc_complex/08.cc b/tests/petsc_complex/08.cc index e34a00a744..3ab73e9b46 100644 --- a/tests/petsc_complex/08.cc +++ b/tests/petsc_complex/08.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 08.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -37,7 +36,7 @@ void test (PETScWrappers::SparseMatrix &m) } norm = std::sqrt(norm); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // compare against the exact value of the l2-norm (max row-sum) deallog << m.frobenius_norm() << std::endl; diff --git a/tests/petsc_complex/09.cc b/tests/petsc_complex/09.cc index e04c644cc6..b4fb084a66 100644 --- a/tests/petsc_complex/09.cc +++ b/tests/petsc_complex/09.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 09.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -32,7 +31,7 @@ void test (PETScWrappers::SparseMatrix &m) if ((i+2*j+1) % 3 == 0) m.set (i,j, std::complex (i*j*.5+.5,i*j*.5)); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // then multiply everything by 1.25 m *= 1.25; diff --git a/tests/petsc_complex/10.cc b/tests/petsc_complex/10.cc index 5d27dd617a..2e22c87c11 100644 --- a/tests/petsc_complex/10.cc +++ b/tests/petsc_complex/10.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $id: 10.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -31,7 +30,7 @@ void test (PETScWrappers::SparseMatrix &m) if ((i+2*j+1) % 3 == 0) m.set (i,j, std::complex (0.,i*j*.5+.5)); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // then divide everything by 4/3 and make sure we retrieve the // values we expect diff --git a/tests/petsc_complex/11.cc b/tests/petsc_complex/11.cc index 2b332d9d5b..07181f7bbe 100644 --- a/tests/petsc_complex/11.cc +++ b/tests/petsc_complex/11.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 11.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -30,7 +29,7 @@ void test (PETScWrappers::Vector &v) for (unsigned int k=0; k (k,.5*k); - v.compress (VectorOperation::add); + v.compress (VectorOperation::insert); Assert (v.size() == 100, ExcInternalError()); diff --git a/tests/petsc_complex/12.cc b/tests/petsc_complex/12.cc index 608fa3baee..d2ab3d5f4d 100644 --- a/tests/petsc_complex/12.cc +++ b/tests/petsc_complex/12.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: 12.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -39,7 +38,7 @@ void test (PETScWrappers::Vector &v) pattern[k] = true; } - v.compress (VectorOperation::add); + v.compress (VectorOperation::insert); // check that they are ok, and this time all of them for (unsigned int k=0; k (k,v.size()-k); - v.compress (VectorOperation::add); + v.compress (VectorOperation::insert); // check that is what we get by casting PetscScalar to std::real() // and std::imag() @@ -67,7 +65,7 @@ int main (int argc, char **argv) try { - PetscInitialize (&argc, &argv, (char *) 0, (char *) 0); + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); { PETScWrappers::Vector v (5); test_vector (v); @@ -75,7 +73,6 @@ int main (int argc, char **argv) deallog << "vector:" << std::endl; v.print (logfile); } - PetscFinalize (); } diff --git a/tests/petsc_complex/element_access_01.cc b/tests/petsc_complex/element_access_01.cc index 31b0a4f940..69c28b990b 100644 --- a/tests/petsc_complex/element_access_01.cc +++ b/tests/petsc_complex/element_access_01.cc @@ -1,8 +1,6 @@ - // --------------------------------------------------------------------- -// $Id: // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -42,7 +40,7 @@ void test_matrix (PETScWrappers::SparseMatrix &m) m.set (k,l, std::complex (el_r,el_i)); } - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); for (unsigned int k=0; kl) m.set (k,l, PetscScalar (k+l,-1.*(k+l))); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); // check the matrix is correctly filled for (unsigned int k=0; kis_locally_owned()) { fe_values.reinit (cell); - cell_mass_matrix = PetscScalar(0); + cell_mass_matrix = PetscScalar(); for (unsigned int q_point=0; q_point(); - -} \ No newline at end of file + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + { + test<2>(); + } +} diff --git a/tests/petsc_complex/solver_real_01.cc b/tests/petsc_complex/solver_real_01.cc index 9c045ca958..c5126c999e 100644 --- a/tests/petsc_complex/solver_real_01.cc +++ b/tests/petsc_complex/solver_real_01.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: solver_real_01.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -85,9 +84,9 @@ int main(int argc, char **argv) PETScWrappers::Vector f(dim); PETScWrappers::Vector u(dim); f = 1.; - A.compress (VectorOperation::add); - f.compress (VectorOperation::add); - u.compress (VectorOperation::add); + A.compress (VectorOperation::insert); + f.compress (VectorOperation::insert); + u.compress (VectorOperation::insert); PETScWrappers::SolverRichardson solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); diff --git a/tests/petsc_complex/solver_real_02.cc b/tests/petsc_complex/solver_real_02.cc index 28f4e0484b..8d952c9285 100644 --- a/tests/petsc_complex/solver_real_02.cc +++ b/tests/petsc_complex/solver_real_02.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: solver_real_02.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -83,9 +82,9 @@ int main(int argc, char **argv) PETScWrappers::Vector f(dim); PETScWrappers::Vector u(dim); f = 1.; - A.compress (VectorOperation::add); - f.compress (VectorOperation::add); - u.compress (VectorOperation::add); + A.compress (VectorOperation::insert); + f.compress (VectorOperation::insert); + u.compress (VectorOperation::insert); PETScWrappers::SolverChebychev solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); diff --git a/tests/petsc_complex/solver_real_03.cc b/tests/petsc_complex/solver_real_03.cc index 0b69601e07..cc5406ac71 100644 --- a/tests/petsc_complex/solver_real_03.cc +++ b/tests/petsc_complex/solver_real_03.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: solver_real_03.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -82,9 +81,9 @@ int main(int argc, char **argv) PETScWrappers::Vector f(dim); PETScWrappers::Vector u(dim); f = 1.; - A.compress (VectorOperation::add); - f.compress (VectorOperation::add); - u.compress (VectorOperation::add); + A.compress (VectorOperation::insert); + f.compress (VectorOperation::insert); + u.compress (VectorOperation::insert); PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); diff --git a/tests/petsc_complex/solver_real_03_mf.cc b/tests/petsc_complex/solver_real_03_mf.cc index b3197e70ea..1bea00f78f 100644 --- a/tests/petsc_complex/solver_real_03_mf.cc +++ b/tests/petsc_complex/solver_real_03_mf.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: solver_03_mf.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -92,9 +91,9 @@ int main(int argc, char **argv) PETScWrappers::Vector f(dim); PETScWrappers::Vector u(dim); f = 1.; - A.compress (VectorOperation::add); - f.compress (VectorOperation::add); - u.compress (VectorOperation::add); + A.compress (VectorOperation::insert); + f.compress (VectorOperation::insert); + u.compress (VectorOperation::insert); PETScWrappers::SolverCG solver(control); PETScWrappers::PreconditionNone preconditioner(A); diff --git a/tests/petsc_complex/solver_real_04.cc b/tests/petsc_complex/solver_real_04.cc index 9ace49088c..eed403f0b8 100644 --- a/tests/petsc_complex/solver_real_04.cc +++ b/tests/petsc_complex/solver_real_04.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id: solver_real_04.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -82,9 +81,9 @@ int main(int argc, char **argv) PETScWrappers::Vector f(dim); PETScWrappers::Vector u(dim); f = 1.; - A.compress (VectorOperation::add); - f.compress (VectorOperation::add); - u.compress (VectorOperation::add); + A.compress (VectorOperation::insert); + f.compress (VectorOperation::insert); + u.compress (VectorOperation::insert); PETScWrappers::SolverBiCG solver(control); PETScWrappers::PreconditionJacobi preconditioner(A); diff --git a/tests/petsc_complex/sparse_matrix_01.cc b/tests/petsc_complex/sparse_matrix_01.cc index 7d7a749b1c..46f783f61d 100644 --- a/tests/petsc_complex/sparse_matrix_01.cc +++ b/tests/petsc_complex/sparse_matrix_01.cc @@ -1,7 +1,6 @@ // --------------------------------------------------------------------- -// $Id sparse_matrix_01.cc $ // -// Copyright (C) 2013 by the deal.II authors +// Copyright (C) 2004 - 2016 by the deal.II authors // // This file is part of the deal.II library. // @@ -33,13 +32,13 @@ void test () for (unsigned int l=0; l<=k; ++l) m.set (k,l, k+2*l); - m.compress (VectorOperation::add); + m.compress (VectorOperation::insert); PETScWrappers::SparseMatrix m2(s,s,s); m2.set(0,1,5.0); for (unsigned int k=0; k