]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert a bunch of places to use AffineConstraint::add_constraint().
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 5 Oct 2023 22:19:22 +0000 (16:19 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 6 Oct 2023 16:56:42 +0000 (10:56 -0600)
include/deal.II/numerics/vector_tools_boundary.templates.h
include/deal.II/numerics/vector_tools_constraints.templates.h
source/dofs/dof_tools_constraints.cc

index 6bd811a010e54fa04034412f7675ff985ce1ebac..7b8b9d4a42168f5a9cdf2ba2458e3aef1ec7c7a2 100644 (file)
@@ -519,11 +519,9 @@ namespace VectorTools
       {
         if (constraints.can_store_line(boundary_value.first) &&
             !constraints.is_constrained(boundary_value.first))
-          {
-            constraints.add_line(boundary_value.first);
-            constraints.set_inhomogeneity(boundary_value.first,
-                                          boundary_value.second);
-          }
+          constraints.add_constraint(boundary_value.first,
+                                     {},
+                                     boundary_value.second);
       }
   }
 
@@ -564,11 +562,9 @@ namespace VectorTools
       {
         if (constraints.can_store_line(boundary_value.first) &&
             !constraints.is_constrained(boundary_value.first))
-          {
-            constraints.add_line(boundary_value.first);
-            constraints.set_inhomogeneity(boundary_value.first,
-                                          boundary_value.second);
-          }
+          constraints.add_constraint(boundary_value.first,
+                                     {},
+                                     boundary_value.second);
       }
   }
 
@@ -955,16 +951,13 @@ namespace VectorTools
     std::map<types::global_dof_index, number> boundary_values;
     project_boundary_values(
       mapping, dof, boundary_functions, q, boundary_values, component_mapping);
-    typename std::map<types::global_dof_index, number>::const_iterator
-      boundary_value = boundary_values.begin();
-    for (; boundary_value != boundary_values.end(); ++boundary_value)
+
+    for (const auto &boundary_value : boundary_values)
       {
-        if (!constraints.is_constrained(boundary_value->first))
-          {
-            constraints.add_line(boundary_value->first);
-            constraints.set_inhomogeneity(boundary_value->first,
-                                          boundary_value->second);
-          }
+        if (!constraints.is_constrained(boundary_value.first))
+          constraints.add_constraint(boundary_value.first,
+                                     {},
+                                     boundary_value.second);
       }
   }
 
@@ -1934,16 +1927,12 @@ namespace VectorTools
                                         face_dof_indices[dof]) &&
                                       !(constraints.is_constrained(
                                         face_dof_indices[dof])))
-                                    {
-                                      constraints.add_line(
-                                        face_dof_indices[dof]);
-                                      if (std::abs(dof_values[dof]) > 1e-13)
-                                        {
-                                          constraints.set_inhomogeneity(
-                                            face_dof_indices[dof],
-                                            dof_values[dof]);
-                                        }
-                                    }
+                                    constraints.add_constraint(
+                                      face_dof_indices[dof],
+                                      {},
+                                      (std::abs(dof_values[dof]) > 1e-13 ?
+                                         dof_values[dof] :
+                                         0));
                                 }
                             }
                         }
@@ -2078,17 +2067,12 @@ namespace VectorTools
                                         face_dof_indices[dof]) &&
                                       !(constraints.is_constrained(
                                         face_dof_indices[dof])))
-                                    {
-                                      constraints.add_line(
-                                        face_dof_indices[dof]);
-
-                                      if (std::abs(dof_values[dof]) > 1e-13)
-                                        {
-                                          constraints.set_inhomogeneity(
-                                            face_dof_indices[dof],
-                                            dof_values[dof]);
-                                        }
-                                    }
+                                    constraints.add_constraint(
+                                      face_dof_indices[dof],
+                                      {},
+                                      (std::abs(dof_values[dof]) > 1e-13 ?
+                                         dof_values[dof] :
+                                         0));
                                 }
                             }
                         }
@@ -2232,12 +2216,11 @@ namespace VectorTools
               cell->face_orientation(face),
               cell->face_flip(face),
               cell->face_rotation(face)))[first_vector_component])
-          {
-            constraints.add_line(face_dof_indices[i]);
-
-            if (std::abs(dof_values(i)) > 1e-14)
-              constraints.set_inhomogeneity(face_dof_indices[i], dof_values(i));
-          }
+          constraints.add_constraint(face_dof_indices[i],
+                                     {},
+                                     (std::abs(dof_values[i]) > 1e-14 ?
+                                        dof_values[i] :
+                                        0));
     }
 
     // dummy implementation of above function for all other dimensions
@@ -2529,12 +2512,11 @@ namespace VectorTools
             for (unsigned int dof = 0; dof < n_dofs; ++dof)
               if ((projected_dofs[dof] != 0) &&
                   !(constraints.is_constrained(dof)))
-                {
-                  constraints.add_line(dof);
-
-                  if (std::abs(dof_values[dof]) > 1e-14)
-                    constraints.set_inhomogeneity(dof, dof_values[dof]);
-                }
+                constraints.add_constraint(dof,
+                                           {},
+                                           (std::abs(dof_values[dof]) > 1e-14 ?
+                                              dof_values[dof] :
+                                              0));
 
             break;
           }
@@ -2688,12 +2670,11 @@ namespace VectorTools
             for (unsigned int dof = 0; dof < n_dofs; ++dof)
               if ((projected_dofs[dof] != 0) &&
                   !(constraints.is_constrained(dof)))
-                {
-                  constraints.add_line(dof);
-
-                  if (std::abs(dof_values[dof]) > 1e-14)
-                    constraints.set_inhomogeneity(dof, dof_values[dof]);
-                }
+                constraints.add_constraint(dof,
+                                           {},
+                                           (std::abs(dof_values[dof]) > 1e-14 ?
+                                              dof_values[dof] :
+                                              0));
 
             break;
           }
index f8c8146c618559e66ca316d46f206e5cb623dae0..7a28a5efb83c638d7e276ac9e7cb39e14ea22844 100644 (file)
@@ -1063,13 +1063,13 @@ namespace VectorTools
                         constraints.can_store_line(
                           same_dof_range[0]->first.dof_indices[i]))
                       {
-                        const types::global_dof_index line =
-                          dof_indices.dof_indices[i];
-                        constraints.add_line(line);
-                        if (std::fabs(b_values[i]) >
-                            std::numeric_limits<double>::epsilon())
-                          constraints.set_inhomogeneity(line, b_values[i]);
-                        // no add_entries here
+                        constraints.add_constraint(
+                          dof_indices.dof_indices[i],
+                          {},
+                          (std::fabs(b_values[i]) >
+                               std::numeric_limits<double>::epsilon() ?
+                             b_values[i] :
+                             0));
                       }
 
                   break;
@@ -1459,10 +1459,7 @@ namespace VectorTools
               {
                 const Vector<double> b_value = dof_vector_to_b_values[dofs];
                 for (unsigned int d = 0; d < dim; ++d)
-                  {
-                    constraints.add_line(dofs[d]);
-                    constraints.set_inhomogeneity(dofs[d], b_value(d));
-                  }
+                  constraints.add_constraint(dofs[d], {}, b_value(d));
                 continue;
               }
 
@@ -1502,12 +1499,15 @@ namespace VectorTools
                 const unsigned int new_index = dofs[d];
                 if (!constraints.is_constrained(new_index))
                   {
-                    constraints.add_line(new_index);
                     if (std::abs(normal[d]) > 1e-13)
-                      constraints.add_entry(new_index,
-                                            dofs[constrained_index],
-                                            -normal[d]);
-                    constraints.set_inhomogeneity(new_index, boundary_value[d]);
+                      constraints.add_constraint(new_index,
+                                                 {{dofs[constrained_index],
+                                                   -normal[d]}},
+                                                 boundary_value[d]);
+                    else
+                      constraints.add_constraint(new_index,
+                                                 {},
+                                                 boundary_value[d]);
                   }
               }
           }
index 7e8aafdef6ed72162d090b350ec734f0ab44369b..716de8eca869550566432db35c34f1733cfb0254 100644 (file)
@@ -571,9 +571,9 @@ namespace DoFTools
                 if (std::fabs(face_constraints(row, i)) >= 1e-14 * abs_sum)
                   entries.emplace_back(primary_dofs[i],
                                        face_constraints(row, i));
-              constraints.add_line(dependent_dofs[row]);
-              constraints.add_entries(dependent_dofs[row], entries);
-              constraints.set_inhomogeneity(dependent_dofs[row], 0.);
+              constraints.add_constraint(dependent_dofs[row],
+                                         entries,
+                                         /* inhomogeneity= */ 0.);
             }
       }
 

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.