From 79a83f9c9c2f86d5fde25906f9535a60822293d3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 10 Nov 2022 14:30:45 -0700 Subject: [PATCH] Simplify the call to a function on a separate task. --- source/base/data_out_base.cc | 57 ++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 26254a1e96..51b8683c64 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -4950,11 +4950,10 @@ namespace DataOutBase // vertices, so do this on a separate task and when wanting to write out the // data, we wait for that task to finish Table<2, double> data_vectors(n_data_sets, n_nodes); - void (*fun_ptr)(const std::vector> &, - Table<2, double> &) = - &write_gmv_reorder_data_vectors; - Threads::Task<> reorder_task = - Threads::new_task(fun_ptr, patches, data_vectors); + Threads::Task<> reorder_task = + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); //----------------------------- // first make up a list of used vertices along with their coordinates @@ -5130,12 +5129,10 @@ namespace DataOutBase // data, we wait for that task to finish Table<2, double> data_vectors(n_data_sets, n_nodes); - - void (*fun_ptr)(const std::vector> &, - Table<2, double> &) = - &write_gmv_reorder_data_vectors; - Threads::Task<> reorder_task = - Threads::new_task(fun_ptr, patches, data_vectors); + Threads::Task<> reorder_task = + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); //----------------------------- // first make up a list of used vertices along with their coordinates @@ -5369,12 +5366,10 @@ namespace DataOutBase // vertices, so do this on a separate task and when wanting to write out the // data, we wait for that task to finish Table<2, double> data_vectors(n_data_sets, n_nodes); - - void (*fun_ptr)(const std::vector> &, - Table<2, double> &) = - &write_gmv_reorder_data_vectors; - Threads::Task<> reorder_task = - Threads::new_task(fun_ptr, patches, data_vectors); + Threads::Task<> reorder_task = + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); //----------------------------- // first make up a list of used vertices along with their coordinates @@ -5674,12 +5669,10 @@ namespace DataOutBase // vertices, so do this on a separate task and when wanting to write out the // data, we wait for that task to finish Table<2, double> data_vectors(n_data_sets, n_nodes); - - void (*fun_ptr)(const std::vector> &, - Table<2, double> &) = - &write_gmv_reorder_data_vectors; - Threads::Task<> reorder_task = - Threads::new_task(fun_ptr, patches, data_vectors); + Threads::Task<> reorder_task = + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); //----------------------------- // first make up a list of used vertices along with their coordinates @@ -6059,11 +6052,10 @@ namespace DataOutBase // data, we wait for that task to finish Table<2, float> data_vectors(n_data_sets, n_nodes); - void (*fun_ptr)(const std::vector> &, - Table<2, float> &) = - &write_gmv_reorder_data_vectors; Threads::Task<> reorder_task = - Threads::new_task(fun_ptr, patches, data_vectors); + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); //----------------------------- // first make up a list of used vertices along with their coordinates @@ -8781,6 +8773,8 @@ namespace #endif } // namespace + + template void DataOutBase::write_filtered_data( @@ -8796,7 +8790,6 @@ DataOutBase::write_filtered_data( { const unsigned int n_data_sets = data_names.size(); Table<2, double> data_vectors; - Threads::Task<> reorder_task; #ifndef DEAL_II_WITH_MPI // verify that there are indeed patches to be written out. most of the times, @@ -8815,10 +8808,10 @@ DataOutBase::write_filtered_data( std::tie(n_nodes, std::ignore) = count_nodes_and_cells(patches); data_vectors = Table<2, double>(n_data_sets, n_nodes); - void (*fun_ptr)(const std::vector> &, - Table<2, double> &) = - &DataOutBase::template write_gmv_reorder_data_vectors; - reorder_task = Threads::new_task(fun_ptr, patches, data_vectors); + Threads::Task<> reorder_task = + Threads::new_task([&patches, &data_vectors]() mutable { + write_gmv_reorder_data_vectors(patches, data_vectors); + }); // Write the nodes/cells to the DataOutFilter object. write_nodes(patches, filtered_data); -- 2.39.5