Debian Codegraph @

include/deal.II/matrix_free/evaluation_template_factory_internal.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2021 - 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_evaluation_template_factory_internal_h
17 #define dealii_matrix_free_evaluation_template_factory_internal_h
18
19
20 #include <deal.II/base/config.h>
21
22 #ifndef FE_EVAL_FACTORY_DEGREE_MAX
23 # define FE_EVAL_FACTORY_DEGREE_MAX 6
24 #endif
25
26 DEAL_II_NAMESPACE_OPEN
27
28 namespace internal
29 {
30 /**
31 * This struct is used to implement
32 * FEEvaluation::fast_evaluation_supported() and
33 * FEFaceEvaluation::fast_evaluation_supported().
34 */
35 struct FastEvaluationSupported
36 {
37 template <int fe_degree, int n_q_points_1d>
38 static bool
39 run()
40 {
41 return fe_degree != -1;
42 }
43 };
44
45 template <int degree, typename EvaluatorType, typename... Args>
46 bool
47 instantiation_helper_run(const unsigned int given_degree,
48 const unsigned int n_q_points_1d,
49 Args &...args)
50 {
51 if (given_degree == degree)
52 {
53 if (n_q_points_1d == degree + 1)
54 return EvaluatorType::template run<degree, degree + 1>(args...);
55 else if (n_q_points_1d == degree + 2)
56 return EvaluatorType::template run<degree, degree + 2>(args...);
57 else if (n_q_points_1d == degree)
58 return EvaluatorType::template run<degree, degree>(args...);
59 else if (n_q_points_1d == (3 * degree) / 2 + 1)
60 return EvaluatorType::template run<degree, (3 * degree) / 2 + 1>(
61 args...);
62 else if ((n_q_points_1d == (2 * degree)) && (degree <= 4))
63 return EvaluatorType::template run<degree, (2 * degree)>(args...);
64 else
65 // slow path
66 return EvaluatorType::template run<-1, 0>(args...);
67 }
68 else if (degree < FE_EVAL_FACTORY_DEGREE_MAX)
69 return instantiation_helper_run<
70 (degree < FE_EVAL_FACTORY_DEGREE_MAX ? degree + 1 : degree),
71 EvaluatorType>(given_degree, n_q_points_1d, args...);
72 else
73 // slow path
74 return EvaluatorType::template run<-1, 0>(args...);
75 }
76
77 template <int degree, typename EvaluatorType, typename... Args>
78 bool
79 instantiation_helper_degree_run(const unsigned int given_degree,
80 Args &...args)
81 {
82 if (given_degree == degree)
83 {
84 return EvaluatorType::template run<degree>(args...);
85 }
86 else if (degree < FE_EVAL_FACTORY_DEGREE_MAX)
87 return instantiation_helper_degree_run<
88 (degree < FE_EVAL_FACTORY_DEGREE_MAX ? degree + 1 : degree),
89 EvaluatorType>(given_degree, args...);
90 else
91 // slow path
92 return EvaluatorType::template run<-1>(args...);
93 }
94
95 } // end of namespace internal
96
97 DEAL_II_NAMESPACE_CLOSE
98
99 #endif