/home/runner/work/kynema/kynema/kynema/src/solver/contribute_beams_to_vector.hpp Source File

Kynema API: /home/runner/work/kynema/kynema/kynema/src/solver/contribute_beams_to_vector.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
contribute_beams_to_vector.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
5namespace kynema::solver {
6
11template <typename DeviceType>
13 using TeamPolicy = Kokkos::TeamPolicy<typename DeviceType::execution_space>;
14 using member_type = typename TeamPolicy::member_type;
15 template <typename ValueType>
16 using View = Kokkos::View<ValueType, DeviceType>;
17 template <typename ValueType>
19 template <typename ValueType>
20 using LeftView = Kokkos::View<ValueType, Kokkos::LayoutLeft, DeviceType>;
21
26
29 const auto element = static_cast<size_t>(member.league_rank());
30 const auto num_nodes = num_nodes_per_element(element);
31 constexpr auto force_atomic =
32 !std::is_same_v<typename DeviceType::execution_space, Kokkos::Serial>;
33
34 Kokkos::parallel_for(
35 Kokkos::TeamVectorRange(member, num_nodes * 6U),
36 [&](size_t node_component) {
37 const auto node = node_component % num_nodes;
38 const auto component = node_component / num_nodes;
39 const auto entry = element_freedom_table(element, node, component);
40 if constexpr (force_atomic) {
41 Kokkos::atomic_add(&vector(entry, 0), elements(element, node, component));
42 } else {
43 vector(entry, 0) += elements(element, node, component);
44 }
45 }
46 );
47 }
48};
49
50} // namespace kynema::solver
Definition calculate_error_sum_squares.hpp:5
A Kernel which sums the residual contributions computed at each node in a beam into the correct locat...
Definition contribute_beams_to_vector.hpp:12
ConstView< double **[6]> elements
Definition contribute_beams_to_vector.hpp:24
typename TeamPolicy::member_type member_type
Definition contribute_beams_to_vector.hpp:14
LeftView< double *[1]> vector
Definition contribute_beams_to_vector.hpp:25
Kokkos::View< ValueType, Kokkos::LayoutLeft, DeviceType > LeftView
Definition contribute_beams_to_vector.hpp:20
Kokkos::TeamPolicy< typename DeviceType::execution_space > TeamPolicy
Definition contribute_beams_to_vector.hpp:13
KOKKOS_FUNCTION void operator()(member_type member) const
Definition contribute_beams_to_vector.hpp:28
ConstView< size_t * > num_nodes_per_element
Definition contribute_beams_to_vector.hpp:22
Kokkos::View< ValueType, DeviceType > View
Definition contribute_beams_to_vector.hpp:16
typename View< ValueType >::const_type ConstView
Definition contribute_beams_to_vector.hpp:18
ConstView< size_t **[6]> element_freedom_table
Definition contribute_beams_to_vector.hpp:23