/home/runner/work/kynema/kynema/kynema/src/constraints/calculate_fixed_bc_constraint.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/constraints/calculate_fixed_bc_constraint.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_fixed_bc_constraint.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <KokkosBatched_Copy_Decl.hpp>
4#include <Kokkos_Core.hpp>
5
8
9namespace kynema::constraints {
10
15template <typename DeviceType>
17 template <typename ValueType>
18 using View = Kokkos::View<ValueType, DeviceType>;
19 template <typename ValueType>
21
23 const ConstView<double[3]>& X0, const ConstView<double[7]>& node_u,
24 const View<double[6]>& residual_terms, const View<double[6][6]>& target_gradient_terms
25 ) {
26 using Kokkos::Array;
27 using Kokkos::make_pair;
28 using Kokkos::subview;
29 using CopyVector = KokkosBatched::SerialCopy<KokkosBatched::Trans::NoTranspose, 1>;
30 using CopyMatrixTranspose = KokkosBatched::SerialCopy<KokkosBatched::Trans::Transpose>;
31
32 constexpr auto u1_data = Array<double, 3>{0., 0., 0.};
33 constexpr auto R1_data = Array<double, 4>{1., 0., 0., 0.};
34 const auto u2_data = Array<double, 3>{node_u(0), node_u(1), node_u(2)};
35 const auto R2_data = Array<double, 4>{node_u(3), node_u(4), node_u(5), node_u(6)};
39 auto A_data = Array<double, 9>{};
40 auto C_data = Array<double, 9>{};
42
43 const auto u1 = ConstView<double[3]>{u1_data.data()};
44 const auto R1 = ConstView<double[4]>{R1_data.data()};
45 const auto u2 = ConstView<double[3]>{u2_data.data()};
46 const auto R2 = ConstView<double[4]>{R2_data.data()};
47 const auto R1t = View<double[4]>{R1t_data.data()};
48 const auto R1_X0 = View<double[4]>{R1_X0_data.data()};
49 const auto R2_R1t = View<double[4]>{R2_R1t_data.data()};
50 const auto A = View<double[3][3]>{A_data.data()};
51 const auto C = View<double[3][3]>{C_data.data()};
52 const auto V3 = View<double[3]>{V3_data.data()};
53
54 //----------------------------------------------------------------------
55 // Residual Vector
56 //----------------------------------------------------------------------
57
58 // Phi(0:3) = u2 + X0 - u1 - R1*X0
61 for (auto component = 0; component < 3; ++component) {
62 residual_terms(component) =
64 }
65
66 // Angular residual
67 // Phi(3:6) = axial(R2*inv(RC)*inv(R1))
71 CopyVector::invoke(V3, subview(residual_terms, make_pair(3, 6)));
72
73 //----------------------------------------------------------------------
74 // Constraint Gradient Matrix
75 //----------------------------------------------------------------------
76
77 //---------------------------------
78 // Target Node
79 //---------------------------------
80
81 // B(0:3,0:3) = I
82 for (auto component = 0; component < 3; ++component) {
83 target_gradient_terms(component, component) = 1.;
84 }
85
86 // B(3:6,3:6) = AX(R1*RC*inv(R2)) = transpose(AX(R2*inv(RC)*inv(R1)))
88 CopyMatrixTranspose::invoke(
89 A, subview(target_gradient_terms, make_pair(3, 6), make_pair(3, 6))
90 );
91 }
92};
93} // namespace kynema::constraints
Definition calculate_constraint_output.hpp:8
KOKKOS_INLINE_FUNCTION void AX_Matrix(const Matrix &A, const Matrix &AX_A)
Computes AX(A) of a square matrix.
Definition matrix_operations.hpp:19
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:204
KOKKOS_INLINE_FUNCTION void RotateVectorByQuaternion(const Quaternion &q, const View1 &v, const View2 &v_rot)
Rotates provided vector by provided unit quaternion and returns the result.
Definition quaternion_operations.hpp:120
KOKKOS_INLINE_FUNCTION void QuaternionToRotationMatrix(const Quaternion &q, const RotationMatrix &R)
Converts a 4x1 quaternion to a 3x3 rotation matrix and returns the result.
Definition quaternion_operations.hpp:20
KOKKOS_INLINE_FUNCTION void QuaternionInverse(const QuaternionInput &q_in, const QuaternionOutput &q_out)
Computes the inverse of a quaternion.
Definition quaternion_operations.hpp:172
KOKKOS_INLINE_FUNCTION void AxialVectorOfMatrix(const Matrix &m, const Vector &v)
Computes the axial vector (also known as the vector representation) of a 3x3 skew-symmetric matrix.
Definition matrix_operations.hpp:47
Kernel for calculating the residual and system gradient for a Fix BC constraint with six degrees of f...
Definition calculate_fixed_bc_constraint.hpp:16
static KOKKOS_FUNCTION void invoke(const ConstView< double[3]> &X0, const ConstView< double[7]> &node_u, const View< double[6]> &residual_terms, const View< double[6][6]> &target_gradient_terms)
Definition calculate_fixed_bc_constraint.hpp:22
typename View< ValueType >::const_type ConstView
Definition calculate_fixed_bc_constraint.hpp:20
Kokkos::View< ValueType, DeviceType > View
Definition calculate_fixed_bc_constraint.hpp:18