From: David Wells Date: Thu, 3 Nov 2022 17:38:34 +0000 (-0400) Subject: AffineConstraints: de-template add_entries_local_to_global() part 1 X-Git-Tag: v9.5.0-rc1~853^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54a0505c8f9d67c46c5e8fe3c67bcdb9380000cf;p=dealii.git AffineConstraints: de-template add_entries_local_to_global() part 1 --- diff --git a/include/deal.II/lac/affine_constraints.h b/include/deal.II/lac/affine_constraints.h index e53dfe41bf..ba263cd24c 100644 --- a/include/deal.II/lac/affine_constraints.h +++ b/include/deal.II/lac/affine_constraints.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -1522,11 +1523,10 @@ public: * caller's site. There is no locking mechanism inside this method to * prevent data races. */ - template void add_entries_local_to_global( const std::vector &local_dof_indices, - SparsityPatternType & sparsity_pattern, + SparsityPatternBase & sparsity_pattern, const bool keep_constrained_entries = true, const Table<2, bool> & dof_mask = Table<2, bool>()) const; diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 0e74dd88dd..b34dcb3fc2 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -4293,11 +4293,10 @@ AffineConstraints::distribute_local_to_global( template -template void AffineConstraints::add_entries_local_to_global( const std::vector &local_dof_indices, - SparsityPatternType & sparsity_pattern, + SparsityPatternBase & sparsity_pattern, const bool keep_constrained_entries, const Table<2, bool> & dof_mask) const { @@ -4327,28 +4326,37 @@ AffineConstraints::add_entries_local_to_global( // now add the indices we collected above to the sparsity pattern. Very // easy here - just add the same array to all the rows... for (size_type i = 0; i < n_actual_dofs; ++i) - sparsity_pattern.add_entries(actual_dof_indices[i], - actual_dof_indices.begin(), - actual_dof_indices.end(), - true); + sparsity_pattern.add_row_entries(actual_dof_indices[i], + make_array_view(actual_dof_indices), + true); // need to add the whole row and column structure in case we keep // constrained entries. Unfortunately, we can't use the nice matrix - // structure we use elsewhere, so manually add those indices one by one. + // structure we use elsewhere, so use the more general update function + actual_dof_indices.resize(0); + actual_dof_indices.reserve(n_local_dofs * n_local_dofs); + std::vector &rows = scratch_data->rows; + rows.resize(0); + rows.reserve(n_local_dofs * n_local_dofs); for (size_type i = 0; i < n_local_dofs; ++i) if (is_constrained(local_dof_indices[i])) { if (keep_constrained_entries == true) for (size_type j = 0; j < n_local_dofs; ++j) { - sparsity_pattern.add(local_dof_indices[i], - local_dof_indices[j]); - sparsity_pattern.add(local_dof_indices[j], - local_dof_indices[i]); + rows.push_back(local_dof_indices[i]); + actual_dof_indices.push_back(local_dof_indices[j]); + rows.push_back(local_dof_indices[j]); + actual_dof_indices.push_back(local_dof_indices[i]); } else - sparsity_pattern.add(local_dof_indices[i], local_dof_indices[i]); + { + rows.push_back(local_dof_indices[i]); + actual_dof_indices.push_back(local_dof_indices[i]); + } } + sparsity_pattern.add_entries(make_array_view(rows), + make_array_view(actual_dof_indices)); return; } @@ -4377,7 +4385,9 @@ AffineConstraints::add_entries_local_to_global( // finally, write all the information that accumulated under the given // process into the global matrix row and into the vector if (col_ptr != cols.begin()) - sparsity_pattern.add_entries(row, cols.begin(), col_ptr, true); + sparsity_pattern.add_row_entries(row, + make_array_view(cols.begin(), col_ptr), + true); } internal::AffineConstraints::set_sparsity_diagonals(global_rows, local_dof_indices, diff --git a/source/lac/affine_constraints.inst.in b/source/lac/affine_constraints.inst.in index b45ba98756..7456d909c6 100644 --- a/source/lac/affine_constraints.inst.in +++ b/source/lac/affine_constraints.inst.in @@ -259,12 +259,6 @@ for (S : REAL_AND_COMPLEX_SCALARS) for (S : REAL_AND_COMPLEX_SCALARS; SP : AFFINE_CONSTRAINTS_SP) { - template void AffineConstraints::add_entries_local_to_global( - const std::vector::size_type> &, - SP &, - const bool, - const Table<2, bool> &) const; - template void AffineConstraints::add_entries_local_to_global( const std::vector::size_type> &, const std::vector::size_type> &, @@ -283,12 +277,6 @@ for (S : REAL_AND_COMPLEX_SCALARS; SP : AFFINE_CONSTRAINTS_SP) for (S : REAL_AND_COMPLEX_SCALARS; SP : AFFINE_CONSTRAINTS_SP_BLOCK) { - template void AffineConstraints::add_entries_local_to_global( - const std::vector::size_type> &, - SP &, - const bool, - const Table<2, bool> &) const; - template void AffineConstraints::add_entries_local_to_global( const std::vector::size_type> &, const std::vector::size_type> &,