]> https://gitweb.dealii.org/ - dealii.git/commitdiff
AffineConstraints: de-template add_entries_local_to_global() part 1
authorDavid Wells <drwells@email.unc.edu>
Thu, 3 Nov 2022 17:38:34 +0000 (13:38 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 14 Nov 2022 18:00:24 +0000 (13:00 -0500)
include/deal.II/lac/affine_constraints.h
include/deal.II/lac/affine_constraints.templates.h
source/lac/affine_constraints.inst.in

index e53dfe41bfba66113024fd64a0d525c3f737e459..ba263cd24c85e0068d29bd3b1cb20ae3b3586ce8 100644 (file)
@@ -25,6 +25,7 @@
 #include <deal.II/base/template_constraints.h>
 #include <deal.II/base/thread_local_storage.h>
 
+#include <deal.II/lac/sparsity_pattern_base.h>
 #include <deal.II/lac/vector.h>
 #include <deal.II/lac/vector_element_access.h>
 
@@ -1522,11 +1523,10 @@ public:
    * caller's site. There is no locking mechanism inside this method to
    * prevent data races.
    */
-  template <typename SparsityPatternType>
   void
   add_entries_local_to_global(
     const std::vector<size_type> &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;
 
index 0e74dd88ddbb6c77ad4f1f7c48926c8d700939a3..b34dcb3fc2e2db0f6db8d43b6f2cfdc273acd5f1 100644 (file)
@@ -4293,11 +4293,10 @@ AffineConstraints<number>::distribute_local_to_global(
 
 
 template <typename number>
-template <typename SparsityPatternType>
 void
 AffineConstraints<number>::add_entries_local_to_global(
   const std::vector<size_type> &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<number>::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<size_type> &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<number>::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,
index b45ba98756b560b7b16cff9dc118a202278ce24e..7456d909c6ae3dfd9870900bfc9308f9ebe508ed 100644 (file)
@@ -259,12 +259,6 @@ for (S : REAL_AND_COMPLEX_SCALARS)
 
 for (S : REAL_AND_COMPLEX_SCALARS; SP : AFFINE_CONSTRAINTS_SP)
   {
-    template void AffineConstraints<S>::add_entries_local_to_global<SP>(
-      const std::vector<AffineConstraints<S>::size_type> &,
-      SP &,
-      const bool,
-      const Table<2, bool> &) const;
-
     template void AffineConstraints<S>::add_entries_local_to_global<SP>(
       const std::vector<AffineConstraints<S>::size_type> &,
       const std::vector<AffineConstraints<S>::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<S>::add_entries_local_to_global<SP>(
-      const std::vector<AffineConstraints<S>::size_type> &,
-      SP &,
-      const bool,
-      const Table<2, bool> &) const;
-
     template void AffineConstraints<S>::add_entries_local_to_global<SP>(
       const std::vector<AffineConstraints<S>::size_type> &,
       const std::vector<AffineConstraints<S>::size_type> &,

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.