]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use self-documenting empty type: std::tuple<> 13828/head
authorMartin Kronbichler <martin.kronbichler@uni-a.de>
Fri, 3 Jun 2022 07:08:16 +0000 (09:08 +0200)
committerMartin Kronbichler <martin.kronbichler@uni-a.de>
Fri, 3 Jun 2022 15:26:02 +0000 (17:26 +0200)
include/deal.II/dofs/dof_accessor.templates.h
source/dofs/dof_handler_policy.cc

index 66129d1792a67a8887474a5fd5922c9fb22401a1..05f1c156bf8b78b5dd31bd083a8b323777ca81d5 100644 (file)
@@ -493,7 +493,7 @@ namespace internal
 
 
       // The next few internal helper functions are needed to support various
-      // DoFIndicesType kinds, e.g. actual vectors of DoFIndices or dummy
+      // DoFIndicesType kinds, e.g. actual vectors of DoFIndices or empty
       // types that we use when we only want to work on the internally stored
       // DoFs and never extract any number.
       static unsigned int
@@ -503,7 +503,7 @@ namespace internal
       }
 
       static unsigned int
-      get_array_length(const int &)
+      get_array_length(const std::tuple<> &)
       {
         return 0;
       }
@@ -524,10 +524,10 @@ namespace internal
         return array[index];
       }
 
-      static unsigned int
-      get_array_entry(const int &, const unsigned int)
+      static types::global_dof_index
+      get_array_entry(const std::tuple<> &, const unsigned int)
       {
-        return 0;
+        return numbers::invalid_dof_index;
       }
 
 
@@ -1021,9 +1021,12 @@ namespace internal
 
         const auto &fe = accessor.get_fe(fe_index);
 
-        // we want to pass in rvalue 'int' types as `DoFIndicesType`, but we
-        // need non-const references for std::vector<> types, so get in a
-        // const reference here and immediately cast it away
+        // we want to pass in rvalue 'std::tuple<>' types as `DoFIndicesType`,
+        // but we need non-const references for std::vector<> types, so get in
+        // a const reference here and immediately cast the constness away -
+        // note that we prevent the use of the dereferenced invalid type, as
+        // we only return an rvalue `types::global_dof_index` into the lambda
+        // function DoFOperation that operates on it
         DoFIndicesType &dof_indices =
           const_cast<DoFIndicesType &>(const_dof_indices);
 
index c8ab7b57b2ec2cac0279a97707a02ee44ae233b3..91334cf40d069c0685c8f4d7b8c85e79cac1168c 100644 (file)
@@ -1763,12 +1763,12 @@ namespace internal
                 ((subdomain_id == numbers::invalid_subdomain_id) ||
                  (cell->subdomain_id() == subdomain_id)))
               {
-                // need to create a dummy int reference to feed the
-                // process_dof_indices function for the case we do want want
-                // to retrieve any index
+                // feed the process_dof_indices function with an empty type
+                // `std::tuple<>`, as we do not want to retrieve any DoF
+                // indices here and rather modify the stored ones
                 DoFAccessorImplementation::Implementation::process_dof_indices(
                   *cell,
-                  0,
+                  std::make_tuple(),
                   cell->active_fe_index(),
                   DoFAccessorImplementation::Implementation::
                     DoFIndexProcessor<dim, spacedim, false>(),
@@ -1868,7 +1868,7 @@ namespace internal
               {
                 DoFAccessorImplementation::Implementation::process_dof_indices(
                   *cell,
-                  0,
+                  std::make_tuple(),
                   0,
                   DoFAccessorImplementation::Implementation::
                     MGDoFIndexProcessor<dim, spacedim>(level),
@@ -4276,7 +4276,7 @@ namespace internal
             {
               DoFAccessorImplementation::Implementation::process_dof_indices(
                 *cell,
-                0,
+                std::make_tuple(),
                 cell->active_fe_index(),
                 DoFAccessorImplementation::Implementation::
                   DoFIndexProcessor<dim, spacedim, false>(),
@@ -4411,7 +4411,7 @@ namespace internal
             {
               DoFAccessorImplementation::Implementation::process_dof_indices(
                 *cell,
-                0,
+                std::make_tuple(),
                 0,
                 DoFAccessorImplementation::Implementation::
                   MGDoFIndexProcessor<dim, spacedim>(cell->level()),

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.