Reference documentation for deal.II version 9.5.0
\(\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// Copyright (C) 2020 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_bounding_box_data_out_h
17#define dealii_bounding_box_data_out_h
18
19#include <deal.II/base/config.h>
20
24#include <deal.II/base/point.h>
25
29
30#include <boost/geometry/index/rtree.hpp>
31#include <boost/geometry/strategies/strategies.hpp>
32
33
35
40template <int dim>
41class BoundingBoxDataOut : public DataOutInterface<dim, dim>
42{
43public:
47 BoundingBoxDataOut() = default;
48
53
61 template <class ConvertibleToBoundingBoxIterator>
62 void
63 build_patches(const ConvertibleToBoundingBoxIterator &begin,
64 const ConvertibleToBoundingBoxIterator &end);
65
74 template <class Container>
75 void
76 build_patches(const Container &boxes);
77
88 void
89 add_datasets(const std::vector<std::vector<double>> &datasets,
90 const std::vector<std::string> & dataset_names);
91
92protected:
93 // Copy doc
94 virtual const std::vector<::DataOutBase::Patch<dim, dim>> &
95 get_patches() const override;
96
97 // Copy doc
98 virtual std::vector<std::string>
99 get_dataset_names() const override;
100
101private:
105 std::vector<DataOutBase::Patch<dim, dim>> patches;
106
110 std::vector<std::string> dataset_names;
111};
112
113
114// Template and inline functions
115#ifndef DOXYGEN
116template <int dim>
117template <class ConvertibleToBoundingBoxIterator>
118void
120 const ConvertibleToBoundingBoxIterator &begin,
121 const ConvertibleToBoundingBoxIterator &end)
122{
124 typename ConvertibleToBoundingBoxIterator::value_type>;
125 Getter getter;
126 constexpr unsigned int boxdim =
127 boost::geometry::dimension<typename Getter::result_type>::value;
128 const unsigned int N = std::distance(begin, end);
129 static_assert(boxdim == dim, "Bounding boxes are of the wrong dimension!");
130
131 dataset_names.clear();
132 patches.resize(N);
133
134 unsigned int i = 0;
135 for (const auto &value :
137 {
139 boost::geometry::convert(getter(*value), box);
140 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
141 {
142 patches[i].vertices[v] = box.vertex(v);
143 patches[i].patch_index = i;
144 patches[i].n_subdivisions = 1;
145 patches[i].reference_cell = ReferenceCells::get_hypercube<dim>();
146 patches[i].points_are_available = false;
147 }
148 ++i;
149 }
150}
151
152
153
154template <int dim>
155template <class Container>
156void
157BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
158{
159 build_patches(boxes.begin(), boxes.end());
160}
161
162
163
164template <int dim>
165void
167 const std::vector<std::vector<double>> &datasets,
168 const std::vector<std::string> & names)
169{
170 AssertDimension(datasets.size(), patches.size());
171 dataset_names = names;
172 for (unsigned int i = 0; i < datasets.size(); ++i)
173 {
174 AssertDimension(datasets[i].size(), names.size());
175 patches[i].data.reinit(names.size(),
177 for (unsigned int j = 0; j < names.size(); ++j)
178 for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
179 patches[i].data(j, k) = datasets[i][j];
180 }
181}
182
183
184
185template <int dim>
186const std::vector<DataOutBase::Patch<dim, dim>> &
188{
189 return patches;
190}
191
192
193
194template <int dim>
195std::vector<std::string>
197{
198 return dataset_names;
199}
200
201#endif
202
204
205#endif
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:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define AssertDimension(dim1, dim2)