From: bangerth Date: Wed, 29 Oct 2008 02:20:03 +0000 (+0000) Subject: Simplify things a bit: let all DataOut* classes use the same internal data structure... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f470b3b6fba9cbf571d1d5ca92cc1ea9763404b;p=dealii-svn.git Simplify things a bit: let all DataOut* classes use the same internal data structure for parallelization. git-svn-id: https://svn.dealii.org/trunk@17390 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/data_out.h b/deal.II/deal.II/include/numerics/data_out.h index fe1b75bd81..1d135a8c00 100644 --- a/deal.II/deal.II/include/numerics/data_out.h +++ b/deal.II/deal.II/include/numerics/data_out.h @@ -30,6 +30,62 @@ DEAL_II_NAMESPACE_OPEN template class FEValuesBase; +namespace internal +{ + namespace DataOut + { + /** + * A data structure that holds + * all data needed in one thread + * when building patches in + * parallel. These data + * structures are created + * globally rather than on each + * cell to avoid allocation of + * memory in the threads. + * + * The #cell_to_patch_index_map is + * an array that stores for index + * [i][j] the number of the + * patch that associated with the + * cell with index @p j on level + * @p i. This information is set + * up prior to generation of the + * patches, and is needed to + * generate neighborship + * information. + * + * This structure is used by + * several of the DataOut* + * classes, not all of which use + * all fields. + */ + template + struct ParallelData + { + unsigned int n_threads; + unsigned int this_thread; + unsigned int n_components; + unsigned int n_datasets; + unsigned int n_subdivisions; + unsigned int n_patches_per_circle; + SmartPointer > mapping; + std::vector patch_values; + std::vector > patch_values_system; + std::vector > patch_gradients; + std::vector > > patch_gradients_system; + std::vector > patch_hessians; + std::vector > > patch_hessians_system; + std::vector > dummy_normals; + std::vector > patch_normals; + std::vector > > postprocessed_values; + + std::vector > *cell_to_patch_index_map; + }; + } +} + + //TODO: Most of the documentation of DataOut_DoFData applies to DataOut. /** @@ -1252,43 +1308,7 @@ class DataOut : public DataOut_DoFData << ", is not valid."); private: - /** - * All data needed in one thread - * is gathered in the struct - * Data. The data is handled - * globally to avoid allocation - * of memory in the threads. - * - * The #cell_to_patch_index_map is - * an array that stores for index - * [i][j] the number of the - * patch that associated with the - * cell with index @p j on level - * @p i. This information is set - * up prior to generation of the - * patches, and is needed to - * generate neighborship - * information. - */ - struct Data - { - unsigned int n_threads; - unsigned int this_thread; - unsigned int n_components; - unsigned int n_datasets; - unsigned int n_subdivisions; - SmartPointer > mapping; - std::vector patch_values; - std::vector > patch_values_system; - std::vector > patch_gradients; - std::vector > > patch_gradients_system; - std::vector > patch_hessians; - std::vector > > patch_hessians_system; - std::vector > dummy_normals; - std::vector > > postprocessed_values; - - std::vector > *cell_to_patch_index_map; - }; + /** * Builds every @p n_threads's * patch. This function may be @@ -1297,7 +1317,7 @@ class DataOut : public DataOut_DoFData * used, the function is called * once and generates all patches. */ - void build_some_patches (Data &data); + void build_some_patches (internal::DataOut::ParallelData &data); /** * Store in which region cells shall be diff --git a/deal.II/deal.II/include/numerics/data_out_faces.h b/deal.II/deal.II/include/numerics/data_out_faces.h index bd86ce8ce8..a7ea418032 100644 --- a/deal.II/deal.II/include/numerics/data_out_faces.h +++ b/deal.II/deal.II/include/numerics/data_out_faces.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -181,32 +181,6 @@ class DataOutFaces : public DataOut_DoFData patch_values; - std::vector > patch_values_system; - std::vector > patch_gradients; - std::vector > > patch_gradients_system; - std::vector > patch_hessians; - std::vector > > patch_hessians_system; - std::vector > > postprocessed_values; - std::vector > patch_normals; - Data () - {} - }; /** * Builds every @p n_threads's * patch. This function may be @@ -215,7 +189,7 @@ class DataOutFaces : public DataOut_DoFData &data); }; diff --git a/deal.II/deal.II/include/numerics/data_out_rotation.h b/deal.II/deal.II/include/numerics/data_out_rotation.h index 843f395281..65b1565a92 100644 --- a/deal.II/deal.II/include/numerics/data_out_rotation.h +++ b/deal.II/deal.II/include/numerics/data_out_rotation.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -169,33 +169,6 @@ class DataOutRotation : public DataOut_DoFData << "The radial variable attains a negative value of " << arg1); private: - /** - * All data needed in one thread - * is gathered in the struct - * Data. - * The data is handled globally - * to avoid allocation of memory - * in the threads. - */ - struct Data - { - unsigned int n_threads; - unsigned int this_thread; - unsigned int n_components; - unsigned int n_datasets; - unsigned int n_patches_per_circle; - unsigned int n_subdivisions; - std::vector patch_values; - std::vector > patch_values_system; - std::vector > patch_gradients; - std::vector > > patch_gradients_system; - std::vector > patch_hessians; - std::vector > > patch_hessians_system; - std::vector > > postprocessed_values; - std::vector > dummy_normals; - Data () - {} - }; /** * Builds every @p n_threads's * patch. This function may be @@ -204,7 +177,7 @@ class DataOutRotation : public DataOut_DoFData * used, the function is called * once and generates all patches. */ - void build_some_patches (Data &data); + void build_some_patches (internal::DataOut::ParallelData &data); }; diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index 18001c900f..b5593136de 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -620,7 +620,7 @@ DataOut_DoFData::memory_consumption () const template -void DataOut::build_some_patches (Data &data) +void DataOut::build_some_patches (internal::DataOut::ParallelData &data) { // Check consistency of redundant // template parameter @@ -1049,7 +1049,7 @@ void DataOut::build_patches (const Mapping &mapping, // init data for the threads - std::vector thread_data(n_threads); + std::vector > thread_data(n_threads); for (unsigned int i=0;i -void DataOutFaces::build_some_patches (Data &data) +void DataOutFaces::build_some_patches (internal::DataOut::ParallelData &data) { // Check consistency of redundant // template parameter @@ -279,7 +279,7 @@ void DataOutFaces::build_patches (const unsigned int nnnn_subdivisions, face = next_face(face)) ++n_patches; - std::vector thread_data(n_threads); + std::vector > thread_data(n_threads); // init data for the threads for (unsigned int i=0;i -void DataOutRotation::build_some_patches (Data &data) +void DataOutRotation::build_some_patches (internal::DataOut::ParallelData &data) { QTrapez<1> q_trapez; QIterated patch_points (q_trapez, data.n_subdivisions); @@ -406,7 +406,7 @@ void DataOutRotation::build_some_patches (Data &data) #else template -void DataOutRotation::build_some_patches (Data&) +void DataOutRotation::build_some_patches (internal::DataOut::ParallelData &) { // would this function make any // sense after all? who would want @@ -477,7 +477,7 @@ void DataOutRotation::build_patches ( // rotation n_patches *= n_patches_per_circle; - std::vector thread_data(n_threads); + std::vector > thread_data(n_threads); // init data for the threads for (unsigned int i=0;i::build_patches ( if (DEAL_II_USE_MT) { - void (DataOutRotation::*p) (Data &) + void (DataOutRotation::*p) (internal::DataOut::ParallelData &) = &DataOutRotation::build_some_patches; Threads::ThreadGroup<> threads;