From: Wolfgang Bangerth Date: Tue, 29 Nov 2022 17:20:06 +0000 (-0700) Subject: Remove a dependency in writing VTU files. X-Git-Tag: v9.5.0-rc1~791^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89cff94a9d025a62a6a72af747af8be3a48fa76b;p=dealii.git Remove a dependency in writing VTU files. Previously, one of the lambda functions that write parts updated a variable outside the lambda function that was later checked. This works when running everything sequentially, but introduces a race condition when we want to run things in parallel. Move the updating code out of the lambda function, and so effectively make it 'const' in the sense that it no longer writes into variables outside of the lambda function. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index f0c05d9484..e303b1bfc7 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -6494,7 +6494,6 @@ namespace DataOutBase // place const Table<2, float> data_vectors = std::move(*create_global_data_table_task.return_value()); - std::vector data_set_written(n_data_sets, false); // then write data. the 'POINT_DATA' means: node data (as opposed to cell // data, which we do not support explicitly here). all following data sets @@ -6502,7 +6501,6 @@ namespace DataOutBase out << " \n"; const auto stringize_nonscalar_data_range = [&flags, - &data_set_written, &data_names, &data_vectors, ascii_or_binary, @@ -6539,10 +6537,6 @@ namespace DataOutBase "in VTK/VTU format.")); } - // mark these components as already written: - for (unsigned int i = first_component; i <= last_component; ++i) - data_set_written[i] = true; - // write the header. concatenate all the component names with double // underscores unless a vector name has been specified o << " data_set_handled(n_data_sets, false); for (const auto &range : nonscalar_data_ranges) { + // Mark these components as already handled: + const auto first_component = std::get<0>(range); + const auto last_component = std::get<1>(range); + for (unsigned int i = first_component; i <= last_component; ++i) + data_set_handled[i] = true; + out << stringize_nonscalar_data_range(range); } // Now do the left over scalar data sets for (unsigned int data_set = 0; data_set < n_data_sets; ++data_set) - if (data_set_written[data_set] == false) + if (data_set_handled[data_set] == false) { out << stringize_scalar_data_set(data_set); }