From: kronbichler Date: Tue, 7 Apr 2009 11:00:51 +0000 (+0000) Subject: Cosmetic code changes. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b554d8713879242c9afabc40e11ece97e160c81;p=dealii-svn.git Cosmetic code changes. git-svn-id: https://svn.dealii.org/trunk@18562 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/constraint_matrix.templates.h b/deal.II/lac/include/lac/constraint_matrix.templates.h index 5699e87841..331bd4c98c 100644 --- a/deal.II/lac/include/lac/constraint_matrix.templates.h +++ b/deal.II/lac/include/lac/constraint_matrix.templates.h @@ -1554,27 +1554,26 @@ distribute_local_to_global (const FullMatrix &local_matrix, // additional construct that also takes // care of block indices. - std::vector block_ends(num_blocks, n_actual_dofs); + std::vector block_starts(num_blocks+1, n_actual_dofs); { typedef std::vector::iterator row_iterator; row_iterator col_indices = localized_indices.begin(); - unsigned int n_cols = n_actual_dofs; // find end of rows. - for (unsigned int i=0;i &local_matrix, // non-block variant from now onwards // is that we go through the blocks // of the matrix separately. - unsigned int block_start = 0; for (unsigned int block=0; block= 0 && loc_row < n_local_dofs, ExcInternalError()); - for (unsigned int j=block_col_start; j < block_ends[block_col]; ++j) + for (unsigned int j=block_starts[block_col]; j < next_block_col; ++j) { const unsigned int loc_col = my_indices[j].local_row; Assert(loc_col >= 0 && loc_col < n_local_dofs, ExcInternalError()); - if (local_matrix(loc_row,loc_col) != 0) + const double mat_val = local_matrix(loc_row, loc_col); + if (mat_val != 0) { - vals[col_counter] = local_matrix(loc_row,loc_col); - cols[col_counter] = localized_indices[j]; - col_counter++; + *col_ptr++ = localized_indices[j]; + *val_ptr++ = mat_val; } } } else { - for (unsigned int j=block_col_start; j < block_ends[block_col]; ++j) + for (unsigned int j=block_starts[block_col]; j < next_block_col; ++j) { double col_val; const unsigned int loc_col = my_indices[j].local_row; @@ -1672,28 +1672,30 @@ distribute_local_to_global (const FullMatrix &local_matrix, if (col_val != 0) { - cols[col_counter] = localized_indices[j]; - vals[col_counter] = col_val; - col_counter++; + *col_ptr++ = localized_indices[j]; + *val_ptr++ = col_val; } } } - block_col_start = block_ends[block_col]; - // finally, write all the information // that accumulated under the given // process into the global matrix row and // into the vector. For the block matrix, // go trough the individual blocks and // look which entries we need to set. - Threads::ThreadMutex::ScopedLock lock(mutex); - global_matrix.block(block, block_col).add(row, col_counter, - &cols[0], &vals[0], - false, true); + const unsigned int n_values = col_ptr - &cols[0]; + Assert (n_values == (unsigned int)(val_ptr - &vals[0]), + ExcInternalError()); + if (n_values > 0) + { + Threads::ThreadMutex::ScopedLock lock(mutex); + global_matrix.block(block, block_col).add(row, n_values, + &cols[0], &vals[0], + false, true); + } } - if (use_vectors == true) { double val = 0; @@ -1723,7 +1725,6 @@ distribute_local_to_global (const FullMatrix &local_matrix, } } } - block_start = block_ends[block]; } } @@ -1879,7 +1880,7 @@ add_entries_local_to_global (const std::vector &local_dof_indices, // out some local dofs. for (unsigned int i=0; i::iterator col_ptr = cols.begin(); const unsigned int row = my_indices[i].global_row; const unsigned int loc_row = my_indices[i].local_row; @@ -1898,7 +1899,7 @@ add_entries_local_to_global (const std::vector &local_dof_indices, ExcInternalError()); if (dof_mask[loc_row][loc_col] == true) - cols[col_counter++] = my_indices[j].global_row; + *col_ptr++ = my_indices[j].global_row; } } @@ -1962,7 +1963,7 @@ add_entries_local_to_global (const std::vector &local_dof_indices, if (add_this == true) { add_this_index: - cols[col_counter++] = my_indices[j].global_row; + *col_ptr++ = my_indices[j].global_row; } } } @@ -1972,8 +1973,8 @@ add_entries_local_to_global (const std::vector &local_dof_indices, // process into the global matrix row and // into the vector Threads::ThreadMutex::ScopedLock lock(mutex); - if (col_counter > 0) - sparsity_pattern.add_entries(row, cols.begin(), cols.begin()+col_counter, + if (col_ptr != cols.begin()) + sparsity_pattern.add_entries(row, cols.begin(), col_ptr, true); } } @@ -2115,27 +2116,25 @@ add_entries_local_to_global (const std::vector &local_dof_indices, // additional construct that also takes // care of block indices. - std::vector block_ends(num_blocks, n_actual_dofs); + std::vector block_starts(num_blocks+1, n_actual_dofs); { typedef std::vector::iterator row_iterator; row_iterator col_indices = localized_indices.begin(); - unsigned int n_cols = n_actual_dofs; // find end of rows. - for (unsigned int i=0;i &local_dof_indices, // unconditionally if (dof_mask_is_active == false) { - unsigned int block_start = 0; Threads::ThreadMutex::ScopedLock lock(mutex); for (unsigned int block=0; block &local_dof_indices, for (unsigned int block_col = 0; block_col &local_dof_indices, // non-block variant from now onwards // is that we go through the blocks // of the matrix separately. - unsigned int block_start = 0; for (unsigned int block=0; block::iterator col_ptr = cols.begin(); if (have_indirect_rows == false) { Assert(loc_row >= 0 && loc_row < n_local_dofs, ExcInternalError()); - for (unsigned int j=block_col_start; j < block_ends[block_col]; ++j) + for (unsigned int j=block_starts[block_col]; j < next_block_col; ++j) { const unsigned int loc_col = my_indices[j].local_row; Assert(loc_col >= 0 && loc_col < n_local_dofs, ExcInternalError()); if (dof_mask[loc_row][loc_col] == true) - cols[col_counter++] = localized_indices[j]; + *col_ptr++ = localized_indices[j]; } } @@ -2209,7 +2206,7 @@ add_entries_local_to_global (const std::vector &local_dof_indices, // constraints, resolve them else { - for (unsigned int j=block_col_start; j < block_ends[block_col]; ++j) + for (unsigned int j=block_starts[block_col]; j < next_block_col; ++j) { const unsigned int loc_col = my_indices[j].local_row; @@ -2245,32 +2242,29 @@ add_entries_local_to_global (const std::vector &local_dof_indices, for (unsigned int p=0; p