deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
q_collection.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2005 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_q_collection_h
16#define dealii_q_collection_h
17
18#include <deal.II/base/config.h>
19
23
25
26#include <memory>
27#include <vector>
28
30
31namespace hp
32{
44 template <int dim>
45 class QCollection : public Collection<Quadrature<dim>>
46 {
47 public:
52 QCollection() = default;
53
57 template <int dim_in>
59
66 template <int dim_in>
67 explicit QCollection(const Quadrature<dim_in> &quadrature);
68
75 template <class... QTypes>
76 explicit QCollection(const QTypes &...quadrature_objects);
77
102 template <int dim_in>
103 void
104 push_back(const Quadrature<dim_in> &new_quadrature);
105
110 bool
111 operator==(const QCollection<dim> &q_collection) const;
112
119 unsigned int
121
126 };
127
128
129
130 /* --------------- inline functions ------------------- */
131
132 template <int dim>
133 template <int dim_in>
135 {
136 for (unsigned int i = 0; i < other.size(); ++i)
137 push_back(other[i]);
138 }
139
140
141
142 template <int dim>
143 template <class... QTypes>
144 QCollection<dim>::QCollection(const QTypes &...quadrature_objects)
145 {
146 // loop over all of the given arguments and add the quadrature objects to
147 // this collection. Inlining the definition of q_pointers causes internal
148 // compiler errors on GCC 7.1.1 so we define it separately:
149 if (is_base_of_all<Quadrature<dim>, QTypes...>::value)
150 {
151 const auto q_pointers = {
152 (reinterpret_cast<const Quadrature<dim> *>(&quadrature_objects))...};
153 for (const auto p : q_pointers)
154 push_back(*p);
155 }
156 else if (is_base_of_all<Quadrature<1>, QTypes...>::value)
157 {
158 const auto q_pointers = {
159 (reinterpret_cast<const Quadrature<1> *>(&quadrature_objects))...};
160 for (const auto p : q_pointers)
161 push_back(*p);
162 }
163 else
164 {
166 }
167 }
168
169
170
171 template <int dim>
172 inline unsigned int
174 {
175 Assert(this->size() > 0,
176 ExcMessage("You can't call this function for an empty collection"));
177
178 unsigned int max = 0;
179 for (unsigned int i = 0; i < this->size(); ++i)
180 max = std::max(max, this->operator[](i).size());
181
182 return max;
183 }
184
185
186
187 template <int dim>
188 inline bool
190 {
191 const unsigned int n_quadratures = this->size();
192 if (n_quadratures != q_collection.size())
193 return false;
194
195 for (unsigned int i = 0; i < n_quadratures; ++i)
196 if ((this->operator[](i) == q_collection[i]) == false)
197 return false;
198
199 return true;
200 }
201
202
203
204 template <int dim>
205 template <int dim_in>
207 {
208 this->push_back(quadrature);
209 }
210
211
212 template <int dim>
213 template <int dim_in>
214 inline void
216 {
217 Collection<Quadrature<dim>>::push_back(
218 std::make_shared<const Quadrature<dim>>(new_quadrature));
219 }
220
221} // namespace hp
222
223
225
226#endif
unsigned int size() const
Definition collection.h:315
bool operator==(const QCollection< dim > &q_collection) const
QCollection(const QTypes &...quadrature_objects)
unsigned int max_n_quadrature_points() const
void push_back(const Quadrature< dim_in > &new_quadrature)
QCollection(const QCollection< dim_in > &other)
QCollection(const Quadrature< dim_in > &quadrature)
QCollection()=default
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define DeclException0(Exception0)
Definition exceptions.h:466
#define Assert(cond, exc)
static ::ExceptionBase & ExcNoQuadrature()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define DEAL_II_NOT_IMPLEMENTED()
std::size_t size
Definition mpi.cc:734
Definition hp.h:117
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)