Reference documentation for deal.II version GIT relicensing-478-g3275795167 2024-04-24 07:10:02+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
util.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2020 - 2023 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
16#ifndef dealii_matrix_free_util_h
17#define dealii_matrix_free_util_h
18
19
20#include <deal.II/base/config.h>
21
24
26
28
30
31
32namespace internal
33{
34 namespace MatrixFreeFunctions
35 {
41 template <int dim>
42 inline std::pair<ReferenceCell, ::hp::QCollection<dim - 1>>
44 const bool do_assert = true)
45 {
46 if (dim == 2 || dim == 3)
47 {
48 for (unsigned int i = 1; i <= 4; ++i)
49 if (quad == QGaussSimplex<dim>(i))
50 return {ReferenceCells::get_simplex<dim>(),
51 ::hp::QCollection<dim - 1>(
52 QGaussSimplex<dim - 1>(i))};
53
54 for (unsigned int i = 1; i <= 5; ++i)
55 if (quad == QWitherdenVincentSimplex<dim>(i))
56 return {ReferenceCells::get_simplex<dim>(),
57 ::hp::QCollection<dim - 1>(
58 QWitherdenVincentSimplex<dim - 1>(i))};
59 }
60
61 if (dim == 3)
62 for (unsigned int i = 1; i <= 3; ++i)
63 if (quad == QGaussWedge<dim>(i))
64 {
65 QGauss<dim - 1> quad(i);
66 QGaussSimplex<dim - 1> tri(i);
67
68 return {
70 ::hp::QCollection<dim - 1>(tri, tri, quad, quad, quad)};
71 }
72
73 if (dim == 3)
74 for (unsigned int i = 1; i <= 2; ++i)
75 if (quad == QGaussPyramid<dim>(i))
76 {
77 QGauss<dim - 1> quad(i);
78 QGaussSimplex<dim - 1> tri(i);
79
80 return {
82 ::hp::QCollection<dim - 1>(quad, tri, tri, tri, tri)};
83 }
84
85 // note: handle hypercubes last since normally this function is not
86 // called for hypercubes
87 for (unsigned int i = 1; i <= 5; ++i)
88 if (quad == QGauss<dim>(i))
89 return {ReferenceCells::get_hypercube<dim>(),
90 ::hp::QCollection<dim - 1>(QGauss<dim - 1>(i))};
91
92 if (do_assert)
94
95 return {ReferenceCells::Invalid, ::hp::QCollection<dim - 1>()};
96 }
97
98
99
108 template <int dim>
109 inline std::pair<Quadrature<dim - 1>, Quadrature<dim - 1>>
111 {
113 quad.size() > 0,
115 "There is nothing useful you can do with a MatrixFree/FEEvaluation "
116 "object when using a quadrature formula with zero "
117 "quadrature points!"));
118
119 if (dim == 2 || dim == 3)
120 {
121 for (unsigned int i = 1; i <= 4; ++i)
122 if (quad == QGaussSimplex<dim>(i))
123 {
124 if (dim == 2)
125 return {QGaussSimplex<dim - 1>(i), // line!
127 else
128 return {Quadrature<dim - 1>(), QGaussSimplex<dim - 1>(i)};
129 }
130
131 for (unsigned int i = 1; i <= 5; ++i)
132 if (quad == QWitherdenVincentSimplex<dim>(i))
133 {
134 if (dim == 2)
135 return {QWitherdenVincentSimplex<dim - 1>(i), // line!
137 else
138 return {Quadrature<dim - 1>(),
140 }
141 }
142
143 if (dim == 3)
144 for (unsigned int i = 1; i <= 3; ++i)
145 if (quad == QGaussWedge<dim>(i))
146 return {QGauss<dim - 1>(i), QGaussSimplex<dim - 1>(i)};
147
148 if (dim == 3)
149 for (unsigned int i = 1; i <= 2; ++i)
150 if (quad == QGaussPyramid<dim>(i))
151 return {QGauss<dim - 1>(i), QGaussSimplex<dim - 1>(i)};
152
153 // note: handle hypercubes last since normally this function is not
154 // called for hypercubes
155 for (unsigned int i = 1; i <= 5; ++i)
156 if (quad == QGauss<dim>(i))
157 return {QGauss<dim - 1>(i), Quadrature<dim - 1>()};
158
160
161 return {Quadrature<dim - 1>(), Quadrature<dim - 1>()};
162 }
163
164 inline DEAL_II_ALWAYS_INLINE unsigned int
165 indicate_power_of_two(const unsigned int vectorization_length)
166 {
167 unsigned int vectorization_length_bits = 0;
168 unsigned int my_length = vectorization_length;
169 while (my_length >>= 1)
170 ++vectorization_length_bits;
171 return 1 << vectorization_length_bits;
172 }
173
174 } // end of namespace MatrixFreeFunctions
175} // end of namespace internal
176
178
179#endif
unsigned int size() const
#define DEAL_II_ALWAYS_INLINE
Definition config.h:109
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Invalid
unsigned int indicate_power_of_two(const unsigned int vectorization_length)
Definition util.h:165
std::pair< Quadrature< dim - 1 >, Quadrature< dim - 1 > > get_unique_face_quadratures(const Quadrature< dim > &quad)
Definition util.h:110
std::pair< ReferenceCell, ::hp::QCollection< dim - 1 > > get_face_quadrature_collection(const Quadrature< dim > &quad, const bool do_assert=true)
Definition util.h:43