/home/runner/work/kynema/kynema/kynema/src/system/calculate_tangent_operator.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/system/calculate_tangent_operator.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_tangent_operator.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <KokkosBatched_Copy_Decl.hpp>
4#include <KokkosBatched_Gemm_Decl.hpp>
5#include <KokkosBlas.hpp>
6#include <Kokkos_Core.hpp>
7
9
10namespace kynema::system {
11
15template <typename DeviceType>
17 template <typename ValueType>
18 using View = Kokkos::View<ValueType, DeviceType>;
19 template <typename ValueType>
21
22 double h;
25
27 void operator()(int node) const {
28 using Kokkos::ALL;
29 using Kokkos::Array;
30 using Kokkos::make_pair;
31 using Kokkos::subview;
32 using CopyMatrix = KokkosBatched::SerialCopy<>;
33 using CopyMatrixTranspose = KokkosBatched::SerialCopy<KokkosBatched::Trans::Transpose>;
34 using NoTranspose = KokkosBatched::Trans::NoTranspose;
35 using Default = KokkosBatched::Algo::Gemm::Default;
36 using Gemm = KokkosBatched::SerialGemm<NoTranspose, NoTranspose, Default>;
37
39 const auto T = View<double[6][6]>(T_data.data());
40
42 auto rv = View<double[3]>{rv_data.data()};
43
45 auto m1 = View<double[3][3]>(m1_data.data());
47 auto m2 = View<double[3][3]>(m2_data.data());
48
49 for (auto k = 0; k < 6; ++k) {
50 T(k, k) = 1.;
51 }
52
53 KokkosBlas::serial_axpy(h, subview(q_delta, node, make_pair(3, 6)), rv);
54 auto phi = KokkosBlas::serial_nrm2(rv);
55 const auto tmp1 = (phi > 1.e-16) ? (Kokkos::cos(phi) - 1.) / (phi * phi) : 0.;
56 const auto tmp2 = (phi > 1.e-16) ? (1. - Kokkos::sin(phi) / phi) / (phi * phi) : 0.;
57
59 CopyMatrix::invoke(m2, m1);
60 Gemm::invoke(tmp2, m2, m2, tmp1, m1);
61
62 KokkosBlas::serial_axpy(1., m1, subview(T, make_pair(3, 6), make_pair(3, 6)));
63
64 CopyMatrixTranspose::invoke(T, subview(T_gbl, node, ALL, ALL));
65 }
66};
67
68} // namespace kynema::system
KOKKOS_INLINE_FUNCTION void VecTilde(const VectorType &vector, const MatrixType &matrix)
Converts a 3x1 vector to a 3x3 skew-symmetric matrix and returns the result.
Definition vector_operations.hpp:11
Definition calculate_tangent_operator.hpp:10
A Kernel for calculating the tangent operator at each node.
Definition calculate_tangent_operator.hpp:16
double h
Definition calculate_tangent_operator.hpp:22
View< double *[6][6]> T_gbl
Definition calculate_tangent_operator.hpp:24
typename View< ValueType >::const_type ConstView
Definition calculate_tangent_operator.hpp:20
Kokkos::View< ValueType, DeviceType > View
Definition calculate_tangent_operator.hpp:18
KOKKOS_FUNCTION void operator()(int node) const
Definition calculate_tangent_operator.hpp:27
ConstView< double *[6]> q_delta
Definition calculate_tangent_operator.hpp:23