From fc9e6872d3efc793cf50ad5743dd7dfc4894a668 Mon Sep 17 00:00:00 2001 From: ESeNonFossiIo Date: Tue, 12 Apr 2016 22:11:33 +0200 Subject: [PATCH] test for PETSc Vector reinit helper --- .../lac/petsc_parallel_sparse_matrix.h | 26 ++++----- include/deal.II/lac/petsc_sparse_matrix.h | 18 +++--- source/lac/petsc_parallel_sparse_matrix.cc | 20 +++---- source/lac/petsc_sparse_matrix.cc | 10 ++-- tests/lac/linear_operator_09.cc | 56 +++++++++++++++++++ ...ator_09.with_cxx11=on.with_petsc=on.output | 2 + 6 files changed, 95 insertions(+), 37 deletions(-) create mode 100644 tests/lac/linear_operator_09.cc create mode 100644 tests/lac/linear_operator_09.with_cxx11=on.with_petsc=on.output diff --git a/include/deal.II/lac/petsc_parallel_sparse_matrix.h b/include/deal.II/lac/petsc_parallel_sparse_matrix.h index fd5905527f..6d17876da6 100644 --- a/include/deal.II/lac/petsc_parallel_sparse_matrix.h +++ b/include/deal.II/lac/petsc_parallel_sparse_matrix.h @@ -379,19 +379,19 @@ namespace PETScWrappers PetscScalar matrix_scalar_product (const Vector &u, const Vector &v) const; - /** - * Return the partitioning of the domain space of this matrix, i.e., the - * partitioning of the vectors this matrix has to be multiplied with. - */ - IndexSet locally_owned_domain_indices() const; - - /** - * Return the partitioning of the range space of this matrix, i.e., the - * partitioning of the vectors that are result from matrix-vector - * products. - */ - IndexSet locally_owned_range_indices() const; - + /** + * Return the partitioning of the domain space of this matrix, i.e., the + * partitioning of the vectors this matrix has to be multiplied with. + */ + IndexSet locally_owned_domain_indices() const; + + /** + * Return the partitioning of the range space of this matrix, i.e., the + * partitioning of the vectors that are result from matrix-vector + * products. + */ + IndexSet locally_owned_range_indices() const; + private: /** diff --git a/include/deal.II/lac/petsc_sparse_matrix.h b/include/deal.II/lac/petsc_sparse_matrix.h index 4c6dbc037c..41a1481f71 100644 --- a/include/deal.II/lac/petsc_sparse_matrix.h +++ b/include/deal.II/lac/petsc_sparse_matrix.h @@ -225,15 +225,15 @@ namespace PETScWrappers PetscScalar matrix_scalar_product (const VectorBase &u, const VectorBase &v) const; - /** - * Return the number of rows of this matrix. - */ - size_t m() const; - - /** - * Return the number of coloumns of this matrix. - */ - size_t n() const; + /** + * Return the number of rows of this matrix. + */ + size_t m() const; + + /** + * Return the number of coloumns of this matrix. + */ + size_t n() const; private: diff --git a/source/lac/petsc_parallel_sparse_matrix.cc b/source/lac/petsc_parallel_sparse_matrix.cc index c2837beb54..043a8f5e00 100644 --- a/source/lac/petsc_parallel_sparse_matrix.cc +++ b/source/lac/petsc_parallel_sparse_matrix.cc @@ -895,16 +895,16 @@ namespace PETScWrappers { PetscInt n_rows, n_cols, min, max; PetscErrorCode ierr; - IS* rows = nullptr; - IS* cols = nullptr; - + IS *rows = nullptr; + IS *cols = nullptr; + ierr = MatGetSize (matrix, &n_rows, &n_cols); ierr = MatGetOwnershipIS(matrix, rows, cols); ierr = ISGetMinMax(*rows, &min, &max); IndexSet locally_owned_domain_indices(n_rows); locally_owned_domain_indices.add_range(min, max); - + return locally_owned_domain_indices; } @@ -913,19 +913,19 @@ namespace PETScWrappers { PetscInt n_rows, n_cols, min, max; PetscErrorCode ierr; - IS* rows = nullptr; - IS* cols = nullptr; - + IS *rows = nullptr; + IS *cols = nullptr; + ierr = MatGetSize (matrix, &n_rows, &n_cols); ierr = MatGetOwnershipIS(matrix, rows, cols); ierr = ISGetMinMax(*cols, &min, &max); - + IndexSet locally_owned_range_indices(n_cols); locally_owned_range_indices.add_range(min, max); - + return locally_owned_range_indices; } - + } } diff --git a/source/lac/petsc_sparse_matrix.cc b/source/lac/petsc_sparse_matrix.cc index d0b4297824..ec0eaa8471 100644 --- a/source/lac/petsc_sparse_matrix.cc +++ b/source/lac/petsc_sparse_matrix.cc @@ -312,8 +312,8 @@ namespace PETScWrappers SparseMatrix::m () const { PetscInt m,n; - PetscErrorCode ierr = MatGetSize(matrix, &m, &n); - + PetscErrorCode ierr = MatGetSize(matrix, &m, &n); + return m; } @@ -321,11 +321,11 @@ namespace PETScWrappers SparseMatrix::n () const { PetscInt m,n; - PetscErrorCode ierr = MatGetSize(matrix, &m, &n); - + PetscErrorCode ierr = MatGetSize(matrix, &m, &n); + return n; } - + // Explicit instantiations // template diff --git a/tests/lac/linear_operator_09.cc b/tests/lac/linear_operator_09.cc new file mode 100644 index 0000000000..41c48cc1a7 --- /dev/null +++ b/tests/lac/linear_operator_09.cc @@ -0,0 +1,56 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 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. +// +// --------------------------------------------------------------------- + +// Test that it is possible to instantiate a LinearOperator object for all +// different kinds of Trilinos matrices and vectors +// TODO: A bit more tests... + +#include "../tests.h" + + +#include + +#include +#include + +#include +#include + +using namespace dealii; + +int main(int argc, char *argv[]) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, 1); + + initlog(); + deallog << std::setprecision(10); + + { + PETScWrappers::SparseMatrix a; + auto op_a = linear_operator(a); + } + + { + PETScWrappers::MPI::SparseMatrix a; + auto op_a = linear_operator(a); + } + + + deallog << "OK" << std::endl; + + return 0; +} + + diff --git a/tests/lac/linear_operator_09.with_cxx11=on.with_petsc=on.output b/tests/lac/linear_operator_09.with_cxx11=on.with_petsc=on.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/lac/linear_operator_09.with_cxx11=on.with_petsc=on.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5