From: ESeNonFossiIo Date: Tue, 12 Apr 2016 20:11:33 +0000 (+0200) Subject: test for PETSc Vector reinit helper X-Git-Tag: v8.5.0-rc1~1104^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc9e6872d3efc793cf50ad5743dd7dfc4894a668;p=dealii.git test for PETSc Vector reinit helper --- 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