/home/runner/work/kynema/kynema/kynema/src/elements/springs/create_springs.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/elements/springs/create_springs.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
create_springs.hpp
Go to the documentation of this file.
1#pragma once
2#include <span>
3
4#include "model/node.hpp"
5#include "springs.hpp"
6#include "springs_input.hpp"
7
8namespace kynema {
9
20template <typename DeviceType>
22 const SpringsInput& springs_input, std::span<const Node> nodes
23) {
24 using Kokkos::create_mirror_view;
25 using Kokkos::deep_copy;
26 using Kokkos::WithoutInitializing;
27
28 Springs<DeviceType> springs(springs_input.NumElements());
29
30 auto host_node_state_indices =
31 create_mirror_view(WithoutInitializing, springs.node_state_indices);
32 auto host_x0 = create_mirror_view(WithoutInitializing, springs.x0);
33 auto host_l_ref = create_mirror_view(WithoutInitializing, springs.l_ref);
34 auto host_k = create_mirror_view(WithoutInitializing, springs.k);
35
36 for (auto elementIdx : std::views::iota(0U, springs_input.NumElements())) {
37 const auto& element = springs_input.elements[elementIdx];
38
39 host_node_state_indices(elementIdx, 0U) = static_cast<size_t>(element.node_ids[0]);
40 host_node_state_indices(elementIdx, 1U) = static_cast<size_t>(element.node_ids[1]);
41
42 for (auto component : std::views::iota(0U, 3U)) {
43 host_x0(elementIdx, component) =
44 nodes[element.node_ids[1]].x0[component] - nodes[element.node_ids[0]].x0[component];
45 }
46
47 host_l_ref(elementIdx) = element.undeformed_length;
48 host_k(elementIdx) = element.stiffness;
49 }
50
51 deep_copy(springs.node_state_indices, host_node_state_indices);
52 deep_copy(springs.x0, host_x0);
53 deep_copy(springs.l_ref, host_l_ref);
54 deep_copy(springs.k, host_k);
55
56 return springs;
57}
58
59} // namespace kynema
Definition calculate_constraint_output.hpp:8
Springs< DeviceType > CreateSprings(const SpringsInput &springs_input, std::span< const Node > nodes)
Creates a springs data structure and initializes its data.
Definition create_springs.hpp:21
Represents the input data for creating spring elements.
Definition springs_input.hpp:13
size_t NumElements() const
Returns the total number of spring elements in the system.
Definition springs_input.hpp:21
std::vector< SpringElement > elements
Definition springs_input.hpp:14
Contains field variables for spring elements to compute per-element contributions to the residual vec...
Definition springs.hpp:14
View< double * > l_ref
Definition springs.hpp:26
View< size_t *[2]> node_state_indices
Definition springs.hpp:21
View< double * > k
Definition springs.hpp:27
View< double *[3]> x0
Definition springs.hpp:25