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

Kynema API: /home/runner/work/kynema/kynema/kynema/src/constraints/calculate_revolute_joint_constraint.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_revolute_joint_constraint.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
7
8namespace kynema::constraints {
9
13template <typename DeviceType>
15 template <typename ValueType>
16 using View = Kokkos::View<ValueType, DeviceType>;
17 template <typename ValueType>
19
21 const ConstView<double[3]>& X0, const ConstView<double[3][3]>& axes,
22 const ConstView<double[7]>& base_node_u, const ConstView<double[7]>& target_node_u,
23 const View<double[6]>& residual_terms, const View<double[6][6]>& base_gradient_terms,
24 const View<double[6][6]>& target_gradient_terms
25 ) {
26 using Kokkos::Array;
27
29 const auto R1_data =
32 const auto R2_data =
34 const auto x0_data = Array<double, 3>{axes(0, 0), axes(0, 1), axes(0, 2)};
35 const auto y0_data = Array<double, 3>{axes(1, 0), axes(1, 1), axes(1, 2)};
36 const auto z0_data = Array<double, 3>{axes(2, 0), axes(2, 1), axes(2, 2)};
39 auto x_data = Array<double, 3>{};
40 auto y_data = Array<double, 3>{};
41 auto z_data = Array<double, 3>{};
44
45 const auto u1 = ConstView<double[3]>{u1_data.data()};
46 const auto R1 = ConstView<double[4]>{R1_data.data()};
47 const auto u2 = ConstView<double[3]>{u2_data.data()};
48 const auto R2 = ConstView<double[4]>{R2_data.data()};
49 const auto x0 = ConstView<double[3]>{x0_data.data()};
50 const auto y0 = ConstView<double[3]>{y0_data.data()};
51 const auto z0 = ConstView<double[3]>{z0_data.data()};
52 const auto R1t = View<double[4]>{R1t_data.data()};
53 const auto R1_X0 = View<double[4]>{R1_X0_data.data()};
54 const auto x = View<double[3]>{x_data.data()};
55 const auto y = View<double[3]>{y_data.data()};
56 const auto z = View<double[3]>{z_data.data()};
57 const auto xcy = View<double[3]>{xcy_data.data()};
58 const auto xcz = View<double[3]>{xcz_data.data()};
59
60 //----------------------------------------------------------------------
61 // Residual Vector, Phi
62 //----------------------------------------------------------------------
63
64 // Phi(0:3) = u2 + X0 - u1 - R1*X0
67 for (auto component = 0; component < 3; ++component) {
68 residual_terms(component) =
70 }
71
72 // Angular residual
76 // Phi(3) = dot(R2 * z0_hat, R1 * x0_hat)
77 residual_terms(3) = math::DotProduct(z, x);
78 // Phi(4) = dot(R2 * y0_hat, R1 * x0_hat)
79 residual_terms(4) = math::DotProduct(y, x);
80
81 //----------------------------------------------------------------------
82 // Constraint Gradient Matrix, B
83 //----------------------------------------------------------------------
84
85 //---------------------------------
86 // Target Node
87 //---------------------------------
88 for (auto component = 0; component < 3; ++component) {
89 target_gradient_terms(component, component) = 1.;
90 }
91
92 // B(3, 3:6) = -cross(R1 * x0_hat, transpose(R2 * z0_hat))
94 // B(4, 3:6) = -cross(R1 * x0_hat, transpose(R2 * y0_hat))
96 for (auto component = 0; component < 3; ++component) {
97 target_gradient_terms(3, component + 3) = -xcz(component);
98 target_gradient_terms(4, component + 3) = -xcy(component);
99 }
100 //---------------------------------
101 // Base Node
102 //---------------------------------
103 // B(0:3,0:3) = -I
104 for (auto component = 0; component < 3; ++component) {
105 base_gradient_terms(component, component) = -1.;
106 }
107
108 // B(3,3:6) = cross(R1 * x0_hat, transpose(R2 * z0_hat))
109 // B(4,3:6) = cross(R1 * x0_hat, transpose(R2 * y0_hat))
110 for (auto component = 0; component < 3; ++component) {
111 base_gradient_terms(3, component + 3) = xcz(component);
112 base_gradient_terms(4, component + 3) = xcy(component);
113 }
114 }
115};
116} // namespace kynema::constraints
Definition calculate_constraint_output.hpp:8
KOKKOS_INLINE_FUNCTION void CrossProduct(const VectorType &a, const VectorType &b, const VectorType &c)
Calculate the cross product between two vector views.
Definition vector_operations.hpp:40
KOKKOS_INLINE_FUNCTION double DotProduct(const AVectorType &a, const BVectorType &b)
Calculate the dot product between two vector views.
Definition vector_operations.hpp:25
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 QuaternionInverse(const QuaternionInput &q_in, const QuaternionOutput &q_out)
Computes the inverse of a quaternion.
Definition quaternion_operations.hpp:172
Kernel for calculating the residual and system gradient for a revolute joint constraint.
Definition calculate_revolute_joint_constraint.hpp:14
Kokkos::View< ValueType, DeviceType > View
Definition calculate_revolute_joint_constraint.hpp:16
static KOKKOS_FUNCTION void invoke(const ConstView< double[3]> &X0, const ConstView< double[3][3]> &axes, const ConstView< double[7]> &base_node_u, const ConstView< double[7]> &target_node_u, const View< double[6]> &residual_terms, const View< double[6][6]> &base_gradient_terms, const View< double[6][6]> &target_gradient_terms)
Definition calculate_revolute_joint_constraint.hpp:20
typename View< ValueType >::const_type ConstView
Definition calculate_revolute_joint_constraint.hpp:18