]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move woker and copier out, use some default captures
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 9 Oct 2019 04:32:43 +0000 (00:32 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Wed, 9 Oct 2019 04:32:43 +0000 (00:32 -0400)
examples/step-13/step-13.cc
examples/step-14/step-14.cc
examples/step-32/step-32.cc

index cab0c387e785c35cfc24dcf1c771ec1407cf089a..5fe1fb1cc003c11bbd9b4358b248b4d133983afe 100644 (file)
@@ -737,19 +737,23 @@ namespace Step13
       Threads::Task<> rhs_task =
         Threads::new_task(&Solver<dim>::assemble_rhs, *this, linear_system.rhs);
 
-      WorkStream::run(
-        dof_handler.begin_active(),
-        dof_handler.end(),
+      auto worker =
         [this](const typename DoFHandler<dim>::active_cell_iterator &cell,
                AssemblyScratchData &scratch_data,
                AssemblyCopyData &   copy_data) {
           this->local_assemble_matrix(cell, scratch_data, copy_data);
-        },
-        [this, &linear_system](const AssemblyCopyData &copy_data) {
-          this->copy_local_to_global(copy_data, linear_system);
-        },
-        AssemblyScratchData(*fe, *quadrature),
-        AssemblyCopyData());
+        };
+
+      auto copier = [this, &linear_system](const AssemblyCopyData &copy_data) {
+        this->copy_local_to_global(copy_data, linear_system);
+      };
+
+      WorkStream::run(dof_handler.begin_active(),
+                      dof_handler.end(),
+                      worker,
+                      copier,
+                      AssemblyScratchData(*fe, *quadrature),
+                      AssemblyCopyData());
       linear_system.hanging_node_constraints.condense(linear_system.matrix);
 
       // The syntax above using lambda functions requires
index 2db1c838550ab4c0f485c7ecf8804fd50b572571..08a9f07a0717d76dd09eb33c319c851e7789873d 100644 (file)
@@ -522,19 +522,23 @@ namespace Step14
       Threads::Task<> rhs_task =
         Threads::new_task(&Solver<dim>::assemble_rhs, *this, linear_system.rhs);
 
-      WorkStream::run(
-        dof_handler.begin_active(),
-        dof_handler.end(),
+      auto worker =
         [this](const typename DoFHandler<dim>::active_cell_iterator &cell,
                AssemblyScratchData &scratch_data,
                AssemblyCopyData &   copy_data) {
           this->local_assemble_matrix(cell, scratch_data, copy_data);
-        },
-        [this, &linear_system](const AssemblyCopyData &copy_data) {
-          this->copy_local_to_global(copy_data, linear_system);
-        },
-        AssemblyScratchData(*fe, *quadrature),
-        AssemblyCopyData());
+        };
+
+      auto copier = [this, &linear_system](const AssemblyCopyData &copy_data) {
+        this->copy_local_to_global(copy_data, linear_system);
+      };
+
+      WorkStream::run(dof_handler.begin_active(),
+                      dof_handler.end(),
+                      worker,
+                      copier,
+                      AssemblyScratchData(*fe, *quadrature),
+                      AssemblyCopyData());
       linear_system.hanging_node_constraints.condense(linear_system.matrix);
 
       std::map<types::global_dof_index, double> boundary_value_map;
@@ -2188,20 +2192,24 @@ namespace Step14
              ++face_no)
           face_integrals[cell->face(face_no)] = -1e20;
 
+      auto worker = [this,
+                     &error_indicators,
+                     &face_integrals](const active_cell_iterator & cell,
+                                      WeightedResidualScratchData &scratch_data,
+                                      WeightedResidualCopyData &   copy_data) {
+        this->estimate_on_one_cell(
+          cell, scratch_data, copy_data, error_indicators, face_integrals);
+      };
+
+      auto copier = std::function<void(const WeightedResidualCopyData &)>();
+
       // Then hand it all off to WorkStream::run() to compute the
       // estimators for all cells in parallel:
       WorkStream::run(
         DualSolver<dim>::dof_handler.begin_active(),
         DualSolver<dim>::dof_handler.end(),
-        [this,
-         &error_indicators,
-         &face_integrals](const active_cell_iterator & cell,
-                          WeightedResidualScratchData &scratch_data,
-                          WeightedResidualCopyData &   copy_data) {
-          this->estimate_on_one_cell(
-            cell, scratch_data, copy_data, error_indicators, face_integrals);
-        },
-        std::function<void(const WeightedResidualCopyData &)>(),
+        worker,
+        copier,
         WeightedResidualScratchData(*DualSolver<dim>::fe,
                                     *DualSolver<dim>::quadrature,
                                     *DualSolver<dim>::face_quadrature,
index b72c40fb18623459dd521853fc2903ab6dc61162..42ad54437bcb0b44052b65a1ec841e93eb970058 100644 (file)
@@ -2144,25 +2144,30 @@ namespace Step32
     using CellFilter =
       FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
 
-    WorkStream::run(
-      CellFilter(IteratorFilters::LocallyOwnedCell(),
-                 stokes_dof_handler.begin_active()),
-      CellFilter(IteratorFilters::LocallyOwnedCell(), stokes_dof_handler.end()),
+    auto worker =
       [this](const typename DoFHandler<dim>::active_cell_iterator &cell,
              Assembly::Scratch::StokesPreconditioner<dim> &        scratch,
              Assembly::CopyData::StokesPreconditioner<dim> &       data) {
         this->local_assemble_stokes_preconditioner(cell, scratch, data);
-      },
+      };
+
+    auto copier =
       [this](const Assembly::CopyData::StokesPreconditioner<dim> &data) {
         this->copy_local_to_global_stokes_preconditioner(data);
-      },
-      Assembly::Scratch::StokesPreconditioner<dim>(stokes_fe,
-                                                   quadrature_formula,
-                                                   mapping,
-                                                   update_JxW_values |
-                                                     update_values |
-                                                     update_gradients),
-      Assembly::CopyData::StokesPreconditioner<dim>(stokes_fe));
+      };
+
+    WorkStream::run(CellFilter(IteratorFilters::LocallyOwnedCell(),
+                               stokes_dof_handler.begin_active()),
+                    CellFilter(IteratorFilters::LocallyOwnedCell(),
+                               stokes_dof_handler.end()),
+                    worker,
+                    copier,
+                    Assembly::Scratch::StokesPreconditioner<dim>(
+                      stokes_fe,
+                      quadrature_formula,
+                      mapping,
+                      update_JxW_values | update_values | update_gradients),
+                    Assembly::CopyData::StokesPreconditioner<dim>(stokes_fe));
 
     stokes_preconditioner_matrix.compress(VectorOperation::add);
   }
@@ -2711,28 +2716,31 @@ namespace Step32
     using CellFilter =
       FilteredIterator<typename DoFHandler<2>::active_cell_iterator>;
 
-    WorkStream::run(
-      CellFilter(IteratorFilters::LocallyOwnedCell(),
-                 temperature_dof_handler.begin_active()),
-      CellFilter(IteratorFilters::LocallyOwnedCell(),
-                 temperature_dof_handler.end()),
-      [this, global_T_range, maximal_velocity, global_entropy_variation](
-        const typename DoFHandler<dim>::active_cell_iterator &cell,
-        Assembly::Scratch::TemperatureRHS<dim> &              scratch,
-        Assembly::CopyData::TemperatureRHS<dim> &             data) {
+    auto worker =
+      [=](const typename DoFHandler<dim>::active_cell_iterator &cell,
+          Assembly::Scratch::TemperatureRHS<dim> &              scratch,
+          Assembly::CopyData::TemperatureRHS<dim> &             data) {
         this->local_assemble_temperature_rhs(global_T_range,
                                              maximal_velocity,
                                              global_entropy_variation,
                                              cell,
                                              scratch,
                                              data);
-      },
-      [this](const Assembly::CopyData::TemperatureRHS<dim> &data) {
-        this->copy_local_to_global_temperature_rhs(data);
-      },
-      Assembly::Scratch::TemperatureRHS<dim>(
-        temperature_fe, stokes_fe, mapping, quadrature_formula),
-      Assembly::CopyData::TemperatureRHS<dim>(temperature_fe));
+      };
+
+    auto copier = [=](const Assembly::CopyData::TemperatureRHS<dim> &data) {
+      this->copy_local_to_global_temperature_rhs(data);
+    };
+
+    WorkStream::run(CellFilter(IteratorFilters::LocallyOwnedCell(),
+                               temperature_dof_handler.begin_active()),
+                    CellFilter(IteratorFilters::LocallyOwnedCell(),
+                               temperature_dof_handler.end()),
+                    worker,
+                    copier,
+                    Assembly::Scratch::TemperatureRHS<dim>(
+                      temperature_fe, stokes_fe, mapping, quadrature_formula),
+                    Assembly::CopyData::TemperatureRHS<dim>(temperature_fe));
 
     temperature_rhs.compress(VectorOperation::add);
   }

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.