deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
bounding_box_data_out.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2020 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_bounding_box_data_out_h
14#define dealii_bounding_box_data_out_h
15
16#include <deal.II/base/config.h>
17
21#include <deal.II/base/point.h>
22
26
27#include <boost/geometry/index/rtree.hpp>
28#include <boost/geometry/strategies/strategies.hpp>
29
30
32
37template <int dim>
38class BoundingBoxDataOut : public DataOutInterface<dim, dim>
39{
40public:
44 BoundingBoxDataOut() = default;
45
50
58 template <class ConvertibleToBoundingBoxIterator>
59 void
60 build_patches(const ConvertibleToBoundingBoxIterator &begin,
61 const ConvertibleToBoundingBoxIterator &end);
62
71 template <class Container>
72 void
73 build_patches(const Container &boxes);
74
85 void
86 add_datasets(const std::vector<std::vector<double>> &datasets,
87 const std::vector<std::string> &dataset_names);
88
89protected:
90 // Copy doc
91 virtual const std::vector<::DataOutBase::Patch<dim, dim>> &
92 get_patches() const override;
93
94 // Copy doc
95 virtual std::vector<std::string>
96 get_dataset_names() const override;
97
98private:
102 std::vector<DataOutBase::Patch<dim, dim>> patches;
103
107 std::vector<std::string> dataset_names;
108};
109
110
111// Template and inline functions
112#ifndef DOXYGEN
113template <int dim>
114template <class ConvertibleToBoundingBoxIterator>
115void
117 const ConvertibleToBoundingBoxIterator &begin,
118 const ConvertibleToBoundingBoxIterator &end)
119{
120 using Getter = boost::geometry::index::indexable<
121 typename ConvertibleToBoundingBoxIterator::value_type>;
122 Getter getter;
123 constexpr unsigned int boxdim =
124 boost::geometry::dimension<typename Getter::result_type>::value;
125 const unsigned int N = std::distance(begin, end);
126 static_assert(boxdim == dim, "Bounding boxes are of the wrong dimension!");
127
128 dataset_names.clear();
129 patches.resize(N);
130
131 unsigned int i = 0;
132 for (const auto &value :
134 {
136 boost::geometry::convert(getter(*value), box);
137 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
138 {
139 patches[i].vertices[v] = box.vertex(v);
140 patches[i].patch_index = i;
141 patches[i].n_subdivisions = 1;
142 patches[i].reference_cell = ReferenceCells::get_hypercube<dim>();
143 patches[i].points_are_available = false;
144 }
145 ++i;
146 }
147}
148
149
150
151template <int dim>
152template <class Container>
153void
154BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
155{
156 build_patches(boxes.begin(), boxes.end());
157}
158
159
160
161template <int dim>
162void
164 const std::vector<std::vector<double>> &datasets,
165 const std::vector<std::string> &names)
166{
167 AssertDimension(datasets.size(), patches.size());
168 dataset_names = names;
169 for (unsigned int i = 0; i < datasets.size(); ++i)
170 {
171 AssertDimension(datasets[i].size(), names.size());
172 patches[i].data.reinit(names.size(),
174 for (unsigned int j = 0; j < names.size(); ++j)
175 for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
176 patches[i].data(j, k) = datasets[i][j];
177 }
178}
179
180
181
182template <int dim>
183const std::vector<DataOutBase::Patch<dim, dim>> &
185{
186 return patches;
187}
188
189
190
191template <int dim>
192std::vector<std::string>
194{
195 return dataset_names;
196}
197
198#endif
199
201
202#endif
*  iterator end()
*  *  iterator begin()
BoundingBoxDataOut()=default
void add_datasets(const std::vector< std::vector< double > > &datasets, const std::vector< std::string > &dataset_names)
void build_patches(const ConvertibleToBoundingBoxIterator &begin, const ConvertibleToBoundingBoxIterator &end)
virtual std::vector< std::string > get_dataset_names() const override
~BoundingBoxDataOut()=default
std::vector< std::string > dataset_names
std::vector< DataOutBase::Patch< dim, dim > > patches
void build_patches(const Container &boxes)
virtual const std::vector<::DataOutBase::Patch< dim, dim > > & get_patches() const override
Point< spacedim, Number > vertex(const unsigned int index) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define AssertDimension(dim1, dim2)
std::vector< index_type > data
Definition mpi.cc:734
std::size_t size
Definition mpi.cc:733