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\}}\)
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 private:
133 std::vector<std::shared_ptr<const Quadrature<dim>>> quadratures;
134 };
135
136
137
138 /* --------------- inline functions ------------------- */
139
140 template <int dim>
141 template <int dim_in>
143 {
144 for (unsigned int i = 0; i < other.size(); ++i)
145 push_back(other[i]);
146 }
147
148
149
150 template <int dim>
151 template <class... QTypes>
152 QCollection<dim>::QCollection(const QTypes &... quadrature_objects)
153 {
154 // loop over all of the given arguments and add the quadrature objects to
155 // this collection. Inlining the definition of q_pointers causes internal
156 // compiler errors on GCC 7.1.1 so we define it separately:
157 if (is_base_of_all<Quadrature<dim>, QTypes...>::value)
158 {
159 const auto q_pointers = {
160 (reinterpret_cast<const Quadrature<dim> *>(&quadrature_objects))...};
161 for (const auto p : q_pointers)
162 push_back(*p);
163 }
164 else if (is_base_of_all<Quadrature<1>, QTypes...>::value)
165 {
166 const auto q_pointers = {
167 (reinterpret_cast<const Quadrature<1> *>(&quadrature_objects))...};
168 for (const auto p : q_pointers)
169 push_back(*p);
170 }
171 else
172 {
173 Assert(false, ExcNotImplemented());
174 }
175 }
176
177
178
179 template <int dim>
180 inline unsigned int
182 {
183 Assert(this->size() > 0,
184 ExcMessage("You can't call this function for an empty collection"));
185
186 unsigned int max = 0;
187 for (unsigned int i = 0; i < this->size(); ++i)
188 max = std::max(max, this->operator[](i).size());
189
190 return max;
191 }
192
193
194
195 template <int dim>
196 inline bool
198 {
199 const unsigned int n_quadratures = this->size();
200 if (n_quadratures != q_collection.size())
201 return false;
202
203 for (unsigned int i = 0; i < n_quadratures; ++i)
204 if ((this->operator[](i) == q_collection[i]) == false)
205 return false;
206
207 return true;
208 }
209
210
211
212 template <int dim>
213 template <int dim_in>
215 {
216 this->push_back(quadrature);
217 }
218
219
220 template <int dim>
221 template <int dim_in>
222 inline void
224 {
225 Collection<Quadrature<dim>>::push_back(
226 std::make_shared<const Quadrature<dim>>(new_quadrature));
227 }
228
229} // namespace hp
230
231
233
234#endif
unsigned int size() const
Definition: collection.h:109
bool operator==(const QCollection< dim > &q_collection) const
Definition: q_collection.h:197
std::vector< std::shared_ptr< const Quadrature< dim > > > quadratures
Definition: q_collection.h:133
unsigned int max_n_quadrature_points() const
Definition: q_collection.h:181
QCollection(const QTypes &... quadrature_objects)
Definition: q_collection.h:152
void push_back(const Quadrature< dim_in > &new_quadrature)
Definition: q_collection.h:223
QCollection(const QCollection< dim_in > &other)
Definition: q_collection.h:142
QCollection(const Quadrature< dim_in > &quadrature)
Definition: q_collection.h:214
QCollection()=default
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
#define DeclException0(Exception0)
Definition: exceptions.h:470
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
Definition: exceptions.h:1465
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 > &)