/home/runner/work/kynema/kynema/kynema/src/elements/beams/interpolation_operations.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/elements/beams/interpolation_operations.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
interpolation_operations.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
5namespace kynema::beams {
6
7template <typename shape_matrix_type, typename node_type, typename qp_type>
8KOKKOS_INLINE_FUNCTION void InterpVector3(
9 const shape_matrix_type& shape_matrix, const node_type& node_v, const qp_type& qp_v
10) {
11 for (auto qp = 0; qp < qp_v.extent_int(0); ++qp) {
12 auto local_total = Kokkos::Array<double, 3>{};
13 for (auto node = 0; node < node_v.extent_int(0); ++node) {
14 const auto phi = shape_matrix(node, qp);
15 for (auto component = 0; component < 3; ++component) {
16 local_total[component] += node_v(node, component) * phi;
17 }
18 }
19 for (auto component = 0; component < 3; ++component) {
20 qp_v(qp, component) = local_total[component];
21 }
22 }
23}
24
25template <typename shape_matrix_type, typename node_type, typename qp_type>
26KOKKOS_INLINE_FUNCTION void InterpVector4(
27 const shape_matrix_type& shape_matrix, const node_type& node_v, const qp_type& qp_v
28) {
29 for (auto qp = 0; qp < qp_v.extent_int(0); ++qp) {
30 auto local_total = Kokkos::Array<double, 4>{};
31 for (auto node = 0; node < node_v.extent_int(0); ++node) {
32 const auto phi = shape_matrix(node, qp);
33 for (auto component = 0; component < 4; ++component) {
34 local_total[component] += node_v(node, component) * phi;
35 }
36 }
37 for (auto component = 0; component < 4; ++component) {
38 qp_v(qp, component) = local_total[component];
39 }
40 }
41}
42
43template <typename shape_matrix_type, typename node_type, typename qp_type>
44KOKKOS_INLINE_FUNCTION void InterpQuaternion(
45 const shape_matrix_type& shape_matrix, const node_type& node_v, const qp_type& qp_v
46) {
47 InterpVector4(shape_matrix, node_v, qp_v);
48 static constexpr auto length_zero_result = Kokkos::Array<double, 4>{1., 0., 0., 0.};
49 for (auto qp = 0; qp < qp_v.extent_int(0); ++qp) {
50 auto length = Kokkos::sqrt(
51 Kokkos::pow(qp_v(qp, 0), 2) + Kokkos::pow(qp_v(qp, 1), 2) + Kokkos::pow(qp_v(qp, 2), 2) +
52 Kokkos::pow(qp_v(qp, 3), 2)
53 );
54 if (length == 0.) {
55 for (auto component = 0; component < 4; ++component) {
56 qp_v(qp, component) = length_zero_result[component];
57 }
58 } else {
59 for (auto component = 0; component < 4; ++component) {
60 qp_v(qp, component) /= length;
61 }
62 }
63 }
64}
65
66template <typename shape_matrix_type, typename jacobian_type, typename node_type, typename qp_type>
67KOKKOS_INLINE_FUNCTION void InterpVector3Deriv(
68 const shape_matrix_type& shape_matrix_deriv, const jacobian_type& jacobian,
69 const node_type& node_v, const qp_type& qp_v
70) {
71 InterpVector3(shape_matrix_deriv, node_v, qp_v);
72 for (auto qp = 0; qp < qp_v.extent_int(0); ++qp) {
73 const auto jac = jacobian(qp);
74 for (auto component = 0; component < qp_v.extent_int(1); ++component) {
75 qp_v(qp, component) /= jac;
76 }
77 }
78}
79
80template <typename shape_matrix_type, typename jacobian_type, typename node_type, typename qp_type>
81KOKKOS_INLINE_FUNCTION void InterpVector4Deriv(
82 const shape_matrix_type& shape_matrix_deriv, const jacobian_type& jacobian,
83 const node_type& node_v, const qp_type& qp_v
84) {
85 InterpVector4(shape_matrix_deriv, node_v, qp_v);
86 for (auto qp = 0; qp < qp_v.extent_int(0); ++qp) {
87 const auto jac = jacobian(qp);
88 for (auto component = 0; component < qp_v.extent_int(1); ++component) {
89 qp_v(qp, component) /= jac;
90 }
91 }
92}
93
94} // namespace kynema::beams
Definition beam_quadrature.hpp:16
KOKKOS_INLINE_FUNCTION void InterpVector3Deriv(const shape_matrix_type &shape_matrix_deriv, const jacobian_type &jacobian, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:67
KOKKOS_INLINE_FUNCTION void InterpVector4(const shape_matrix_type &shape_matrix, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:26
KOKKOS_INLINE_FUNCTION void InterpQuaternion(const shape_matrix_type &shape_matrix, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:44
KOKKOS_INLINE_FUNCTION void InterpVector4Deriv(const shape_matrix_type &shape_matrix_deriv, const jacobian_type &jacobian, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:81
KOKKOS_INLINE_FUNCTION void InterpVector3(const shape_matrix_type &shape_matrix, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:8