/home/runner/work/kynema/kynema/kynema/src/elements/beams/calculate_jacobian.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/elements/beams/calculate_jacobian.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
calculate_jacobian.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
6
7namespace kynema::beams {
8
21template <typename DeviceType>
23 template <typename ValueType>
24 using View = Kokkos::View<ValueType, DeviceType>;
25 template <typename ValueType>
27
30 ConstView<double***> shape_derivative; //< num_elems x num_nodes x num_qps
31 ConstView<double** [7]> node_position_rotation; //< num_elems x num_nodes x 7
32 View<double** [3]> qp_position_derivative; //< output: num_elems x num_qps x 3
33 View<double**> qp_jacobian; //< output: num_elems x num_qps
34
36 void operator()(int element) const {
37 using Kokkos::ALL;
38 using Kokkos::make_pair;
39 using Kokkos::pow;
40 using Kokkos::sqrt;
41 using Kokkos::subview;
42
43 const auto num_nodes = num_nodes_per_element(element);
44 const auto num_qps = num_qps_per_element(element);
45 const auto shape_deriv = subview(
46 shape_derivative, element, make_pair(size_t{0U}, num_nodes),
47 make_pair(size_t{0U}, num_qps)
48 );
49 const auto qp_pos_deriv =
50 subview(qp_position_derivative, element, make_pair(size_t{0U}, num_qps), ALL);
51 const auto node_pos = subview(
52 node_position_rotation, element, make_pair(size_t{0U}, num_nodes), make_pair(0U, 3U)
53 );
54 const auto qp_jacob = subview(qp_jacobian, element, make_pair(size_t{0U}, num_qps));
55
56 // Interpolate position derivatives at quadrature points using shape functions
57 // qp_pos_deriv = Σ(dN/dξ * node_pos)
58 InterpVector3(shape_deriv, node_pos, qp_pos_deriv);
59
60 for (auto qp = 0U; qp < num_qps; ++qp) {
61 // Calculate Jacobian - this is a scalar that represents the "stretching" factor between
62 // parametric (ξ) and physical (x) space
63 // J = |dx/dξ| = sqrt((dx/dξ)² + (dy/dξ)² + (dz/dξ)²)
64 const auto jacobian = sqrt(
65 pow(qp_pos_deriv(qp, 0), 2.) + pow(qp_pos_deriv(qp, 1), 2.) +
66 pow(qp_pos_deriv(qp, 2), 2.)
67 );
69
70 // Normalize position derivatives by Jacobian to get unit tangent vector that points
71 // in the direction of curve/beam
72 for (auto component = 0U; component < 3U; ++component) {
74 }
75 }
76 }
77};
78
79} // namespace kynema::beams
Definition beam_quadrature.hpp:16
KOKKOS_INLINE_FUNCTION void InterpVector3(const shape_matrix_type &shape_matrix, const node_type &node_v, const qp_type &qp_v)
Definition interpolation_operations.hpp:8
Functor to calculate Jacobians and unit tangent vectors at quadrature points for beam elements.
Definition calculate_jacobian.hpp:22
ConstView< size_t * > num_qps_per_element
Definition calculate_jacobian.hpp:29
View< double **[3]> qp_position_derivative
Definition calculate_jacobian.hpp:32
typename View< ValueType >::const_type ConstView
Definition calculate_jacobian.hpp:26
KOKKOS_FUNCTION void operator()(int element) const
Definition calculate_jacobian.hpp:36
ConstView< double *** > shape_derivative
Definition calculate_jacobian.hpp:30
View< double ** > qp_jacobian
Definition calculate_jacobian.hpp:33
ConstView< double **[7]> node_position_rotation
Definition calculate_jacobian.hpp:31
ConstView< size_t * > num_nodes_per_element
Definition calculate_jacobian.hpp:28
Kokkos::View< ValueType, DeviceType > View
Definition calculate_jacobian.hpp:24