/home/runner/work/kynema-fmb/kynema-fmb/src/system/masses/calculate_quadrature_point_values.hpp Source File

Kynema-FMB API: /home/runner/work/kynema-fmb/kynema-fmb/src/system/masses/calculate_quadrature_point_values.hpp Source File
Kynema-FMB API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_quadrature_point_values.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <KokkosBlas.hpp>
4#include <Kokkos_Core.hpp>
5
12
13namespace kynema_fmb::masses {
14
15template <typename DeviceType>
17 using TeamPolicy = typename Kokkos::TeamPolicy<typename DeviceType::execution_space>;
18 using member_type = typename TeamPolicy::member_type;
19 template <typename ValueType>
20 using View = Kokkos::View<ValueType, DeviceType>;
21 template <typename ValueType>
23
24 double beta_prime;
26
30
36
41
43 void operator()(size_t element) const {
44 using Kokkos::ALL;
45 using Kokkos::Array;
46 using Kokkos::subview;
47 using CopyMatrix = KokkosBatched::SerialCopy<>;
48 using NoTranspose = KokkosBatched::Trans::NoTranspose;
49 using Default = KokkosBatched::Algo::Gemm::Default;
50 using Gemm = KokkosBatched::SerialGemm<NoTranspose, NoTranspose, Default>;
51
52 const auto index = node_state_indices(element);
53
54 // Allocate scratch views
55 const auto u_ddot_data = Array<double, 3>{A(index, 0), A(index, 1), A(index, 2)};
56 const auto omega_dot_data = Array<double, 3>{A(index, 3), A(index, 4), A(index, 5)};
57 const auto omega_data = Array<double, 3>{V(index, 3), V(index, 4), V(index, 5)};
63
64 // Set up Views
65 const auto u_ddot = ConstView<double[3]>(u_ddot_data.data());
67 const auto omega = ConstView<double[3]>(omega_data.data());
68 auto Muu = View<double[6][6]>(Muu_data.data());
69 auto eta = View<double[3]>(eta_data.data());
70 auto rho = View<double[3][3]>(rho_data.data());
73
74 // Do the math
75 {
77 const auto r0_data = Array<double, 4>{
78 node_x0(element, 3), node_x0(element, 4), node_x0(element, 5), node_x0(element, 6)
79 };
80 const auto r_data = Array<double, 4>{Q(index, 3), Q(index, 4), Q(index, 5), Q(index, 6)};
82
83 const auto Mstar = View<double[6][6]>(Mstar_data.data());
84 const auto r0 = ConstView<double[4]>(r0_data.data());
85 const auto r = ConstView<double[4]>(r_data.data());
86 const auto xr = View<double[4]>(xr_data.data());
87
88 CopyMatrix::invoke(subview(qp_Mstar, element, ALL, ALL), Mstar);
92
94
97 }
98
99 {
101 auto Fg_data = Array<double, 6>{};
102 auto Fi_data = Array<double, 6>{};
103
105 auto Fg = View<double[6]>(Fg_data.data());
106 auto Fi = View<double[6]>(Fi_data.data());
107
108 const auto mass = Muu(0, 0);
109
111
115 );
116
117 for (auto component = 0U; component < 6U; ++component) {
119 }
120 }
121
122 {
125 auto T_data = Array<double, 36>{};
127
128 auto Guu = View<double[6][6]>(Guu_data.data());
129 auto Kuu = View<double[6][6]>(Kuu_data.data());
130 auto T = View<double[6][6]>(T_data.data());
131 auto STpI = View<double[6][6]>(STpI_data.data());
132
133 const auto mass = Muu(0, 0);
134
138 );
139
140 CopyMatrix::invoke(Kokkos::subview(tangent, index, Kokkos::ALL, Kokkos::ALL), T);
141
142 for (auto component_1 = 0U; component_1 < 6U; ++component_1) {
143 for (auto component_2 = 0U; component_2 < 6U; ++component_2) {
146 }
147 }
148
149 if (include_stiffness) {
150 if (include_tangent) {
151 Gemm::invoke(1., Kuu, T, 1., STpI);
152 } else {
153 KokkosBlas::serial_axpy(1., Kuu, STpI);
154 }
155 }
156
157 CopyMatrix::invoke(
158 STpI, Kokkos::subview(system_matrix_terms, element, Kokkos::ALL, Kokkos::ALL)
159 );
160 }
161 }
162};
163
164} // namespace kynema_fmb::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:10
KOKKOS_INLINE_FUNCTION void QuaternionCompose(const Quaternion1 &q1, const Quaternion2 &q2, QuaternionN &qn)
Composes (i.e. multiplies) two quaternions and stores the result in a third quaternion.
Definition quaternion_operations.hpp:87
static KOKKOS_FUNCTION void invoke(double mass, const ConstView< double[3]> &gravity, const ConstView< double[3][3]> &eta_tilde, const View< double[6]> &FG)
Definition calculate_gravity_force.hpp:15
static KOKKOS_FUNCTION void invoke(double mass, const ConstView< double[3]> &omega, const ConstView< double[3]> &eta, const ConstView< double[3][3]> &rho, const ConstView< double[3][3]> &omega_tilde, const Kokkos::View< double[6][6], DeviceType > &Guu)
Definition calculate_gyroscopic_matrix.hpp:20
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
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]> &eta_tilde, 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]> &FI)
Definition calculate_inertial_force.hpp:16
Definition calculate_quadrature_point_values.hpp:16
bool include_stiffness
Definition calculate_quadrature_point_values.hpp:39
View< double *[6]> residual_vector_terms
Definition calculate_quadrature_point_values.hpp:37
View< double *[6]> V
Definition calculate_quadrature_point_values.hpp:28
typename View< ValueType >::const_type ConstView
Definition calculate_quadrature_point_values.hpp:22
View< double *[6]> A
Definition calculate_quadrature_point_values.hpp:29
KOKKOS_FUNCTION void operator()(size_t element) const
Definition calculate_quadrature_point_values.hpp:43
double beta_prime
Definition calculate_quadrature_point_values.hpp:24
ConstView< double *[7]> node_x0
Definition calculate_quadrature_point_values.hpp:35
ConstView< double *[6][6]> qp_Mstar
Definition calculate_quadrature_point_values.hpp:34
View< double *[6][6]> system_matrix_terms
Definition calculate_quadrature_point_values.hpp:38
View< double *[7]> Q
Definition calculate_quadrature_point_values.hpp:27
ConstView< double *[6][6]> tangent
Definition calculate_quadrature_point_values.hpp:31
ConstView< double[3]> gravity
Definition calculate_quadrature_point_values.hpp:33
ConstView< size_t * > node_state_indices
Definition calculate_quadrature_point_values.hpp:32
typename Kokkos::TeamPolicy< typename DeviceType::execution_space > TeamPolicy
Definition calculate_quadrature_point_values.hpp:17
Kokkos::View< ValueType, DeviceType > View
Definition calculate_quadrature_point_values.hpp:20
double gamma_prime
Definition calculate_quadrature_point_values.hpp:25
typename TeamPolicy::member_type member_type
Definition calculate_quadrature_point_values.hpp:18
bool include_tangent
Definition calculate_quadrature_point_values.hpp:40
static KOKKOS_FUNCTION void invoke(const ConstView< double[4]> &xr, const ConstView< double[6][6]> &Cstar, const View< double[6][6]> &Cuu)
Definition rotate_section_matrix.hpp:17