Reference documentation for deal.II version 9.4.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 - 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_q_collection_h
17#define dealii_q_collection_h
18
19#include <deal.II/base/config.h>
20
24
26
27#include <memory>
28#include <vector>
29
31
32namespace hp
33{
45 template <int dim>
46 class QCollection : public Collection<Quadrature<dim>>
47 {
48 public:
53 QCollection() = default;
54
58 template <int dim_in>
60
67 template <int dim_in>
68 explicit QCollection(const Quadrature<dim_in> &quadrature);
69
76 template <class... QTypes>
77 explicit QCollection(const QTypes &...quadrature_objects);
78
103 template <int dim_in>
104 void
105 push_back(const Quadrature<dim_in> &new_quadrature);
106
111 bool
112 operator==(const QCollection<dim> &q_collection) const;
113
120 unsigned int
122
127 };
128
129
130
131 /* --------------- inline functions ------------------- */
132
133 template <int dim>
134 template <int dim_in>
136 {
137 for (unsigned int i = 0; i < other.size(); ++i)
138 push_back(other[i]);
139 }
140
141
142
143 template <int dim>
144 template <class... QTypes>
145 QCollection<dim>::QCollection(const QTypes &...quadrature_objects)
146 {
147 // loop over all of the given arguments and add the quadrature objects to
148 // this collection. Inlining the definition of q_pointers causes internal
149 // compiler errors on GCC 7.1.1 so we define it separately:
150 if (is_base_of_all<Quadrature<dim>, QTypes...>::value)
151 {
152 const auto q_pointers = {
153 (reinterpret_cast<const Quadrature<dim> *>(&quadrature_objects))...};
154 for (const auto p : q_pointers)
155 push_back(*p);
156 }
157 else if (is_base_of_all<Quadrature<1>, QTypes...>::value)
158 {
159 const auto q_pointers = {
160 (reinterpret_cast<const Quadrature<1> *>(&quadrature_objects))...};
161 for (const auto p : q_pointers)
162 push_back(*p);
163 }
164 else
165 {
166 Assert(false, ExcNotImplemented());
167 }
168 }
169
170
171
172 template <int dim>
173 inline unsigned int
175 {
176 Assert(this->size() > 0,
177 ExcMessage("You can't call this function for an empty collection"));
178
179 unsigned int max = 0;
180 for (unsigned int i = 0; i < this->size(); ++i)
181 max = std::max(max, this->operator[](i).size());
182
183 return max;
184 }
185
186
187
188 template <int dim>
189 inline bool
191 {
192 const unsigned int n_quadratures = this->size();
193 if (n_quadratures != q_collection.size())
194 return false;
195
196 for (unsigned int i = 0; i < n_quadratures; ++i)
197 if ((this->operator[](i) == q_collection[i]) == false)
198 return false;
199
200 return true;
201 }
202
203
204
205 template <int dim>
206 template <int dim_in>
208 {
209 this->push_back(quadrature);
210 }
211
212
213 template <int dim>
214 template <int dim_in>
215 inline void
217 {
218 Collection<Quadrature<dim>>::push_back(
219 std::make_shared<const Quadrature<dim>>(new_quadrature));
220 }
221
222} // namespace hp
223
224
226
227#endif
unsigned int size() const
Definition: collection.h:264
bool operator==(const QCollection< dim > &q_collection) const
Definition: q_collection.h:190
QCollection(const QTypes &...quadrature_objects)
Definition: q_collection.h:145
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:174
void push_back(const Quadrature< dim_in > &new_quadrature)
Definition: q_collection.h:216
QCollection(const QCollection< dim_in > &other)
Definition: q_collection.h:135
QCollection(const Quadrature< dim_in > &quadrature)
Definition: q_collection.h:207
QCollection()=default
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
Definition: exceptions.h:1473
static ::ExceptionBase & ExcNoQuadrature()
static ::ExceptionBase & ExcMessage(std::string arg1)
Definition: hp.h:118
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)