From: kronbichler Date: Thu, 6 Nov 2008 12:41:33 +0000 (+0000) Subject: Added a templated call to PETSc matrix initialization with SparsityPattern to allow... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb2797428df0f00a2937f0a705f934c1dce07aa0;p=dealii-svn.git Added a templated call to PETSc matrix initialization with SparsityPattern to allow different types of SparsityPatterns. git-svn-id: https://svn.dealii.org/trunk@17486 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h index 01f40197ea..6d81587c7f 100644 --- a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h @@ -18,7 +18,6 @@ #include #include -#include #include @@ -265,8 +264,9 @@ namespace PETScWrappers * get memory allocation right from * the start. */ + template SparseMatrix (const MPI_Comm &communicator, - const CompressedSparsityPattern &sparsity_pattern, + const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, @@ -356,8 +356,9 @@ namespace PETScWrappers * get memory allocation right from * the start. */ - void reinit (const MPI_Comm &communicator, - const CompressedSparsityPattern &sparsity_pattern, + template + void reinit (const MPI_Comm &communicator, + const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, @@ -416,7 +417,8 @@ namespace PETScWrappers /** * Same as previous functions. */ - void do_reinit (const CompressedSparsityPattern &sparsity_pattern, + template + void do_reinit (const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, diff --git a/deal.II/lac/include/lac/petsc_sparse_matrix.h b/deal.II/lac/include/lac/petsc_sparse_matrix.h index 7a7de77feb..54a3978001 100644 --- a/deal.II/lac/include/lac/petsc_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_sparse_matrix.h @@ -17,7 +17,6 @@ #include #include #include -#include #include @@ -182,8 +181,9 @@ namespace PETScWrappers * flag has a default value equal to * @p false. */ - SparseMatrix (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations = false); + template + SparseMatrix (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations = false); /** * This operator assigns a scalar to @@ -277,8 +277,9 @@ namespace PETScWrappers * flag has a default value equal to * @p false. */ - void reinit (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations = false); + template + void reinit (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations = false); /** * Return a reference to the MPI @@ -314,8 +315,9 @@ namespace PETScWrappers /** * Same as previous function. */ - void do_reinit (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations); + template + void do_reinit (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations); }; } diff --git a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc index 9ab68aec80..44c65a3d01 100644 --- a/deal.II/lac/source/petsc_parallel_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_parallel_sparse_matrix.cc @@ -15,6 +15,10 @@ #include #include +#include +#include +#include + #ifdef DEAL_II_USE_PETSC DEAL_II_NAMESPACE_OPEN @@ -70,9 +74,10 @@ namespace PETScWrappers + template SparseMatrix:: SparseMatrix (const MPI_Comm &communicator, - const CompressedSparsityPattern &sparsity_pattern, + const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, @@ -139,10 +144,11 @@ namespace PETScWrappers + template void SparseMatrix:: reinit (const MPI_Comm &communicator, - const CompressedSparsityPattern &sparsity_pattern, + const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, @@ -248,9 +254,10 @@ namespace PETScWrappers + template void SparseMatrix:: - do_reinit (const CompressedSparsityPattern &sparsity_pattern, + do_reinit (const SparsityType &sparsity_pattern, const std::vector &local_rows_per_process, const std::vector &local_columns_per_process, const unsigned int this_process, @@ -445,6 +452,73 @@ namespace PETScWrappers //TODO: We should use the appropriate option with MatSetOption here indicating that we do not intend to add any further matrix entries. Maybe this would accelerate some things as well } } + + + + // explicit instantiations + // + template + SparseMatrix::SparseMatrix (const MPI_Comm &, + const SparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + template + SparseMatrix::SparseMatrix (const MPI_Comm &, + const CompressedSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + template + SparseMatrix::SparseMatrix (const MPI_Comm &, + const CompressedSimpleSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + + template void + SparseMatrix::reinit (const MPI_Comm &, + const SparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + template void + SparseMatrix::reinit (const MPI_Comm &, + const CompressedSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + template void + SparseMatrix::reinit (const MPI_Comm &, + const CompressedSimpleSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int, + const bool); + + template void + SparseMatrix::do_reinit (const SparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int , + const bool); + template void + SparseMatrix::do_reinit (const CompressedSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int , + const bool); + template void + SparseMatrix::do_reinit (const CompressedSimpleSparsityPattern &, + const std::vector &, + const std::vector &, + const unsigned int , + const bool); } } diff --git a/deal.II/lac/source/petsc_sparse_matrix.cc b/deal.II/lac/source/petsc_sparse_matrix.cc index ec84471f02..95ca455d4d 100644 --- a/deal.II/lac/source/petsc_sparse_matrix.cc +++ b/deal.II/lac/source/petsc_sparse_matrix.cc @@ -15,6 +15,10 @@ #include #include +#include +#include +#include + #ifdef DEAL_II_USE_PETSC DEAL_II_NAMESPACE_OPEN @@ -52,9 +56,10 @@ namespace PETScWrappers + template SparseMatrix:: - SparseMatrix (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations) + SparseMatrix (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations) { do_reinit (sparsity_pattern, preset_nonzero_locations); } @@ -101,10 +106,12 @@ namespace PETScWrappers } + + template void SparseMatrix:: - reinit (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations) + reinit (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations) { // get rid of old matrix and generate a // new one @@ -185,9 +192,10 @@ namespace PETScWrappers + template void - SparseMatrix::do_reinit (const CompressedSparsityPattern &sparsity_pattern, - const bool preset_nonzero_locations) + SparseMatrix::do_reinit (const SparsityType &sparsity_pattern, + const bool preset_nonzero_locations) { std::vector row_lengths (sparsity_pattern.n_rows()); for (unsigned int i=0; i