Reference documentation for deal.II version 9.4.1
\(\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 - 2021 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
31#include <boost/geometry/index/rtree.hpp>
32#include <boost/geometry/strategies/strategies.hpp>
34
35
37
42template <int dim>
43class BoundingBoxDataOut : public DataOutInterface<dim, dim>
44{
45public:
49 BoundingBoxDataOut() = default;
50
55
63 template <class ConvertibleToBoundingBoxIterator>
64 void
65 build_patches(const ConvertibleToBoundingBoxIterator &begin,
66 const ConvertibleToBoundingBoxIterator &end);
67
76 template <class Container>
77 void
78 build_patches(const Container &boxes);
79
90 void
91 add_datasets(const std::vector<std::vector<double>> &datasets,
92 const std::vector<std::string> & dataset_names);
93
94protected:
95 // Copy doc
96 virtual const std::vector<::DataOutBase::Patch<dim, dim>> &
97 get_patches() const override;
98
99 // Copy doc
100 virtual std::vector<std::string>
101 get_dataset_names() const override;
102
103private:
107 std::vector<DataOutBase::Patch<dim, dim>> patches;
108
112 std::vector<std::string> dataset_names;
113};
114
115
116// Template and inline functions
117#ifndef DOXYGEN
118template <int dim>
119template <class ConvertibleToBoundingBoxIterator>
120void
122 const ConvertibleToBoundingBoxIterator &begin,
123 const ConvertibleToBoundingBoxIterator &end)
124{
126 typename ConvertibleToBoundingBoxIterator::value_type>;
127 Getter getter;
128 constexpr unsigned int boxdim =
129 boost::geometry::dimension<typename Getter::result_type>::value;
130 const unsigned int N = std::distance(begin, end);
131 static_assert(boxdim == dim, "Bounding boxes are of the wrong dimension!");
132
133 dataset_names.clear();
134 patches.resize(N);
135
136 unsigned int i = 0;
137 for (const auto &value :
139 {
141 boost::geometry::convert(getter(*value), box);
142 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
143 {
144 patches[i].vertices[v] = box.vertex(v);
145 patches[i].patch_index = i;
146 patches[i].n_subdivisions = 1;
147 patches[i].reference_cell = ReferenceCells::get_hypercube<dim>();
148 patches[i].points_are_available = false;
149 }
150 ++i;
151 }
152}
153
154
155
156template <int dim>
157template <class Container>
158void
159BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
160{
161 build_patches(boxes.begin(), boxes.end());
162}
163
164
165
166template <int dim>
167void
169 const std::vector<std::vector<double>> &datasets,
170 const std::vector<std::string> & names)
171{
172 AssertDimension(datasets.size(), patches.size());
173 dataset_names = names;
174 for (unsigned int i = 0; i < datasets.size(); ++i)
175 {
176 AssertDimension(datasets[i].size(), names.size());
177 patches[i].data.reinit(names.size(),
179 for (unsigned int j = 0; j < names.size(); ++j)
180 for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
181 patches[i].data(j, k) = datasets[i][j];
182 }
183}
184
185
186
187template <int dim>
188const std::vector<DataOutBase::Patch<dim, dim>> &
190{
191 return patches;
192}
193
194
195
196template <int dim>
197std::vector<std::string>
199{
200 return dataset_names;
201}
202
203#endif
204
206
207#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:442
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:456
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:495
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1667