From: Daniel Arndt Date: Wed, 9 Oct 2019 04:32:43 +0000 (-0400) Subject: Move woker and copier out, use some default captures X-Git-Tag: v9.2.0-rc1~966^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0436a7b83952a4dc5a3ef700bc21b6c39484c00c;p=dealii.git Move woker and copier out, use some default captures --- diff --git a/examples/step-13/step-13.cc b/examples/step-13/step-13.cc index cab0c387e7..5fe1fb1cc0 100644 --- a/examples/step-13/step-13.cc +++ b/examples/step-13/step-13.cc @@ -737,19 +737,23 @@ namespace Step13 Threads::Task<> rhs_task = Threads::new_task(&Solver::assemble_rhs, *this, linear_system.rhs); - WorkStream::run( - dof_handler.begin_active(), - dof_handler.end(), + auto worker = [this](const typename DoFHandler::active_cell_iterator &cell, AssemblyScratchData &scratch_data, AssemblyCopyData & copy_data) { this->local_assemble_matrix(cell, scratch_data, copy_data); - }, - [this, &linear_system](const AssemblyCopyData ©_data) { - this->copy_local_to_global(copy_data, linear_system); - }, - AssemblyScratchData(*fe, *quadrature), - AssemblyCopyData()); + }; + + auto copier = [this, &linear_system](const AssemblyCopyData ©_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 diff --git a/examples/step-14/step-14.cc b/examples/step-14/step-14.cc index 2db1c83855..08a9f07a07 100644 --- a/examples/step-14/step-14.cc +++ b/examples/step-14/step-14.cc @@ -522,19 +522,23 @@ namespace Step14 Threads::Task<> rhs_task = Threads::new_task(&Solver::assemble_rhs, *this, linear_system.rhs); - WorkStream::run( - dof_handler.begin_active(), - dof_handler.end(), + auto worker = [this](const typename DoFHandler::active_cell_iterator &cell, AssemblyScratchData &scratch_data, AssemblyCopyData & copy_data) { this->local_assemble_matrix(cell, scratch_data, copy_data); - }, - [this, &linear_system](const AssemblyCopyData ©_data) { - this->copy_local_to_global(copy_data, linear_system); - }, - AssemblyScratchData(*fe, *quadrature), - AssemblyCopyData()); + }; + + auto copier = [this, &linear_system](const AssemblyCopyData ©_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 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(); + // Then hand it all off to WorkStream::run() to compute the // estimators for all cells in parallel: WorkStream::run( DualSolver::dof_handler.begin_active(), DualSolver::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(), + worker, + copier, WeightedResidualScratchData(*DualSolver::fe, *DualSolver::quadrature, *DualSolver::face_quadrature, diff --git a/examples/step-32/step-32.cc b/examples/step-32/step-32.cc index b72c40fb18..42ad54437b 100644 --- a/examples/step-32/step-32.cc +++ b/examples/step-32/step-32.cc @@ -2144,25 +2144,30 @@ namespace Step32 using CellFilter = FilteredIterator::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::active_cell_iterator &cell, Assembly::Scratch::StokesPreconditioner & scratch, Assembly::CopyData::StokesPreconditioner & data) { this->local_assemble_stokes_preconditioner(cell, scratch, data); - }, + }; + + auto copier = [this](const Assembly::CopyData::StokesPreconditioner &data) { this->copy_local_to_global_stokes_preconditioner(data); - }, - Assembly::Scratch::StokesPreconditioner(stokes_fe, - quadrature_formula, - mapping, - update_JxW_values | - update_values | - update_gradients), - Assembly::CopyData::StokesPreconditioner(stokes_fe)); + }; + + WorkStream::run(CellFilter(IteratorFilters::LocallyOwnedCell(), + stokes_dof_handler.begin_active()), + CellFilter(IteratorFilters::LocallyOwnedCell(), + stokes_dof_handler.end()), + worker, + copier, + Assembly::Scratch::StokesPreconditioner( + stokes_fe, + quadrature_formula, + mapping, + update_JxW_values | update_values | update_gradients), + Assembly::CopyData::StokesPreconditioner(stokes_fe)); stokes_preconditioner_matrix.compress(VectorOperation::add); } @@ -2711,28 +2716,31 @@ namespace Step32 using CellFilter = FilteredIterator::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::active_cell_iterator &cell, - Assembly::Scratch::TemperatureRHS & scratch, - Assembly::CopyData::TemperatureRHS & data) { + auto worker = + [=](const typename DoFHandler::active_cell_iterator &cell, + Assembly::Scratch::TemperatureRHS & scratch, + Assembly::CopyData::TemperatureRHS & data) { this->local_assemble_temperature_rhs(global_T_range, maximal_velocity, global_entropy_variation, cell, scratch, data); - }, - [this](const Assembly::CopyData::TemperatureRHS &data) { - this->copy_local_to_global_temperature_rhs(data); - }, - Assembly::Scratch::TemperatureRHS( - temperature_fe, stokes_fe, mapping, quadrature_formula), - Assembly::CopyData::TemperatureRHS(temperature_fe)); + }; + + auto copier = [=](const Assembly::CopyData::TemperatureRHS &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( + temperature_fe, stokes_fe, mapping, quadrature_formula), + Assembly::CopyData::TemperatureRHS(temperature_fe)); temperature_rhs.compress(VectorOperation::add); }