Reference documentation for deal.II version 9.2.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\}}\)
q_collection.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 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_q_collection_h
17 #define dealii_q_collection_h
18 
19 #include <deal.II/base/config.h>
20 
24 
25 #include <deal.II/fe/fe.h>
26 
27 #include <memory>
28 #include <vector>
29 
31 
32 namespace hp
33 {
47  template <int dim>
48  class QCollection : public Subscriptor
49  {
50  public:
55  QCollection() = default;
56 
63  explicit QCollection(const Quadrature<dim> &quadrature);
64 
71  template <class... QTypes>
72  explicit QCollection(const QTypes &... quadrature_objects);
73 
98  void
99  push_back(const Quadrature<dim> &new_quadrature);
100 
107  const Quadrature<dim> &operator[](const unsigned int index) const;
108 
113  bool
114  operator==(const QCollection<dim> &q_collection) const;
115 
119  unsigned int
120  size() const;
121 
128  unsigned int
129  max_n_quadrature_points() const;
130 
135  std::size_t
136  memory_consumption() const;
137 
142 
143  private:
148  std::vector<std::shared_ptr<const Quadrature<dim>>> quadratures;
149  };
150 
151 
152 
153  /* --------------- inline functions ------------------- */
154 
155  template <int dim>
156  template <class... QTypes>
157  QCollection<dim>::QCollection(const QTypes &... quadrature_objects)
158  {
159  static_assert(is_base_of_all<Quadrature<dim>, QTypes...>::value,
160  "Not all of the input arguments of this function "
161  "are derived from Quadrature<dim>!");
162 
163  // loop over all of the given arguments and add the quadrature objects to
164  // this collection. Inlining the definition of q_pointers causes internal
165  // compiler errors on GCC 7.1.1 so we define it separately:
166  const auto q_pointers = {
167  (static_cast<const Quadrature<dim> *>(&quadrature_objects))...};
168  for (const auto p : q_pointers)
169  push_back(*p);
170  }
171 
172 
173 
174  template <int dim>
175  inline unsigned int
177  {
178  return quadratures.size();
179  }
180 
181 
182 
183  template <int dim>
184  inline unsigned int
186  {
187  Assert(quadratures.size() > 0,
188  ExcMessage("You can't call this function for an empty collection"));
189 
190  unsigned int m = 0;
191  for (unsigned int i = 0; i < quadratures.size(); ++i)
192  if (quadratures[i]->size() > m)
193  m = quadratures[i]->size();
194 
195  return m;
196  }
197 
198 
199 
200  template <int dim>
201  inline const Quadrature<dim> &QCollection<dim>::
202  operator[](const unsigned int index) const
203  {
204  AssertIndexRange(index, quadratures.size());
205  return *quadratures[index];
206  }
207 
208 
209 
210  template <int dim>
211  inline bool
213  {
214  const unsigned int n_quadratures = size();
215  if (n_quadratures != q_collection.size())
216  return false;
217 
218  for (unsigned int i = 0; i < n_quadratures; ++i)
219  if (!(*quadratures[i] == q_collection[i]))
220  return false;
221 
222  return true;
223  }
224 
225 
226 
227  template <int dim>
229  {
230  quadratures.push_back(std::make_shared<const Quadrature<dim>>(quadrature));
231  }
232 
233 
234 
235  template <int dim>
236  inline std::size_t
238  {
239  return (sizeof(*this) + MemoryConsumption::memory_consumption(quadratures));
240  }
241 
242 
243  template <int dim>
244  inline void
246  {
247  quadratures.push_back(
248  std::make_shared<const Quadrature<dim>>(new_quadrature));
249  }
250 
251 } // namespace hp
252 
253 
255 
256 #endif
hp::QCollection::quadratures
std::vector< std::shared_ptr< const Quadrature< dim > > > quadratures
Definition: q_collection.h:148
is_base_of_all
Definition: template_constraints.h:60
hp::QCollection::memory_consumption
std::size_t memory_consumption() const
Definition: q_collection.h:237
memory_consumption.h
hp::QCollection::operator[]
const Quadrature< dim > & operator[](const unsigned int index) const
Definition: q_collection.h:202
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
hp::QCollection
Definition: q_collection.h:48
Subscriptor
Definition: subscriptor.h:62
hp::QCollection::size
unsigned int size() const
Definition: q_collection.h:176
hp::QCollection::QCollection
QCollection()=default
hp::QCollection::max_n_quadrature_points
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:185
StandardExceptions::ExcMessage
static ::ExceptionBase & ExcMessage(std::string arg1)
subscriptor.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
MemoryConsumption::memory_consumption
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
Definition: memory_consumption.h:268
fe.h
value
static const bool value
Definition: dof_tools_constraints.cc:433
Assert
#define Assert(cond, exc)
Definition: exceptions.h:1419
DeclException0
#define DeclException0(Exception0)
Definition: exceptions.h:473
hp
Definition: hp.h:117
hp::QCollection::ExcNoQuadrature
static ::ExceptionBase & ExcNoQuadrature()
hp::QCollection::operator==
bool operator==(const QCollection< dim > &q_collection) const
Definition: q_collection.h:212
quadrature.h
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
Quadrature
Definition: quadrature.h:85
hp::QCollection::push_back
void push_back(const Quadrature< dim > &new_quadrature)
Definition: q_collection.h:245