From: Kainan Wang Date: Fri, 19 Apr 2013 23:04:59 +0000 (+0000) Subject: Change row_length type integers back to unsigned int, make related notes in documentation X-Git-Tag: v8.0.0~316^2~40 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ecd44c3c6f595c046fa733f33252d96e8e1d464;p=dealii.git Change row_length type integers back to unsigned int, make related notes in documentation git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@29346 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/doxygen/headers/global_dof_index.h b/deal.II/doc/doxygen/headers/global_dof_index.h index fc6ae6c03a..f01770a050 100644 --- a/deal.II/doc/doxygen/headers/global_dof_index.h +++ b/deal.II/doc/doxygen/headers/global_dof_index.h @@ -56,6 +56,11 @@ *
@anchor GlobalDoFIndexSparseMatrix * SparseMatrix
*
- * The size SparseMatrix can be arbitrary large therefore, - * types::global_do_index is used. + * The size of SparseMatrix can be arbitrary large therefore, + * types::global_do_index is used. However, even for a large complex problem we + * can solve now, there is no reason for the number of non-zero entries in a + * sparse matrix to go over four billions. Thus, we still use unsigned int + * for, e.g., row_lengths in the object. + * + * */ diff --git a/deal.II/include/deal.II/lac/block_list.h b/deal.II/include/deal.II/lac/block_list.h index bd67329c0a..0a5d40b905 100644 --- a/deal.II/include/deal.II/lac/block_list.h +++ b/deal.II/include/deal.II/lac/block_list.h @@ -296,7 +296,7 @@ inline void BlockList::create_sparsity_pattern(SparsityPattern &sparsity, size_type n) const { - std::vector sizes(size()); + std::vector sizes(size()); for (size_type b=0; b > &row_lengths); + const std::vector > &row_lengths); /** @@ -968,7 +968,7 @@ public: * the @p index th entry in row @p row. */ size_type column_number (const size_type row, - const size_type index) const; + const unsigned int index) const; /** * Allow the use of the reinit @@ -1341,7 +1341,7 @@ BlockSparsityPatternBase::n_block_rows () const inline BlockCompressedSimpleSparsityPattern::size_type BlockCompressedSimpleSparsityPattern::column_number (const size_type row, - const size_type index) const + const unsigned int index) const { // .first= ith block, .second = jth row in that block const std::pair @@ -1350,9 +1350,9 @@ BlockCompressedSimpleSparsityPattern::column_number (const size_type row, Assert(indexrow_length (row_index.second); + unsigned int rowlen = sub_objects[row_index.first][b]->row_length (row_index.second); if (indexcolumn_number(row_index.second, index-c); c += rowlen; diff --git a/deal.II/include/deal.II/lac/sparse_matrix.templates.h b/deal.II/include/deal.II/lac/sparse_matrix.templates.h index 2e87e2eb34..cc5a68d4d3 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix.templates.h +++ b/deal.II/include/deal.II/lac/sparse_matrix.templates.h @@ -1010,7 +1010,7 @@ SparseMatrix::mmult (SparseMatrix &C, // create an array that caches some // elements that are going to be written // into the new matrix. - size_type max_n_cols_B = 0; + unsigned int max_n_cols_B = 0; for (size_type i=0; i new_entries(max_n_cols_B); @@ -1140,7 +1140,7 @@ SparseMatrix::Tmmult (SparseMatrix &C, // create an array that caches some // elements that are going to be written // into the new matrix. - size_type max_n_cols_B = 0; + unsigned int max_n_cols_B = 0; for (size_type i=0; i new_entries(max_n_cols_B); diff --git a/deal.II/include/deal.II/lac/sparsity_pattern.h b/deal.II/include/deal.II/lac/sparsity_pattern.h index aad75b9c46..381e872508 100644 --- a/deal.II/include/deal.II/lac/sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/sparsity_pattern.h @@ -436,7 +436,7 @@ public: */ SparsityPattern (const size_type m, const size_type n, - const size_type max_per_row, + const unsigned int max_per_row, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -448,7 +448,7 @@ public: */ SparsityPattern (const size_type m, const size_type n, - const size_type max_per_row); + const unsigned int max_per_row); /** * Initialize a rectangular matrix. @@ -464,7 +464,7 @@ public: */ SparsityPattern (const size_type m, const size_type n, - const std::vector &row_lengths, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -477,7 +477,7 @@ public: */ SparsityPattern (const size_type m, const size_type n, - const std::vector &row_lengths); + const std::vector &row_lengths); /** * Initialize a quadratic matrix of dimension n with at most @@ -488,7 +488,7 @@ public: * numbers separately. */ SparsityPattern (const size_type n, - const size_type max_per_row); + const unsigned int max_per_row); /** * Initialize a quadratic matrix. @@ -502,7 +502,7 @@ public: * it is ignored. */ SparsityPattern (const size_type m, - const std::vector &row_lengths, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -513,7 +513,7 @@ public: * vector must have one entry for each row. */ SparsityPattern (const size_type m, - const std::vector &row_lengths); + const std::vector &row_lengths); /** * Make a copy with extra off-diagonals. @@ -538,7 +538,7 @@ public: * compressed after this function finishes. */ SparsityPattern (const SparsityPattern &original, - const size_type max_per_row, + const unsigned int max_per_row, const size_type extra_off_diagonals); /** @@ -566,7 +566,7 @@ public: */ void reinit (const size_type m, const size_type n, - const size_type max_per_row, + const unsigned int max_per_row, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -579,7 +579,7 @@ public: */ void reinit (const size_type m, const size_type n, - const size_type max_per_row); + const unsigned int max_per_row); /** * Reallocate memory for a matrix of size m x n. The number of @@ -600,7 +600,7 @@ public: */ void reinit (const size_type m, const size_type n, - const std::vector &row_lengths, + const std::vector &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -619,7 +619,7 @@ public: */ void reinit (const size_type m, const size_type n, - const std::vector &row_lengths); + const std::vector &row_lengths); /** * Same as above, but with a VectorSlice argument instead. @@ -629,7 +629,7 @@ public: */ void reinit (const size_type m, const size_type n, - const VectorSlice > &row_lengths, + const VectorSlice > &row_lengths, const bool optimize_diagonal) DEAL_II_DEPRECATED; /** @@ -637,7 +637,7 @@ public: */ void reinit (const size_type m, const size_type n, - const VectorSlice > &row_lengths); + const VectorSlice > &row_lengths); /** * This function compresses the sparsity structure that this object @@ -1028,7 +1028,7 @@ public: /** * Number of entries in a specific row. */ - size_type row_length (const size_type row) const; + unsigned int row_length (const size_type row) const; /** * Determine whether the matrix uses the special convention for quadratic @@ -1131,7 +1131,7 @@ public: * column_number(row,i+1). */ size_type column_number (const size_type row, - const size_type index) const; + const unsigned int index) const; // @} @@ -1367,7 +1367,7 @@ private: * reinit versions are called. Its value is more or less meaningless after * compress() has been called. */ - size_type max_row_length; + unsigned int max_row_length; /** * Array which hold for each row which is the first element in #colnums @@ -1766,7 +1766,7 @@ SparsityPattern::get_column_numbers () const inline -SparsityPattern::size_type +unsigned int SparsityPattern::row_length (const size_type row) const { Assert(row(row,0,rows)); @@ -1778,10 +1778,10 @@ SparsityPattern::row_length (const size_type row) const inline SparsityPattern::size_type SparsityPattern::column_number (const size_type row, - const size_type index) const + const unsigned int index) const { Assert(row(row,0,rows)); - Assert(index(index,0,row_length(row))); + Assert(index row_lengths; + std::vector row_lengths; row_lengths.reserve(n_rows); for (ForwardIterator i=begin; i!=end; ++i) row_lengths.push_back (std::distance (i->begin(), i->end()) diff --git a/deal.II/include/deal.II/matrix_free/dof_info.templates.h b/deal.II/include/deal.II/matrix_free/dof_info.templates.h index ebb8577a20..77a15a8d0b 100644 --- a/deal.II/include/deal.II/matrix_free/dof_info.templates.h +++ b/deal.II/include/deal.II/matrix_free/dof_info.templates.h @@ -1702,10 +1702,10 @@ not_connect: task_info.n_blocks : size_info.n_active_cells; // first determine row lengths - std::vector row_lengths(n_rows); + std::vector row_lengths(n_rows); unsigned int cell_start = 0, mcell_start = 0; std::vector scratch; - for (types::global_dof_index block = 0; block < n_blocks; ++block) + for (unsigned int block = 0; block < n_blocks; ++block) { // if we have the blocking variant (used in the coloring scheme), we // want to build a graph with the blocks with interaction with diff --git a/deal.II/source/dofs/dof_tools.cc b/deal.II/source/dofs/dof_tools.cc index cecdc058a4..11cca60f9e 100644 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@ -5830,7 +5830,7 @@ namespace DoFTools numbers::invalid_unsigned_int); // Estimate for the number of dofs at this point - std::vector vertex_dof_count(dof_handler.get_tria().n_vertices(), 0); + std::vector vertex_dof_count(dof_handler.get_tria().n_vertices(), 0); // Identify all vertices active on this level and remember some data // about them diff --git a/deal.II/source/lac/block_sparsity_pattern.cc b/deal.II/source/lac/block_sparsity_pattern.cc index 6560f60486..3df0ecb92c 100644 --- a/deal.II/source/lac/block_sparsity_pattern.cc +++ b/deal.II/source/lac/block_sparsity_pattern.cc @@ -359,7 +359,7 @@ void BlockSparsityPattern::reinit( const BlockIndices &rows, const BlockIndices &cols, - const std::vector > &row_lengths) + const std::vector > &row_lengths) { AssertDimension (row_lengths.size(), cols.size()); @@ -375,7 +375,7 @@ BlockSparsityPattern::reinit( cols.block_size(j), row_lengths[j][0]); else { - VectorSlice > + VectorSlice > block_rows(row_lengths[j], start, length); block(i,j).reinit(rows.block_size(i), cols.block_size(j), diff --git a/deal.II/source/lac/chunk_sparsity_pattern.cc b/deal.II/source/lac/chunk_sparsity_pattern.cc index 79a3aaabe6..2c5a9442be 100644 --- a/deal.II/source/lac/chunk_sparsity_pattern.cc +++ b/deal.II/source/lac/chunk_sparsity_pattern.cc @@ -222,7 +222,7 @@ ChunkSparsityPattern::reinit ( // row zero at columns {0,2} and for row // one at {4,6} --> we'll need 4 chunks for // the first chunk row!) : - std::vector chunk_row_lengths (m_chunks, 0); + std::vector chunk_row_lengths (m_chunks, 0); for (size_type i=0; i &row_lengths, + const std::vector &row_lengths, const bool) : max_dim(0), @@ -120,7 +120,7 @@ SparsityPattern::SparsityPattern (const size_type m, SparsityPattern::SparsityPattern (const size_type m, const size_type n, - const std::vector &row_lengths) + const std::vector &row_lengths) : max_dim(0), max_vec_len(0), @@ -134,7 +134,7 @@ SparsityPattern::SparsityPattern (const size_type m, SparsityPattern::SparsityPattern (const size_type n, - const size_type max_per_row) + const unsigned int max_per_row) : max_dim(0), max_vec_len(0), @@ -147,7 +147,7 @@ SparsityPattern::SparsityPattern (const size_type n, SparsityPattern::SparsityPattern (const size_type m, - const std::vector &row_lengths, + const std::vector &row_lengths, const bool) : max_dim(0), @@ -160,7 +160,7 @@ SparsityPattern::SparsityPattern (const size_type m, SparsityPattern::SparsityPattern (const size_type m, - const std::vector &row_lengths) + const std::vector &row_lengths) : max_dim(0), max_vec_len(0), @@ -173,7 +173,7 @@ SparsityPattern::SparsityPattern (const size_type m, SparsityPattern::SparsityPattern (const SparsityPattern &original, - const size_type max_per_row, + const unsigned int max_per_row, const size_type extra_off_diagonals) : max_dim(0), @@ -303,12 +303,12 @@ SparsityPattern::operator = (const SparsityPattern &s) void SparsityPattern::reinit (const size_type m, const size_type n, - const size_type max_per_row, + const unsigned int max_per_row, const bool) { // simply map this function to the // other @p{reinit} function - const std::vector row_lengths (m, max_per_row); + const std::vector row_lengths (m, max_per_row); reinit (m, n, row_lengths); } @@ -317,11 +317,11 @@ SparsityPattern::reinit (const size_type m, void SparsityPattern::reinit (const size_type m, const size_type n, - const size_type max_per_row) + const unsigned int max_per_row) { // simply map this function to the // other @p{reinit} function - const std::vector row_lengths (m, max_per_row); + const std::vector row_lengths (m, max_per_row); reinit (m, n, row_lengths); } @@ -330,7 +330,7 @@ SparsityPattern::reinit (const size_type m, void SparsityPattern::reinit (const size_type m, const size_type n, - const VectorSlice > &row_lengths, + const VectorSlice > &row_lengths, const bool) { reinit (m, n, row_lengths); @@ -341,7 +341,7 @@ SparsityPattern::reinit (const size_type m, void SparsityPattern::reinit (const size_type m, const size_type n, - const VectorSlice > &row_lengths) + const VectorSlice > &row_lengths) { AssertDimension (row_lengths.size(), m); @@ -381,11 +381,12 @@ SparsityPattern::reinit (const size_type m, // note that the number of elements // per row is bounded by the number // of columns + // std::size_t vec_len = 0; for (size_type i=0; i (1U)) : - row_lengths[i]), + vec_len += std::min(static_cast(store_diagonal_first_in_row ? + std::max(row_lengths[i], 1U) : + row_lengths[i]), n); // sometimes, no entries are @@ -410,8 +411,8 @@ SparsityPattern::reinit (const size_type m, max_row_length = (row_lengths.size() == 0 ? 0 : - std::min (*std::max_element(row_lengths.begin(), - row_lengths.end()), + std::min (static_cast(*std::max_element(row_lengths.begin(), + row_lengths.end())), n)); if (store_diagonal_first_in_row && (max_row_length==0) && (m!=0)) @@ -462,8 +463,9 @@ SparsityPattern::reinit (const size_type m, for (size_type i=1; i<=rows; ++i) rowstart[i] = rowstart[i-1] + (store_diagonal_first_in_row ? - std::max(std::min(row_lengths[i-1],n),static_cast (1U)) : - std::min(row_lengths[i-1],n)); + std::max(std::min(static_cast(row_lengths[i-1]),n), + static_cast (1U)) : + std::min(static_cast(row_lengths[i-1]),n)); Assert ((rowstart[rows]==vec_len) || ((vec_len == 1) && (rowstart[rows] == 0)), @@ -637,7 +639,7 @@ SparsityPattern::copy_from (const CSP &csp) // diagonal entry is in a certain // row or not const bool do_diag_optimize = (csp.n_rows() == csp.n_cols()); - std::vector row_lengths (csp.n_rows()); + std::vector row_lengths (csp.n_rows()); for (size_type i=0; i &matrix) // also have to allocate memory for the // diagonal entry, unless we have already // counted it - std::vector entries_per_row (matrix.m(), 0); + std::vector entries_per_row (matrix.m(), 0); for (size_type row=0; row &matrix) void SparsityPattern::reinit (const size_type m, const size_type n, - const std::vector &row_lengths, + const std::vector &row_lengths, const bool) { reinit(m, n, make_slice(row_lengths)); @@ -734,7 +736,7 @@ SparsityPattern::reinit (const size_type m, void SparsityPattern::reinit (const size_type m, const size_type n, - const std::vector &row_lengths) + const std::vector &row_lengths) { reinit(m, n, make_slice(row_lengths)); }