/home/runner/work/kynema-fmb/kynema-fmb/kynema-fmb/src/solver/compute_system_col_inds.hpp Source File

Kynema API: /home/runner/work/kynema-fmb/kynema-fmb/kynema-fmb/src/solver/compute_system_col_inds.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
compute_system_col_inds.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
5namespace kynema_fmb::solver {
6
11template <typename RowPtrType, typename IndicesType>
13 using RowPtrValueType = typename RowPtrType::value_type;
14 using IndicesValueType = typename IndicesType::value_type;
15 using DeviceType = typename RowPtrType::device_type;
16 template <typename ValueType>
17 using View = Kokkos::View<ValueType, DeviceType>;
18 template <typename ValueType>
20
31 typename RowPtrType::const_type row_ptrs;
33
35 bool ElementContainsNode(size_t element, size_t node) const {
36 const auto num_nodes = num_nodes_per_element(element);
37 for (auto node_idx = 0U; node_idx < num_nodes; ++node_idx) {
38 if (node_state_indices(element, node_idx) == node) {
39 return true;
40 }
41 }
42 return false;
43 }
44
46 bool BaseContainsNode(size_t constraint, size_t dof_index) const {
47 return dof_index == base_node_freedom_table(constraint, 0) &&
48 base_active_dofs(constraint) != 0UL;
49 }
50
52 bool TargetContainsNode(size_t constraint, size_t dof_index) const {
53 return dof_index == target_node_freedom_table(constraint, 0) &&
54 target_active_dofs(constraint) != 0UL;
55 }
56
58 bool ConstraintContainsNode(size_t constraint, size_t dof_index) const {
59 return BaseContainsNode(constraint, dof_index) || TargetContainsNode(constraint, dof_index);
60 }
61
64 size_t element, size_t node, RowPtrValueType index
65 ) const {
66 for (auto node_index = 0U; node_index < num_nodes_per_element(element); ++node_index) {
67 const auto node_state_index = node_state_indices(element, node_index);
68 if (node_state_index != node) {
71 for (auto component = 0U; component < num_dof; ++component, ++index) {
72 const auto col_index = dof_index + component;
73 col_inds(index) = static_cast<IndicesValueType>(col_index);
74 }
75 }
76 }
77 return index;
78 }
79
82 const auto first_row = row_range(constraint).first;
83 const auto end_row = row_range(constraint).second;
84 for (auto k = first_row; k < end_row; ++k, ++index) {
85 const auto col_index = num_system_dofs + k;
86 col_inds(index) = static_cast<IndicesValueType>(col_index);
87 }
88 return index;
89 }
90
92 void operator()(size_t node) const {
93 const auto num_dof = active_dofs(node);
94 const auto dof_index = node_freedom_map_table(node);
95
96 const auto num_elements = num_nodes_per_element.extent(0);
97 const auto num_constraints = row_range.extent(0);
98
99 auto current_col = Kokkos::Array<RowPtrValueType, 6>{};
100
101 for (auto component_1 = 0U; component_1 < num_dof; ++component_1) {
102 auto index = row_ptrs(dof_index + component_1);
103
104 for (auto component_2 = 0U; component_2 < num_dof; ++component_2, ++index) {
105 col_inds(index) = static_cast<IndicesValueType>(dof_index) +
106 static_cast<IndicesValueType>(component_2);
107 }
109 }
110
111 for (auto element = 0U; element < num_elements; ++element) {
112 if (!ElementContainsNode(element, node)) {
113 continue;
114 }
115 for (auto component = 0U; component < num_dof; ++component) {
116 const auto index = row_ptrs(dof_index + component) + current_col[component];
117 const auto new_index = ComputeColIndsInElement(element, node, index);
118 current_col[component] += new_index - index;
119 }
120 }
121
122 for (auto constraint = 0U; constraint < num_constraints; ++constraint) {
123 if (!ConstraintContainsNode(constraint, dof_index)) {
124 continue;
125 }
126 for (auto component = 0U; component < num_dof; ++component) {
127 const auto index = row_ptrs(dof_index + component) + current_col[component];
128 const auto new_index = ComputeColIndsInConstraint(constraint, index);
129 current_col[component] += new_index - index;
130 }
131 }
132 }
133};
134
135} // namespace kynema_fmb::solver
Definition calculate_error_sum_squares.hpp:5
A Kernel for computing the system elements' contribution to the column indicies for the CRS matrix to...
Definition compute_system_col_inds.hpp:12
ConstView< size_t * > num_nodes_per_element
Definition compute_system_col_inds.hpp:24
KOKKOS_FUNCTION RowPtrValueType ComputeColIndsInConstraint(size_t constraint, RowPtrValueType index) const
Definition compute_system_col_inds.hpp:81
ConstView< size_t * > base_active_dofs
Definition compute_system_col_inds.hpp:26
ConstView< Kokkos::pair< size_t, size_t > * > row_range
Definition compute_system_col_inds.hpp:30
KOKKOS_FUNCTION bool BaseContainsNode(size_t constraint, size_t dof_index) const
Definition compute_system_col_inds.hpp:46
RowPtrType::const_type row_ptrs
Definition compute_system_col_inds.hpp:31
KOKKOS_FUNCTION bool TargetContainsNode(size_t constraint, size_t dof_index) const
Definition compute_system_col_inds.hpp:52
typename RowPtrType::device_type DeviceType
Definition compute_system_col_inds.hpp:15
ConstView< size_t *[6]> target_node_freedom_table
Definition compute_system_col_inds.hpp:29
typename View< ValueType >::const_type ConstView
Definition compute_system_col_inds.hpp:19
typename IndicesType::value_type IndicesValueType
Definition compute_system_col_inds.hpp:14
ConstView< size_t * > active_dofs
Definition compute_system_col_inds.hpp:22
ConstView< size_t * > target_active_dofs
Definition compute_system_col_inds.hpp:27
KOKKOS_FUNCTION bool ConstraintContainsNode(size_t constraint, size_t dof_index) const
Definition compute_system_col_inds.hpp:58
ConstView< size_t * > node_freedom_map_table
Definition compute_system_col_inds.hpp:23
ConstView< size_t *[6]> base_node_freedom_table
Definition compute_system_col_inds.hpp:28
Kokkos::View< ValueType, DeviceType > View
Definition compute_system_col_inds.hpp:17
IndicesType col_inds
Definition compute_system_col_inds.hpp:32
KOKKOS_FUNCTION bool ElementContainsNode(size_t element, size_t node) const
Definition compute_system_col_inds.hpp:35
KOKKOS_FUNCTION RowPtrValueType ComputeColIndsInElement(size_t element, size_t node, RowPtrValueType index) const
Definition compute_system_col_inds.hpp:63
typename RowPtrType::value_type RowPtrValueType
Definition compute_system_col_inds.hpp:13
size_t num_system_dofs
Definition compute_system_col_inds.hpp:21
KOKKOS_FUNCTION void operator()(size_t node) const
Definition compute_system_col_inds.hpp:92
ConstView< size_t ** > node_state_indices
Definition compute_system_col_inds.hpp:25