deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2020 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_matrix_free_util_h
15#define dealii_matrix_free_util_h
16
17
18#include <deal.II/base/config.h>
19
22
24
26
28
30
31
32namespace internal
33{
34 namespace MatrixFreeFunctions
35 {
41 template <int dim>
42 inline std::pair<ReferenceCell<dim>, ::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 for (unsigned int i = 1; i <= 3; ++i)
61 {
62 const FE_SimplexP<dim> fe(i);
64 return {ReferenceCells::get_simplex<dim>(),
65 ::hp::QCollection<dim - 1>(Quadrature<dim - 1>(
67 }
68 }
69
70 if constexpr (dim == 3)
71 for (unsigned int i = 1; i <= 3; ++i)
72 if (quad == QGaussWedge<dim>(i))
73 {
74 QGauss<dim - 1> quad(i);
75 QGaussSimplex<dim - 1> tri(i);
76
77 return {
79 ::hp::QCollection<dim - 1>(tri, tri, quad, quad, quad)};
80 }
81
82 if constexpr (dim == 3)
83 for (unsigned int i = 1; i <= 2; ++i)
84 if (quad == QGaussPyramid<dim>(i))
85 {
86 QGauss<dim - 1> quad(i);
87 QGaussSimplex<dim - 1> tri(i);
88
89 return {
91 ::hp::QCollection<dim - 1>(quad, tri, tri, tri, tri)};
92 }
93
94 // note: handle hypercubes last since normally this function is not
95 // called for hypercubes
96 for (unsigned int i = 1; i <= 5; ++i)
97 if (quad == QGauss<dim>(i))
98 return {ReferenceCells::get_hypercube<dim>(),
99 ::hp::QCollection<dim - 1>(QGauss<dim - 1>(i))};
100
101 if (do_assert)
103
104 return {ReferenceCells::Invalid<dim>, ::hp::QCollection<dim - 1>()};
105 }
106
107
108
117 template <int dim>
118 inline std::pair<Quadrature<dim - 1>, Quadrature<dim - 1>>
120 {
122 quad.size() > 0,
124 "There is nothing useful you can do with a MatrixFree/FEEvaluation "
125 "object when using a quadrature formula with zero "
126 "quadrature points!"));
127
128 if (dim == 2 || dim == 3)
129 {
130 for (unsigned int i = 1; i <= 4; ++i)
131 if (quad == QGaussSimplex<dim>(i))
132 {
133 if (dim == 2)
134 return {QGaussSimplex<dim - 1>(i), // line!
136 else
137 return {Quadrature<dim - 1>(), QGaussSimplex<dim - 1>(i)};
138 }
139
140 for (unsigned int i = 1; i <= 5; ++i)
141 if (quad == QWitherdenVincentSimplex<dim>(i))
142 {
143 if (dim == 2)
144 return {QWitherdenVincentSimplex<dim - 1>(i), // line!
146 else
147 return {Quadrature<dim - 1>(),
149 }
150
151 for (unsigned int i = 1; i <= 3; ++i)
152 {
153 const FE_SimplexP<dim> fe(i);
155 {
156 if (dim == 2)
157 return {Quadrature<dim - 1>(
158 fe.get_unit_face_support_points()), // line!
160 else
161 return {Quadrature<dim - 1>(),
164 }
165 }
166 }
167
168 if (dim == 3)
169 for (unsigned int i = 1; i <= 3; ++i)
170 if (quad == QGaussWedge<dim>(i))
171 return {QGauss<dim - 1>(i), QGaussSimplex<dim - 1>(i)};
172
173 if (dim == 3)
174 for (unsigned int i = 1; i <= 2; ++i)
175 if (quad == QGaussPyramid<dim>(i))
176 return {QGauss<dim - 1>(i), QGaussSimplex<dim - 1>(i)};
177
178 // note: handle hypercubes last since normally this function is not
179 // called for hypercubes
180 for (unsigned int i = 1; i <= 5; ++i)
181 if (quad == QGauss<dim>(i))
182 return {QGauss<dim - 1>(i), Quadrature<dim - 1>()};
183
185
186 return {Quadrature<dim - 1>(), Quadrature<dim - 1>()};
187 }
188
189 inline DEAL_II_ALWAYS_INLINE unsigned int
190 indicate_power_of_two(const unsigned int vectorization_length)
191 {
192 unsigned int vectorization_length_bits = 0;
193 unsigned int my_length = vectorization_length;
194 while (my_length >>= 1)
195 ++vectorization_length_bits;
196 return 1 << vectorization_length_bits;
197 }
198
199 } // end of namespace MatrixFreeFunctions
200} // end of namespace internal
201
203
204#endif
const std::vector< Point< dim > > & get_unit_support_points() const
const std::vector< Point< dim - 1 > > & get_unit_face_support_points(const unsigned int face_no=0) const
unsigned int size() const
#define DEAL_II_ALWAYS_INLINE
Definition config.h:166
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
constexpr ReferenceCell< 3 > Pyramid
constexpr ReferenceCell< 3 > Wedge
unsigned int indicate_power_of_two(const unsigned int vectorization_length)
Definition util.h:190
std::pair< ReferenceCell< dim >, ::hp::QCollection< dim - 1 > > get_face_quadrature_collection(const Quadrature< dim > &quad, const bool do_assert=true)
Definition util.h:43
std::pair< Quadrature< dim - 1 >, Quadrature< dim - 1 > > get_unique_face_quadratures(const Quadrature< dim > &quad)
Definition util.h:119