Reference documentation for deal.II version 9.3.2
\(\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\}}\)
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 #include <boost/geometry/index/rtree.hpp>
32 #include <boost/geometry/strategies/strategies.hpp>
34 
35 
37 
42 template <int dim>
43 class BoundingBoxDataOut : public DataOutInterface<dim, dim>
44 {
45 public:
49  BoundingBoxDataOut() = default;
50 
54  ~BoundingBoxDataOut() = default;
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 
94 protected:
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 
103 private:
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
118 template <int dim>
119 template <class ConvertibleToBoundingBoxIterator>
120 void
122  const ConvertibleToBoundingBoxIterator &begin,
123  const ConvertibleToBoundingBoxIterator &end)
124 {
125  using Getter = boost::geometry::index::indexable<
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  {
140  BoundingBox<dim> box;
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].points_are_available = false;
148  }
149  ++i;
150  }
151 }
152 
153 
154 
155 template <int dim>
156 template <class Container>
157 void
158 BoundingBoxDataOut<dim>::build_patches(const Container &boxes)
159 {
160  build_patches(boxes.begin(), boxes.end());
161 }
162 
163 
164 
165 template <int dim>
166 void
168  const std::vector<std::vector<double>> &datasets,
169  const std::vector<std::string> & names)
170 {
171  AssertDimension(datasets.size(), patches.size());
172  dataset_names = names;
173  for (unsigned int i = 0; i < datasets.size(); ++i)
174  {
175  AssertDimension(datasets[i].size(), names.size());
176  patches[i].data.reinit(names.size(),
178  for (unsigned int j = 0; j < names.size(); ++j)
179  for (unsigned int k = 0; k < GeometryInfo<dim>::vertices_per_cell; ++k)
180  patches[i].data(j, k) = datasets[i][j];
181  }
182 }
183 
184 
185 
186 template <int dim>
187 const std::vector<DataOutBase::Patch<dim, dim>> &
189 {
190  return patches;
191 }
192 
193 
194 
195 template <int dim>
196 std::vector<std::string>
198 {
199  return dataset_names;
200 }
201 
202 #endif
203 
205 
206 #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)
~BoundingBoxDataOut()=default
std::vector< std::string > dataset_names
virtual const std::vector<::DataOutBase::Patch< dim, dim > > & get_patches() const override
std::vector< DataOutBase::Patch< dim, dim > > patches
virtual std::vector< std::string > get_dataset_names() const override
void build_patches(const Container &boxes)
Point< spacedim, Number > vertex(const unsigned int index) const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:396
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:410
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:397
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:448
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1622
static const char N
VectorType::value_type * begin(VectorType &V)
VectorType::value_type * end(VectorType &V)