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

Kynema API: /home/runner/work/kynema/kynema/kynema/src/constraints/calculate_rigid_joint_3DOF_constraint.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_rigid_joint_3DOF_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]>& base_node_u,
24 const ConstView<double[7]>& target_node_u, const View<double[6]>& residual_terms,
25 const View<double[6][6]>& base_gradient_terms,
26 const View<double[6][6]>& target_gradient_terms
27 ) {
28 using Kokkos::Array;
29 using Kokkos::make_pair;
30 using Kokkos::subview;
31 using CopyMatrix = KokkosBatched::SerialCopy<>;
32
34 const auto R1_data =
39 auto A_data = Array<double, 9>{};
40
41 const auto u1 = ConstView<double[3]>{u1_data.data()};
42 const auto R1 = ConstView<double[4]>{R1_data.data()};
43 const auto u2 = ConstView<double[3]>{u2_data.data()};
44 const auto R1_X0 = View<double[3]>{R1_X0_data.data()};
45 const auto R1t = View<double[4]>{R1t_data.data()};
46 const auto A = View<double[3][3]>{A_data.data()};
47
48 //----------------------------------------------------------------------
49 // Residual Vector
50 //----------------------------------------------------------------------
51
52 // Phi(0:3) = u2 + X0 - u1 - R1*X0
55 for (auto constraint = 0; constraint < 3; ++constraint) {
56 residual_terms(constraint) =
57 u2(constraint) + X0(constraint) - u1(constraint) - R1_X0(constraint);
58 }
59
60 //----------------------------------------------------------------------
61 // Constraint Gradient Matrix
62 //----------------------------------------------------------------------
63
64 // Target Node gradients
65 // B(0:3,0:3) = I
66 for (auto constraint = 0; constraint < 3; ++constraint) {
67 target_gradient_terms(constraint, constraint) = 1.;
68 }
69
70 // Base Node gradients
71 // B(0:3,0:3) = -I
72 for (auto constraint = 0; constraint < 3; ++constraint) {
73 base_gradient_terms(constraint, constraint) = -1.;
74 }
75
76 // B(0:3,3:6) = tilde(R1*X0)
78 CopyMatrix::invoke(A, subview(base_gradient_terms, make_pair(0, 3), make_pair(3, 6)));
79 }
80};
81} // namespace kynema::constraints
Definition calculate_constraint_output.hpp:8
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
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 rigid joint constraint with three degre...
Definition calculate_rigid_joint_3DOF_constraint.hpp:16
typename View< ValueType >::const_type ConstView
Definition calculate_rigid_joint_3DOF_constraint.hpp:20
static KOKKOS_FUNCTION void invoke(const ConstView< double[3]> &X0, 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_rigid_joint_3DOF_constraint.hpp:22
Kokkos::View< ValueType, DeviceType > View
Definition calculate_rigid_joint_3DOF_constraint.hpp:18