From a7722d51d58bc51fd4848866d10735e18ab89a18 Mon Sep 17 00:00:00 2001 From: turcksin Date: Tue, 12 Mar 2013 00:59:19 +0000 Subject: [PATCH] Fix some errors in the TrilinosWrapper. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@28861 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/types.h | 1 + deal.II/include/deal.II/lac/sparse_direct.h | 5 ++++ .../lac/trilinos_block_sparse_matrix.h | 5 ---- .../deal.II/lac/trilinos_sparse_matrix.h | 23 +++++++++------- .../deal.II/lac/trilinos_sparsity_pattern.h | 23 +++++++++++----- deal.II/include/deal.II/lac/trilinos_vector.h | 2 +- .../deal.II/lac/trilinos_vector_base.h | 23 ++++++++-------- .../lac/trilinos_block_sparse_matrix.cc | 2 +- deal.II/source/lac/trilinos_precondition.cc | 2 +- deal.II/source/lac/trilinos_sparse_matrix.cc | 12 +++++---- .../source/lac/trilinos_sparsity_pattern.cc | 27 ++++++++++--------- 11 files changed, 72 insertions(+), 53 deletions(-) diff --git a/deal.II/include/deal.II/base/types.h b/deal.II/include/deal.II/base/types.h index 6cf53a8440..544178d172 100644 --- a/deal.II/include/deal.II/base/types.h +++ b/deal.II/include/deal.II/base/types.h @@ -145,6 +145,7 @@ namespace TrilinosWrapper { namespace types { +#define DEAL_II_EPETRA_NO_64BIT_GLOBAL_INDICES #ifdef DEAL_II_EPETRA_NO_64BIT_GLOBAL_INDICES /** * Declare type of integer used in the Epetra package of Trilinos. diff --git a/deal.II/include/deal.II/lac/sparse_direct.h b/deal.II/include/deal.II/lac/sparse_direct.h index 14adaac7ce..c4566f101b 100644 --- a/deal.II/include/deal.II/lac/sparse_direct.h +++ b/deal.II/include/deal.II/lac/sparse_direct.h @@ -1071,6 +1071,11 @@ private: class SparseDirectUMFPACK : public Subscriptor { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Dummy class needed for the * usual initalization interface diff --git a/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h index 181a471786..5f295a977a 100644 --- a/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_block_sparse_matrix.h @@ -70,11 +70,6 @@ namespace TrilinosWrappers class BlockSparseMatrix : public BlockMatrixBase { public: - /** - * Declare the type for container size. - */ - typedef types::global_dof_index size_type; - /** * Typedef the base class for simpler * access to its own typedefs. diff --git a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h index 0910b7b1b3..176910aa14 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -511,6 +511,11 @@ namespace TrilinosWrappers class SparseMatrix : public Subscriptor { public: + /** + * Declare the type for container size. + */ + typedef types::global_dof_index size_type; + /** * A structure that describes * some of the traits of this @@ -2651,7 +2656,7 @@ namespace TrilinosWrappers inline - size_type + AccessorBase::size_type AccessorBase::row() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -2660,7 +2665,7 @@ namespace TrilinosWrappers inline - size_type + AccessorBase::size_type AccessorBase::column() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -2669,7 +2674,7 @@ namespace TrilinosWrappers inline - size_type + AccessorBase::size_type AccessorBase::index() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -3179,7 +3184,7 @@ namespace TrilinosWrappers TrilinosWrapper::types::int_type *col_index_ptr; TrilinosScalar const *col_value_ptr; - TrilinosWrapper::types::int_typeint_type n_columns; + TrilinosWrapper::types::int_type n_columns; // If we don't elide zeros, the pointers // are already available... @@ -3516,7 +3521,7 @@ namespace TrilinosWrappers // called frequently and do only involve // a call to some Trilinos function. inline - size_type + SparseMatrix::size_type SparseMatrix::m () const { return matrix -> NumGlobalRows(); @@ -3525,7 +3530,7 @@ namespace TrilinosWrappers inline - size_type + SparseMatrix::size_type SparseMatrix::n () const { return matrix -> NumGlobalCols(); @@ -3534,7 +3539,7 @@ namespace TrilinosWrappers inline - size_type + SparseMatrix::size_type SparseMatrix::local_size () const { return matrix -> NumMyRows(); @@ -3543,7 +3548,7 @@ namespace TrilinosWrappers inline - std::pair + std::pair SparseMatrix::local_range () const { size_type begin, end; @@ -3556,7 +3561,7 @@ namespace TrilinosWrappers inline - size_type + SparseMatrix::size_type SparseMatrix::n_nonzero_elements () const { return matrix->NumGlobalNonzeros(); diff --git a/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h b/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h index 09d601890c..99b547e927 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h @@ -183,6 +183,10 @@ namespace TrilinosWrappers class Iterator { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; /** * Constructor. Create an @@ -240,7 +244,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcInvalidIndexWithinRow, - size_type, syze_type, + size_type, size_type, << "Attempt to access element " << arg2 << " of row " << arg1 << " which doesn't have that many elements."); @@ -282,6 +286,11 @@ namespace TrilinosWrappers { public: + /** + * Declare type for container size. + */ + typedef types::global_dof_index size_type; + /** * Declare a typedef for the * iterator class. @@ -572,7 +581,7 @@ namespace TrilinosWrappers */ SparsityPattern (const Epetra_Map &row_parallel_partitioning, const Epetra_Map &col_parallel_partitioning, - const std::vector &n_entries_per_row); + const std::vector &n_entries_per_row); /** * Reinitialization function for @@ -623,7 +632,7 @@ namespace TrilinosWrappers */ void reinit (const Epetra_Map ¶llel_partitioning, - const std::vector &n_entries_per_row); + const std::vector &n_entries_per_row); /** * This reinit function is similar to @@ -1399,7 +1408,7 @@ namespace TrilinosWrappers inline - size_type + Accessor::size_type Accessor::row() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1409,7 +1418,7 @@ namespace TrilinosWrappers inline - size_type + Accessor::size_type Accessor::column() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1419,7 +1428,7 @@ namespace TrilinosWrappers inline - size_type + Accessor::size_type Accessor::index() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1809,7 +1818,7 @@ namespace TrilinosWrappers SparsityPattern::reinit (const IndexSet &row_parallel_partitioning, const IndexSet &col_parallel_partitioning, const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) { Epetra_Map row_map = row_parallel_partitioning.make_trilinos_map (communicator, false); diff --git a/deal.II/include/deal.II/lac/trilinos_vector.h b/deal.II/include/deal.II/lac/trilinos_vector.h index bb3964e697..7ce20c91a2 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_vector.h @@ -520,7 +520,7 @@ namespace TrilinosWrappers // Need to copy out values, since the // deal.II might not use doubles, so // that a direct access is not possible. - for (Trilinos::Wrapper::Types::int_type i=0; iMap().LID(static_cast(row)); + const TrilinosWrapper::types::int_type local_row = vector->Map().LID(static_cast(row)); if (local_row == -1) { const int ierr = vector->ReplaceGlobalValues (1, @@ -1449,7 +1450,7 @@ namespace TrilinosWrappers for (size_type i=0; iMap().LID(static_cast(row)); + const TrilinosWrapper::types::int_type local_row = vector->Map().LID(static_cast(row)); if (local_row == -1) { const int ierr = vector->SumIntoGlobalValues (1, @@ -1466,7 +1467,7 @@ namespace TrilinosWrappers inline - size_type + VectorBase::size_type VectorBase::size () const { return (size_type) (vector->Map().MaxAllGID() + 1 - @@ -1476,7 +1477,7 @@ namespace TrilinosWrappers inline - size_type + VectorBase::size_type VectorBase::local_size () const { return (size_type) vector->Map().NumMyElements(); @@ -1485,7 +1486,7 @@ namespace TrilinosWrappers inline - std::pair + std::pair VectorBase::local_range () const { TrilinosWrapper::types::int_type begin, end; diff --git a/deal.II/source/lac/trilinos_block_sparse_matrix.cc b/deal.II/source/lac/trilinos_block_sparse_matrix.cc index ec72a3f67f..7cd896a529 100644 --- a/deal.II/source/lac/trilinos_block_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_block_sparse_matrix.cc @@ -260,7 +260,7 @@ namespace TrilinosWrappers - size_type + BlockSparseMatrix::size_type BlockSparseMatrix::n_nonzero_elements () const { size_type n_nonzero = 0; diff --git a/deal.II/source/lac/trilinos_precondition.cc b/deal.II/source/lac/trilinos_precondition.cc index a0bdc3d167..b7c046c054 100644 --- a/deal.II/source/lac/trilinos_precondition.cc +++ b/deal.II/source/lac/trilinos_precondition.cc @@ -695,7 +695,7 @@ namespace TrilinosWrappers - size_type + PreconditionAMG::size_type PreconditionAMG::memory_consumption() const { unsigned int memory = sizeof(this); diff --git a/deal.II/source/lac/trilinos_sparse_matrix.cc b/deal.II/source/lac/trilinos_sparse_matrix.cc index 25e6f8665f..d92784cee3 100644 --- a/deal.II/source/lac/trilinos_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_sparse_matrix.cc @@ -378,8 +378,8 @@ namespace TrilinosWrappers } void copy_row (const dealii::SparsityPattern &csp, - const size_int row, - std::vector &row_indices) + const size_type row, + std::vector &row_indices) { dealii::SparsityPattern::iterator col_num = csp.begin (row); for (size_type col=0; col_num != csp.end (row); ++col_num, ++col) @@ -937,7 +937,7 @@ namespace TrilinosWrappers - size_type + SparseMatrix::size_type SparseMatrix::row_length (const size_type row) const { Assert (row < m(), ExcInternalError()); @@ -964,6 +964,8 @@ namespace TrilinosWrappers namespace internals { + typedef types::global_dof_index size_type; + void perform_mmult (const SparseMatrix &inputleft, const SparseMatrix &inputright, SparseMatrix &result, @@ -1059,7 +1061,7 @@ namespace TrilinosWrappers inputleft.trilinos_sparsity_pattern().ExtractMyRowView(i, num_entries, indices); Assert (num_entries >= 0, ExcInternalError()); - const sizretype GID = inputleft.row_partitioner().GID(i); + const size_type GID = inputleft.row_partitioner().GID(i); for (TrilinosWrapper::types::int_type j=0; j &n_entries_per_row) + const std::vector &n_entries_per_row) { // release memory before reallocation graph.reset (); @@ -277,6 +277,7 @@ namespace TrilinosWrappers { namespace { + typedef types::global_dof_index size_type; // distinguish between compressed sparsity types that define row_begin() // and SparsityPattern that uses begin() as iterator type template @@ -324,7 +325,7 @@ namespace TrilinosWrappers const size_type first_row = input_row_map.MinMyGID(), last_row = input_row_map.MaxMyGID()+1; - std::vector n_entries_per_row(last_row - first_row); + std::vector n_entries_per_row(last_row - first_row); for (size_type row=first_row; rowExtractMyRowView(i, num_entries, indices); for (size_type j=0; j<(size_type)num_entries; ++j) { - if (static_cast(std::abs(static_cast(i-indices[j]))) > local_b) + if (static_cast(std::abs(static_cast(i-indices[j]))) > local_b) local_b = std::abs(static_cast(i-indices[j])); } } @@ -540,7 +541,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::n_rows () const { const TrilinosWrapper::types::int_type n_rows = graph -> NumGlobalRows(); @@ -549,7 +550,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::n_cols () const { TrilinosWrapper::types::int_type n_cols; @@ -563,7 +564,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::local_size () const { TrilinosWrapper::types::int_type n_rows = graph -> NumMyRows(); @@ -573,7 +574,7 @@ namespace TrilinosWrappers - std::pair + std::pair SparsityPattern::local_range () const { size_type begin, end; @@ -585,7 +586,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::n_nonzero_elements () const { TrilinosWrapper::types::int_type nnz = graph->NumGlobalEntries(); @@ -595,7 +596,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::max_entries_per_row () const { TrilinosWrapper::types::int_type nnz = graph->MaxNumIndices(); @@ -605,7 +606,7 @@ namespace TrilinosWrappers - size_type + SparsityPattern::size_type SparsityPattern::row_length (const size_type row) const { Assert (row < n_rows(), ExcInternalError()); @@ -669,7 +670,7 @@ namespace TrilinosWrappers Assert (graph->Filled() == true, ExcInternalError()); for (size_type row=0; rowExtractMyRowView (row, num_entries, indices); @@ -680,7 +681,7 @@ namespace TrilinosWrappers // x-y, that is we have to exchange // the order of output out << indices[graph->GRID(static_cast(j))] - << " " << -static_cast(row) + << " " << -static_cast(row) << std::endl; } -- 2.39.5