From: Marc Fehling Date: Tue, 24 Nov 2020 05:52:42 +0000 (-0700) Subject: Introduce `patch_dim` and `patch_spacedim` in DataOut classes. X-Git-Tag: v9.4.0-rc1~1325^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5e84e5664c9d590d86ce509cda05f7e738937ed;p=dealii.git Introduce `patch_dim` and `patch_spacedim` in DataOut classes. --- diff --git a/include/deal.II/base/data_out_base.h b/include/deal.II/base/data_out_base.h index affac017a7..dab3f2df5a 100644 --- a/include/deal.II/base/data_out_base.h +++ b/include/deal.II/base/data_out_base.h @@ -2456,8 +2456,8 @@ namespace DataOutBase * This class is thought as a base class to classes actually generating data * for output. It has two abstract virtual functions, get_patches() and * get_dataset_names() produce the data which is actually needed. These are - * the only functions that need to be overloaded by a derived class. In - * additional to that, it has a function for each output format supported by + * the only functions that need to be overloaded by a derived class. In + * addition to that, it has a function for each output format supported by * the underlying base class which gets the output data using these two * virtual functions and passes them to the raw output functions. * diff --git a/include/deal.II/numerics/data_out_faces.h b/include/deal.II/numerics/data_out_faces.h index 2b941aadd8..840e3269eb 100644 --- a/include/deal.II/numerics/data_out_faces.h +++ b/include/deal.II/numerics/data_out_faces.h @@ -100,28 +100,30 @@ namespace internal * applications certainly exist, for which the author is not imaginative * enough. * - * @pre This class only makes sense if the first template argument, - * dim equals the dimension of the DoFHandler type given as the - * second template argument, i.e., if dim == - * DoFHandlerType::dimension. This redundancy is a historical relic - * from the time where the library had only a single DoFHandler class and this - * class consequently only a single template argument. - * * @todo Reimplement this whole class using actual FEFaceValues and * MeshWorker. * * @ingroup output */ template -class DataOutFaces : public DataOut_DoFData +class DataOutFaces : public DataOut_DoFData { + static_assert(dim == spacedim, "Not implemented for dim != spacedim."); + public: + /** + * Dimension parameters for the patches. + */ + static constexpr int patch_dim = dim - 1; + static constexpr int patch_spacedim = spacedim; + /** * Alias to the iterator type of the dof handler class under * consideration. */ using cell_iterator = - typename DataOut_DoFData::cell_iterator; + typename DataOut_DoFData:: + cell_iterator; /** * Constructor determining whether a surface mesh (default) or the whole @@ -167,8 +169,8 @@ public: * hp::MappingCollection in case of a DoFHandler with hp-capabilities. */ virtual void - build_patches(const Mapping &mapping, - const unsigned int n_subdivisions = 0); + build_patches(const Mapping &mapping, + const unsigned int n_subdivisions = 0); /** * Declare a way to describe a face which we would like to generate output @@ -229,9 +231,9 @@ private: */ void build_one_patch( - const FaceDescriptor * cell_and_face, - internal::DataOutFacesImplementation::ParallelData &data, - DataOutBase::Patch & patch); + const FaceDescriptor *cell_and_face, + internal::DataOutFacesImplementation::ParallelData &data, + DataOutBase::Patch & patch); }; namespace Legacy diff --git a/include/deal.II/numerics/data_out_rotation.h b/include/deal.II/numerics/data_out_rotation.h index ed8e907d6d..7416fc19dc 100644 --- a/include/deal.II/numerics/data_out_rotation.h +++ b/include/deal.II/numerics/data_out_rotation.h @@ -109,25 +109,28 @@ namespace internal * It is in the responsibility of the user to make sure that the radial * variable attains only non-negative values. * - * @pre This class only makes sense if the first template argument, - * dim equals the dimension of the DoFHandler type given as the - * second template argument, i.e., if dim == - * DoFHandlerType::dimension. This redundancy is a historical relic - * from the time where the library had only a single DoFHandler class and this - * class consequently only a single template argument. - * * @ingroup output */ template -class DataOutRotation : public DataOut_DoFData +class DataOutRotation + : public DataOut_DoFData { + static_assert(dim == spacedim, "Not implemented for dim != spacedim."); + public: + /** + * Dimension parameters for the patches. + */ + static constexpr int patch_dim = dim + 1; + static constexpr int patch_spacedim = spacedim + 1; + /** * Typedef to the iterator type of the dof handler class under * consideration. */ using cell_iterator = - typename DataOut_DoFData::cell_iterator; + typename DataOut_DoFData:: + cell_iterator; /** * This is the central function of this class since it builds the list of @@ -196,7 +199,7 @@ private: build_one_patch( const cell_iterator * cell, internal::DataOutRotationImplementation::ParallelData &data, - std::vector> &my_patches); + std::vector> &my_patches); }; namespace Legacy diff --git a/include/deal.II/numerics/data_out_stack.h b/include/deal.II/numerics/data_out_stack.h index dbc01d1b37..4a8d8c7ec4 100644 --- a/include/deal.II/numerics/data_out_stack.h +++ b/include/deal.II/numerics/data_out_stack.h @@ -131,9 +131,18 @@ public: * @ingroup output */ template -class DataOutStack : public DataOutInterface +class DataOutStack + : public DataOutInterface { + static_assert(dim == spacedim, "Not implemented for dim != spacedim."); + public: + /** + * Dimension parameters for the patches. + */ + static constexpr int patch_dim = dim + 1; + static constexpr int patch_spacedim = spacedim + 1; + /** * Data type declaring the two types of vectors which are used in this * class. @@ -336,7 +345,7 @@ private: /** * List of patches of all past and present parameter value data sets. */ - std::vector> patches; + std::vector> patches; /** * Structure holding data vectors (cell and dof data) for the present @@ -377,7 +386,8 @@ private: * data in the form of Patch structures (declared in the base class * DataOutBase) to the actual output function. */ - virtual const std::vector> & + virtual const std::vector< + dealii::DataOutBase::Patch> & get_patches() const override; diff --git a/source/numerics/data_out_faces.cc b/source/numerics/data_out_faces.cc index 1844379514..fbe204cc7d 100644 --- a/source/numerics/data_out_faces.cc +++ b/source/numerics/data_out_faces.cc @@ -69,8 +69,13 @@ namespace internal template void append_patch_to_list( - const DataOutBase::Patch & patch, - std::vector> &patches) + const DataOutBase::Patch::patch_dim, + DataOutFaces::patch_spacedim> + &patch, + std::vector< + DataOutBase::Patch::patch_dim, + DataOutFaces::patch_spacedim>> + &patches) { patches.push_back(patch); patches.back().patch_index = patches.size() - 1; @@ -90,9 +95,9 @@ DataOutFaces::DataOutFaces(const bool so) template void DataOutFaces::build_one_patch( - const FaceDescriptor * cell_and_face, - internal::DataOutFacesImplementation::ParallelData &data, - DataOutBase::Patch & patch) + const FaceDescriptor *cell_and_face, + internal::DataOutFacesImplementation::ParallelData &data, + DataOutBase::Patch & patch) { Assert(cell_and_face->first->is_locally_owned(), ExcNotImplemented()); @@ -314,15 +319,16 @@ template void DataOutFaces::build_patches(const unsigned int n_subdivisions_) { - build_patches(StaticMappingQ1::mapping, n_subdivisions_); + build_patches(StaticMappingQ1::mapping, n_subdivisions_); } template void -DataOutFaces::build_patches(const Mapping &mapping, - const unsigned int n_subdivisions_) +DataOutFaces::build_patches( + const Mapping &mapping, + const unsigned int n_subdivisions_) { const unsigned int n_subdivisions = (n_subdivisions_ != 0) ? n_subdivisions_ : this->default_subdivisions; @@ -379,21 +385,23 @@ DataOutFaces::build_patches(const Mapping &mapping, mapping, this->get_fes(), update_flags); - DataOutBase::Patch sample_patch; + DataOutBase::Patch sample_patch; sample_patch.n_subdivisions = n_subdivisions; sample_patch.data.reinit(n_datasets, - Utilities::fixed_power(n_subdivisions + 1)); + Utilities::fixed_power(n_subdivisions + + 1)); // now build the patches in parallel WorkStream::run( all_faces.data(), all_faces.data() + all_faces.size(), - [this](const FaceDescriptor *cell_and_face, - internal::DataOutFacesImplementation::ParallelData &data, - DataOutBase::Patch &patch) { + [this]( + const FaceDescriptor *cell_and_face, + internal::DataOutFacesImplementation::ParallelData &data, + DataOutBase::Patch &patch) { this->build_one_patch(cell_and_face, data, patch); }, - [this](const DataOutBase::Patch &patch) { + [this](const DataOutBase::Patch &patch) { internal::DataOutFacesImplementation::append_patch_to_list( patch, this->patches); }, diff --git a/source/numerics/data_out_rotation.cc b/source/numerics/data_out_rotation.cc index f75b1e95a0..b3609418a6 100644 --- a/source/numerics/data_out_rotation.cc +++ b/source/numerics/data_out_rotation.cc @@ -84,8 +84,14 @@ namespace internal template void append_patch_to_list( - const std::vector> &new_patches, - std::vector> & patches) + const std::vector< + DataOutBase::Patch::patch_dim, + DataOutRotation::patch_spacedim>> + &new_patches, + std::vector< + DataOutBase::Patch::patch_dim, + DataOutRotation::patch_spacedim>> + &patches) { for (unsigned int i = 0; i < new_patches.size(); ++i) { @@ -103,7 +109,7 @@ void DataOutRotation::build_one_patch( const cell_iterator * cell, internal::DataOutRotationImplementation::ParallelData &data, - std::vector> &my_patches) + std::vector> &my_patches) { if (dim == 3) { @@ -506,33 +512,34 @@ DataOutRotation::build_patches( n_postprocessor_outputs[dataset] = 0; internal::DataOutRotationImplementation::ParallelData - thread_data(n_datasets, + thread_data(n_datasets, n_subdivisions, n_patches_per_circle, n_postprocessor_outputs, StaticMappingQ1::mapping, this->get_fes(), update_flags); - std::vector> new_patches( + std::vector> new_patches( n_patches_per_circle); for (unsigned int i = 0; i < new_patches.size(); ++i) { new_patches[i].n_subdivisions = n_subdivisions; new_patches[i].data.reinit( - n_datasets, Utilities::fixed_power(n_subdivisions + 1)); + n_datasets, Utilities::fixed_power(n_subdivisions + 1)); } // now build the patches in parallel WorkStream::run( all_cells.data(), all_cells.data() + all_cells.size(), - [this](const cell_iterator *cell, - internal::DataOutRotationImplementation::ParallelData - & data, - std::vector> &my_patches) { + [this]( + const cell_iterator *cell, + internal::DataOutRotationImplementation::ParallelData + & data, + std::vector> &my_patches) { this->build_one_patch(cell, data, my_patches); }, - [this](const std::vector> + [this](const std::vector> &new_patches) { internal::DataOutRotationImplementation::append_patch_to_list( diff --git a/source/numerics/data_out_stack.cc b/source/numerics/data_out_stack.cc index f28044fedb..f2011bb21f 100644 --- a/source/numerics/data_out_stack.cc +++ b/source/numerics/data_out_stack.cc @@ -308,15 +308,16 @@ DataOutStack::build_patches( // patch with n_q_points (in the plane // of the cells) times n_subdivisions+1 (in // the time direction) points - dealii::DataOutBase::Patch default_patch; + dealii::DataOutBase::Patch default_patch; default_patch.n_subdivisions = n_subdivisions; default_patch.data.reinit(n_datasets, n_q_points * (n_subdivisions + 1)); patches.insert(patches.end(), n_patches, default_patch); // now loop over all cells and // actually create the patches - typename std::vector>::iterator - patch = patches.begin() + (patches.size() - n_patches); + typename std::vector< + dealii::DataOutBase::Patch>::iterator patch = + patches.begin() + (patches.size() - n_patches); unsigned int cell_number = 0; for (typename DoFHandler::active_cell_iterator cell = dof_handler->begin_active(); @@ -451,7 +452,7 @@ template std::size_t DataOutStack::memory_consumption() const { - return (DataOutInterface::memory_consumption() + + return (DataOutInterface::memory_consumption() + MemoryConsumption::memory_consumption(parameter) + MemoryConsumption::memory_consumption(parameter_step) + MemoryConsumption::memory_consumption(dof_handler) + @@ -463,8 +464,11 @@ DataOutStack::memory_consumption() const template -const std::vector> & -DataOutStack::get_patches() const +const std::vector< + dealii::DataOutBase::Patch::patch_dim, + DataOutStack::patch_spacedim>> + & + DataOutStack::get_patches() const { return patches; }