From: turcksin Date: Wed, 13 Feb 2013 17:49:36 +0000 (+0000) Subject: Replace unsigned int by size_type in lac and replace int by int_type in Trilinos... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25481484d6f8c92c1b340aca41e91a69ef08f467;p=dealii-svn.git Replace unsigned int by size_type in lac and replace int by int_type in Trilinos wrappers to allow the use of long long with Trilinos 11. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@28388 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/files b/deal.II/files index e3600a10a8..782de750ca 100644 --- a/deal.II/files +++ b/deal.II/files @@ -157,20 +157,20 @@ source/lac/sparse_mic.cc source/lac/sparse_vanka.cc source/lac/sparsity_pattern.cc source/lac/sparsity_tools.cc -source/lac/swappable_vector.cc -source/lac/timestep_control.cc -source/lac/tridiagonal_matrix.cc -source/lac/trilinos_block_sparse_matrix.cc -source/lac/trilinos_block_vector.cc -source/lac/trilinos_precondition.cc -source/lac/trilinos_solver.cc -source/lac/trilinos_sparse_matrix.cc -source/lac/trilinos_sparsity_pattern.cc -source/lac/trilinos_vector_base.cc -source/lac/trilinos_vector.cc -source/lac/vector.cc -source/lac/vector_memory.cc -source/lac/vector_view.cc +BRUNO source/lac/swappable_vector.cc +BRUNO source/lac/timestep_control.cc +BRUNO source/lac/tridiagonal_matrix.cc +BRUNO source/lac/trilinos_block_sparse_matrix.cc +BRUNO source/lac/trilinos_block_vector.cc +BRUNO source/lac/trilinos_precondition.cc +BRUNO source/lac/trilinos_solver.cc +BRUNO source/lac/trilinos_sparse_matrix.cc +BRUNO source/lac/trilinos_sparsity_pattern.cc +BRUNO source/lac/trilinos_vector_base.cc +BRUNO source/lac/trilinos_vector.cc +BRUNO source/lac/vector.cc +BRUNO source/lac/vector_memory.cc +BRUNO source/lac/vector_view.cc source/multigrid/mg_base.cc source/multigrid/mg_dof_accessor.cc source/multigrid/mg_dof_handler.cc @@ -378,9 +378,9 @@ MARKUS include/deal.II/lac/compressed_simple_sparsity_pattern.h MARKUS include/deal.II/lac/compressed_sparsity_pattern.h WOLFGANG include/deal.II/lac/constraint_matrix.h WOLFGANG include/deal.II/lac/constraint_matrix.templates.h -include/deal.II/lac/eigen.h -include/deal.II/lac/exceptions.h -include/deal.II/lac/filtered_matrix.h +BRUNO include/deal.II/lac/eigen.h +BRUNO include/deal.II/lac/exceptions.h +BRUNO include/deal.II/lac/filtered_matrix.h include/deal.II/lac/full_matrix.h include/deal.II/lac/full_matrix.templates.h include/deal.II/lac/householder.h @@ -446,23 +446,23 @@ include/deal.II/lac/sparse_vanka.h include/deal.II/lac/sparse_vanka.templates.h include/deal.II/lac/sparsity_pattern.h include/deal.II/lac/sparsity_tools.h -include/deal.II/lac/swappable_vector.h -include/deal.II/lac/swappable_vector.templates.h -include/deal.II/lac/transpose_matrix.h -include/deal.II/lac/tridiagonal_matrix.h -include/deal.II/lac/trilinos_block_sparse_matrix.h -include/deal.II/lac/trilinos_block_vector.h -include/deal.II/lac/trilinos_parallel_block_vector.h -include/deal.II/lac/trilinos_precondition.h -include/deal.II/lac/trilinos_solver.h -include/deal.II/lac/trilinos_sparse_matrix.h -include/deal.II/lac/trilinos_sparsity_pattern.h -include/deal.II/lac/trilinos_vector_base.h -include/deal.II/lac/trilinos_vector.h -include/deal.II/lac/vector.h -include/deal.II/lac/vector_memory.h -include/deal.II/lac/vector.templates.h -include/deal.II/lac/vector_view.h +BRUNO include/deal.II/lac/swappable_vector.h +BRUNO include/deal.II/lac/swappable_vector.templates.h +BRUNO include/deal.II/lac/transpose_matrix.h +BRUNO include/deal.II/lac/tridiagonal_matrix.h +BRUNO include/deal.II/lac/trilinos_block_sparse_matrix.h +BRUNO include/deal.II/lac/trilinos_block_vector.h +BRUNO include/deal.II/lac/trilinos_parallel_block_vector.h +BRUNO include/deal.II/lac/trilinos_precondition.h +BRUNO include/deal.II/lac/trilinos_solver.h +BRUNO include/deal.II/lac/trilinos_sparse_matrix.h +BRUNO include/deal.II/lac/trilinos_sparsity_pattern.h +BRUNO include/deal.II/lac/trilinos_vector_base.h +BRUNO include/deal.II/lac/trilinos_vector.h +BRUNO include/deal.II/lac/vector.h +BRUNO include/deal.II/lac/vector_memory.h +BRUNO include/deal.II/lac/vector.templates.h +BRUNO include/deal.II/lac/vector_view.h KAINAN include/deal.II/matrix_free/dof_info.h KAINAN include/deal.II/matrix_free/dof_info.templates.h BRUNO include/deal.II/matrix_free/fe_evaluation.h diff --git a/deal.II/include/deal.II/lac/eigen.h b/deal.II/include/deal.II/lac/eigen.h index f0c0ef8f0e..4a1708fa93 100644 --- a/deal.II/include/deal.II/lac/eigen.h +++ b/deal.II/include/deal.II/lac/eigen.h @@ -50,6 +50,11 @@ template > class EigenPower : private Solver { public: + /** + * Declare type of container size. + */ + typedef std::size_t size_type; + /** * Standardized data struct to * pipe additional data to the @@ -270,7 +275,7 @@ EigenPower::solve (double &value, // do a little trick to compute the sign // with not too much effect of round-off errors. double entry = 0.; - unsigned int i = 0; + size_type i = 0; double thresh = length/x.size(); do { @@ -365,7 +370,7 @@ EigenInverse::solve (double &value, x.scale(1./length); // Main loop - for (unsigned int iter=0; conv==SolverControl::iterate; iter++) + for (size_type iter=0; conv==SolverControl::iterate; iter++) { solver.solve (A_s, y, x, prec); @@ -375,7 +380,7 @@ EigenInverse::solve (double &value, // do a little trick to compute the sign // with not too much effect of round-off errors. double entry = 0.; - unsigned int i = 0; + size_type i = 0; double thresh = length/x.size(); do { diff --git a/deal.II/include/deal.II/lac/filtered_matrix.h b/deal.II/include/deal.II/lac/filtered_matrix.h index 8a1ee43bf7..718c58e316 100644 --- a/deal.II/include/deal.II/lac/filtered_matrix.h +++ b/deal.II/include/deal.II/lac/filtered_matrix.h @@ -206,6 +206,11 @@ class FilteredMatrix : public Subscriptor public: class const_iterator; + /** + * Declare the type of container size. + */ + typedef std::size_t size_type; + /** * Accessor class for iterators */ @@ -218,7 +223,7 @@ public: * pointer is sufficient. */ Accessor (const FilteredMatrix *matrix, - const unsigned int index); + const size_type index); public: /** @@ -226,14 +231,14 @@ public: * represented by this * object. */ - unsigned int row() const; + size_type row() const; /** * Column number of the * element represented by * this object. */ - unsigned int column() const; + size_type column() const; /** * Value of the right hand @@ -255,7 +260,7 @@ public: /** * Current row number. */ - unsigned int index; + size_type index; /* * Make enclosing class a * friend. @@ -273,7 +278,7 @@ public: * Constructor. */ const_iterator(const FilteredMatrix *matrix, - const unsigned int index); + const size_type index); /** * Prefix increment. @@ -337,7 +342,7 @@ public: * freedom index and the value it * shall have. */ - typedef std::pair IndexValuePair; + typedef std::pair IndexValuePair; /** * @name Constructors and initialization @@ -416,7 +421,7 @@ public: * should have the value * v. */ - void add_constraint (const unsigned int i, const double v); + void add_constraint (const size_type i, const double v); /** * Add a list of constraints to @@ -655,7 +660,7 @@ template inline FilteredMatrix::Accessor::Accessor( const FilteredMatrix *matrix, - const unsigned int index) + const size_type index) : matrix(matrix), index(index) @@ -668,7 +673,7 @@ FilteredMatrix::Accessor::Accessor( template inline -unsigned int +size_type FilteredMatrix::Accessor::row() const { return matrix->constraints[index].first; @@ -678,7 +683,7 @@ FilteredMatrix::Accessor::row() const template inline -unsigned int +size_type FilteredMatrix::Accessor::column() const { return matrix->constraints[index].first; @@ -712,7 +717,7 @@ template inline FilteredMatrix::const_iterator::const_iterator( const FilteredMatrix *matrix, - const unsigned int index) + const size_type index) : accessor(matrix, index) {} @@ -860,7 +865,7 @@ FilteredMatrix::operator = (const FilteredMatrix &fm) template inline void -FilteredMatrix::add_constraint (const unsigned int index, const double value) +FilteredMatrix::add_constraint (const size_type index, const double value) { // add new constraint to end constraints.push_back(IndexValuePair(index, value)); @@ -875,7 +880,7 @@ void FilteredMatrix::add_constraints (const ConstraintList &new_constraints) { // add new constraints to end - const unsigned int old_size = constraints.size(); + const size_type old_size = constraints.size(); constraints.reserve (old_size + new_constraints.size()); constraints.insert (constraints.end(), new_constraints.begin(), diff --git a/deal.II/include/deal.II/lac/full_matrix.h b/deal.II/include/deal.II/lac/full_matrix.h index 6a2854ef91..f56ebf01cb 100644 --- a/deal.II/include/deal.II/lac/full_matrix.h +++ b/deal.II/include/deal.II/lac/full_matrix.h @@ -60,6 +60,11 @@ template class FullMatrix : public Table<2,number> { public: + /** + * Declare type of container size. + */ + typedef std::size_t size_type; + /** * Type of matrix entries. In analogy to * the STL container classes. @@ -104,22 +109,22 @@ public: * pointer is sufficient. */ Accessor (const FullMatrix *matrix, - const unsigned int row, - const unsigned int col); + const size_type row, + const size_type col); /** * Row number of the element * represented by this * object. */ - unsigned int row() const; + size_type row() const; /** * Column number of the * element represented by * this object. */ - unsigned int column() const; + size_type column() const; /** * Value of this matrix entry. @@ -135,7 +140,7 @@ public: /** * Current row number. */ - unsigned int a_row; + size_type a_row; /** * Current column number. @@ -159,8 +164,8 @@ public: * Constructor. */ const_iterator(const FullMatrix *matrix, - const unsigned int row, - const unsigned int col); + const size_type row, + const size_type col); /** * Prefix increment. @@ -237,15 +242,15 @@ public: * By default, no memory is * allocated. */ - explicit FullMatrix (const unsigned int n = 0); + explicit FullMatrix (const size_type n = 0); /** * Constructor. Initialize the * matrix as a rectangular * matrix. */ - FullMatrix (const unsigned int rows, - const unsigned int cols); + FullMatrix (const size_type rows, + const size_type cols); /** * Copy constructor. This @@ -274,8 +279,8 @@ public: * is arranged line by line. No * range checking is performed. */ - FullMatrix (const unsigned int rows, - const unsigned int cols, + FullMatrix (const size_type rows, + const size_type cols, const number *entries); /** @@ -391,12 +396,12 @@ public: template void copy_from (const Tensor<2,dim> &T, - const unsigned int src_r_i=0, - const unsigned int src_r_j=dim-1, - const unsigned int src_c_i=0, - const unsigned int src_c_j=dim-1, - const unsigned int dst_r=0, - const unsigned int dst_c=0); + const size_type src_r_i=0, + const size_type src_r_j=dim-1, + const size_type src_c_i=0, + const size_type src_c_j=dim-1, + const size_type dst_r=0, + const size_type dst_c=0); /** * Insert a submatrix (also @@ -414,12 +419,12 @@ public: template void copy_to(Tensor<2,dim> &T, - const unsigned int src_r_i=0, - const unsigned int src_r_j=dim-1, - const unsigned int src_c_i=0, - const unsigned int src_c_j=dim-1, - const unsigned int dst_r=0, - const unsigned int dst_c=0) const; + const size_type src_r_i=0, + const size_type src_r_j=dim-1, + const size_type src_c_i=0, + const size_type src_c_j=dim-1, + const size_type dst_r=0, + const size_type dst_c=0) const; /** * Copy a subset of the rows and columns of another matrix into the @@ -435,8 +440,8 @@ public: */ template void extract_submatrix_from (const MatrixType &matrix, - const std::vector &row_index_set, - const std::vector &column_index_set); + const std::vector &row_index_set, + const std::vector &column_index_set); /** * Copy the elements of the current matrix object into a specified @@ -452,8 +457,8 @@ public: */ template void - scatter_matrix_to (const std::vector &row_index_set, - const std::vector &column_index_set, + scatter_matrix_to (const std::vector &row_index_set, + const std::vector &column_index_set, MatrixType &matrix) const; /** @@ -476,10 +481,10 @@ public: */ template void fill (const FullMatrix &src, - const unsigned int dst_offset_i = 0, - const unsigned int dst_offset_j = 0, - const unsigned int src_offset_i = 0, - const unsigned int src_offset_j = 0); + const size_type dst_offset_i = 0, + const size_type dst_offset_j = 0, + const size_type src_offset_i = 0, + const size_type src_offset_j = 0); /** @@ -509,8 +514,8 @@ public: */ template void fill_permutation (const FullMatrix &src, - const std::vector &p_rows, - const std::vector &p_cols); + const std::vector &p_rows, + const std::vector &p_cols); /** * Set a particular entry of the matrix to a value. Thus, calling @@ -522,8 +527,8 @@ public: * @param j The columns index of the element to be set. * @param value The value to be written into the element. */ - void set (const unsigned int i, - const unsigned int j, + void set (const size_type i, + const size_type j, const number value); /** * @} @@ -551,14 +556,14 @@ public: * To remember: this matrix is an * m x n-matrix. */ - unsigned int m () const; + size_type m () const; /** * Number of columns of this matrix. * To remember: this matrix is an * m x n-matrix. */ - unsigned int n () const; + size_type n () const; /** * Return whether the matrix @@ -775,12 +780,12 @@ public: * STL-like iterator with the * first entry of row r. */ - const_iterator begin (const unsigned int r) const; + const_iterator begin (const size_type r) const; /** * Final iterator of row r. */ - const_iterator end (const unsigned int r) const; + const_iterator end (const size_type r) const; //@} ///@name Modifying operators @@ -874,10 +879,10 @@ public: template void add (const FullMatrix &src, const number factor, - const unsigned int dst_offset_i = 0, - const unsigned int dst_offset_j = 0, - const unsigned int src_offset_i = 0, - const unsigned int src_offset_j = 0); + const size_type dst_offset_i = 0, + const size_type dst_offset_j = 0, + const size_type src_offset_i = 0, + const size_type src_offset_j = 0); /** * Weighted addition of the @@ -915,17 +920,17 @@ public: template void Tadd (const FullMatrix &src, const number factor, - const unsigned int dst_offset_i = 0, - const unsigned int dst_offset_j = 0, - const unsigned int src_offset_i = 0, - const unsigned int src_offset_j = 0); + const size_type dst_offset_i = 0, + const size_type dst_offset_j = 0, + const size_type src_offset_i = 0, + const size_type src_offset_j = 0); /** * Add a single element at the * given position. */ - void add (const unsigned int row, - const unsigned int column, + void add (const size_type row, + const size_type column, const number value); /** @@ -945,9 +950,9 @@ public: * implementation. */ template - void add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, + void add (const size_type row, + const size_type n_cols, + const size_type *col_indices, const number2 *values, const bool elide_zero_values = true, const bool col_indices_are_sorted = false); @@ -957,51 +962,51 @@ public: * s*A(j,1...n). Simple * addition of rows of this */ - void add_row (const unsigned int i, - const number s, - const unsigned int j); + void add_row (const size_type i, + const number s, + const size_type j); /** * A(i,1...n) += s*A(j,1...n) + * t*A(k,1...n). Multiple * addition of rows of this. */ - void add_row (const unsigned int i, - const number s, const unsigned int j, - const number t, const unsigned int k); + void add_row (const size_type i, + const number s, const size_type j, + const number t, const size_type k); /** * A(1...n,i) += s*A(1...n,j). * Simple addition of columns of this. */ - void add_col (const unsigned int i, - const number s, - const unsigned int j); + void add_col (const size_type i, + const number s, + const size_type j); /** * A(1...n,i) += s*A(1...n,j) + * t*A(1...n,k). Multiple * addition of columns of this. */ - void add_col (const unsigned int i, - const number s, const unsigned int j, - const number t, const unsigned int k); + void add_col (const size_type i, + const number s, const size_type j, + const number t, const size_type k); /** * Swap A(i,1...n) <-> * A(j,1...n). Swap rows i * and j of this */ - void swap_row (const unsigned int i, - const unsigned int j); + void swap_row (const size_type i, + const size_type j); /** * Swap A(1...n,i) <-> * A(1...n,j). Swap columns * i and j of this */ - void swap_col (const unsigned int i, - const unsigned int j); + void swap_col (const size_type int i, + const size_type int j); /** * Add constant to diagonal @@ -1444,7 +1449,7 @@ public: * Exception */ DeclException3 (ExcInvalidDestination, - int, int, int, + size_type, size_type, size_type, << "Target region not in matrix: size in this direction=" << arg1 << ", size of new matrix=" << arg2 << ", offset=" << arg3); @@ -1471,7 +1476,7 @@ public: template inline -unsigned int +size_type FullMatrix::m() const { return this->n_rows(); @@ -1481,7 +1486,7 @@ FullMatrix::m() const template inline -unsigned int +size_type FullMatrix::n() const { return this->n_cols(); @@ -1547,17 +1552,17 @@ template inline void FullMatrix::extract_submatrix_from (const MatrixType &matrix, - const std::vector &row_index_set, - const std::vector &column_index_set) + const std::vector &row_index_set, + const std::vector &column_index_set) { AssertDimension(row_index_set.size(), this->n_rows()); AssertDimension(column_index_set.size(), this->n_cols()); - const unsigned int n_rows_submatrix = row_index_set.size(); - const unsigned int n_cols_submatrix = column_index_set.size(); + const size_type n_rows_submatrix = row_index_set.size(); + const size_type n_cols_submatrix = column_index_set.size(); - for (unsigned int sub_row = 0; sub_row < n_rows_submatrix; ++sub_row) - for (unsigned int sub_col = 0; sub_col < n_cols_submatrix; ++sub_col) + for (size_type sub_row = 0; sub_row < n_rows_submatrix; ++sub_row) + for (size_type sub_col = 0; sub_col < n_cols_submatrix; ++sub_col) (*this)(sub_row, sub_col) = matrix.el(row_index_set[sub_row], column_index_set[sub_col]); } @@ -1567,18 +1572,18 @@ template template inline void -FullMatrix::scatter_matrix_to (const std::vector &row_index_set, - const std::vector &column_index_set, +FullMatrix::scatter_matrix_to (const std::vector &row_index_set, + const std::vector &column_index_set, MatrixType &matrix) const { AssertDimension(row_index_set.size(), this->n_rows()); AssertDimension(column_index_set.size(), this->n_cols()); - const unsigned int n_rows_submatrix = row_index_set.size(); - const unsigned int n_cols_submatrix = column_index_set.size(); + const size_type n_rows_submatrix = row_index_set.size(); + const size_type n_cols_submatrix = column_index_set.size(); - for (unsigned int sub_row = 0; sub_row < n_rows_submatrix; ++sub_row) - for (unsigned int sub_col = 0; sub_col < n_cols_submatrix; ++sub_col) + for (size_type sub_row = 0; sub_row < n_rows_submatrix; ++sub_row) + for (size_type sub_col = 0; sub_col < n_cols_submatrix; ++sub_col) matrix.set(row_index_set[sub_row], column_index_set[sub_col], (*this)(sub_row, sub_col)); @@ -1588,8 +1593,8 @@ FullMatrix::scatter_matrix_to (const std::vector &row_inde template inline void -FullMatrix::set (const unsigned int i, - const unsigned int j, +FullMatrix::set (const size_type i, + const size_type j, const number value) { (*this)(i,j) = value; @@ -1624,8 +1629,8 @@ template inline FullMatrix::Accessor:: Accessor (const FullMatrix *matrix, - const unsigned int r, - const unsigned int c) + const size_type r, + const size_type c) : matrix(matrix), a_row(r), @@ -1635,7 +1640,7 @@ Accessor (const FullMatrix *matrix, template inline -unsigned int +size_type FullMatrix::Accessor::row() const { return a_row; @@ -1644,7 +1649,7 @@ FullMatrix::Accessor::row() const template inline -unsigned int +size_type FullMatrix::Accessor::column() const { return a_col; @@ -1665,8 +1670,8 @@ template inline FullMatrix::const_iterator:: const_iterator(const FullMatrix *matrix, - const unsigned int r, - const unsigned int c) + const size_type r, + const size_type c) : accessor(matrix, r, c) {} @@ -1771,7 +1776,7 @@ FullMatrix::end () const template inline typename FullMatrix::const_iterator -FullMatrix::begin (const unsigned int r) const +FullMatrix::begin (const size_type r) const { Assert (r::begin (const unsigned int r) const template inline typename FullMatrix::const_iterator -FullMatrix::end (const unsigned int r) const +FullMatrix::end (const size_type r) const { Assert (r::end (const unsigned int r) const template inline void -FullMatrix::add (const unsigned int r, const unsigned int c, const number v) +FullMatrix::add (const size_type r, const size_type c, const number v) { AssertIndexRange(r, this->m()); AssertIndexRange(c, this->n()); @@ -1807,15 +1812,15 @@ template template inline void -FullMatrix::add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, - const number2 *values, +FullMatrix::add (const size_type row, + const size_type n_cols, + const size_type *col_indices, + const number2 *values, const bool, const bool) { AssertIndexRange(row, this->m()); - for (unsigned int col=0; coln()); this->operator()(row,col_indices[col]) += values[col]; @@ -1827,15 +1832,15 @@ template template inline void -FullMatrix::print (STREAM &s, - const unsigned int w, - const unsigned int p) const +FullMatrix::print (STREAM &s, + const size_type w, + const size_type p) const { Assert (!this->empty(), ExcEmptyMatrix()); - for (unsigned int i=0; im(); ++i) + for (size_type i=0; im(); ++i) { - for (unsigned int j=0; jn(); ++j) + for (size_type j=0; jn(); ++j) s << std::setw(w) << std::setprecision(p) << this->el(i,j); s << std::endl; } diff --git a/deal.II/include/deal.II/lac/tridiagonal_matrix.h b/deal.II/include/deal.II/lac/tridiagonal_matrix.h index 163b2cfa34..738bde20c6 100644 --- a/deal.II/include/deal.II/lac/tridiagonal_matrix.h +++ b/deal.II/include/deal.II/lac/tridiagonal_matrix.h @@ -45,6 +45,11 @@ template class TridiagonalMatrix { public: + /** + * Declare type for container size. + */ + typedef std::size_t size_type; + /** * @name Constructors and initalization. */ @@ -53,7 +58,7 @@ public: * empty matrix of dimension * n. */ - TridiagonalMatrix(unsigned int n = 0, + TridiagonalMatrix(size_type n = 0, bool symmetric = false); /** @@ -62,7 +67,7 @@ public: * to zero. The symmetry * properties may be set as well. */ - void reinit(unsigned int n, + void reinit(size_type n, bool symmetric = false); @@ -75,14 +80,14 @@ public: * To remember: this matrix is an * m x m-matrix. */ - unsigned int m () const; + size_type m () const; /** * Number of columns of this matrix. * To remember: this matrix is an * n x n-matrix. */ - unsigned int n () const; + size_type n () const; /** * Return whether the matrix @@ -107,7 +112,7 @@ public: * the case where |i-j| <= * 1. */ - number operator()(unsigned int i, unsigned int j) const; + number operator()(size_type i, size_type j) const; /** * Read-write access to a @@ -124,7 +129,7 @@ public: * for matrix assembling in order * not to obtain doubled entries. */ - number &operator()(unsigned int i, unsigned int j); + number &operator()(size_type i, size_type j); //@} ///@name Multiplications with vectors @@ -294,7 +299,7 @@ public: * compute_eigenvalues(), you can * access each eigenvalue here. */ - number eigenvalue(const unsigned int i) const; + number eigenvalue(const size_type i) const; //@} ///@name Miscellanea //@{ @@ -375,7 +380,7 @@ private: #ifndef DOXYGEN template -unsigned int +size_type TridiagonalMatrix::m() const { return diagonal.size(); @@ -384,7 +389,7 @@ TridiagonalMatrix::m() const template -unsigned int +size_type TridiagonalMatrix::n() const { return diagonal.size(); @@ -394,7 +399,7 @@ TridiagonalMatrix::n() const template inline number -TridiagonalMatrix::operator()(unsigned int i, unsigned int j) const +TridiagonalMatrix::operator()(size_type i, size_type j) const { Assert(i::operator()(unsigned int i, unsigned int j) const template inline number & -TridiagonalMatrix::operator()(unsigned int i, unsigned int j) +TridiagonalMatrix::operator()(size_type i, size_type j) { Assert(i::print ( const unsigned int width, const unsigned int) const { - for (unsigned int i=0; i0) s << std::setw(width) << (*this)(i,i-1); 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 0680b3c883..1a5dc2d2ec 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,6 +70,23 @@ namespace TrilinosWrappers class BlockSparseMatrix : public BlockMatrixBase { public: + /** + * Declare the type for container size. + */ + typedef std::size_t size_type; + +#ifdef EPETRA_NO_64BIT_GLOBAL_INDICES + /** + * Declare the type of integer. + */ + typedef int int_type; +#else + /** + * Declare the type of integer. + */ + typedef long long int_type; +#endif + /** * Typedef the base class for simpler * access to its own typedefs. @@ -175,8 +192,8 @@ namespace TrilinosWrappers * user call whatever function * she desires. */ - void reinit (const unsigned int n_block_rows, - const unsigned int n_block_columns); + void reinit (const size_type n_block_rows, + const size_type n_block_columns); /** * Resize the matrix, by using an @@ -289,7 +306,7 @@ namespace TrilinosWrappers * elements of this * matrix. */ - unsigned int n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Matrix-vector multiplication: @@ -639,8 +656,8 @@ namespace TrilinosWrappers { Assert (d==0, ExcScalarAssignmentOnlyForZeroValue()); - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) + for (size_type r=0; rn_block_rows(); ++r) + for (size_type c=0; cn_block_cols(); ++c) this->block(r,c) = d; return *this; @@ -653,8 +670,8 @@ namespace TrilinosWrappers BlockSparseMatrix::is_compressed () const { bool compressed = true; - for (unsigned int row=0; row { public: + /** + * Declare the type for container size. + */ + typedef std::size_t size_type; + /** * Typedef the base class for simpler * access to its own typedefs. @@ -146,7 +151,7 @@ namespace TrilinosWrappers * fill appropriate data using a * reinit of the blocks. */ - BlockVector (const unsigned int num_blocks); + BlockVector (const size_type num_blocks); /** * Constructor. Set the number of @@ -156,7 +161,7 @@ namespace TrilinosWrappers * * References BlockVector.reinit(). */ - BlockVector (const std::vector &N); + BlockVector (const std::vector &N); /** * Constructor. Set the number of @@ -177,9 +182,9 @@ namespace TrilinosWrappers * different blocks. */ template - BlockVector (const std::vector &n, - const InputIterator first, - const InputIterator end); + BlockVector (const std::vector &n, + const InputIterator first, + const InputIterator end); /** * Destructor. Clears memory @@ -308,8 +313,8 @@ namespace TrilinosWrappers * If fast==false, the vector * is filled with zeros. */ - void reinit (const std::vector &N, - const bool fast=false); + void reinit (const std::vector &N, + const bool fast=false); /** * Reinit the function @@ -360,7 +365,7 @@ namespace TrilinosWrappers * calls collect_sizes * afterwards. */ - void reinit (const unsigned int num_blocks); + void reinit (const size_type num_blocks); /** * Swap the contents of this @@ -454,7 +459,7 @@ namespace TrilinosWrappers inline - BlockVector::BlockVector (const std::vector &N) + BlockVector::BlockVector (const std::vector &N) { reinit (N); } @@ -462,21 +467,21 @@ namespace TrilinosWrappers template - BlockVector::BlockVector (const std::vector &n, - const InputIterator first, - const InputIterator end) + BlockVector::BlockVector (const std::vector &n, + const InputIterator first, + const InputIterator end) { // first set sizes of blocks, but // don't initialize them as we will // copy elements soon reinit (n, true); InputIterator start = first; - for (unsigned int b=0; b(n[b])); + std::advance (end, static_cast(n[b])); - for (unsigned int i=0; iblock(b)(i) = *start; } Assert (start == end, ExcIteratorRangeDoesNotMatchVectorSize()); @@ -485,7 +490,7 @@ namespace TrilinosWrappers inline - BlockVector::BlockVector (const unsigned int num_blocks) + BlockVector::BlockVector (const size_type num_blocks) { reinit (num_blocks); } @@ -514,7 +519,7 @@ namespace TrilinosWrappers this->components.resize (v.n_blocks()); this->block_indices = v.block_indices; - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.components[i]; } @@ -539,7 +544,7 @@ namespace TrilinosWrappers Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(),v.n_blocks())); - for (unsigned int row=0; row block_sizes (v.n_blocks(), 0); + std::vector block_sizes (v.n_blocks(), 0); block_indices.reinit (block_sizes); if (components.size() != n_blocks()) components.resize(n_blocks()); } - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.block(i); collect_sizes(); diff --git a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h index df5bb65a79..ec8d1bbd86 100644 --- a/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_parallel_block_vector.h @@ -67,6 +67,11 @@ namespace TrilinosWrappers class BlockVector : public BlockVectorBase { public: + /** + * Declare the type for container size. + */ + typedef std::size_t size_type; + /** * Typedef the base class for simpler * access to its own typedefs. @@ -140,7 +145,7 @@ namespace TrilinosWrappers * fill appropriate data using a * reinit of the blocks. */ - BlockVector (const unsigned int num_blocks); + BlockVector (const size_type num_blocks); /** * Destructor. Clears memory @@ -266,7 +271,7 @@ namespace TrilinosWrappers * calls collect_sizes * afterwards. */ - void reinit (const unsigned int num_blocks); + void reinit (const size_type num_blocks); /** * This reinit function is meant to @@ -420,7 +425,7 @@ namespace TrilinosWrappers inline - BlockVector::BlockVector (const unsigned int num_blocks) + BlockVector::BlockVector (const size_type num_blocks) { reinit (num_blocks); } @@ -435,7 +440,7 @@ namespace TrilinosWrappers this->components.resize (v.n_blocks()); this->block_indices = v.block_indices; - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.components[i]; } @@ -446,7 +451,7 @@ namespace TrilinosWrappers BlockVector::is_compressed () const { bool compressed = true; - for (unsigned int row=0; row block_sizes (v.n_blocks(), 0); + std::vector block_sizes (v.n_blocks(), 0); block_indices.reinit (block_sizes); if (components.size() != n_blocks()) components.resize(n_blocks()); } - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.block(i); collect_sizes(); @@ -504,7 +509,7 @@ namespace TrilinosWrappers Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(),v.n_blocks())); - for (unsigned int row=0; row &dst, const dealii::Vector &src) const { - AssertDimension (static_cast(dst.size()), + AssertDimension (static_cast(dst.size()), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension (static_cast(src.size()), + AssertDimension (static_cast(src.size()), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), dst.begin()); @@ -1577,9 +1593,9 @@ namespace TrilinosWrappers void PreconditionBase::Tvmult (dealii::Vector &dst, const dealii::Vector &src) const { - AssertDimension (static_cast(dst.size()), + AssertDimension (static_cast(dst.size()), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension (static_cast(src.size()), + AssertDimension (static_cast(src.size()), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), dst.begin()); @@ -1599,9 +1615,9 @@ namespace TrilinosWrappers PreconditionBase::vmult (parallel::distributed::Vector &dst, const parallel::distributed::Vector &src) const { - AssertDimension (static_cast(dst.local_size()), + AssertDimension (static_cast(dst.local_size()), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension (static_cast(src.local_size()), + AssertDimension (static_cast(src.local_size()), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), dst.begin()); @@ -1617,9 +1633,9 @@ namespace TrilinosWrappers PreconditionBase::Tvmult (parallel::distributed::Vector &dst, const parallel::distributed::Vector &src) const { - AssertDimension (static_cast(dst.local_size()), + AssertDimension (static_cast(dst.local_size()), preconditioner->OperatorDomainMap().NumMyElements()); - AssertDimension (static_cast(src.local_size()), + AssertDimension (static_cast(src.local_size()), preconditioner->OperatorRangeMap().NumMyElements()); Epetra_Vector tril_dst (View, preconditioner->OperatorDomainMap(), dst.begin()); 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 688c21eae3..3b89fde249 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -73,7 +73,7 @@ namespace TrilinosWrappers * Exception */ DeclException3 (ExcAccessToNonlocalRow, - int, int, int, + std::size_t, std::size_t, std::size_t, << "You tried to access row " << arg1 << " of a distributed sparsity pattern, " << " but only rows " << arg2 << " through " << arg3 @@ -98,30 +98,47 @@ namespace TrilinosWrappers class AccessorBase { public: + /** + * Declare the type for container size. + */ + typedef std::size_t size_type; + +#ifdef EPETRA_NO_64BIT_GLOBAL_INDICES + /** + * Declare type of integer. + */ + typedef int int_type; +#else + /** + * Declare type of integer. + */ + typedef long long int_type; +#endif + /** * Constructor. */ AccessorBase (SparseMatrix *matrix, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Row number of the element * represented by this object. */ - unsigned int row() const; + size_type row() const; /** * Index in row of the element * represented by this object. */ - unsigned int index() const; + size_type index() const; /** * Column number of the element * represented by this object. */ - unsigned int column() const; + size_type column() const; protected: /** @@ -139,12 +156,12 @@ namespace TrilinosWrappers /** * Current row number. */ - unsigned int a_row; + size_type a_row; /** * Current index in row. */ - unsigned int a_index; + size_type a_index; /** * Discard the old row caches @@ -181,7 +198,7 @@ namespace TrilinosWrappers * than one accessor can access * this data if necessary. */ - std_cxx1x::shared_ptr > colnum_cache; + std_cxx1x::shared_ptr > colnum_cache; /** * Cache for the values @@ -235,8 +252,8 @@ namespace TrilinosWrappers * pointer is sufficient. */ Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Copy constructor to get from a @@ -336,8 +353,8 @@ namespace TrilinosWrappers * pointer is sufficient. */ Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Value of this matrix entry. @@ -375,6 +392,11 @@ namespace TrilinosWrappers class Iterator { public: + /** + * Declare type for container size. + */ + typedef std::size_t size_type; + /** * Typedef for the matrix type * (including constness) we are to @@ -389,8 +411,8 @@ namespace TrilinosWrappers * the index within it. */ Iterator (MatrixType *matrix, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Copy constructor with @@ -450,7 +472,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcInvalidIndexWithinRow, - int, int, + size_type, size_type, << "Attempt to access element " << arg2 << " of row " << arg1 << " which doesn't have that many elements."); @@ -561,9 +583,9 @@ namespace TrilinosWrappers * row is specified as the maximum * number of entries argument. */ - SparseMatrix (const unsigned int m, - const unsigned int n, - const unsigned int n_max_entries_per_row); + SparseMatrix (const size_type m, + const size_type n, + const size_type n_max_entries_per_row); /** * Generate a matrix that is completely @@ -575,9 +597,9 @@ namespace TrilinosWrappers * specifies the number of entries in * each row. */ - SparseMatrix (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row); + SparseMatrix (const size_type m, + const size_type n, + const std::vector &n_entries_per_row); /** * Generate a matrix from a Trilinos @@ -730,8 +752,8 @@ namespace TrilinosWrappers * memory prior to use (in the * compress() step). */ - SparseMatrix (const Epetra_Map ¶llel_partitioning, - const unsigned int n_max_entries_per_row = 0); + SparseMatrix (const Epetra_Map ¶llel_partitioning, + const size_type n_max_entries_per_row = 0); /** * Same as before, but now set a @@ -746,8 +768,8 @@ namespace TrilinosWrappers * SparseMatrix::reinit call * considerably faster. */ - SparseMatrix (const Epetra_Map ¶llel_partitioning, - const std::vector &n_entries_per_row); + SparseMatrix (const Epetra_Map ¶llel_partitioning, + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -778,9 +800,9 @@ namespace TrilinosWrappers * number of columns entries per row * that will be allocated. */ - SparseMatrix (const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const unsigned int n_max_entries_per_row = 0); + SparseMatrix (const Epetra_Map &row_parallel_partitioning, + const Epetra_Map &col_parallel_partitioning, + const size_type n_max_entries_per_row = 0); /** * This constructor is similar to the @@ -813,7 +835,7 @@ namespace TrilinosWrappers */ SparseMatrix (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); /** * This function is initializes the @@ -976,9 +998,9 @@ namespace TrilinosWrappers * memory prior to use (in the * compress() step). */ - SparseMatrix (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_max_entries_per_row = 0); + SparseMatrix (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_max_entries_per_row = 0); /** * Same as before, but now set the @@ -994,9 +1016,9 @@ namespace TrilinosWrappers * SparseMatrix::reinit call * considerably faster. */ - SparseMatrix (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + SparseMatrix (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -1025,10 +1047,10 @@ namespace TrilinosWrappers * structure is reorganized in the * compress() call. */ - SparseMatrix (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_max_entries_per_row = 0); + SparseMatrix (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_max_entries_per_row = 0); /** * This constructor is similar to the @@ -1059,10 +1081,10 @@ namespace TrilinosWrappers * each row of the newly generated * matrix. */ - SparseMatrix (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + SparseMatrix (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * This function is initializes the @@ -1212,13 +1234,13 @@ namespace TrilinosWrappers * Return the number of rows in * this matrix. */ - unsigned int m () const; + size_type m () const; /** * Return the number of columns * in this matrix. */ - unsigned int n () const; + size_type n () const; /** * Return the local dimension @@ -1234,7 +1256,7 @@ namespace TrilinosWrappers * exactly are stored locally, * use local_range(). */ - unsigned int local_size () const; + size_type local_size () const; /** * Return a pair of indices @@ -1252,7 +1274,7 @@ namespace TrilinosWrappers * where * n=local_size(). */ - std::pair + std::pair local_range () const; /** @@ -1260,19 +1282,19 @@ namespace TrilinosWrappers * in the local range or not, * see also local_range(). */ - bool in_local_range (const unsigned int index) const; + bool in_local_range (const size_type index) const; /** * Return the number of nonzero * elements of this matrix. */ - unsigned int n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Number of entries in a * specific row. */ - unsigned int row_length (const unsigned int row) const; + size_type row_length (const size_type row) const; /** * Returns the state of the matrix, @@ -1293,7 +1315,7 @@ namespace TrilinosWrappers * returned in case this is called in * an MPI-based program. */ - std::size_t memory_consumption () const; + size_type memory_consumption () const; //@} /** @@ -1404,8 +1426,8 @@ namespace TrilinosWrappers * the matrix with a sparsity pattern * first. */ - void set (const unsigned int i, - const unsigned int j, + void set (const size_type i, + const size_type j, const TrilinosScalar value); /** @@ -1444,7 +1466,7 @@ namespace TrilinosWrappers * false, i.e., even zero * values are inserted/replaced. */ - void set (const std::vector &indices, + void set (const std::vector &indices, const FullMatrix &full_matrix, const bool elide_zero_values = false); @@ -1455,8 +1477,8 @@ namespace TrilinosWrappers * different local-to-global indexing * on rows and columns, respectively. */ - void set (const std::vector &row_indices, - const std::vector &col_indices, + void set (const std::vector &row_indices, + const std::vector &col_indices, const FullMatrix &full_matrix, const bool elide_zero_values = false); @@ -1487,8 +1509,8 @@ namespace TrilinosWrappers * false, i.e., even zero * values are inserted/replaced. */ - void set (const unsigned int row, - const std::vector &col_indices, + void set (const size_type row, + const std::vector &col_indices, const std::vector &values, const bool elide_zero_values = false); @@ -1519,9 +1541,9 @@ namespace TrilinosWrappers * false, i.e., even zero * values are inserted/replaced. */ - void set (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, + void set (const size_type row, + const size_type n_cols, + const size_type *col_indices, const TrilinosScalar *values, const bool elide_zero_values = false); @@ -1540,8 +1562,8 @@ namespace TrilinosWrappers * value is not a finite * number an exception is thrown. */ - void add (const unsigned int i, - const unsigned int j, + void add (const size_type i, + const size_type j, const TrilinosScalar value); /** @@ -1580,7 +1602,7 @@ namespace TrilinosWrappers * i.e., zero values won't be added * into the matrix. */ - void add (const std::vector &indices, + void add (const std::vector &indices, const FullMatrix &full_matrix, const bool elide_zero_values = true); @@ -1591,8 +1613,8 @@ namespace TrilinosWrappers * different local-to-global indexing * on rows and columns, respectively. */ - void add (const std::vector &row_indices, - const std::vector &col_indices, + void add (const std::vector &row_indices, + const std::vector &col_indices, const FullMatrix &full_matrix, const bool elide_zero_values = true); @@ -1622,8 +1644,8 @@ namespace TrilinosWrappers * i.e., zero values won't be added * into the matrix. */ - void add (const unsigned int row, - const std::vector &col_indices, + void add (const size_type row, + const std::vector &col_indices, const std::vector &values, const bool elide_zero_values = true); @@ -1652,9 +1674,9 @@ namespace TrilinosWrappers * i.e., zero values won't be added * into the matrix. */ - void add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, + void add (const size_type row, + const size_type n_cols, + const size_type *col_indices, const TrilinosScalar *values, const bool elide_zero_values = true, const bool col_indices_are_sorted = false); @@ -1731,7 +1753,7 @@ namespace TrilinosWrappers * default is to set it to * zero. */ - void clear_row (const unsigned int row, + void clear_row (const size_type row, const TrilinosScalar new_diag_value = 0); /** @@ -1750,8 +1772,8 @@ namespace TrilinosWrappers * diagonal entries, you have * to set them by hand. */ - void clear_rows (const std::vector &rows, - const TrilinosScalar new_diag_value = 0); + void clear_rows (const std::vector &rows, + const TrilinosScalar new_diag_value = 0); /** * Make an in-place transpose @@ -1784,8 +1806,8 @@ namespace TrilinosWrappers * is not saved on the calling * process. */ - TrilinosScalar operator () (const unsigned int i, - const unsigned int j) const; + TrilinosScalar operator () (const size_type i, + const size_type j) const; /** * Return the value of the @@ -1824,8 +1846,8 @@ namespace TrilinosWrappers * processor, and possibly so * with a nonzero value. */ - TrilinosScalar el (const unsigned int i, - const unsigned int j) const; + TrilinosScalar el (const size_type i, + const size_type j) const; /** * Return the main diagonal @@ -1838,7 +1860,7 @@ namespace TrilinosWrappers * See also the comment in * trilinos_sparse_matrix.cc. */ - TrilinosScalar diag_element (const unsigned int i) const; + TrilinosScalar diag_element (const size_type i) const; //@} /** @@ -2342,7 +2364,7 @@ namespace TrilinosWrappers * that the iterator may not be * dereferencable in that case. */ - const_iterator begin (const unsigned int r) const; + const_iterator begin (const size_type r) const; /** * Final iterator of row @@ -2359,7 +2381,7 @@ namespace TrilinosWrappers * the end iterator for the * last row of a matrix. */ - const_iterator end (const unsigned int r) const; + const_iterator end (const size_type r) const; /** * STL-like iterator with the @@ -2385,7 +2407,7 @@ namespace TrilinosWrappers * that the iterator may not be * dereferencable in that case. */ - iterator begin (const unsigned int r); + iterator begin (const size_type r); /** * Final iterator of row @@ -2402,7 +2424,7 @@ namespace TrilinosWrappers * the end iterator for the * last row of a matrix. */ - iterator end (const unsigned int r); + iterator end (const size_type r); //@} /** @@ -2453,7 +2475,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcInvalidIndex, - int, int, + size_type, size_type, << "The entry with index <" << arg1 << ',' << arg2 << "> does not exist."); @@ -2471,7 +2493,7 @@ namespace TrilinosWrappers * Exception */ DeclException4 (ExcAccessToNonLocalElement, - int, int, int, int, + size_type, size_type, size_type, size_type, << "You tried to access element (" << arg1 << "/" << arg2 << ")" << " of a distributed matrix, but only rows " @@ -2482,7 +2504,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcAccessToNonPresentElement, - int, int, + size_type, size_type, << "You tried to access element (" << arg1 << "/" << arg2 << ")" << " of a sparse matrix, but it appears to not" @@ -2597,7 +2619,7 @@ namespace TrilinosWrappers * adding/inserting local data into * the (large) sparse matrix. */ - std::vector column_indices; + std::vector column_indices; /** * An internal array of double values @@ -2626,7 +2648,7 @@ namespace TrilinosWrappers namespace SparseMatrixIterators { inline - AccessorBase::AccessorBase(SparseMatrix *matrix, unsigned int row, unsigned int index) + AccessorBase::AccessorBase(SparseMatrix *matrix, size_type row, size_type index) : matrix(matrix), a_row(row), @@ -2637,7 +2659,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type AccessorBase::row() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -2646,7 +2668,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type AccessorBase::column() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -2655,7 +2677,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type AccessorBase::index() const { Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix()); @@ -2665,8 +2687,8 @@ namespace TrilinosWrappers inline Accessor::Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index) + const size_type row, + const size_type index) : AccessorBase(const_cast(matrix), row, index) {} @@ -2760,8 +2782,8 @@ namespace TrilinosWrappers inline Accessor::Accessor (MatrixType *matrix, - const unsigned int row, - const unsigned int index) + const size_type row, + const size_type index) : AccessorBase(matrix, row, index) {} @@ -2780,8 +2802,8 @@ namespace TrilinosWrappers template inline Iterator::Iterator(MatrixType *matrix, - const unsigned int row, - const unsigned int index) + const size_type row, + const size_type index) : accessor(matrix, row, index) {} @@ -2921,7 +2943,7 @@ namespace TrilinosWrappers inline SparseMatrix::const_iterator - SparseMatrix::begin(const unsigned int r) const + SparseMatrix::begin(const size_type r) const { Assert (r < m(), ExcIndexRange(r, 0, m())); if (row_length(r) > 0) @@ -2934,14 +2956,14 @@ namespace TrilinosWrappers inline SparseMatrix::const_iterator - SparseMatrix::end(const unsigned int r) const + SparseMatrix::end(const size_type r) const { Assert (r < m(), ExcIndexRange(r, 0, m())); // place the iterator on the first entry // past this line, or at the end of the // matrix - for (unsigned int i=r+1; i 0) return const_iterator(this, i, 0); @@ -2972,7 +2994,7 @@ namespace TrilinosWrappers inline SparseMatrix::iterator - SparseMatrix::begin(const unsigned int r) + SparseMatrix::begin(const size_type r) { Assert (r < m(), ExcIndexRange(r, 0, m())); if (row_length(r) > 0) @@ -2985,14 +3007,14 @@ namespace TrilinosWrappers inline SparseMatrix::iterator - SparseMatrix::end(const unsigned int r) + SparseMatrix::end(const size_type r) { Assert (r < m(), ExcIndexRange(r, 0, m())); // place the iterator on the first entry // past this line, or at the end of the // matrix - for (unsigned int i=r+1; i 0) return iterator(this, i, 0); @@ -3005,14 +3027,14 @@ namespace TrilinosWrappers inline bool - SparseMatrix::in_local_range (const unsigned int index) const + SparseMatrix::in_local_range (const size_type index) const { - int begin, end; + int_type begin, end; begin = matrix->RowMap().MinMyGID(); end = matrix->RowMap().MaxMyGID()+1; - return ((index >= static_cast(begin)) && - (index < static_cast(end))); + return ((index >= static_cast(begin)) && + (index < static_cast(end))); } @@ -3071,8 +3093,8 @@ namespace TrilinosWrappers // compile time. inline void - SparseMatrix::set (const unsigned int i, - const unsigned int j, + SparseMatrix::set (const size_type i, + const size_type j, const TrilinosScalar value) { @@ -3085,7 +3107,7 @@ namespace TrilinosWrappers inline void - SparseMatrix::set (const std::vector &indices, + SparseMatrix::set (const std::vector &indices, const FullMatrix &values, const bool elide_zero_values) { @@ -3093,7 +3115,7 @@ namespace TrilinosWrappers ExcDimensionMismatch(indices.size(), values.m())); Assert (values.m() == values.n(), ExcNotQuadratic()); - for (unsigned int i=0; i &row_indices, - const std::vector &col_indices, + SparseMatrix::set (const std::vector &row_indices, + const std::vector &col_indices, const FullMatrix &values, const bool elide_zero_values) { @@ -3112,7 +3134,7 @@ namespace TrilinosWrappers Assert (col_indices.size() == values.n(), ExcDimensionMismatch(col_indices.size(), values.n())); - for (unsigned int i=0; i &col_indices, + SparseMatrix::set (const size_type row, + const std::vector &col_indices, const std::vector &values, const bool elide_zero_values) { @@ -3137,9 +3159,9 @@ namespace TrilinosWrappers inline void - SparseMatrix::set (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, + SparseMatrix::set (const size_type row, + const size_type n_cols, + const size_type *col_indices, const TrilinosScalar *values, const bool elide_zero_values) { @@ -3154,15 +3176,15 @@ namespace TrilinosWrappers last_action = Insert; - int *col_index_ptr; + int_type *col_index_ptr; TrilinosScalar const *col_value_ptr; - int n_columns; + int_type n_columns; // If we don't elide zeros, the pointers // are already available... if (elide_zero_values == false) { - col_index_ptr = (int *)col_indices; + col_index_ptr = (int_type *)col_indices; col_value_ptr = values; n_columns = n_cols; } @@ -3178,7 +3200,7 @@ namespace TrilinosWrappers } n_columns = 0; - for (unsigned int j=0; j(row)) == true) + if (row_partitioner().MyGID(static_cast(row)) == true) { if (matrix->Filled() == false) { @@ -3248,7 +3270,7 @@ namespace TrilinosWrappers if (matrix->Filled() == false) { - ierr = matrix->InsertGlobalValues (1, (int *)&row, + ierr = matrix->InsertGlobalValues (1, (int_type *)&row, n_columns, col_index_ptr, &col_value_ptr, Epetra_FECrsMatrix::ROW_MAJOR); @@ -3256,7 +3278,7 @@ namespace TrilinosWrappers ierr = 0; } else - ierr = matrix->ReplaceGlobalValues (1, (int *)&row, + ierr = matrix->ReplaceGlobalValues (1, (int_type *)&row, n_columns, col_index_ptr, &col_value_ptr, Epetra_FECrsMatrix::ROW_MAJOR); @@ -3270,8 +3292,8 @@ namespace TrilinosWrappers inline void - SparseMatrix::add (const unsigned int i, - const unsigned int j, + SparseMatrix::add (const size_type i, + const size_type j, const TrilinosScalar value) { Assert (numbers::is_finite(value), ExcNumberNotFinite()); @@ -3310,7 +3332,7 @@ namespace TrilinosWrappers inline void - SparseMatrix::add (const std::vector &indices, + SparseMatrix::add (const std::vector &indices, const FullMatrix &values, const bool elide_zero_values) { @@ -3318,7 +3340,7 @@ namespace TrilinosWrappers ExcDimensionMismatch(indices.size(), values.m())); Assert (values.m() == values.n(), ExcNotQuadratic()); - for (unsigned int i=0; i &row_indices, - const std::vector &col_indices, + SparseMatrix::add (const std::vector &row_indices, + const std::vector &col_indices, const FullMatrix &values, const bool elide_zero_values) { @@ -3337,7 +3359,7 @@ namespace TrilinosWrappers Assert (col_indices.size() == values.n(), ExcDimensionMismatch(col_indices.size(), values.n())); - for (unsigned int i=0; i &col_indices, + SparseMatrix::add (const size_type row, + const std::vector &col_indices, const std::vector &values, const bool elide_zero_values) { @@ -3362,9 +3384,9 @@ namespace TrilinosWrappers inline void - SparseMatrix::add (const unsigned int row, - const unsigned int n_cols, - const unsigned int *col_indices, + SparseMatrix::add (const size_type row, + const size_type n_cols, + const size_type *col_indices, const TrilinosScalar *values, const bool elide_zero_values, const bool /*col_indices_are_sorted*/) @@ -3382,19 +3404,19 @@ namespace TrilinosWrappers last_action = Add; - int *col_index_ptr; + int_type *col_index_ptr; TrilinosScalar const *col_value_ptr; - int n_columns; + int_type n_columns; // If we don't elide zeros, the pointers // are already available... if (elide_zero_values == false) { - col_index_ptr = (int *)col_indices; + col_index_ptr = (int_type *)col_indices; col_value_ptr = values; n_columns = n_cols; #ifdef DEBUG - for (unsigned int j=0; j(row)) == true) + if (row_partitioner().MyGID(static_cast(row)) == true) { ierr = matrix->Epetra_CrsMatrix::SumIntoGlobalValues(row, n_columns, const_cast(col_value_ptr), @@ -3452,7 +3474,7 @@ namespace TrilinosWrappers // one element at a time). compressed = false; - ierr = matrix->SumIntoGlobalValues (1, (int *)&row, n_columns, + ierr = matrix->SumIntoGlobalValues (1, (int_type *)&row, n_columns, col_index_ptr, &col_value_ptr, Epetra_FECrsMatrix::ROW_MAJOR); @@ -3466,15 +3488,15 @@ namespace TrilinosWrappers std::cout << "Got error " << ierr << " in row " << row << " of proc " << row_partitioner().Comm().MyPID() << " when trying to add the columns:" << std::endl; - for (int i=0; i(row)), + int_type n_indices, *indices; + trilinos_sparsity_pattern().ExtractMyRowView(row_partitioner().LID(static_cast(row)), n_indices, indices); - for (int i=0; i NumGlobalRows(); @@ -3499,7 +3521,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type SparseMatrix::n () const { return matrix -> NumGlobalCols(); @@ -3508,7 +3530,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type SparseMatrix::local_size () const { return matrix -> NumMyRows(); @@ -3517,10 +3539,10 @@ namespace TrilinosWrappers inline - std::pair + std::pair SparseMatrix::local_range () const { - unsigned int begin, end; + size_type begin, end; begin = matrix -> RowMap().MinMyGID(); end = matrix -> RowMap().MaxMyGID()+1; @@ -3530,7 +3552,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type SparseMatrix::n_nonzero_elements () const { return matrix->NumGlobalNonzeros(); @@ -3693,8 +3715,8 @@ namespace TrilinosWrappers Assert (&src != &dst, ExcSourceEqualsDestination()); Assert (matrix->Filled(), ExcMatrixNotCompressed()); - AssertDimension (dst.local_size(), static_cast(matrix->RangeMap().NumMyElements())); - AssertDimension (src.local_size(), static_cast(matrix->DomainMap().NumMyElements())); + AssertDimension (dst.local_size(), static_cast(matrix->RangeMap().NumMyElements())); + AssertDimension (src.local_size(), static_cast(matrix->DomainMap().NumMyElements())); Epetra_Vector tril_dst (View, matrix->RangeMap(), dst.begin()); Epetra_Vector tril_src (View, matrix->DomainMap(), @@ -3715,10 +3737,10 @@ namespace TrilinosWrappers Assert (&src != &dst, ExcSourceEqualsDestination()); Assert (matrix->Filled(), ExcMatrixNotCompressed()); - AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), - static_cast(matrix->DomainMap().NumGlobalElements())); - AssertDimension (dst.size(), static_cast(matrix->RangeMap().NumMyElements())); - AssertDimension (src.size(), static_cast(matrix->DomainMap().NumMyElements())); + AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), + static_cast(matrix->DomainMap().NumGlobalElements())); + AssertDimension (dst.size(), static_cast(matrix->RangeMap().NumMyElements())); + AssertDimension (src.size(), static_cast(matrix->DomainMap().NumMyElements())); Epetra_Vector tril_dst (View, matrix->RangeMap(), dst.begin()); Epetra_Vector tril_src (View, matrix->DomainMap(), @@ -3760,8 +3782,8 @@ namespace TrilinosWrappers Assert (&src != &dst, ExcSourceEqualsDestination()); Assert (matrix->Filled(), ExcMatrixNotCompressed()); - AssertDimension (dst.local_size(), static_cast(matrix->DomainMap().NumMyElements())); - AssertDimension (src.local_size(), static_cast(matrix->RangeMap().NumMyElements())); + AssertDimension (dst.local_size(), static_cast(matrix->DomainMap().NumMyElements())); + AssertDimension (src.local_size(), static_cast(matrix->RangeMap().NumMyElements())); Epetra_Vector tril_dst (View, matrix->DomainMap(), dst.begin()); Epetra_Vector tril_src (View, matrix->RangeMap(), @@ -3782,10 +3804,10 @@ namespace TrilinosWrappers Assert (&src != &dst, ExcSourceEqualsDestination()); Assert (matrix->Filled(), ExcMatrixNotCompressed()); - AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), - static_cast(matrix->DomainMap().NumGlobalElements())); - AssertDimension (dst.size(), static_cast(matrix->DomainMap().NumMyElements())); - AssertDimension (src.size(), static_cast(matrix->RangeMap().NumMyElements())); + AssertDimension (static_cast(matrix->DomainMap().NumMyElements()), + static_cast(matrix->DomainMap().NumGlobalElements())); + AssertDimension (dst.size(), static_cast(matrix->DomainMap().NumMyElements())); + AssertDimension (src.size(), static_cast(matrix->RangeMap().NumMyElements())); Epetra_Vector tril_dst (View, matrix->DomainMap(), dst.begin()); Epetra_Vector tril_src (View, matrix->RangeMap(), 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 38aacf23b0..6588ba7053 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h @@ -70,30 +70,48 @@ namespace TrilinosWrappers class Accessor { public: + /** + * Declare type for container size. + */ + typedef std::size_t size_type; + +#ifdef EPETRA_NO_64BIT_GLOBAL_INDICES + /** + * Declare type of integer. + */ + typedef int int_type; +#else + /** + * Declare type of integer. + */ + typedef long long int_type; +#endif + + /** * Constructor. */ Accessor (const SparsityPattern *sparsity_pattern, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Row number of the element * represented by this object. */ - unsigned int row() const; + size_type row() const; /** * Index in row of the element * represented by this object. */ - unsigned int index() const; + size_type index() const; /** * Column number of the element * represented by this object. */ - unsigned int column() const; + size_type column() const; /** * Exception @@ -104,7 +122,7 @@ namespace TrilinosWrappers * Exception */ DeclException3 (ExcAccessToNonlocalRow, - int, int, int, + size_type, size_type, size_type, << "You tried to access row " << arg1 << " of a distributed sparsity pattern, " << " but only rows " << arg2 << " through " << arg3 @@ -119,12 +137,12 @@ namespace TrilinosWrappers /** * Current row number. */ - unsigned int a_row; + size_type a_row; /** * Current index in row. */ - unsigned int a_index; + size_type a_index; /** * Cache where we store the @@ -151,7 +169,7 @@ namespace TrilinosWrappers * than one accessor can access * this data if necessary. */ - std_cxx1x::shared_ptr > colnum_cache; + std_cxx1x::shared_ptr > colnum_cache; /** * Discard the old row caches @@ -186,8 +204,8 @@ namespace TrilinosWrappers * the index within it. */ Iterator (const SparsityPattern *sparsity_pattern, - const unsigned int row, - const unsigned int index); + const size_type row, + const size_type index); /** * Prefix increment. @@ -235,7 +253,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcInvalidIndexWithinRow, - int, int, + size_type, syze_type, << "Attempt to access element " << arg2 << " of row " << arg1 << " which doesn't have that many elements."); @@ -321,9 +339,9 @@ namespace TrilinosWrappers * will reduce the setup time of the * sparsity pattern. */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int n_entries_per_row = 0); + SparsityPattern (const size_type m, + const size_type n, + const size_type n_entries_per_row = 0); /** * Generate a sparsity pattern that is @@ -338,9 +356,9 @@ namespace TrilinosWrappers * each row (an information usually * not available, though). */ - SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row); + SparsityPattern (const size_type m, + const size_type n, + const std::vector &n_entries_per_row); /** * Copy constructor. Sets the calling @@ -376,9 +394,9 @@ namespace TrilinosWrappers * pattern. */ void - reinit (const unsigned int m, - const unsigned int n, - const unsigned int n_entries_per_row = 0); + reinit (const size_type m, + const size_type n, + const size_type n_entries_per_row = 0); /** * Initialize a sparsity pattern that @@ -393,9 +411,9 @@ namespace TrilinosWrappers * each row. */ void - reinit (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row); + reinit (const size_type m, + const size_type n, + const std::vector &n_entries_per_row); /** * Copy function. Sets the calling @@ -488,8 +506,8 @@ namespace TrilinosWrappers * increases the performance when * creating the sparsity pattern. */ - SparsityPattern (const Epetra_Map ¶llel_partitioning, - const unsigned int n_entries_per_row = 0); + SparsityPattern (const Epetra_Map ¶llel_partitioning, + const size_type n_entries_per_row = 0); /** * Same as before, but now use the @@ -510,8 +528,8 @@ namespace TrilinosWrappers * sparsity pattern is designed to * describe. */ - SparsityPattern (const Epetra_Map ¶llel_partitioning, - const std::vector &n_entries_per_row); + SparsityPattern (const Epetra_Map ¶llel_partitioning, + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -543,7 +561,7 @@ namespace TrilinosWrappers */ SparsityPattern (const Epetra_Map &row_parallel_partitioning, const Epetra_Map &col_parallel_partitioning, - const unsigned int n_entries_per_row = 0); + const size_type n_entries_per_row = 0); /** * This constructor is similar to the @@ -565,9 +583,9 @@ namespace TrilinosWrappers * the number of entries in each row of * the newly generated matrix. */ - SparsityPattern (const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const std::vector &n_entries_per_row); + SparsityPattern (const Epetra_Map &row_parallel_partitioning, + const Epetra_Map &col_parallel_partitioning, + const std::vector &n_entries_per_row); /** * Reinitialization function for @@ -595,8 +613,8 @@ namespace TrilinosWrappers * add() function. */ void - reinit (const Epetra_Map ¶llel_partitioning, - const unsigned int n_entries_per_row = 0); + reinit (const Epetra_Map ¶llel_partitioning, + const size_type n_entries_per_row = 0); /** * Same as before, but now use the @@ -617,8 +635,8 @@ namespace TrilinosWrappers * designed to describe. */ void - reinit (const Epetra_Map ¶llel_partitioning, - const std::vector &n_entries_per_row); + reinit (const Epetra_Map ¶llel_partitioning, + const std::vector &n_entries_per_row); /** * This reinit function is similar to @@ -651,7 +669,7 @@ namespace TrilinosWrappers void reinit (const Epetra_Map &row_parallel_partitioning, const Epetra_Map &col_parallel_partitioning, - const unsigned int n_entries_per_row = 0); + const size_type n_entries_per_row = 0); /** * This reinit function is similar to @@ -677,9 +695,9 @@ namespace TrilinosWrappers * matrix. */ void - reinit (const Epetra_Map &row_parallel_partitioning, - const Epetra_Map &col_parallel_partitioning, - const std::vector &n_entries_per_row); + reinit (const Epetra_Map &row_parallel_partitioning, + const Epetra_Map &col_parallel_partitioning, + const std::vector &n_entries_per_row); /** * Reinit function. Takes one of the @@ -750,9 +768,9 @@ namespace TrilinosWrappers * increases the performance when * creating the sparsity pattern. */ - SparsityPattern (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_entries_per_row = 0); + SparsityPattern (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_entries_per_row = 0); /** * Same as before, but now use the @@ -775,7 +793,7 @@ namespace TrilinosWrappers */ SparsityPattern (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -800,10 +818,10 @@ namespace TrilinosWrappers * row is specified as the maximum * number of entries argument. */ - SparsityPattern (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_entries_per_row = 0); + SparsityPattern (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_entries_per_row = 0); /** * This constructor is similar to the @@ -825,10 +843,10 @@ namespace TrilinosWrappers * the number of entries in each row of * the newly generated matrix. */ - SparsityPattern (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + SparsityPattern (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * Reinitialization function for @@ -857,9 +875,9 @@ namespace TrilinosWrappers * add() function. */ void - reinit (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_entries_per_row = 0); + reinit (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_entries_per_row = 0); /** * Same as before, but now use the @@ -880,9 +898,9 @@ namespace TrilinosWrappers * designed to describe. */ void - reinit (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + reinit (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * This reinit function is similar to @@ -914,10 +932,10 @@ namespace TrilinosWrappers * n_entries_per_row. */ void - reinit (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const unsigned int n_entries_per_row = 0); + reinit (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const size_type n_entries_per_row = 0); /** * Same as before, but now using a @@ -927,10 +945,10 @@ namespace TrilinosWrappers * sparsity pattern. */ void - reinit (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + reinit (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * Reinit function. Takes one of the @@ -997,19 +1015,19 @@ namespace TrilinosWrappers * entries per row on the current * processor. */ - unsigned int max_entries_per_row () const; + size_type max_entries_per_row () const; /** * Return the number of rows in this * sparsity pattern. */ - unsigned int n_rows () const; + size_type n_rows () const; /** * Return the number of columns in * this sparsity pattern. */ - unsigned int n_cols () const; + size_type n_cols () const; /** * Return the local dimension of the @@ -1024,7 +1042,7 @@ namespace TrilinosWrappers * exactly are stored locally, * use local_range(). */ - unsigned int local_size () const; + size_type local_size () const; /** * Return a pair of indices @@ -1040,7 +1058,7 @@ namespace TrilinosWrappers * it will be a pair (i,i+n), where * n=local_size(). */ - std::pair + std::pair local_range () const; /** @@ -1048,19 +1066,19 @@ namespace TrilinosWrappers * in the local range or not, * see also local_range(). */ - bool in_local_range (const unsigned int index) const; + bool in_local_range (const size_type index) const; /** * Return the number of nonzero * elements of this sparsity pattern. */ - unsigned int n_nonzero_elements () const; + size_type n_nonzero_elements () const; /** * Number of entries in a * specific row. */ - unsigned int row_length (const unsigned int row) const; + size_type row_length (const size_type row) const; /** * Compute the bandwidth of the @@ -1073,7 +1091,7 @@ namespace TrilinosWrappers * bandwidth a $n\times m$ matrix can * have is $\max\{n-1,m-1\}$. */ - unsigned int bandwidth () const; + size_type bandwidth () const; /** * Return whether the object is @@ -1089,8 +1107,8 @@ namespace TrilinosWrappers * sparsity pattern (i.e., it may be * non-zero) or not. */ - bool exists (const unsigned int i, - const unsigned int j) const; + bool exists (const size_type i, + const size_type j) const; /** * Determine an estimate for the @@ -1109,8 +1127,8 @@ namespace TrilinosWrappers * Add the element (i,j) to * the sparsity pattern. */ - void add (const unsigned int i, - const unsigned int j); + void add (const size_type i, + const size_type j); /** @@ -1118,10 +1136,10 @@ namespace TrilinosWrappers * the sparsity pattern. */ template - void add_entries (const unsigned int row, - ForwardIterator begin, - ForwardIterator end, - const bool indices_are_sorted = false); + void add_entries (const size_type row, + ForwardIterator begin, + ForwardIterator end, + const bool indices_are_sorted = false); //@} /** * @name Access of underlying Trilinos data @@ -1216,7 +1234,7 @@ namespace TrilinosWrappers * that the iterator may not be * dereferencable in that case. */ - const_iterator begin (const unsigned int r) const; + const_iterator begin (const size_type r) const; /** * Final iterator of row @@ -1233,7 +1251,7 @@ namespace TrilinosWrappers * the end iterator for the * last row of a matrix. */ - const_iterator end (const unsigned int r) const; + const_iterator end (const size_type r) const; //@} /** @@ -1309,7 +1327,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcInvalidIndex, - int, int, + size_type, size_type, << "The entry with index <" << arg1 << ',' << arg2 << "> does not exist."); @@ -1322,7 +1340,7 @@ namespace TrilinosWrappers * Exception */ DeclException4 (ExcAccessToNonLocalElement, - int, int, int, int, + size_type, size_type, size_type, size_type, << "You tried to access element (" << arg1 << "/" << arg2 << ")" << " of a distributed matrix, but only rows " @@ -1333,7 +1351,7 @@ namespace TrilinosWrappers * Exception */ DeclException2 (ExcAccessToNonPresentElement, - int, int, + size_type, size_type, << "You tried to access element (" << arg1 << "/" << arg2 << ")" << " of a sparse matrix, but it appears to not" @@ -1382,8 +1400,8 @@ namespace TrilinosWrappers inline Accessor::Accessor (const SparsityPattern *sp, - const unsigned int row, - const unsigned int index) + const size_type row, + const size_type index) : sparsity_pattern(const_cast(sp)), a_row(row), @@ -1394,7 +1412,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type Accessor::row() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1404,7 +1422,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type Accessor::column() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1414,7 +1432,7 @@ namespace TrilinosWrappers inline - unsigned int + size_type Accessor::index() const { Assert (a_row < sparsity_pattern->n_rows(), ExcBeyondEndOfSparsityPattern()); @@ -1425,8 +1443,8 @@ namespace TrilinosWrappers inline Iterator::Iterator(const SparsityPattern *sp, - const unsigned int row, - const unsigned int index) + const size_type row, + const size_type index) : accessor(sp, row, index) {} @@ -1544,7 +1562,7 @@ namespace TrilinosWrappers inline SparsityPattern::const_iterator - SparsityPattern::begin(const unsigned int r) const + SparsityPattern::begin(const size_type r) const { Assert (r < n_rows(), ExcIndexRange(r, 0, n_rows())); if (row_length(r) > 0) @@ -1557,14 +1575,14 @@ namespace TrilinosWrappers inline SparsityPattern::const_iterator - SparsityPattern::end(const unsigned int r) const + SparsityPattern::end(const size_type r) const { Assert (r < n_rows(), ExcIndexRange(r, 0, n_rows())); // place the iterator on the first entry // past this line, or at the end of the // matrix - for (unsigned int i=r+1; i 0) return const_iterator(this, i, 0); @@ -1577,14 +1595,14 @@ namespace TrilinosWrappers inline bool - SparsityPattern::in_local_range (const unsigned int index) const + SparsityPattern::in_local_range (const size_type index) const { - int begin, end; + int_type begin, end; begin = graph->RowMap().MinMyGID(); end = graph->RowMap().MaxMyGID()+1; - return ((index >= static_cast(begin)) && - (index < static_cast(end))); + return ((index >= static_cast(begin)) && + (index < static_cast(end))); } @@ -1609,8 +1627,8 @@ namespace TrilinosWrappers inline void - SparsityPattern::add (const unsigned int i, - const unsigned int j) + SparsityPattern::add (const size_type i, + const size_type j) { add_entries (i, &j, &j+1); } @@ -1620,19 +1638,19 @@ namespace TrilinosWrappers template inline void - SparsityPattern::add_entries (const unsigned int row, - ForwardIterator begin, - ForwardIterator end, - const bool /*indices_are_sorted*/) + SparsityPattern::add_entries (const size_type row, + ForwardIterator begin, + ForwardIterator end, + const bool /*indices_are_sorted*/) { if (begin == end) return; - int *col_index_ptr = (int *)(&*begin); - const int n_cols = static_cast(end - begin); + int_type *col_index_ptr = (int_type *)(&*begin); + const int_type n_cols = static_cast(end - begin); compressed = false; - const int ierr = graph->InsertGlobalIndices (1, (int *)&row, + const int ierr = graph->InsertGlobalIndices (1, (int_type *)&row, n_cols, col_index_ptr); AssertThrow (ierr >= 0, ExcTrilinosError(ierr)); @@ -1695,9 +1713,9 @@ namespace TrilinosWrappers inline - SparsityPattern::SparsityPattern (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const unsigned int n_entries_per_row) + SparsityPattern::SparsityPattern (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const size_type n_entries_per_row) : compressed (false) { @@ -1711,7 +1729,7 @@ namespace TrilinosWrappers inline SparsityPattern::SparsityPattern (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : compressed (false) { @@ -1723,10 +1741,10 @@ namespace TrilinosWrappers inline - SparsityPattern::SparsityPattern (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const unsigned int n_entries_per_row) + SparsityPattern::SparsityPattern (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const size_type n_entries_per_row) : compressed (false) { @@ -1744,7 +1762,7 @@ namespace TrilinosWrappers SparsityPattern (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) : compressed (false) { @@ -1759,9 +1777,9 @@ namespace TrilinosWrappers inline void - SparsityPattern::reinit (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const unsigned int n_entries_per_row) + SparsityPattern::reinit (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const size_type n_entries_per_row) { Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator, false); @@ -1773,7 +1791,7 @@ namespace TrilinosWrappers inline void SparsityPattern::reinit (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) { Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator, false); @@ -1783,10 +1801,10 @@ namespace TrilinosWrappers inline - void SparsityPattern::reinit (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const unsigned int n_entries_per_row) + void SparsityPattern::reinit (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const size_type n_entries_per_row) { Epetra_Map row_map = row_parallel_partitioning.make_trilinos_map (communicator, false); @@ -1801,7 +1819,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 40be55fe07..4436f4542e 100644 --- a/deal.II/include/deal.II/lac/trilinos_vector.h +++ b/deal.II/include/deal.II/lac/trilinos_vector.h @@ -127,12 +127,12 @@ namespace TrilinosWrappers * @verbatim * TrilinosWrappers::Vector vector; * // do some write operations on the vector - * for (unsigned int i=0; isize(); ++i) + * for (size_type i=0; isize(); ++i) * vector(i) = i; * * // do some additions to vector elements, but * // only for some elements - * for (unsigned int i=0; isize(); ++i) + * for (size_type i=0; isize(); ++i) * if (some_condition(i) == true) * vector(i) += 1; * @@ -166,6 +166,24 @@ namespace TrilinosWrappers class Vector : public VectorBase { public: + /** + * Declare type for container size. + */ + typedef std::size_t size_type; + +#ifdef EPETRA_NO_64BIT_GLOBAL_INDICES + /** + * Declare type of integer. + */ + typedef int int_type; +#else + /** + * Declare type of integer. + */ + typedef long long int_type; +#endif + + /** * @name Basic constructors and initalization. */ @@ -510,12 +528,12 @@ namespace TrilinosWrappers has_ghosts = vector->Map().UniqueGIDs()==false; - const int size = parallel_partitioner.NumMyElements(); + const int_type size = parallel_partitioner.NumMyElements(); // Need to copy out values, since the // deal.II might not use doubles, so // that a direct access is not possible. - for (int i=0; in. */ - void reinit (const unsigned int n, - const bool fast = false); + void reinit (const size_type n, + const bool fast = false); /** * Initialization with an @@ -771,7 +811,7 @@ namespace TrilinosWrappers template Vector::Vector (const dealii::Vector &v) { - Epetra_LocalMap map ((int)v.size(), 0, Utilities::Trilinos::comm_self()); + Epetra_LocalMap map ((int_type)v.size(), 0, Utilities::Trilinos::comm_self()); vector.reset (new Epetra_FEVector(map)); *this = v; } @@ -797,13 +837,13 @@ namespace TrilinosWrappers { vector.reset(); - Epetra_LocalMap map ((int)v.size(), 0, + Epetra_LocalMap map ((int_type)v.size(), 0, Utilities::Trilinos::comm_self()); vector.reset (new Epetra_FEVector(map)); } const Epetra_Map &map = vector_partitioner(); - const int size = map.NumMyElements(); + const int_type size = map.NumMyElements(); Assert (map.MaxLID() == size-1, ExcDimensionMismatch(map.MaxLID(), size-1)); @@ -811,7 +851,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 (int i=0; in=local_size(). */ - std::pair local_range () const; + std::pair local_range () const; /** * Return whether @p index is in * the local range or not, see * also local_range(). */ - bool in_local_range (const unsigned int index) const; + bool in_local_range (const size_type index) const; /** * Return if the vector contains ghost @@ -590,7 +619,7 @@ namespace TrilinosWrappers * element, both read and write. */ reference - operator () (const unsigned int index); + operator () (const size_type index); /** * Provide read-only access to an @@ -598,7 +627,7 @@ namespace TrilinosWrappers * the el() command. */ TrilinosScalar - operator () (const unsigned int index) const; + operator () (const size_type index) const; /** * Provide access to a given @@ -607,7 +636,7 @@ namespace TrilinosWrappers * Exactly the same as operator(). */ reference - operator [] (const unsigned int index); + operator [] (const size_type index); /** * Provide read-only access to an @@ -617,7 +646,7 @@ namespace TrilinosWrappers * Exactly the same as operator(). */ TrilinosScalar - operator [] (const unsigned int index) const; + operator [] (const size_type index) const; /** * Return the value of the vector @@ -630,7 +659,7 @@ namespace TrilinosWrappers * elements sits on another * process. */ - TrilinosScalar el (const unsigned int index) const; + TrilinosScalar el (const size_type index) const; /** * A collective set operation: @@ -643,7 +672,7 @@ namespace TrilinosWrappers * argument, the corresponding * values in the second. */ - void set (const std::vector &indices, + void set (const std::vector &indices, const std::vector &values); /** @@ -653,7 +682,7 @@ namespace TrilinosWrappers * takes a deal.II vector of * values. */ - void set (const std::vector &indices, + void set (const std::vector &indices, const ::dealii::Vector &values); //@} @@ -673,8 +702,8 @@ namespace TrilinosWrappers * the number of elements to be * set. */ - void set (const unsigned int n_elements, - const unsigned int *indices, + void set (const size_type n_elements, + const size_type *indices, const TrilinosScalar *values); /** @@ -685,7 +714,7 @@ namespace TrilinosWrappers * components specified by @p * indices. */ - void add (const std::vector &indices, + void add (const std::vector &indices, const std::vector &values); /** @@ -695,7 +724,7 @@ namespace TrilinosWrappers * takes a deal.II vector of * values. */ - void add (const std::vector &indices, + void add (const std::vector &indices, const ::dealii::Vector &values); /** @@ -707,8 +736,8 @@ namespace TrilinosWrappers * other two add() * functions above. */ - void add (const unsigned int n_elements, - const unsigned int *indices, + void add (const size_type n_elements, + const size_type *indices, const TrilinosScalar *values); /** @@ -971,7 +1000,7 @@ namespace TrilinosWrappers * Exception */ DeclException3 (ExcAccessToNonlocalElement, - int, int, int, + size_type, size_type, size_type, << "You tried to access element " << arg1 << " of a distributed vector, but only entries " << arg2 << " through " << arg3 @@ -1062,8 +1091,8 @@ namespace TrilinosWrappers namespace internal { inline - VectorReference::VectorReference (VectorBase &vector, - const unsigned int index) + VectorReference::VectorReference (VectorBase &vector, + const size_t index) : vector (vector), index (index) @@ -1161,9 +1190,9 @@ namespace TrilinosWrappers inline bool - VectorBase::in_local_range (const unsigned int index) const + VectorBase::in_local_range (const size_type index) const { - std::pair range = local_range(); + std::pair range = local_range(); return ((index >= range.first) && (index < range.second)); } @@ -1181,7 +1210,7 @@ namespace TrilinosWrappers inline internal::VectorReference - VectorBase::operator () (const unsigned int index) + VectorBase::operator () (const size_type index) { return internal::VectorReference (*this, index); } @@ -1190,7 +1219,7 @@ namespace TrilinosWrappers inline internal::VectorReference - VectorBase::operator [] (const unsigned int index) + VectorBase::operator [] (const size_type index) { return operator() (index); } @@ -1198,7 +1227,7 @@ namespace TrilinosWrappers inline TrilinosScalar - VectorBase::operator [] (const unsigned int index) const + VectorBase::operator [] (const size_type index) const { return operator() (index); } @@ -1311,7 +1340,7 @@ namespace TrilinosWrappers inline void - VectorBase::set (const std::vector &indices, + VectorBase::set (const std::vector &indices, const std::vector &values) { // if we have ghost values, do not allow @@ -1328,7 +1357,7 @@ namespace TrilinosWrappers inline void - VectorBase::set (const std::vector &indices, + VectorBase::set (const std::vector &indices, const ::dealii::Vector &values) { // if we have ghost values, do not allow @@ -1345,8 +1374,8 @@ namespace TrilinosWrappers inline void - VectorBase::set (const unsigned int n_elements, - const unsigned int *indices, + VectorBase::set (const size_type n_elements, + const size_type *indices, const TrilinosScalar *values) { // if we have ghost values, do not allow @@ -1359,14 +1388,14 @@ namespace TrilinosWrappers if (last_action != Insert) last_action = Insert; - for (unsigned int i=0; iMap().LID(static_cast(row)); + const size_type row = indices[i]; + const int_type local_row = vector->Map().LID(static_cast(row)); if (local_row == -1) { const int ierr = vector->ReplaceGlobalValues (1, - (const int *)(&row), + (const int_type *)(&row), &values[i]); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); compressed = false; @@ -1380,7 +1409,7 @@ namespace TrilinosWrappers inline void - VectorBase::add (const std::vector &indices, + VectorBase::add (const std::vector &indices, const std::vector &values) { // if we have ghost values, do not allow @@ -1396,7 +1425,7 @@ namespace TrilinosWrappers inline void - VectorBase::add (const std::vector &indices, + VectorBase::add (const std::vector &indices, const ::dealii::Vector &values) { // if we have ghost values, do not allow @@ -1412,8 +1441,8 @@ namespace TrilinosWrappers inline void - VectorBase::add (const unsigned int n_elements, - const unsigned int *indices, + VectorBase::add (const size_type n_elements, + const size_type *indices, const TrilinosScalar *values) { // if we have ghost values, do not allow @@ -1427,14 +1456,14 @@ namespace TrilinosWrappers last_action = Add; } - for (unsigned int i=0; iMap().LID(static_cast(row)); + const size_type row = indices[i]; + const int_type local_row = vector->Map().LID(static_cast(row)); if (local_row == -1) { const int ierr = vector->SumIntoGlobalValues (1, - (const int *)(&row), + (const int_type *)(&row), &values[i]); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); compressed = false; @@ -1447,29 +1476,29 @@ namespace TrilinosWrappers inline - unsigned int + size_type VectorBase::size () const { - return (unsigned int) (vector->Map().MaxAllGID() + 1 - + return (size_type) (vector->Map().MaxAllGID() + 1 - vector->Map().MinAllGID()); } inline - unsigned int + size_type VectorBase::local_size () const { - return (unsigned int) vector->Map().NumMyElements(); + return (size_type) vector->Map().NumMyElements(); } inline - std::pair + std::pair VectorBase::local_range () const { - int begin, end; + int_type begin, end; begin = vector->Map().MinMyGID(); end = vector->Map().MaxMyGID()+1; return std::make_pair (begin, end); @@ -1571,11 +1600,11 @@ namespace TrilinosWrappers TrilinosScalar norm = 0; TrilinosScalar sum=0; - const unsigned int n_local = local_size(); + const size_type n_local = local_size(); // loop over all the elements because // Trilinos does not support lp norms - for (unsigned int i=0; i(1./p)); @@ -1683,8 +1712,8 @@ namespace TrilinosWrappers Assert (!has_ghost_elements(), ExcGhostsPresent()); Assert (numbers::is_finite(s), ExcNumberNotFinite()); - unsigned int n_local = local_size(); - for (unsigned int i=0; i - void add (const std::vector &indices, + void add (const std::vector &indices, const std::vector &values); /** @@ -718,8 +718,8 @@ public: * values. */ template - void add (const std::vector &indices, - const Vector &values); + void add (const std::vector &indices, + const Vector &values); /** * Take an address where @@ -731,8 +731,8 @@ public: * functions above. */ template - void add (const unsigned int n_elements, - const unsigned int *indices, + void add (const size_type n_elements, + const size_type *indices, const OtherNumber *values); /** @@ -998,7 +998,7 @@ public: * memory consumption (in bytes) * of this object. */ - std::size_t memory_consumption () const; + size_type memory_consumption () const; //@} /** @@ -1025,7 +1025,7 @@ protected: * vector. Get this number by * calling size(). */ - unsigned int vec_size; + size_type vec_size; /** * Amount of memory actually @@ -1039,7 +1039,7 @@ protected: * memory when the number of * needed elements is reduced. */ - unsigned int max_vec_size; + size_type max_vec_size; /** * Pointer to the array of @@ -1103,7 +1103,7 @@ Vector::Vector (const InputIterator first, const InputIterator last) template inline -Vector::Vector (const unsigned int n) +Vector::Vector (const size_type n) : vec_size(0), max_vec_size(0), @@ -1129,7 +1129,7 @@ Vector::~Vector () template inline -void Vector::reinit (const unsigned int n, const bool fast) +void Vector::reinit (const size_type n, const bool fast) { if (n==0) { @@ -1191,7 +1191,7 @@ Vector::operator = (const Vector &v) template inline -unsigned int Vector::size () const +size_type Vector::size () const { return vec_size; } @@ -1249,7 +1249,7 @@ Vector::end () const template inline -Number Vector::operator() (const unsigned int i) const +Number Vector::operator() (const size_type i) const { Assert (i::operator() (const unsigned int i) const template inline -Number &Vector::operator() (const unsigned int i) +Number &Vector::operator() (const size_type i) { Assert (i::operator() (const unsigned int i) template inline -Number Vector::operator[] (const unsigned int i) const +Number Vector::operator[] (const size_type i) const { return operator()(i); } @@ -1278,7 +1278,7 @@ Number Vector::operator[] (const unsigned int i) const template inline -Number &Vector::operator[] (const unsigned int i) +Number &Vector::operator[] (const size_type i) { return operator()(i); } @@ -1303,7 +1303,7 @@ template template inline void -Vector::add (const std::vector &indices, +Vector::add (const std::vector &indices, const std::vector &values) { Assert (indices.size() == values.size(), @@ -1317,8 +1317,8 @@ template template inline void -Vector::add (const std::vector &indices, - const Vector &values) +Vector::add (const std::vector &indices, + const Vector &values) { Assert (indices.size() == values.size(), ExcDimensionMismatch(indices.size(), values.size())); @@ -1331,11 +1331,11 @@ template template inline void -Vector::add (const unsigned int n_indices, - const unsigned int *indices, +Vector::add (const size_type n_indices, + const size_type *indices, const OtherNumber *values) { - for (unsigned int i=0; i::all_zero () const { Assert (vec_size!=0, ExcEmptyObject()); - for (unsigned int i=0; i::is_non_negative () const { Assert (vec_size!=0, ExcEmptyObject()); - for (unsigned int i=0; i void set_subrange (const T s, - const unsigned int begin, - const unsigned int end, + const size_type begin, + const size_type end, dealii::Vector &dst) { if (s == T()) @@ -335,8 +335,8 @@ namespace internal } template - void copy_subrange (const unsigned int begin, - const unsigned int end, + void copy_subrange (const size_type begin, + const size_type end, const dealii::Vector &src, dealii::Vector &dst) { @@ -345,8 +345,8 @@ namespace internal } template - void copy_subrange (const unsigned int begin, - const unsigned int end, + void copy_subrange (const size_type begin, + const size_type end, const dealii::Vector &src, dealii::Vector &dst) { @@ -358,8 +358,8 @@ namespace internal } template - void copy_subrange_wrap (const unsigned int begin, - const unsigned int end, + void copy_subrange_wrap (const size_type begin, + const size_type end, const dealii::Vector &src, dealii::Vector &dst) { @@ -370,8 +370,8 @@ namespace internal void copy_vector (const dealii::Vector &src, dealii::Vector &dst) { - const unsigned int vec_size = src.size(); - const unsigned int dst_size = dst.size(); + const size_type vec_size = src.size(); + const size_type dst_size = dst.size(); if (dst_size != vec_size) dst.reinit (vec_size, true); if (vec_size>internal::Vector::minimum_parallel_grain_size) @@ -573,7 +573,7 @@ namespace internal const Number *X, const Number2 *Y, const ResultType power, - const unsigned int vec_size, + const size_type vec_size, ResultType &result) { if (vec_size <= 4096) @@ -583,24 +583,24 @@ namespace internal // order to obtain known loop bounds for most of the work. const Number *X_original = X; ResultType outer_results [128]; - unsigned int n_chunks = vec_size / 32; - const unsigned int remainder = vec_size % 32; + size_type n_chunks = vec_size / 32; + const size_type remainder = vec_size % 32; Assert (remainder == 0 || n_chunks < 128, ExcInternalError()); - for (unsigned int i=0; i 0) { - const unsigned int inner_chunks = remainder / 8; + const size_type inner_chunks = remainder / 8; Assert (inner_chunks <= 3, ExcInternalError()); - const unsigned int remainder_inner = remainder % 8; + const size_type remainder_inner = remainder % 8; ResultType r0 = ResultType(), r1 = ResultType(), r2 = ResultType(); switch (inner_chunks) { case 3: r2 = op(X, Y, power); - for (unsigned int j=1; j<8; ++j) + for (size_type j=1; j<8; ++j) r2 += op(X, Y, power); // no break case 2: r1 = op(X, Y, power); - for (unsigned int j=1; j<8; ++j) + for (size_type j=1; j<8; ++j) r1 += op(X, Y, power); r1 += r2; // no break case 1: r2 = op(X, Y, power); - for (unsigned int j=1; j<8; ++j) + for (size_type j=1; j<8; ++j) r2 += op(X, Y, power); // no break default: - for (unsigned int j=0; j task_group; task_group += Threads::new_task(&accumulate::l2_norm () const { real_type scale = 0.; real_type sum = 1.; - for (unsigned int i=0; i::lp_norm (const real_type p) const { real_type scale = 0.; real_type sum = 1.; - for (unsigned int i=0; i::linfty_norm () const real_type max = 0.; - for (unsigned int i=0; i::abs(val[i]), max); return max; @@ -900,7 +900,7 @@ Vector &Vector::operator -= (const Vector &v) (boost::lambda::_1 - boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::add (const Number v) (boost::lambda::_1 + v), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::add (const Vector &v) (boost::lambda::_1 + boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::add (const Number a, const Vector &v, (boost::lambda::_1 + a*boost::lambda::_2 + b*boost::lambda::_3), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::sadd (const Number x, (x*boost::lambda::_1 + boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::sadd (const Number x, const Number a, (x*boost::lambda::_1 + a*boost::lambda::_2 + b*boost::lambda::_3), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::scale (const Vector &s) (boost::lambda::_1*boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::scale (const Vector &s) Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == s.vec_size, ExcDimensionMismatch(vec_size, s.vec_size)); - for (unsigned int i=0; i::equ (const Number a, (a*boost::lambda::_1), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::equ (const Number a, // because // operator*(complex,complex) // is not defined by default - for (unsigned int i=0; i::equ (const Number a, const Vector &u, (a*boost::lambda::_1 + b*boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::equ (const Number a, const Vector &u, (a*boost::lambda::_1 + b*boost::lambda::_2 + c*boost::lambda::_3), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::ratio (const Vector &a, (boost::lambda::_1 / boost::lambda::_2), internal::Vector::minimum_parallel_grain_size); else if (vec_size > 0) - for (unsigned int i=0; i::operator = (const BlockVector &v) if (v.size() != vec_size) reinit (v.size(), true); - unsigned int this_index = 0; - for (unsigned int b=0; b::operator == (const Vector &v) const // because // operator==(complex,complex) // is not defined by default - for (unsigned int i=0; i::print (const char *format) const { Assert (vec_size!=0, ExcEmptyObject()); - for (unsigned int j=0; j::print (std::ostream &out, out.setf (std::ios::fixed, std::ios::floatfield); if (across) - for (unsigned int i=0; i::print (LogStream &out, const unsigned int width, const bool acro Assert (vec_size!=0, ExcEmptyObject()); if (across) - for (unsigned int i=0; i::block_write (std::ostream &out) const // some resources that lead to // problems in a multithreaded // environment - const unsigned int sz = size(); + const size_type sz = size(); char buf[16]; std::sprintf(buf, "%d", sz); @@ -1403,7 +1403,7 @@ void Vector::block_read (std::istream &in) { AssertThrow (in, ExcIO()); - unsigned int sz; + size_type sz; char buf[16]; @@ -1432,7 +1432,7 @@ void Vector::block_read (std::istream &in) template -std::size_t +size_type Vector::memory_consumption () const { return sizeof(*this) + (max_vec_size * sizeof(Number)); diff --git a/deal.II/include/deal.II/lac/vector_memory.h b/deal.II/include/deal.II/lac/vector_memory.h index a5f35ac422..c61e34c3aa 100644 --- a/deal.II/include/deal.II/lac/vector_memory.h +++ b/deal.II/include/deal.II/lac/vector_memory.h @@ -253,13 +253,18 @@ template > class GrowingVectorMemory : public VectorMemory { public: + /** + * Declare type for container size. + */ + typedef std::size_t size_type; + /** * Constructor. The argument * allows to preallocate a * certain number of vectors. The * default is not to do this. */ - GrowingVectorMemory (const unsigned int initial_size = 0, + GrowingVectorMemory (const size_type initial_size = 0, const bool log_statistics = false); /** @@ -356,7 +361,7 @@ private: * nothing after first * initialization */ - void initialize(const unsigned int size); + void initialize(const size_type size); /** * Pointer to the storage * object @@ -376,13 +381,13 @@ private: * output at the end of an * object's lifetime. */ - unsigned int total_alloc; + size_type total_alloc; /** * Number of vectors currently * allocated in this object; used * for detecting memory leaks. */ - unsigned int current_alloc; + size_type current_alloc; /** * A flag controlling the logging diff --git a/deal.II/include/deal.II/lac/vector_view.h b/deal.II/include/deal.II/lac/vector_view.h index 7c875227cd..e5d6308c1f 100644 --- a/deal.II/include/deal.II/lac/vector_view.h +++ b/deal.II/include/deal.II/lac/vector_view.h @@ -132,6 +132,12 @@ template class VectorView : public Vector { public: + + /** + * Declare type for container size. + */ + typedef std::size_t int size_type; + /** * Read write constructor. Takes the size * of the vector, just like the standard @@ -139,7 +145,7 @@ public: * from the location of the pointer @p * ptr. */ - VectorView(const unsigned int new_size, Number *ptr); + VectorView(const size_type new_size, Number *ptr); /** * The constant constructor is the same @@ -154,7 +160,7 @@ public: * construct it as a non const object or * attempt to write on it. */ - VectorView(const unsigned int new_size, const Number *ptr); + VectorView(const size_type new_size, const Number *ptr); /** * This desctructor will only reset the @@ -221,7 +227,7 @@ public: * call this reinit function if you * really know what you are doing. */ - virtual void reinit (const unsigned int N, + virtual void reinit (const size_type N, const bool fast=false); /** This reinit function is @@ -229,7 +235,7 @@ public: new object with the given size, starting from the pointer ptr. */ - void reinit(const unsigned int N, Number *ptr); + void reinit(const size_type N, Number *ptr); /** This reinit function is equivalent to constructing a @@ -238,7 +244,7 @@ public: pointer ptr. The same considerations made for the constructor apply here. */ - void reinit(const unsigned int N, const Number *ptr); + void reinit(const size_type N, const Number *ptr); /** * This function is here to prevent @@ -257,7 +263,7 @@ public: template inline -VectorView::VectorView(const unsigned int new_size, Number *ptr) +VectorView::VectorView(const size_type new_size, Number *ptr) { this->vec_size = new_size; this->max_vec_size = new_size; @@ -268,7 +274,7 @@ VectorView::VectorView(const unsigned int new_size, Number *ptr) template inline -VectorView::VectorView(const unsigned int new_size, const Number *ptr) +VectorView::VectorView(const size_type new_size, const Number *ptr) { this->vec_size = new_size; this->max_vec_size = new_size; @@ -291,7 +297,7 @@ VectorView::~VectorView() template inline -void VectorView::reinit(const unsigned int N, const bool fast) +void VectorView::reinit(const size_type N, const bool fast) { this->vec_size = N; this->max_vec_size = N; @@ -302,7 +308,7 @@ void VectorView::reinit(const unsigned int N, const bool fast) template inline -void VectorView::reinit(const unsigned int new_size, Number *ptr) +void VectorView::reinit(const size_type new_size, Number *ptr) { this->vec_size = new_size; this->max_vec_size = new_size; @@ -312,7 +318,7 @@ void VectorView::reinit(const unsigned int new_size, Number *ptr) template inline -void VectorView::reinit(const unsigned int new_size, const Number *ptr) +void VectorView::reinit(const size_type new_size, const Number *ptr) { this->vec_size = new_size; this->max_vec_size = new_size; diff --git a/deal.II/source/lac/tridiagonal_matrix.cc b/deal.II/source/lac/tridiagonal_matrix.cc index 26531826da..33d968845d 100644 --- a/deal.II/source/lac/tridiagonal_matrix.cc +++ b/deal.II/source/lac/tridiagonal_matrix.cc @@ -21,7 +21,7 @@ using namespace LAPACKSupport; template TridiagonalMatrix::TridiagonalMatrix( - unsigned int size, + size_type size, bool symmetric) : diagonal(size, 0.), @@ -35,7 +35,7 @@ TridiagonalMatrix::TridiagonalMatrix( template void TridiagonalMatrix::reinit( - unsigned int size, + size_type size, bool symmetric) { is_symmetric = symmetric; @@ -86,7 +86,7 @@ TridiagonalMatrix::vmult ( // The actual loop skips the first // and last row - const unsigned int e=n()-1; + const size_type e=n()-1; // Let iterators point to the first // entry of each diagonal typename std::vector::const_iterator d = diagonal.begin(); @@ -107,7 +107,7 @@ TridiagonalMatrix::vmult ( ++d; ++r; // All rows with three entries - for (unsigned int i=1; i::vmult ( w(0) = (*d) * v(0) + (*r) * v(1); ++d; ++r; - for (unsigned int i=1; i::Tvmult ( if (n()==0) return; - const unsigned int e=n()-1; + const size_type e=n()-1; typename std::vector::const_iterator d = diagonal.begin(); typename std::vector::const_iterator r = right.begin(); typename std::vector::const_iterator l = left.begin(); @@ -162,7 +162,7 @@ TridiagonalMatrix::Tvmult ( w(0) += (*d) * v(0) + (*l) * v(1); ++d; ++l; - for (unsigned int i=1; i::Tvmult ( w(0) = (*d) * v(0) + (*l) * v(1); ++d; ++l; - for (unsigned int i=1; i::matrix_scalar_product( { Assert(state == matrix, ExcState(state)); - const unsigned int e=n()-1; + const size_type e=n()-1; typename std::vector::const_iterator d = diagonal.begin(); typename std::vector::const_iterator r = right.begin(); typename std::vector::const_iterator l = left.begin(); @@ -208,7 +208,7 @@ TridiagonalMatrix::matrix_scalar_product( number result = w(0) * ((*d) * v(0) + (*r) * v(1)); ++d; ++r; - for (unsigned int i=1; i::compute_eigenvalues() template number -TridiagonalMatrix::eigenvalue(const unsigned int i) const +TridiagonalMatrix::eigenvalue(const size_type i) const { Assert(state == eigenvalues, ExcState(state)); Assert(icolumn_block_indices.reinit (n_block_columns, 0); // and reinitialize the blocks - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) + for (size_type r=0; rn_block_rows(); ++r) + for (size_type c=0; cn_block_cols(); ++c) { BlockType *p = new BlockType(); @@ -91,7 +91,7 @@ namespace TrilinosWrappers ExcDimensionMismatch (parallel_partitioning.size(), block_sparsity_pattern.n_block_cols())); - const unsigned int n_block_rows = parallel_partitioning.size(); + const size_type n_block_rows = parallel_partitioning.size(); Assert (n_block_rows == block_sparsity_pattern.n_block_rows(), ExcDimensionMismatch (n_block_rows, @@ -111,8 +111,8 @@ namespace TrilinosWrappers // ... and then assign the correct // data to the blocks. - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) + for (size_type r=0; rn_block_rows(); ++r) + for (size_type c=0; cn_block_cols(); ++c) { this->sub_objects[r][c]->reinit (parallel_partitioning[r], parallel_partitioning[c], @@ -130,7 +130,7 @@ namespace TrilinosWrappers const MPI_Comm &communicator) { std::vector epetra_maps; - for (unsigned int i=0; i parallel_partitioning; - for (unsigned int i=0; i(block_sparsity_pattern.block(i,0).n_rows()), + (Epetra_Map(static_cast(block_sparsity_pattern.block(i,0).n_rows()), 0, Utilities::Trilinos::comm_self())); @@ -173,8 +173,8 @@ namespace TrilinosWrappers // ... and then assign the correct // data to the blocks. - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) + for (size_type r=0; rn_block_rows(); ++r) + for (size_type c=0; cn_block_cols(); ++c) { this->sub_objects[r][c]->reinit (block_sparsity_pattern.block(r,c)); } @@ -188,7 +188,7 @@ namespace TrilinosWrappers const ::dealii::BlockSparseMatrix &dealii_block_sparse_matrix, const double drop_tolerance) { - const unsigned int n_block_rows = parallel_partitioning.size(); + const size_type n_block_rows = parallel_partitioning.size(); Assert (n_block_rows == dealii_block_sparse_matrix.n_block_rows(), ExcDimensionMismatch (n_block_rows, @@ -202,8 +202,8 @@ namespace TrilinosWrappers // ... and then assign the correct // data to the blocks. - for (unsigned int r=0; rn_block_rows(); ++r) - for (unsigned int c=0; cn_block_cols(); ++c) + for (size_type r=0; rn_block_rows(); ++r) + for (size_type c=0; cn_block_cols(); ++c) { this->sub_objects[r][c]->reinit(parallel_partitioning[r], parallel_partitioning[c], @@ -239,8 +239,8 @@ namespace TrilinosWrappers #endif std::vector parallel_partitioning; - for (unsigned int i=0; i(dealii_block_sparse_matrix.block(i,0).m()), + for (size_type i=0; i(dealii_block_sparse_matrix.block(i,0).m()), 0, trilinos_communicator)); @@ -260,12 +260,12 @@ namespace TrilinosWrappers - unsigned int + size_type BlockSparseMatrix::n_nonzero_elements () const { - unsigned int n_nonzero = 0; - for (unsigned int rows = 0; rowsn_block_rows(); ++rows) - for (unsigned int cols = 0; colsn_block_cols(); ++cols) + size_type n_nonzero = 0; + for (size_type rows = 0; rowsn_block_rows(); ++rows) + for (size_type cols = 0; colsn_block_cols(); ++cols) n_nonzero += this->block(rows,cols).n_nonzero_elements(); return n_nonzero; diff --git a/deal.II/source/lac/trilinos_block_vector.cc b/deal.II/source/lac/trilinos_block_vector.cc index 46e2db16cd..754460ddfa 100644 --- a/deal.II/source/lac/trilinos_block_vector.cc +++ b/deal.II/source/lac/trilinos_block_vector.cc @@ -33,14 +33,14 @@ namespace TrilinosWrappers } - + BlockVector & BlockVector::operator = (const BlockVector &v) { if (this->n_blocks() != v.n_blocks()) reinit(v.n_blocks()); - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.block(i); collect_sizes(); @@ -56,7 +56,7 @@ namespace TrilinosWrappers Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(),v.n_blocks())); - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.block(i); return *this; @@ -73,10 +73,10 @@ namespace TrilinosWrappers BlockVector::reinit (const std::vector &input_maps, const bool fast) { - const unsigned int no_blocks = input_maps.size(); - std::vector block_sizes (no_blocks); + const size_type no_blocks = input_maps.size(); + std::vector block_sizes (no_blocks); - for (unsigned int i=0; i block_sizes (no_blocks); + const size_type no_blocks = parallel_partitioning.size(); + std::vector block_sizes (no_blocks); - for (unsigned int i=0; i block_sizes (num_blocks, 0); + std::vector block_sizes (num_blocks, 0); this->block_indices.reinit (block_sizes); if (this->components.size() != this->n_blocks()) this->components.resize(this->n_blocks()); - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) components[i].clear(); collect_sizes(); @@ -166,7 +166,7 @@ namespace TrilinosWrappers components.resize(v.n_blocks()); } - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) components[i].import_nonlocal_data_for_fe(m.block(i,i), v.block(i)); collect_sizes(); @@ -179,7 +179,7 @@ namespace TrilinosWrappers const bool scientific, const bool across) const { - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) { if (across) out << 'C' << i << ':'; @@ -209,10 +209,10 @@ namespace TrilinosWrappers BlockVector::reinit (const std::vector &input_maps, const bool fast) { - unsigned int no_blocks = input_maps.size(); - std::vector block_sizes (no_blocks); + size_type no_blocks = input_maps.size(); + std::vector block_sizes (no_blocks); - for (unsigned int i=0; i block_sizes (no_blocks); + size_type no_blocks = partitioning.size(); + std::vector block_sizes (no_blocks); - for (unsigned int i=0; i &block_sizes, - const bool fast) + BlockVector::reinit (const std::vector &block_sizes, + const bool fast) { this->block_indices.reinit (block_sizes); if (components.size() != n_blocks()) components.resize(n_blocks()); - for (unsigned int i=0; i block_sizes (num_blocks, 0); + std::vector block_sizes (num_blocks, 0); block_indices.reinit (block_sizes); if (components.size() != n_blocks()) components.resize(n_blocks()); - for (unsigned int i=0; i block_sizes (v.n_blocks(), 0); + std::vector block_sizes (v.n_blocks(), 0); block_indices.reinit (block_sizes); if (components.size() != n_blocks()) components.resize(n_blocks()); } - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) this->components[i] = v.block(i); collect_sizes(); @@ -349,7 +349,7 @@ namespace TrilinosWrappers const bool scientific, const bool across) const { - for (unsigned int i=0; in_blocks(); ++i) + for (size_type i=0; in_blocks(); ++i) { if (across) out << 'C' << i << ':'; diff --git a/deal.II/source/lac/trilinos_precondition.cc b/deal.II/source/lac/trilinos_precondition.cc index 15d34d5d4b..8f5afe056b 100644 --- a/deal.II/source/lac/trilinos_precondition.cc +++ b/deal.II/source/lac/trilinos_precondition.cc @@ -509,7 +509,7 @@ namespace TrilinosWrappers PreconditionAMG:: initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - const unsigned int n_rows = matrix.m(); + const size_type n_rows = matrix.m(); // Build the AMG preconditioner. Teuchos::ParameterList parameter_list; @@ -574,7 +574,7 @@ namespace TrilinosWrappers const Epetra_Map &domain_map = matrix.domain_partitioner(); - const unsigned int constant_modes_dimension = + const size_type constant_modes_dimension = additional_data.constant_modes.size(); Epetra_MultiVector distributed_constant_modes (domain_map, constant_modes_dimension); @@ -584,14 +584,14 @@ namespace TrilinosWrappers { const bool constant_modes_are_global = additional_data.constant_modes[0].size() == n_rows; - const unsigned int n_relevant_rows = + const size_type n_relevant_rows = constant_modes_are_global ? n_rows : additional_data.constant_modes[0].size(); - const unsigned int my_size = domain_map.NumMyElements(); + const size_type my_size = domain_map.NumMyElements(); if (constant_modes_are_global == false) Assert (n_relevant_rows == my_size, ExcDimensionMismatch(n_relevant_rows, my_size)); Assert (n_rows == - static_cast(distributed_constant_modes.GlobalLength()), + static_cast(distributed_constant_modes.GlobalLength()), ExcDimensionMismatch(n_rows, distributed_constant_modes.GlobalLength())); @@ -599,10 +599,10 @@ namespace TrilinosWrappers // contiguous vector of // doubles so that Trilinos // can read from it. - for (unsigned int d=0; d(n_rows), 0, communicator)); + vector_distributor.reset (new Epetra_Map(static_cast(n_rows), 0, communicator)); if (trilinos_matrix.get() == 0) trilinos_matrix.reset (new SparseMatrix()); @@ -693,7 +693,7 @@ namespace TrilinosWrappers - std::size_t + 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 5442c86c27..601b4bfab5 100644 --- a/deal.II/source/lac/trilinos_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_sparse_matrix.cc @@ -54,12 +54,12 @@ namespace TrilinosWrappers // get a representation of the present // row - int ncols; - int colnums = matrix->n(); + int_type ncols; + int_type colnums = matrix->n(); if (value_cache.get() == 0) { value_cache.reset (new std::vector (matrix->n())); - colnum_cache.reset (new std::vector (matrix->n())); + colnum_cache.reset (new std::vector (matrix->n())); } else { @@ -68,10 +68,10 @@ namespace TrilinosWrappers } int ierr = matrix->trilinos_matrix(). - ExtractGlobalRowCopy((int)this->a_row, + ExtractGlobalRowCopy((int_type)this->a_row, colnums, ncols, &((*value_cache)[0]), - reinterpret_cast(&((*colnum_cache)[0]))); + reinterpret_cast(&((*colnum_cache)[0]))); value_cache->resize (ncols); colnum_cache->resize (ncols); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); @@ -112,11 +112,11 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_map, - const unsigned int n_max_entries_per_row) + const size_type n_max_entries_per_row) : column_space_map (new Epetra_Map (input_map)), matrix (new Epetra_FECrsMatrix(Copy, *column_space_map, - int(n_max_entries_per_row), false)), + int_type(n_max_entries_per_row), false)), last_action (Zero), compressed (false) {} @@ -124,12 +124,12 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map (input_map)), matrix (new Epetra_FECrsMatrix (Copy, *column_space_map, - (int *)const_cast(&(n_entries_per_row[0])), + (int_type *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -139,11 +139,11 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const unsigned int n_max_entries_per_row) + const size_type n_max_entries_per_row) : column_space_map (new Epetra_Map (input_col_map)), matrix (new Epetra_FECrsMatrix(Copy, input_row_map, - int(n_max_entries_per_row), false)), + int_type(n_max_entries_per_row), false)), last_action (Zero), compressed (false) {} @@ -152,11 +152,11 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map (input_col_map)), matrix (new Epetra_FECrsMatrix(Copy, input_row_map, - (int *)const_cast(&(n_entries_per_row[0])), + (int_type *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -164,11 +164,11 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const unsigned int m, - const unsigned int n, - const unsigned int n_max_entries_per_row) + SparseMatrix::SparseMatrix (const size_type m, + const size_type n, + const size_type n_max_entries_per_row) : - column_space_map (new Epetra_Map (static_cast(n), 0, + column_space_map (new Epetra_Map (static_cast(n), 0, Utilities::Trilinos::comm_self())), // on one processor only, we know how the @@ -180,7 +180,7 @@ namespace TrilinosWrappers // information from columns is only // available when entries have been added matrix (new Epetra_FECrsMatrix(Copy, - Epetra_Map (static_cast(m), 0, + Epetra_Map (static_cast(m), 0, Utilities::Trilinos::comm_self()), *column_space_map, n_max_entries_per_row, @@ -191,17 +191,17 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row) + SparseMatrix::SparseMatrix (const size_type m, + const size_type n, + const std::vector &n_entries_per_row) : - column_space_map (new Epetra_Map (static_cast(n), 0, + column_space_map (new Epetra_Map (static_cast(n), 0, Utilities::Trilinos::comm_self())), matrix (new Epetra_FECrsMatrix(Copy, - Epetra_Map (static_cast(m), 0, + Epetra_Map (static_cast(m), 0, Utilities::Trilinos::comm_self()), *column_space_map, - (int *)const_cast(&(n_entries_per_row[0])), + (int_type *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -211,7 +211,7 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const unsigned int n_max_entries_per_row) + const size_type n_max_entries_per_row) : column_space_map (new Epetra_Map(parallel_partitioning. make_trilinos_map(communicator, false))), @@ -227,13 +227,13 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map(parallel_partitioning. make_trilinos_map(communicator, false))), matrix (new Epetra_FECrsMatrix(Copy, *column_space_map, - (int *)const_cast(&(n_entries_per_row[0])), + (int_type *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -241,10 +241,10 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const unsigned int n_max_entries_per_row) + SparseMatrix::SparseMatrix (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const size_type n_max_entries_per_row) : column_space_map (new Epetra_Map(col_parallel_partitioning. make_trilinos_map(communicator, false))), @@ -262,14 +262,14 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (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) : column_space_map (new Epetra_Map(col_parallel_partitioning. make_trilinos_map(communicator, false))), matrix (new Epetra_FECrsMatrix(Copy, row_parallel_partitioning. make_trilinos_map(communicator, false), - (int *)const_cast(&(n_entries_per_row[0])), + (int_type *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -338,10 +338,10 @@ namespace TrilinosWrappers void SparseMatrix::reinit (const SparsityType &sparsity_pattern) { - const Epetra_Map rows (static_cast(sparsity_pattern.n_rows()), + const Epetra_Map rows (static_cast(sparsity_pattern.n_rows()), 0, Utilities::Trilinos::comm_self()); - const Epetra_Map columns (static_cast(sparsity_pattern.n_cols()), + const Epetra_Map columns (static_cast(sparsity_pattern.n_cols()), 0, Utilities::Trilinos::comm_self()); @@ -394,18 +394,18 @@ namespace TrilinosWrappers if (input_row_map.Comm().MyPID() == 0) { AssertDimension (sparsity_pattern.n_rows(), - static_cast(input_row_map.NumGlobalElements())); + static_cast(input_row_map.NumGlobalElements())); AssertDimension (sparsity_pattern.n_cols(), - static_cast(input_col_map.NumGlobalElements())); + static_cast(input_col_map.NumGlobalElements())); } column_space_map.reset (new Epetra_Map (input_col_map)); - const unsigned int first_row = input_row_map.MinMyGID(), + const size_t 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 (unsigned int row=first_row; row row_indices; + std::vector row_indices; - for (unsigned int row=first_row; rowEpetra_CrsGraph::InsertGlobalIndices (row, row_length, @@ -474,7 +474,7 @@ namespace TrilinosWrappers // check whether we got the number of // columns right. AssertDimension (sparsity_pattern.n_cols(), - static_cast(graph->NumGlobalCols())); + static_cast(graph->NumGlobalCols())); // And now finally generate the matrix. matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false)); @@ -526,10 +526,10 @@ namespace TrilinosWrappers const bool copy_values, const ::dealii::SparsityPattern *use_this_sparsity) { - const Epetra_Map rows (static_cast(dealii_sparse_matrix.m()), + const Epetra_Map rows (static_cast(dealii_sparse_matrix.m()), 0, Utilities::Trilinos::comm_self()); - const Epetra_Map columns (static_cast(dealii_sparse_matrix.n()), + const Epetra_Map columns (static_cast(dealii_sparse_matrix.n()), 0, Utilities::Trilinos::comm_self()); reinit (rows, columns, dealii_sparse_matrix, drop_tolerance, @@ -574,12 +574,12 @@ namespace TrilinosWrappers return; } - const unsigned int n_rows = dealii_sparse_matrix.m(); + const size_type n_rows = dealii_sparse_matrix.m(); - Assert (input_row_map.NumGlobalElements() == (int)n_rows, + Assert (input_row_map.NumGlobalElements() == (int_type)n_rows, ExcDimensionMismatch (input_row_map.NumGlobalElements(), n_rows)); - Assert (input_col_map.NumGlobalElements() == (int)dealii_sparse_matrix.n(), + Assert (input_col_map.NumGlobalElements() == (int_type)dealii_sparse_matrix.n(), ExcDimensionMismatch (input_col_map.NumGlobalElements(), dealii_sparse_matrix.n())); @@ -601,19 +601,19 @@ namespace TrilinosWrappers // and the specified sparsity pattern might be different, need to go // through the row for both these sparsity structures simultaneously in // order to really set the correct values. - unsigned int maximum_row_length = matrix->MaxNumEntries(); - std::vector row_indices (maximum_row_length); + size_type maximum_row_length = matrix->MaxNumEntries(); + std::vector row_indices (maximum_row_length); std::vector values (maximum_row_length); - for (unsigned int row=0; row(row)) == true) + if (input_row_map.MyGID(static_cast(row)) == true) { ::dealii::SparsityPattern::iterator select_index = sparsity_pattern.begin(row); typename ::dealii::SparseMatrix::const_iterator it = dealii_sparse_matrix.begin(row); - unsigned int col = 0; + size_type col = 0; if (sparsity_pattern.n_rows() == sparsity_pattern.n_cols()) { // optimized diagonal @@ -647,7 +647,7 @@ namespace TrilinosWrappers ++select_index; ++it; } - set (row, col, reinterpret_cast(&row_indices[0]), + set (row, col, reinterpret_cast(&row_indices[0]), &values[0], false); } @@ -679,7 +679,7 @@ namespace TrilinosWrappers // matrices and copy the content const TrilinosScalar *in_values = input_matrix[0]; TrilinosScalar *values = (*matrix)[0]; - const unsigned int my_nonzeros = input_matrix.NumMyNonzeros(); + const size_type my_nonzeros = input_matrix.NumMyNonzeros(); std::memcpy (&values[0], &in_values[0], my_nonzeros*sizeof (TrilinosScalar)); } @@ -708,30 +708,30 @@ namespace TrilinosWrappers void - SparseMatrix::clear_row (const unsigned int row, + SparseMatrix::clear_row (const size_type row, const TrilinosScalar new_diag_value) { Assert (matrix->Filled()==true, ExcMatrixNotCompressed()); // Only do this on the rows owned // locally on this processor. - int local_row = matrix->LRID(static_cast(row)); + int_map local_row = matrix->LRID(static_cast(row)); if (local_row >= 0) { TrilinosScalar *values; - int *col_indices; - int num_entries; + int_map *col_indices; + int_map num_entries; const int ierr = matrix->ExtractMyRowView(local_row, num_entries, values, col_indices); Assert (ierr == 0, ExcTrilinosError(ierr)); - int *diag_find = std::find(col_indices,col_indices+num_entries, + int_map *diag_find = std::find(col_indices,col_indices+num_entries, local_row); - int diag_index = (int)(diag_find - col_indices); + int_map diag_index = (int_map)(diag_find - col_indices); - for (int j=0; j &rows, - const TrilinosScalar new_diag_value) + SparseMatrix::clear_rows (const std::vector &rows, + const TrilinosScalar new_diag_value) { compress(); - for (unsigned int row=0; rowLRID(static_cast(i)), - trilinos_j = matrix->LCID(static_cast(j)); + int_type trilinos_i = matrix->LRID(static_cast(i)), + trilinos_j = matrix->LCID(static_cast(j)); TrilinosScalar value = 0.; // If the data is not on the @@ -791,9 +791,9 @@ namespace TrilinosWrappers // Prepare pointers for extraction // of a view of the row. - int nnz_present = matrix->NumMyEntries(trilinos_i); - int nnz_extracted; - int *col_indices; + int_type nnz_present = matrix->NumMyEntries(trilinos_i); + int_type nnz_extracted; + int_type *col_indices; TrilinosScalar *values; // Generate the view and make @@ -810,10 +810,10 @@ namespace TrilinosWrappers // look for the value, and then // finally get it. - int *el_find = std::find(col_indices, col_indices + nnz_present, + int_type *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - int local_col_index = (int)(el_find - col_indices); + int_type local_col_index = (int_type)(el_find - col_indices); // This is actually the only // difference to the el(i,j) @@ -837,12 +837,12 @@ namespace TrilinosWrappers TrilinosScalar - SparseMatrix::el (const unsigned int i, - const unsigned int j) const + SparseMatrix::el (const size_type i, + const size_type j) const { // Extract local indices in // the matrix. - int trilinos_i = matrix->LRID(static_cast(i)), trilinos_j = matrix->LCID(static_cast(j)); + int_type trilinos_i = matrix->LRID(static_cast(i)), trilinos_j = matrix->LCID(static_cast(j)); TrilinosScalar value = 0.; // If the data is not on the @@ -863,9 +863,9 @@ namespace TrilinosWrappers // Prepare pointers for extraction // of a view of the row. - int nnz_present = matrix->NumMyEntries(trilinos_i); - int nnz_extracted; - int *col_indices; + int_type nnz_present = matrix->NumMyEntries(trilinos_i); + int_type nnz_extracted; + int_type *col_indices; TrilinosScalar *values; // Generate the view and make @@ -881,10 +881,10 @@ namespace TrilinosWrappers // Search the index where we // look for the value, and then // finally get it. - int *el_find = std::find(col_indices, col_indices + nnz_present, + int_type *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - int local_col_index = (int)(el_find - col_indices); + int_type local_col_index = (int_type)(el_find - col_indices); // This is actually the only @@ -906,7 +906,7 @@ namespace TrilinosWrappers TrilinosScalar - SparseMatrix::diag_element (const unsigned int i) const + SparseMatrix::diag_element (const size_type i) const { Assert (m() == n(), ExcNotQuadratic()); @@ -926,15 +926,15 @@ namespace TrilinosWrappers - unsigned int - SparseMatrix::row_length (const unsigned int row) const + size_type + SparseMatrix::row_length (const size_type row) const { Assert (row < m(), ExcInternalError()); // get a representation of the // present row - int ncols = -1; - int local_row = matrix->LRID(static_cast(row)); + int_type ncols = -1; + int_type local_row = matrix->LRID(static_cast(row)); // on the processor who owns this // row, we'll have a non-negative @@ -1000,15 +1000,15 @@ namespace TrilinosWrappers ExcMessage ("Parallel distribution of matrix B and vector V " "does not match.")); - const int local_N = inputright.local_size(); - for (int i=0; iExtractMyRowView (i, N_entries, new_data); inputright.trilinos_matrix().ExtractMyRowView (i, N_entries, B_data); double value = V.trilinos_vector()[0][i]; - for (int j=0; j= 0, ExcInternalError()); - const unsigned int GID = inputleft.row_partitioner().GID(i); - for (int j=0; j= 0, ExcInternalError()); - const unsigned int GID = inputleft.row_partitioner().GID(i); - for (int j=0; jinvec_leng; + int_type max_per_proc; + int_type N_input_vector = B_->invec_leng; getrow_comm = B_->getrow->pre_comm; if ( getrow_comm != NULL) - for (int i = 0; i < getrow_comm->N_neighbors; i++) - for (int j = 0; j < getrow_comm->neighbors[i].N_send; j++) + for (int_type i = 0; i < getrow_comm->N_neighbors; i++) + for (int_type j = 0; j < getrow_comm->neighbors[i].N_send; j++) AssertThrow (getrow_comm->neighbors[i].send_list[j] < N_input_vector, ExcInternalError()); @@ -1180,7 +1180,7 @@ namespace TrilinosWrappers Assert (rhs.m() == m(), ExcDimensionMismatch (rhs.m(), m())); Assert (rhs.n() == n(), ExcDimensionMismatch (rhs.n(), n())); - const std::pair + const std::pair local_range = rhs.local_range(); int ierr; @@ -1200,7 +1200,7 @@ namespace TrilinosWrappers rhs.matrix->Filled() == true && this->local_range() == local_range && matrix->NumMyNonzeros() == rhs.matrix->NumMyNonzeros()) - for (unsigned int row=local_range.first; + for (size_type row=local_range.first; row < local_range.second; ++row) { Assert (matrix->NumGlobalEntries(row) == @@ -1208,8 +1208,8 @@ namespace TrilinosWrappers ExcDimensionMismatch(matrix->NumGlobalEntries(row), rhs.matrix->NumGlobalEntries(row))); - const int row_local = matrix->RowMap().LID(static_cast(row)); - int n_entries, rhs_n_entries; + const int_type row_local = matrix->RowMap().LID(static_cast(row)); + int_type n_entries, rhs_n_entries; TrilinosScalar *value_ptr, *rhs_value_ptr; // In debug mode, we want to check @@ -1221,7 +1221,7 @@ namespace TrilinosWrappers // indices is relatively slow compared to // just working with the values. #ifdef DEBUG - int *index_ptr, *rhs_index_ptr; + int_type *index_ptr, *rhs_index_ptr; ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries, rhs_value_ptr, rhs_index_ptr); Assert (ierr == 0, ExcTrilinosError(ierr)); @@ -1237,7 +1237,7 @@ namespace TrilinosWrappers AssertThrow (n_entries == rhs_n_entries, ExcDimensionMismatch (n_entries, rhs_n_entries)); - for (int i=0; i(rhs.matrix->NumGlobalEntries(row))); + static_cast(rhs.matrix->NumGlobalEntries(row))); - std::vector column_indices (max_row_length); + std::vector column_indices (max_row_length); std::vector values (max_row_length); if (matrix->Filled() == true && rhs.matrix->Filled() == true && this->local_range() == local_range) - for (unsigned int row=local_range.first; + for (size_type row=local_range.first; row < local_range.second; ++row) { - const int row_local = matrix->RowMap().LID(static_cast(row)); - int n_entries; + const int_type row_local = matrix->RowMap().LID(static_cast(row)); + int_type n_entries; ierr = rhs.matrix->ExtractMyRowCopy (row_local, max_row_length, n_entries, @@ -1279,7 +1279,7 @@ namespace TrilinosWrappers &column_indices[0]); Assert (ierr == 0, ExcTrilinosError(ierr)); - for (int i=0; iEpetra_CrsMatrix::ExtractGlobalRowCopy - ((int)row, max_row_length, n_entries, &values[0], &column_indices[0]); + ((int_type)row, max_row_length, n_entries, &values[0], &column_indices[0]); Assert (ierr == 0, ExcTrilinosError(ierr)); - for (int i=0; iEpetra_CrsMatrix::SumIntoGlobalValues - ((int)row, n_entries, &values[0], &column_indices[0]); + ((int_type)row, n_entries, &values[0], &column_indices[0]); Assert (ierr == 0, ExcTrilinosError(ierr)); } compress (); @@ -1357,13 +1357,13 @@ namespace TrilinosWrappers else { double *values; - int *indices; - int num_entries; + int_type *indices; + int_type num_entries; - for (int i=0; iNumMyRows(); ++i) + for (int_type i=0; iNumMyRows(); ++i) { matrix->ExtractMyRowView (i, num_entries, values, indices); - for (int j=0; jGRID(i) << "," << matrix->GCID(indices[j]) << ") " << values[j] << std::endl; } @@ -1374,12 +1374,12 @@ namespace TrilinosWrappers - std::size_t + size_type SparseMatrix::memory_consumption () const { - unsigned int static_memory = sizeof(this) + sizeof (*matrix) + size_type static_memory = sizeof(this) + sizeof (*matrix) + sizeof(*matrix->Graph().DataPtr()); - return ((sizeof(TrilinosScalar)+sizeof(int))*matrix->NumMyNonzeros() + + return ((sizeof(TrilinosScalar)+sizeof(int_type))*matrix->NumMyNonzeros() + sizeof(int)*local_size() + static_memory); } diff --git a/deal.II/source/lac/trilinos_sparsity_pattern.cc b/deal.II/source/lac/trilinos_sparsity_pattern.cc index b3d2dabf0c..7b46ae7047 100644 --- a/deal.II/source/lac/trilinos_sparsity_pattern.cc +++ b/deal.II/source/lac/trilinos_sparsity_pattern.cc @@ -52,10 +52,10 @@ namespace TrilinosWrappers int colnums = sparsity_pattern->n_cols(); int ierr; - ierr = sparsity_pattern->graph->ExtractGlobalRowCopy((int)this->a_row, + ierr = sparsity_pattern->graph->ExtractGlobalRowCopy((int_type)this->a_row, colnums, ncols, - (int *)&(*colnum_cache)[0]); + (int_type *)&(*colnum_cache)[0]); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); // copy it into our caches if the @@ -65,7 +65,7 @@ namespace TrilinosWrappers // iterator for an empty line (what // would it point to?) Assert (ncols != 0, ExcInternalError()); - colnum_cache.reset (new std::vector (colnums, + colnum_cache.reset (new std::vector (colnums, colnums+ncols)); } } @@ -93,15 +93,15 @@ namespace TrilinosWrappers SparsityPattern::SparsityPattern (const Epetra_Map &input_map, - const unsigned int n_entries_per_row) + const size_type n_entries_per_row) { reinit (input_map, input_map, n_entries_per_row); } - SparsityPattern::SparsityPattern (const Epetra_Map &input_map, - const std::vector &n_entries_per_row) + SparsityPattern::SparsityPattern (const Epetra_Map &input_map, + const std::vector &n_entries_per_row) { reinit (input_map, input_map, n_entries_per_row); } @@ -110,7 +110,7 @@ namespace TrilinosWrappers SparsityPattern::SparsityPattern (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const unsigned int n_entries_per_row) + const size_type n_entries_per_row) { reinit (input_row_map, input_col_map, n_entries_per_row); } @@ -119,25 +119,25 @@ namespace TrilinosWrappers SparsityPattern::SparsityPattern (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) { reinit (input_row_map, input_col_map, n_entries_per_row); } - SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const unsigned int n_entries_per_row) + SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const size_type n_entries_per_row) { reinit (m, n, n_entries_per_row); } - SparsityPattern::SparsityPattern (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row) + SparsityPattern::SparsityPattern (const size_type m, + const size_type n, + const std::vector &n_entries_per_row) { reinit (m, n, n_entries_per_row); } @@ -165,29 +165,29 @@ namespace TrilinosWrappers void - SparsityPattern::reinit (const Epetra_Map &input_map, - const unsigned int n_entries_per_row) + SparsityPattern::reinit (const Epetra_Map &input_map, + const size_type n_entries_per_row) { reinit (input_map, input_map, n_entries_per_row); } void - SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const unsigned int n_entries_per_row) + SparsityPattern::reinit (const size_type m, + const size_type n, + const size_type n_entries_per_row) { - const Epetra_Map rows (static_cast(m), 0, Utilities::Trilinos::comm_self()); - const Epetra_Map columns (static_cast(n), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map rows (static_cast(m), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map columns (static_cast(n), 0, Utilities::Trilinos::comm_self()); reinit (rows, columns, n_entries_per_row); } void - SparsityPattern::reinit (const Epetra_Map &input_row_map, - const Epetra_Map &input_col_map, - const unsigned int n_entries_per_row) + SparsityPattern::reinit (const Epetra_Map &input_row_map, + const Epetra_Map &input_col_map, + const size_type n_entries_per_row) { graph.reset (); column_space_map.reset (new Epetra_Map (input_col_map)); @@ -215,7 +215,7 @@ namespace TrilinosWrappers void SparsityPattern::reinit (const Epetra_Map &input_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) { reinit (input_map, input_map, n_entries_per_row); } @@ -223,12 +223,12 @@ namespace TrilinosWrappers void - SparsityPattern::reinit (const unsigned int m, - const unsigned int n, - const std::vector &n_entries_per_row) + SparsityPattern::reinit (const size_type m, + const size_type n, + const std::vector &n_entries_per_row) { - const Epetra_Map rows (static_cast(m), 0, Utilities::Trilinos::comm_self()); - const Epetra_Map columns (static_cast(n), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map rows (static_cast(m), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map columns (static_cast(n), 0, Utilities::Trilinos::comm_self()); reinit (rows, columns, n_entries_per_row); } @@ -238,12 +238,12 @@ namespace TrilinosWrappers void SparsityPattern::reinit (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) { // release memory before reallocation graph.reset (); AssertDimension (n_entries_per_row.size(), - static_cast(input_row_map.NumGlobalElements())); + static_cast(input_row_map.NumGlobalElements())); column_space_map.reset (new Epetra_Map (input_col_map)); compressed = false; @@ -281,9 +281,9 @@ namespace TrilinosWrappers graph.reset (); AssertDimension (sp.n_rows(), - static_cast(input_row_map.NumGlobalElements())); + static_cast(input_row_map.NumGlobalElements())); AssertDimension (sp.n_cols(), - static_cast(input_col_map.NumGlobalElements())); + static_cast(input_col_map.NumGlobalElements())); column_space_map.reset (new Epetra_Map (input_col_map)); compressed = false; @@ -291,11 +291,11 @@ namespace TrilinosWrappers Assert (input_row_map.LinearMap() == true, ExcMessage ("This function is not efficient if the map is not contiguous.")); - const unsigned int first_row = input_row_map.MinMyGID(), + 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 (unsigned int row=first_row; row 1) @@ -308,17 +308,17 @@ namespace TrilinosWrappers false)); AssertDimension (sp.n_rows(), - static_cast(graph->NumGlobalRows())); + static_cast(graph->NumGlobalRows())); - std::vector row_indices; + std::vector row_indices; // Include possibility to exchange data // since CompressedSimpleSparsityPattern is // able to do so if (exchange_data==false) - for (unsigned int row=first_row; rowEpetra_CrsGraph::InsertGlobalIndices (row, row_length, &row_indices[0]); } else - for (unsigned int row=0; rowInsertGlobalIndices (1, reinterpret_cast(&row), row_length, - &row_indices[0]); + graph->InsertGlobalIndices (1, reinterpret_cast(&row), + row_length, &row_indices[0]); } compress(); @@ -368,8 +368,8 @@ namespace TrilinosWrappers void SparsityPattern::copy_from (const SparsityType &sp) { - const Epetra_Map rows (static_cast(sp.n_rows()), 0, Utilities::Trilinos::comm_self()); - const Epetra_Map columns (static_cast(sp.n_cols()), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map rows (static_cast(sp.n_rows()), 0, Utilities::Trilinos::comm_self()); + const Epetra_Map columns (static_cast(sp.n_cols()), 0, Utilities::Trilinos::comm_self()); reinit (rows, columns, sp); } @@ -412,12 +412,12 @@ namespace TrilinosWrappers bool - SparsityPattern::exists (const unsigned int i, - const unsigned int j) const + SparsityPattern::exists (const size_type i, + const size_type j) const { // Extract local indices in // the matrix. - int trilinos_i = graph->LRID(static_cast(i)), trilinos_j = graph->LCID(static_cast(j)); + int_type trilinos_i = graph->LRID(static_cast(i)), trilinos_j = graph->LCID(static_cast(j)); // If the data is not on the // present processor, we throw @@ -436,9 +436,9 @@ namespace TrilinosWrappers // local indices. if (graph->Filled() == false) { - int nnz_present = graph->NumGlobalIndices(i); - int nnz_extracted; - int *col_indices; + int_type nnz_present = graph->NumGlobalIndices(i); + int_type nnz_extracted; + int_type *col_indices; // Generate the view and make // sure that we have not generated @@ -450,10 +450,10 @@ namespace TrilinosWrappers ExcDimensionMismatch(nnz_present, nnz_extracted)); // Search the index - int *el_find = std::find(col_indices, col_indices + nnz_present, + int_type *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - int local_col_index = (int)(el_find - col_indices); + int_type local_col_index = (int_type)(el_find - col_indices); if (local_col_index == nnz_present) return false; @@ -462,9 +462,9 @@ namespace TrilinosWrappers { // Prepare pointers for extraction // of a view of the row. - int nnz_present = graph->NumGlobalIndices(i); - int nnz_extracted; - int *col_indices; + int_type nnz_present = graph->NumGlobalIndices(i); + int_type nnz_extracted; + int_type *col_indices; // Generate the view and make // sure that we have not generated @@ -477,10 +477,10 @@ namespace TrilinosWrappers ExcDimensionMismatch(nnz_present, nnz_extracted)); // Search the index - int *el_find = std::find(col_indices, col_indices + nnz_present, + int_type *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - int local_col_index = (int)(el_find - col_indices); + int_type local_col_index = (int_type)(el_find - col_indices); if (local_col_index == nnz_present) return false; @@ -492,41 +492,41 @@ namespace TrilinosWrappers - unsigned int + size_type SparsityPattern::bandwidth () const { - unsigned int local_b=0; - int global_b=0; - for (unsigned int i=0; iExtractMyRowView(i, num_entries, indices); - for (unsigned int j=0; j<(unsigned int)num_entries; ++j) + for (size_type j=0; j<(size_type)num_entries; ++j) { - if (static_cast(std::abs(static_cast(i-indices[j]))) > local_b) - local_b = std::abs(static_cast(i-indices[j])); + if (static_cast(std::abs(static_cast(i-indices[j]))) > local_b) + local_b = std::abs(static_cast(i-indices[j])); } } - graph->Comm().MaxAll((int *)&local_b, &global_b, 1); - return static_cast(global_b); + graph->Comm().MaxAll((int_type *)&local_b, &global_b, 1); + return static_cast(global_b); } - unsigned int + size_type SparsityPattern::n_rows () const { - const int n_rows = graph -> NumGlobalRows(); + const int_type n_rows = graph -> NumGlobalRows(); return n_rows; } - unsigned int + size_type SparsityPattern::n_cols () const { - int n_cols; + int_type n_cols; if (graph->Filled() == true) n_cols = graph -> NumGlobalCols(); else @@ -537,20 +537,20 @@ namespace TrilinosWrappers - unsigned int + size_type SparsityPattern::local_size () const { - int n_rows = graph -> NumMyRows(); + int_type n_rows = graph -> NumMyRows(); return n_rows; } - std::pair + std::pair SparsityPattern::local_range () const { - unsigned int begin, end; + size_type begin, end; begin = graph -> RowMap().MinMyGID(); end = graph -> RowMap().MaxMyGID()+1; @@ -559,35 +559,35 @@ namespace TrilinosWrappers - unsigned int + size_type SparsityPattern::n_nonzero_elements () const { - int nnz = graph->NumGlobalEntries(); + int_type nnz = graph->NumGlobalEntries(); - return static_cast(nnz); + return static_cast(nnz); } - unsigned int + size_type SparsityPattern::max_entries_per_row () const { - int nnz = graph->MaxNumIndices(); + int_type nnz = graph->MaxNumIndices(); - return static_cast(nnz); + return static_cast(nnz); } - unsigned int - SparsityPattern::row_length (const unsigned int row) const + size_type + SparsityPattern::row_length (const size_type row) const { Assert (row < n_rows(), ExcInternalError()); // get a representation of the // present row - int ncols = -1; - int local_row = graph->LRID(static_cast(row)); + int_type ncols = -1; + int_type local_row = graph->LRID(static_cast(row)); // on the processor who owns this // row, we'll have a non-negative @@ -595,7 +595,7 @@ namespace TrilinosWrappers if (local_row >= 0) ncols = graph->NumMyIndices (local_row); - return static_cast(ncols); + return static_cast(ncols); } @@ -619,13 +619,13 @@ namespace TrilinosWrappers out << *graph; else { - int *indices; - int num_entries; + int_type *indices; + int_type num_entries; - for (int i=0; iNumMyRows(); ++i) + for (int_type i=0; iNumMyRows(); ++i) { graph->ExtractMyRowView (i, num_entries, indices); - for (int j=0; jGRID(j)] << ") " << std::endl; } @@ -640,19 +640,19 @@ namespace TrilinosWrappers SparsityPattern::print_gnuplot (std::ostream &out) const { Assert (graph->Filled() == true, ExcInternalError()); - for (unsigned int row=0; rowExtractMyRowView (row, num_entries, indices); - for (unsigned int j=0; j<(unsigned int)num_entries; ++j) + for (size_type j=0; j<(size_type)num_entries; ++j) // while matrix entries are usually // written (i,j), with i vertical and // j horizontal, gnuplot output is // x-y, that is we have to exchange // the order of output - out << indices[graph->GRID(static_cast(j))] << " " << -static_cast(row) + out << indices[graph->GRID(static_cast(j))] << " " << -static_cast(row) << std::endl; } @@ -723,4 +723,4 @@ namespace TrilinosWrappers DEAL_II_NAMESPACE_CLOSE -#endif // DEAL_II_USE_TRILINOS +#endif // DEAL_II_USE_TRILINOS diff --git a/deal.II/source/lac/trilinos_vector.cc b/deal.II/source/lac/trilinos_vector.cc index 9a66831234..7b73a08247 100644 --- a/deal.II/source/lac/trilinos_vector.cc +++ b/deal.II/source/lac/trilinos_vector.cc @@ -228,14 +228,15 @@ namespace TrilinosWrappers // create a vector that holds all the elements // contained in the block vector. need to // manually create an Epetra_Map. - unsigned int n_elements = 0, added_elements = 0, block_offset = 0; - for (unsigned int block=0; block global_ids (n_elements, -1); - for (unsigned int block=0; block global_ids (n_elements, -1); + for (size_type block=0; block(actual_vec->GlobalLength()) + AssertThrow (static_cast(actual_vec->GlobalLength()) == v.size(), ExcDimensionMismatch (actual_vec->GlobalLength(), v.size())); @@ -373,10 +374,10 @@ namespace TrilinosWrappers - Vector::Vector (const unsigned int n) + Vector::Vector (const size_type n) { last_action = Zero; - Epetra_LocalMap map ((int)n, 0, Utilities::Trilinos::comm_self()); + Epetra_LocalMap map ((int_type)n, 0, Utilities::Trilinos::comm_self()); vector.reset (new Epetra_FEVector (map)); } @@ -397,7 +398,7 @@ namespace TrilinosWrappers const MPI_Comm &communicator) { last_action = Zero; - Epetra_LocalMap map (static_cast(partitioning.size()), + Epetra_LocalMap map (static_cast(partitioning.size()), 0, #ifdef DEAL_II_COMPILER_SUPPORTS_MPI Epetra_MpiComm(communicator)); @@ -431,12 +432,12 @@ namespace TrilinosWrappers void - Vector::reinit (const unsigned int n, - const bool fast) + Vector::reinit (const size_type n, + const bool fast) { if (size() != n) { - Epetra_LocalMap map ((int)n, 0, + Epetra_LocalMap map ((int_type)n, 0, Utilities::Trilinos::comm_self()); vector.reset (new Epetra_FEVector (map)); } @@ -487,9 +488,9 @@ namespace TrilinosWrappers const bool fast) { if (vector->Map().NumGlobalElements() != - static_cast(partitioning.size())) + static_cast(partitioning.size())) { - Epetra_LocalMap map (static_cast(partitioning.size()), + Epetra_LocalMap map (static_cast(partitioning.size()), 0, #ifdef DEAL_II_COMPILER_SUPPORTS_MPI Epetra_MpiComm(communicator)); diff --git a/deal.II/source/lac/trilinos_vector_base.cc b/deal.II/source/lac/trilinos_vector_base.cc index 63e8c4e9ca..255d72f7a5 100644 --- a/deal.II/source/lac/trilinos_vector_base.cc +++ b/deal.II/source/lac/trilinos_vector_base.cc @@ -40,7 +40,8 @@ namespace TrilinosWrappers // we can use []. Note that we // can only get local values. - const int local_index = vector.vector->Map().LID(static_cast(index)); + const int_type local_index = + vector.vector->Map().LID(static_cast(index)); Assert (local_index >= 0, ExcAccessToNonLocalElement (index, vector.vector->Map().MinMyGID(), @@ -152,9 +153,9 @@ namespace TrilinosWrappers // // let's hope this isn't a // particularly frequent operation - std::pair + std::pair local_range = this->local_range (); - for (unsigned int i=local_range.first; iMap().LID(static_cast(index)); + int_type trilinos_i = vector->Map().LID(static_cast(index)); TrilinosScalar value = 0.; // If the element is not @@ -191,11 +192,11 @@ namespace TrilinosWrappers TrilinosScalar - VectorBase::operator () (const unsigned int index) const + VectorBase::operator () (const size_type index) const { // Extract local indices in // the vector. - int trilinos_i = vector->Map().LID(static_cast(index)); + int_type trilinos_i = vector->Map().LID(static_cast(index)); TrilinosScalar value = 0.; // If the element is not present @@ -246,7 +247,7 @@ namespace TrilinosWrappers if (local_size() != v.local_size()) return false; - unsigned int i; + size_type i; for (i=0; iGlobalLength()!=0, ExcEmptyObject()); - for (unsigned int j=0; j(val[i]) << ' '; else - for (unsigned int i=0; i(val[i]) << std::endl; out << std::endl; @@ -422,7 +423,7 @@ namespace TrilinosWrappers //one index and the value per local //entry. return sizeof(*this) - + this->local_size()*( sizeof(double)+sizeof(int) ); + + this->local_size()*( sizeof(double)+sizeof(int_type) ); } } /* end of namespace TrilinosWrappers */ diff --git a/deal.II/source/lac/vector_memory.cc b/deal.II/source/lac/vector_memory.cc index 2e138a2644..0ca33b4065 100644 --- a/deal.II/source/lac/vector_memory.cc +++ b/deal.II/source/lac/vector_memory.cc @@ -53,13 +53,10 @@ GrowingVectorMemory::Pool::~Pool() // vectors. Actually, there should // be none, if there is no memory // leak - unsigned int n=0; for (typename std::vector::iterator i=data->begin(); i != data->end(); ++i) { - if (i->first == true) - ++n; delete i->second; } delete data; @@ -69,7 +66,7 @@ GrowingVectorMemory::Pool::~Pool() template inline void -GrowingVectorMemory::Pool::initialize(const unsigned int size) +GrowingVectorMemory::Pool::initialize(const size_type size) { if (data == 0) { @@ -88,7 +85,7 @@ GrowingVectorMemory::Pool::initialize(const unsigned int size) template inline -GrowingVectorMemory::GrowingVectorMemory (const unsigned int initial_size, +GrowingVectorMemory::GrowingVectorMemory (const size_type initial_size, const bool log_statistics) :