/home/runner/work/kynema/kynema/kynema/src/system/masses/calculate_inertia_stiffness_matrix.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/system/masses/calculate_inertia_stiffness_matrix.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_inertia_stiffness_matrix.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <KokkosBatched_Gemm_Decl.hpp>
4#include <KokkosBlas.hpp>
5#include <KokkosBlas1_set.hpp>
6#include <Kokkos_Core.hpp>
7
9
10namespace kynema::masses {
11
12template <typename DeviceType>
14 template <typename ValueType>
15 using View = Kokkos::View<ValueType, DeviceType>;
16 template <typename ValueType>
18
20 double mass, const ConstView<double[3]>& u_ddot, const ConstView<double[3]>& omega,
21 const ConstView<double[3]>& omega_dot, const ConstView<double[3]>& eta,
22 const ConstView<double[3][3]>& rho, const ConstView<double[3][3]>& omega_tilde,
23 const ConstView<double[3][3]>& omega_dot_tilde, const View<double[6][6]>& Kuu
24 ) {
25 using NoTranspose = KokkosBatched::Trans::NoTranspose;
26 using Transpose = KokkosBatched::Trans::Transpose;
27 using GemmDefault = KokkosBatched::Algo::Gemm::Default;
28 using GemvDefault = KokkosBatched::Algo::Gemv::Default;
29 using GemmNN = KokkosBatched::SerialGemm<NoTranspose, NoTranspose, GemmDefault>;
30 using GemmNT = KokkosBatched::SerialGemm<NoTranspose, Transpose, GemmDefault>;
31 using Gemv = KokkosBlas::SerialGemv<NoTranspose, GemvDefault>;
32 using Kokkos::Array;
33 using Kokkos::make_pair;
34 using Kokkos::subview;
35
36 auto v1 = Array<double, 3>{};
37 auto V1 = View<double[3]>(v1.data());
38 auto m1 = Array<double, 9>{};
39 auto M1 = View<double[3][3]>(m1.data());
40 auto m2 = Array<double, 9>{};
41 auto M2 = View<double[3][3]>(m2.data());
42
43 KokkosBlas::serial_axpy(1., omega_dot_tilde, M1);
44 GemmNN::invoke(1., omega_tilde, omega_tilde, 1., M1);
45 KokkosBlas::serial_axpy(mass, eta, V1);
47 auto Kuu_12 = subview(Kuu, make_pair(0, 3), make_pair(3, 6));
48 GemmNT::invoke(1., M1, M2, 0., Kuu_12);
50 auto Kuu_22 = subview(Kuu, make_pair(3, 6), make_pair(3, 6));
51 GemmNN::invoke(1., rho, omega_dot_tilde, 0., Kuu_22);
52 GemmNN::invoke(1., M1, M2, 1., Kuu_22);
53 Gemv::invoke(1., rho, omega_dot, 0., V1);
55 KokkosBlas::serial_axpy(-1., M2, Kuu_22);
56 Gemv::invoke(1., rho, omega, 0., V1);
58 GemmNN::invoke(1., rho, omega_tilde, -1., M1);
59 GemmNN::invoke(1., omega_tilde, M1, 1., Kuu_22);
60 }
61};
62} // namespace kynema::masses
Definition calculate_gravity_force.hpp:6
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_inertia_stiffness_matrix.hpp:13
static KOKKOS_FUNCTION void invoke(double mass, const ConstView< double[3]> &u_ddot, const ConstView< double[3]> &omega, const ConstView< double[3]> &omega_dot, const ConstView< double[3]> &eta, const ConstView< double[3][3]> &rho, const ConstView< double[3][3]> &omega_tilde, const ConstView< double[3][3]> &omega_dot_tilde, const View< double[6][6]> &Kuu)
Definition calculate_inertia_stiffness_matrix.hpp:19
typename View< ValueType >::const_type ConstView
Definition calculate_inertia_stiffness_matrix.hpp:17
Kokkos::View< ValueType, DeviceType > View
Definition calculate_inertia_stiffness_matrix.hpp:15