From: turcksin Date: Wed, 13 Feb 2013 21:17:11 +0000 (+0000) Subject: Merge from mainline. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e08bf75d61781a27214e35ee2c92ce1dd738d3dc;p=dealii-svn.git Merge from mainline. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@28396 0785d39b-7218-0410-832d-ea1e28bc413d --- e08bf75d61781a27214e35ee2c92ce1dd738d3dc diff --cc deal.II/include/deal.II/dofs/dof_accessor.h index 27a731ddd2,bac83d687b..53fe88c3db --- a/deal.II/include/deal.II/dofs/dof_accessor.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.h @@@ -438,11 -438,27 +438,27 @@@ public * cell-@>active_fe_index * as last argument. */ - void get_dof_indices (std::vector &dof_indices, + void get_dof_indices (std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index) const; + /** + * Return the indices of the dofs of this + * object in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, ... + * dofs on line 0, dofs on line 1, ..., + * then quads, then hexes. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the local numbering + * for the level this line lives on. + */ - void get_mg_dof_indices (const int level, std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index) const; + void get_mg_dof_indices (const int level, std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index) const; + + /** + * Sets the level DoF indices that are returned by get_mg_dof_indices. + */ - void set_mg_dof_indices (const int level, const std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index); + void set_mg_dof_indices (const int level, const std::vector &dof_indices, const unsigned int fe_index = DH::default_fe_index); /** * Global DoF index of the i @@@ -480,11 -496,15 +496,15 @@@ * match the result of * active_fe_index(). */ - unsigned int vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const unsigned int fe_index = DH::default_fe_index) const; + types::global_dof_index vertex_dof_index (const unsigned int vertex, + const unsigned int i, + const unsigned int fe_index = DH::default_fe_index) const; + /** + * Returns the Global DoF index of the i degree associated with the @p + * vertexth vertex on the level @p level. Also see vertex_dof_index(). + */ - unsigned int mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int fe_index = DH::default_fe_index) const; + types::global_dof_index mg_vertex_dof_index (const int level, const unsigned int vertex, const unsigned int i, const unsigned int fe_index = DH::default_fe_index) const; /** * Index of the ith degree @@@ -540,10 -560,13 +560,13 @@@ * degrees are defined in the interior of * the face. */ - unsigned int dof_index (const unsigned int i, - const unsigned int fe_index = DH::default_fe_index) const; + types::global_dof_index dof_index (const unsigned int i, + const unsigned int fe_index = DH::default_fe_index) const; + /** + * Returns the dof_index on the given level. Also see dof_index. + */ - unsigned int mg_dof_index (const int level, const unsigned int i) const; + types::global_dof_index mg_dof_index (const int level, const unsigned int i) const; /** * @} @@@ -2076,11 -2099,9 +2099,9 @@@ public * * Examples for this use are in the implementation of DoFRenumbering. */ - void dof_indices (std::vector &dof_indices) const; - void get_active_or_mg_dof_indices (std::vector &dof_indices) const; ++ void get_active_or_mg_dof_indices (std::vector &dof_indices) const; /** - * @deprecated Use dof_indices() instead. - * * Return the indices of the dofs of this * quad in the standard ordering: dofs * on vertex 0, dofs on vertex 1, etc, @@@ -2111,11 -2132,13 +2132,13 @@@ * * This is a function which requires that the cell be active. * + * Also see get_active_or_mg_dof_indices(). + * * @deprecated Currently, this function can also be called for non-active cells, if all degrees of freedom of the FiniteElement are located in vertices. This functionality will vanish in a future release. */ - void get_dof_indices (std::vector &dof_indices) const; + void get_dof_indices (std::vector &dof_indices) const; /** - * @deprecated Use dof_indices() with level_cell_iterator returned from begin_mg(). + * @deprecated Use get_active_or_mg_dof_indices() with level_cell_iterator returned from begin_mg(). * * Retrieve the global indices of the degrees of freedom on this cell in the level vector associated to the level of the cell. */ @@@ -2169,8 -2192,13 +2192,13 @@@ * cache, if one exists for the * given DoF handler class. */ - void set_dof_indices (const std::vector &dof_indices); + void set_dof_indices (const std::vector &dof_indices); + + /** + * Set the Level DoF indices of this + * cell to the given values. + */ - void set_mg_dof_indices (const std::vector &dof_indices); + void set_mg_dof_indices (const std::vector &dof_indices); /** * Update the cache in which we diff --cc deal.II/include/deal.II/dofs/dof_accessor.templates.h index 6e836a3204,3f3ffedcbe..3cac193055 --- a/deal.II/include/deal.II/dofs/dof_accessor.templates.h +++ b/deal.II/include/deal.II/dofs/dof_accessor.templates.h @@@ -3654,7 -3555,7 +3574,7 @@@ void DoFCellAccessor::set_mg_do template inline - void DoFCellAccessor::dof_indices (std::vector &dof_indices) const -void DoFCellAccessor::get_active_or_mg_dof_indices (std::vector &dof_indices) const ++void DoFCellAccessor::get_active_or_mg_dof_indices (std::vector &dof_indices) const { if (lda) get_mg_dof_indices (dof_indices); diff --cc deal.II/source/lac/chunk_sparsity_pattern.cc index 08ac4f12f8,788ed489b9..b5a9c2bea8 --- a/deal.II/source/lac/chunk_sparsity_pattern.cc +++ b/deal.II/source/lac/chunk_sparsity_pattern.cc @@@ -67,11 -67,11 +67,11 @@@ ChunkSparsityPattern::ChunkSparsityPatt ChunkSparsityPattern::ChunkSparsityPattern ( - const unsigned int m, - const unsigned int n, + const types::global_dof_index m, + const types::global_dof_index n, const std::vector &row_lengths, const unsigned int chunk_size, - const bool optimize_diag) + const bool) { Assert (chunk_size > 0, ExcInvalidNumber (chunk_size)); @@@ -103,10 -103,10 +103,10 @@@ ChunkSparsityPattern::ChunkSparsityPatt ChunkSparsityPattern::ChunkSparsityPattern ( - const unsigned int m, + const types::global_dof_index m, const std::vector &row_lengths, const unsigned int chunk_size, - const bool optimize_diag) + const bool) { Assert (chunk_size > 0, ExcInvalidNumber (chunk_size)); diff --cc deal.II/source/lac/trilinos_sparse_matrix.cc index 601b4bfab5,0163269d84..3527268163 --- a/deal.II/source/lac/trilinos_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_sparse_matrix.cc @@@ -361,6 -361,35 +361,35 @@@ namespace TrilinosWrapper + namespace internal + { + namespace + { + // distinguish between compressed sparsity types that define row_begin() + // and SparsityPattern that uses begin() as iterator type + template - void copy_row (const Sparsity &csp, - const unsigned int row, - std::vector &row_indices) ++ void copy_row (const Sparsity &csp, ++ const size_type row, ++ std::vector &row_indices) + { + typename Sparsity::row_iterator col_num = csp.row_begin (row); - for (unsigned int col=0; col_num != csp.row_end (row); ++col_num, ++col) ++ for (size_type col=0; col_num != csp.row_end (row); ++col_num, ++col) + row_indices[col] = *col_num; + } + + void copy_row (const dealii::SparsityPattern &csp, - const unsigned int row, - std::vector &row_indices) ++ const size_int row, ++ std::vector &row_indices) + { + dealii::SparsityPattern::iterator col_num = csp.begin (row); - for (unsigned int col=0; col_num != csp.end (row); ++col_num, ++col) ++ for (size_type col=0; col_num != csp.end (row); ++col_num, ++col) + row_indices[col] = col_num->column(); + } + } + } + + + template void SparseMatrix::reinit (const Epetra_Map &input_row_map, @@@ -401,36 -426,26 +426,26 @@@ 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 graph; if (input_row_map.Comm().NumProc() > 1) graph.reset (new Epetra_CrsGraph (Copy, input_row_map, @@@ -471,10 -478,9 +478,9 @@@ graph->FillComplete(input_col_map, input_row_map); graph->OptimizeStorage(); - // check whether we got the number of - // columns right. + // 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)); @@@ -715,23 -720,23 +720,23 @@@ // Only do this on the rows owned // locally on this processor. - int_map local_row = matrix->LRID(static_cast(row)); - int local_row = matrix->LRID(static_cast(row)); ++ int_type local_row = matrix->LRID(static_cast(row)); if (local_row >= 0) { TrilinosScalar *values; - int_map *col_indices; - int_map num_entries; - int *col_indices; - int num_entries; ++ int_type *col_indices; ++ int_type num_entries; const int ierr = matrix->ExtractMyRowView(local_row, num_entries, values, col_indices); Assert (ierr == 0, ExcTrilinosError(ierr)); - int_map *diag_find = std::find(col_indices,col_indices+num_entries, - int *diag_find = std::find(col_indices,col_indices+num_entries, ++ int_type *diag_find = std::find(col_indices,col_indices+num_entries, local_row); - int_map diag_index = (int_map)(diag_find - col_indices); - int diag_index = (int)(diag_find - col_indices); ++ int_type diag_index = (int_type)(diag_find - col_indices); - for (int_map j=0; jn_cols(); ++ int_type ncols; ++ int_type 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 @@@ -271,6 -271,35 +271,35 @@@ + namespace internal + { + namespace + { + // distinguish between compressed sparsity types that define row_begin() + // and SparsityPattern that uses begin() as iterator type + template + void copy_row (const Sparsity &csp, - const unsigned int row, - std::vector &row_indices) ++ const size_type row, ++ std::vector &row_indices) + { + typename Sparsity::row_iterator col_num = csp.row_begin (row); - for (unsigned int col=0; col_num != csp.row_end (row); ++col_num, ++col) ++ for (size_type col=0; col_num != csp.row_end (row); ++col_num, ++col) + row_indices[col] = *col_num; + } + + void copy_row (const dealii::SparsityPattern &csp, - const unsigned int row, - std::vector &row_indices) ++ const size_type row, ++ std::vector &row_indices) + { + dealii::SparsityPattern::iterator col_num = csp.begin (row); - for (unsigned int col=0; col_num != csp.end (row); ++col_num, ++col) ++ for (size_type col=0; col_num != csp.end (row); ++col_num, ++col) + row_indices[col] = col_num->column(); + } + } + } + + + template void SparsityPattern::reinit (const Epetra_Map &input_row_map, @@@ -340,13 -364,8 +364,8 @@@ continue; row_indices.resize (row_length, -1); - - typename SparsityType::row_iterator col_num = sp.row_begin (row), - row_end = sp.row_end(row); - for (size_type col = 0; col_num != row_end; ++col_num, ++col) - row_indices[col] = *col_num; - - graph->InsertGlobalIndices (1, reinterpret_cast(&row), + internal::copy_row(sp, row, row_indices); - graph->InsertGlobalIndices (1, reinterpret_cast(&row), ++ graph->InsertGlobalIndices (1, reinterpret_cast(&row), row_length, &row_indices[0]); } diff --cc deal.II/source/numerics/matrix_tools.cc index 04fe330ba3,2282d6cd41..e5dca7807a --- a/deal.II/source/numerics/matrix_tools.cc +++ b/deal.II/source/numerics/matrix_tools.cc @@@ -2427,26 -2420,9 +2420,9 @@@ namespace MatrixTool // treated in the other functions. matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); - // the next thing is to set right hand - // side to the wanted value. there's one - // drawback: if we write to individual - // vector elements, then we have to do - // that on all processors. however, some - // processors may not need to set - // anything because their chunk of - // matrix/rhs do not contain any boundary - // nodes. therefore, rather than using - // individual calls, we use one call for - // all elements, thereby making sure that - // all processors call this function, - // even if some only have an empty set of - // elements to set - right_hand_side.compress (); - solution.compress (); - - std::vector indices; + std::vector indices; std::vector solution_values; - for (std::map::const_iterator + for (std::map::const_iterator dof = boundary_values.begin(); dof != boundary_values.end(); ++dof) @@@ -2656,30 -2632,9 +2632,9 @@@ // matrix classes in deal.II. matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); - // the next thing is to set right - // hand side to the wanted - // value. there's one drawback: - // if we write to individual - // vector elements, then we have - // to do that on all - // processors. however, some - // processors may not need to set - // anything because their chunk - // of matrix/rhs do not contain - // any boundary nodes. therefore, - // rather than using individual - // calls, we use one call for all - // elements, thereby making sure - // that all processors call this - // function, even if some only - // have an empty set of elements - // to set - right_hand_side.compress (); - solution.compress (); - - std::vector indices; + std::vector indices; std::vector solution_values; - for (std::map::const_iterator + for (std::map::const_iterator dof = boundary_values.begin(); dof != boundary_values.end(); ++dof)