Reference documentation for deal.II version GIT relicensing-439-g5fda5c893d 2024-04-20 06:50:02+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: 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// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_bounding_box_data_out_h
16#define dealii_bounding_box_data_out_h
17
18#include <deal.II/base/config.h>
19
23#include <deal.II/base/point.h>
24
28
29#include <boost/geometry/index/rtree.hpp>
30#include <boost/geometry/strategies/strategies.hpp>
31
32
34
39template <int dim>
40class BoundingBoxDataOut : public DataOutInterface<dim, dim>
41{
42public:
46 BoundingBoxDataOut() = default;
47
52
60 template <class ConvertibleToBoundingBoxIterator>
61 void
62 build_patches(const ConvertibleToBoundingBoxIterator &begin,
63 const ConvertibleToBoundingBoxIterator &end);
64
73 template <class Container>
74 void
75 build_patches(const Container &boxes);
76
87 void
88 add_datasets(const std::vector<std::vector<double>> &datasets,
89 const std::vector<std::string> &dataset_names);
90
91protected:
92 // Copy doc
93 virtual const std::vector<::DataOutBase::Patch<dim, dim>> &
94 get_patches() const override;
95
96 // Copy doc
97 virtual std::vector<std::string>
98 get_dataset_names() const override;
99
100private:
104 std::vector<DataOutBase::Patch<dim, dim>> patches;
105
109 std::vector<std::string> dataset_names;
110};
111
112
113// Template and inline functions
114#ifndef DOXYGEN
115template <int dim>
116template <class ConvertibleToBoundingBoxIterator>
117void
119 const ConvertibleToBoundingBoxIterator &begin,
120 const ConvertibleToBoundingBoxIterator &end)
121{
123 typename ConvertibleToBoundingBoxIterator::value_type>;
124 Getter getter;
125 constexpr unsigned int boxdim =
126 boost::geometry::dimension<typename Getter::result_type>::value;
127 const unsigned int N = std::distance(begin, end);
128 static_assert(boxdim == dim, "Bounding boxes are of the wrong dimension!");
129
130 dataset_names.clear();
131 patches.resize(N);
132
133 unsigned int i = 0;
134 for (const auto &value :
136 {
138 boost::geometry::convert(getter(*value), box);
139 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
140 {
141 patches[i].vertices[v] = box.vertex(v);
142 patches[i].patch_index = i;
143 patches[i].n_subdivisions = 1;
144 patches[i].reference_cell = ReferenceCells::get_hypercube<dim>();
145 patches[i].points_are_available = false;
146 }
147 ++i;
148 }
149}
150
151
152
153template <int dim>
154template <class Container>
155void
156BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
157{
158 build_patches(boxes.begin(), boxes.end());
159}
160
161
162
163template <int dim>
164void
166 const std::vector<std::vector<double>> &datasets,
167 const std::vector<std::string> &names)
168{
169 AssertDimension(datasets.size(), patches.size());
170 dataset_names = names;
171 for (unsigned int i = 0; i < datasets.size(); ++i)
172 {
173 AssertDimension(datasets[i].size(), names.size());
174 patches[i].data.reinit(names.size(),
176 for (unsigned int j = 0; j < names.size(); ++j)
177 for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
178 patches[i].data(j, k) = datasets[i][j];
179 }
180}
181
182
183
184template <int dim>
185const std::vector<DataOutBase::Patch<dim, dim>> &
187{
188 return patches;
189}
190
191
192
193template <int dim>
194std::vector<std::string>
196{
197 return dataset_names;
198}
199
200#endif
201
203
204#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:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define AssertDimension(dim1, dim2)