/home/runner/work/kynema/kynema/kynema/src/math/vector_operations.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/math/vector_operations.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
vector_operations.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4#include <Kokkos_Core.hpp>
5
6namespace kynema::math {
7
9template <typename VectorType, typename MatrixType>
10KOKKOS_INLINE_FUNCTION void VecTilde(const VectorType& vector, const MatrixType& matrix) {
11 matrix(0, 0) = 0.;
12 matrix(0, 1) = -vector(2);
13 matrix(0, 2) = vector(1);
14 matrix(1, 0) = vector(2);
15 matrix(1, 1) = 0.;
16 matrix(1, 2) = -vector(0);
17 matrix(2, 0) = -vector(1);
18 matrix(2, 1) = vector(0);
19 matrix(2, 2) = 0.;
20}
21
23template <typename AVectorType, typename BVectorType>
24KOKKOS_INLINE_FUNCTION double DotProduct(const AVectorType& a, const BVectorType& b) {
25 double sum = 0.;
26 for (auto i = 0; i < a.extent_int(0); ++i) {
27 sum += a(i) * b(i);
28 }
29 return sum;
30}
31
33template <typename VectorType>
34KOKKOS_INLINE_FUNCTION void CrossProduct(
35 const VectorType& a, const VectorType& b, const VectorType& c
36) {
37 c(0) = a(1) * b(2) - a(2) * b(1);
38 c(1) = a(2) * b(0) - a(0) * b(2);
39 c(2) = a(0) * b(1) - a(1) * b(0);
40}
41
42} // namespace kynema::math
Definition gl_quadrature.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:34
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 double DotProduct(const AVectorType &a, const BVectorType &b)
Calculate the dot product between two vector views.
Definition vector_operations.hpp:24