Loading [MathJax]/extensions/TeX/newcommand.js
 Reference documentation for deal.II version 9.3.3
\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\}}
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
bounding_box_data_out.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2020 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#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
32# define BOOST_ALLOW_DEPRECATED_HEADERS
33#endif
34#include <boost/geometry/index/rtree.hpp>
35#include <boost/geometry/strategies/strategies.hpp>
36#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
37# undef BOOST_ALLOW_DEPRECATED_HEADERS
38#endif
40
41
43
48template <int dim>
49class BoundingBoxDataOut : public DataOutInterface<dim, dim>
50{
51public:
55 BoundingBoxDataOut() = default;
56
61
69 template <class ConvertibleToBoundingBoxIterator>
70 void
71 build_patches(const ConvertibleToBoundingBoxIterator &begin,
72 const ConvertibleToBoundingBoxIterator &end);
73
82 template <class Container>
83 void
84 build_patches(const Container &boxes);
85
96 void
97 add_datasets(const std::vector<std::vector<double>> &datasets,
98 const std::vector<std::string> & dataset_names);
99
100protected:
101 // Copy doc
102 virtual const std::vector<::DataOutBase::Patch<dim, dim>> &
103 get_patches() const override;
104
105 // Copy doc
106 virtual std::vector<std::string>
107 get_dataset_names() const override;
108
109private:
113 std::vector<DataOutBase::Patch<dim, dim>> patches;
114
118 std::vector<std::string> dataset_names;
119};
120
121
122// Template and inline functions
123#ifndef DOXYGEN
124template <int dim>
125template <class ConvertibleToBoundingBoxIterator>
126void
128 const ConvertibleToBoundingBoxIterator &begin,
129 const ConvertibleToBoundingBoxIterator &end)
130{
132 typename ConvertibleToBoundingBoxIterator::value_type>;
133 Getter getter;
134 constexpr unsigned int boxdim =
135 boost::geometry::dimension<typename Getter::result_type>::value;
136 const unsigned int N = std::distance(begin, end);
137 static_assert(boxdim == dim, "Bounding boxes are of the wrong dimension!");
138
139 dataset_names.clear();
140 patches.resize(N);
141
142 unsigned int i = 0;
143 for (const auto &value :
145 {
147 boost::geometry::convert(getter(*value), box);
148 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
149 {
150 patches[i].vertices[v] = box.vertex(v);
151 patches[i].patch_index = i;
152 patches[i].n_subdivisions = 1;
153 patches[i].points_are_available = false;
154 }
155 ++i;
156 }
157}
158
159
160
161template <int dim>
162template <class Container>
163void
164BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
165{
166 build_patches(boxes.begin(), boxes.end());
167}
168
169
170
171template <int dim>
172void
174 const std::vector<std::vector<double>> &datasets,
175 const std::vector<std::string> & names)
176{
177 AssertDimension(datasets.size(), patches.size());
178 dataset_names = names;
179 for (unsigned int i = 0; i < datasets.size(); ++i)
180 {
181 AssertDimension(datasets[i].size(), names.size());
182 patches[i].data.reinit(names.size(),
184 for (unsigned int j = 0; j < names.size(); ++j)
185 for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
186 patches[i].data(j, k) = datasets[i][j];
187 }
188}
189
190
191
192template <int dim>
193const std::vector<DataOutBase::Patch<dim, dim>> &
195{
196 return patches;
197}
198
199
200
201template <int dim>
202std::vector<std::string>
204{
205 return dataset_names;
206}
207
208#endif
209
211
212#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:402
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:416
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:454
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1622
static const char N
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)