ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
tensor_product_point_kernels.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception or LGPL-2.1-or-later
3// Copyright (C) 2024 - 2024 by Maximilian Bergbauer
4// Copyright (C) 2020 - 2023 by the ryujin authors
5//
6
7#pragma once
8
9#include <deal.II/base/config.h>
10
11#include <deal.II/base/ndarray.h>
12#include <deal.II/base/polynomial.h>
13#include <deal.II/base/utilities.h>
14#include <deal.II/matrix_free/tensor_product_point_kernels.h>
15
16#include <deal.II/matrix_free/shape_info.h>
17
18namespace ryujin
19{
20
21 namespace internal
22 {
30 template <int dim, typename Number, typename Number2, bool add>
32 const Number2 &value,
33 Number2 *values,
34 const dealii::Point<dim, Number> &p)
35 {
36 static_assert(dim >= 0 && dim <= 3, "Only dim=0,1,2,3 implemented");
37
38 if (dim == 0) {
39 if (add)
40 values[0] += value;
41 else
42 values[0] = value;
43 } else if (dim == 1) {
44 const auto x0 = Number(1.) - p[0], x1 = p[0];
45
46 if (add) {
47 values[0] += value * x0;
48 values[1] += value * x1;
49 } else {
50 values[0] = value * x0;
51 values[1] = value * x1;
52 }
53 } else if (dim == 2) {
54 const auto x0 = Number(1.) - p[0], x1 = p[0], y0 = Number(1.) - p[1],
55 y1 = p[1];
56
57 const auto test_value_y0 = value * y0;
58 const auto test_value_y1 = value * y1;
59
60 if (add) {
61 values[0] += x0 * test_value_y0;
62 values[1] += x1 * test_value_y0;
63 values[2] += x0 * test_value_y1;
64 values[3] += x1 * test_value_y1;
65 } else {
66 values[0] = x0 * test_value_y0;
67 values[1] = x1 * test_value_y0;
68 values[2] = x0 * test_value_y1;
69 values[3] = x1 * test_value_y1;
70 }
71 } else if (dim == 3) {
72 const auto x0 = Number(1.) - p[0], x1 = p[0], y0 = Number(1.) - p[1],
73 y1 = p[1], z0 = Number(1.) - p[2], z1 = p[2];
74
75 const auto test_value_z0 = value * z0;
76 const auto test_value_z1 = value * z1;
77
78 const auto test_value_y00 = test_value_z0 * y0;
79 const auto test_value_y01 = test_value_z0 * y1;
80 const auto test_value_y10 = test_value_z1 * y0;
81 const auto test_value_y11 = test_value_z1 * y1;
82
83 if (add) {
84 values[0] += x0 * test_value_y00;
85 values[1] += x1 * test_value_y00;
86 values[2] += x0 * test_value_y01;
87 values[3] += x1 * test_value_y01;
88 values[4] += x0 * test_value_y10;
89 values[5] += x1 * test_value_y10;
90 values[6] += x0 * test_value_y11;
91 values[7] += x1 * test_value_y11;
92 } else {
93 values[0] = x0 * test_value_y00;
94 values[1] = x1 * test_value_y00;
95 values[2] = x0 * test_value_y01;
96 values[3] = x1 * test_value_y01;
97 values[4] = x0 * test_value_y10;
98 values[5] = x1 * test_value_y10;
99 values[6] = x0 * test_value_y11;
100 values[7] = x1 * test_value_y11;
101 }
102 }
103 }
104
105 template <bool is_linear, int dim, typename Number, typename Number2>
107 const dealii::ndarray<Number, 2, dim> *shapes,
108 const unsigned int n_shapes,
109 const Number2 &value,
110 Number2 *values,
111 const dealii::Point<dim, Number> &p,
112 const bool do_add)
113 {
114 if (do_add) {
115 if (is_linear)
116 integrate_add_tensor_product_value_linear<dim, Number, Number2, true>(
117 value, values, p);
118 else
119 dealii::internal::integrate_add_tensor_product_value_shapes<dim,
120 Number,
121 Number2,
122 true>(
123 shapes, n_shapes, value, values);
124 } else {
125 if (is_linear)
127 Number,
128 Number2,
129 false>(value, values, p);
130 else
131 dealii::internal::integrate_add_tensor_product_value_shapes<dim,
132 Number,
133 Number2,
134 false>(
135 shapes, n_shapes, value, values);
136 }
137 }
138 } // end of namespace internal
139
140} // namespace ryujin
void integrate_add_tensor_product_value_linear(const Number2 &value, Number2 *values, const dealii::Point< dim, Number > &p)
void integrate_tensor_product_value(const dealii::ndarray< Number, 2, dim > *shapes, const unsigned int n_shapes, const Number2 &value, Number2 *values, const dealii::Point< dim, Number > &p, const bool do_add)
DEAL_II_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)