/home/runner/work/kynema/kynema/kynema/src/dof_management/assemble_node_freedom_allocation_table.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/dof_management/assemble_node_freedom_allocation_table.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
assemble_node_freedom_allocation_table.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
8#include "state/state.hpp"
9
10namespace kynema::dof {
11
15template <typename DeviceType>
17 template <typename ValueType>
18 using View = Kokkos::View<ValueType, DeviceType>;
19 template <typename ValueType>
21
26
28 void operator()(size_t element) const {
29 const auto num_nodes = num_nodes_per_element(element);
30 for (auto node = 0U; node < num_nodes; ++node) {
31 const auto node_index = node_state_indices(element, node);
32 Kokkos::atomic_or(
34 );
35 }
36 }
37};
38
42template <typename DeviceType>
44 template <typename ValueType>
45 using View = Kokkos::View<ValueType, DeviceType>;
46 template <typename ValueType>
48
51 Kokkos::View<FreedomSignature*, DeviceType> node_freedom_allocation_table;
52
54 void operator()(size_t element) const {
55 // Masses always have one node per element
56 const auto node_index = node_state_indices(element);
57 Kokkos::atomic_or(
59 );
60 }
61};
62
66template <typename DeviceType>
68 template <typename ValueType>
69 using View = Kokkos::View<ValueType, DeviceType>;
70 template <typename ValueType>
72
76
78 void operator()(size_t element) const {
79 // Springs always have two nodes per element
80 for (auto node = 0U; node < 2U; ++node) {
81 const auto node_index = node_state_indices(element, node);
82 Kokkos::atomic_or(
84 );
85 }
86 }
87};
88
92template <typename DeviceType>
94 template <typename ValueType>
95 using View = Kokkos::View<ValueType, DeviceType>;
96 template <typename ValueType>
98
105
107 void operator()(size_t node) const {
108 {
109 const auto node_index = target_node_index(node);
110 Kokkos::atomic_or(
112 );
113 }
114
115 if (GetNumberOfNodes(type(node)) == 2U) {
116 const auto node_index = base_node_index(node);
117 Kokkos::atomic_or(
119 );
120 }
121 }
122};
123
139template <typename DeviceType>
141 State<DeviceType>& state, const Elements<DeviceType>& elements,
142 const Constraints<DeviceType>& constraints
143) {
144 using Kokkos::parallel_for;
145 using RangePolicy = Kokkos::RangePolicy<typename DeviceType::execution_space>;
147
148 auto beams_range = RangePolicy(0, elements.beams.num_elems);
149
150 parallel_for(
151 "AssembleNodeFreedomMapTable_Beams", beams_range,
153 elements.beams.num_nodes_per_element, elements.beams.node_state_indices,
154 elements.beams.element_freedom_signature, state.node_freedom_allocation_table
155 }
156 );
157 auto masses_range = RangePolicy(0, elements.masses.num_elems);
158 parallel_for(
159 "AssembleNodeFreedomMapTable_Masses", masses_range,
161 elements.masses.state_indices, elements.masses.element_freedom_signature,
163 }
164 );
165 auto springs_range = RangePolicy(0, elements.springs.num_elems);
166 parallel_for(
167 "AssembleNodeFreedomMapTable_Springs", springs_range,
169 elements.springs.node_state_indices, elements.springs.element_freedom_signature,
171 }
172 );
173 auto constraints_range = RangePolicy(0, constraints.num_constraints);
174 parallel_for(
175 "AssembleNodeFreedomMapTable_Constraints", constraints_range,
177 constraints.type, constraints.target_node_index, constraints.base_node_index,
180 }
181 );
182
183 const auto active_dofs = state.active_dofs;
184 const auto node_freedom_allocation_table = state.node_freedom_allocation_table;
185 auto system_range = RangePolicy(0, state.num_system_nodes);
186 parallel_for(
187 "ComputeActiveDofs", system_range,
188 KOKKOS_LAMBDA(size_t node) {
189 active_dofs(node) = count_active_dofs(node_freedom_allocation_table(node));
190 }
191 );
192}
193
194} // namespace kynema::dof
Definition assemble_node_freedom_allocation_table.hpp:10
KOKKOS_INLINE_FUNCTION size_t count_active_dofs(FreedomSignature x)
Counts the number of active degrees of freedom in a signature.
Definition freedom_signature.hpp:45
void assemble_node_freedom_allocation_table(State< DeviceType > &state, const Elements< DeviceType > &elements, const Constraints< DeviceType > &constraints)
Creates the node freedom allocation table in state based on the connectivities defined in the element...
Definition assemble_node_freedom_allocation_table.hpp:140
Container class for managing multiple constraints in a simulation.
Definition constraints.hpp:29
View< size_t * > base_node_index
Definition constraints.hpp:41
View< dof::FreedomSignature * > base_node_freedom_signature
Definition constraints.hpp:46
View< size_t * > target_node_index
Definition constraints.hpp:42
View< dof::FreedomSignature * > target_node_freedom_signature
Definition constraints.hpp:47
size_t num_constraints
Definition constraints.hpp:35
View< constraints::ConstraintType * > type
Definition constraints.hpp:39
A container providing handle to all structural elements present in the model.
Definition elements.hpp:20
Masses< DeviceType > masses
Definition elements.hpp:22
Springs< DeviceType > springs
Definition elements.hpp:23
Beams< DeviceType > beams
Definition elements.hpp:21
Container for storing the complete system state of the simulation at a given time increment.
Definition state.hpp:18
View< dof::FreedomSignature * > node_freedom_allocation_table
Definition state.hpp:25
size_t num_system_nodes
Definition state.hpp:23
View< size_t * > active_dofs
Definition state.hpp:26
A Kernel for applying a Beam element's freedom signature to all nodes it contains.
Definition assemble_node_freedom_allocation_table.hpp:16
typename View< ValueType >::const_type ConstView
Definition assemble_node_freedom_allocation_table.hpp:20
View< FreedomSignature * > node_freedom_allocation_table
Definition assemble_node_freedom_allocation_table.hpp:25
Kokkos::View< ValueType, DeviceType > View
Definition assemble_node_freedom_allocation_table.hpp:18
ConstView< size_t ** > node_state_indices
Definition assemble_node_freedom_allocation_table.hpp:23
KOKKOS_FUNCTION void operator()(size_t element) const
Definition assemble_node_freedom_allocation_table.hpp:28
ConstView< size_t * > num_nodes_per_element
Definition assemble_node_freedom_allocation_table.hpp:22
ConstView< FreedomSignature ** > element_freedom_signature
Definition assemble_node_freedom_allocation_table.hpp:24
A Kernel for applying a constraint's freedom signature to its base and target nodes.
Definition assemble_node_freedom_allocation_table.hpp:93
ConstView< constraints::ConstraintType * > type
Definition assemble_node_freedom_allocation_table.hpp:99
ConstView< size_t * > target_node_index
Definition assemble_node_freedom_allocation_table.hpp:100
KOKKOS_FUNCTION void operator()(size_t node) const
Definition assemble_node_freedom_allocation_table.hpp:107
Kokkos::View< ValueType, DeviceType > View
Definition assemble_node_freedom_allocation_table.hpp:95
ConstView< FreedomSignature * > target_node_freedom_signature
Definition assemble_node_freedom_allocation_table.hpp:102
typename View< ValueType >::const_type ConstView
Definition assemble_node_freedom_allocation_table.hpp:97
ConstView< FreedomSignature * > base_node_freedom_signature
Definition assemble_node_freedom_allocation_table.hpp:103
View< FreedomSignature * > node_freedom_allocation_table
Definition assemble_node_freedom_allocation_table.hpp:104
ConstView< size_t * > base_node_index
Definition assemble_node_freedom_allocation_table.hpp:101
A Kernel for applying a mass element's freedom signature to its node.
Definition assemble_node_freedom_allocation_table.hpp:43
ConstView< FreedomSignature * > element_freedom_signature
Definition assemble_node_freedom_allocation_table.hpp:50
ConstView< size_t * > node_state_indices
Definition assemble_node_freedom_allocation_table.hpp:49
Kokkos::View< ValueType, DeviceType > View
Definition assemble_node_freedom_allocation_table.hpp:45
KOKKOS_FUNCTION void operator()(size_t element) const
Definition assemble_node_freedom_allocation_table.hpp:54
Kokkos::View< FreedomSignature *, DeviceType > node_freedom_allocation_table
Definition assemble_node_freedom_allocation_table.hpp:51
typename View< ValueType >::const_type ConstView
Definition assemble_node_freedom_allocation_table.hpp:47
A Kernel for applying a spring element's freedom signature to both of its nodes.
Definition assemble_node_freedom_allocation_table.hpp:67
View< FreedomSignature * > node_freedom_allocation_table
Definition assemble_node_freedom_allocation_table.hpp:75
Kokkos::View< ValueType, DeviceType > View
Definition assemble_node_freedom_allocation_table.hpp:69
typename View< ValueType >::const_type ConstView
Definition assemble_node_freedom_allocation_table.hpp:71
KOKKOS_FUNCTION void operator()(size_t element) const
Definition assemble_node_freedom_allocation_table.hpp:78
ConstView< FreedomSignature *[2]> element_freedom_signature
Definition assemble_node_freedom_allocation_table.hpp:74
ConstView< size_t *[2]> node_state_indices
Definition assemble_node_freedom_allocation_table.hpp:73