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

Kynema API: /home/runner/work/kynema/kynema/kynema/src/solver/create_full_matrix.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
create_full_matrix.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <KokkosSparse.hpp>
4#include <Kokkos_Core.hpp>
5#include <Kokkos_Profiling_ScopedRegion.hpp>
6
9
10namespace kynema::solver {
11
19template <typename CrsMatrixType>
21 using DeviceType = typename CrsMatrixType::device_type;
22 template <typename ValueType>
23 using View = Kokkos::View<ValueType, DeviceType>;
24 template <typename ValueType>
26
27 [[nodiscard]] static CrsMatrixType invoke(
28 size_t num_system_dofs, size_t num_dofs, const ConstView<size_t*>& base_active_dofs,
29 const ConstView<size_t*>& target_active_dofs,
30 const ConstView<size_t* [6]>& base_node_freedom_table,
31 const ConstView<size_t* [6]>& target_node_freedom_table,
32 const ConstView<Kokkos::pair<size_t, size_t>*>& row_range,
33 const ConstView<size_t*>& active_dofs, const ConstView<size_t*>& node_freedom_map_table,
34 const ConstView<size_t*>& num_nodes_per_element,
35 const ConstView<size_t**>& node_state_indices
36 ) {
37 auto region = Kokkos::Profiling::ScopedRegion("Create Full Matrix");
38
39 using ValuesType = typename CrsMatrixType::values_type::non_const_type;
40 using RowPtrType = typename CrsMatrixType::staticcrsgraph_type::row_map_type::non_const_type;
41 using IndicesType =
42 typename CrsMatrixType::staticcrsgraph_type::entries_type::non_const_type;
43
44 using RowPtrValueType = typename RowPtrType::value_type;
45 using IndicesValueType = typename IndicesType::value_type;
46
47 const auto row_ptrs = ComputeRowPtrs<RowPtrType>::invoke(
48 num_system_dofs, num_dofs, active_dofs, node_freedom_map_table, num_nodes_per_element,
49 node_state_indices, base_active_dofs, target_active_dofs, base_node_freedom_table,
50 target_node_freedom_table, row_range
51 );
52
53 auto num_non_zero = RowPtrValueType{};
54 Kokkos::deep_copy(num_non_zero, Kokkos::subview(row_ptrs, num_dofs));
55
57 num_non_zero, num_system_dofs, active_dofs, node_freedom_map_table,
58 num_nodes_per_element, node_state_indices, base_active_dofs, target_active_dofs,
59 base_node_freedom_table, target_node_freedom_table, row_range, row_ptrs
60 );
61
62 KokkosSparse::sort_crs_graph(row_ptrs, col_inds);
63
64 return CrsMatrixType(
65 "full_matrix", static_cast<IndicesValueType>(num_dofs),
66 static_cast<IndicesValueType>(num_dofs), num_non_zero,
68 Kokkos::view_alloc("values", Kokkos::WithoutInitializing),
69 static_cast<size_t>(num_non_zero)
70 ),
71 row_ptrs, col_inds
72 );
73 }
74};
75} // namespace kynema::solver
Definition calculate_error_sum_squares.hpp:5
static IndicesType invoke(typename RowPtrType::value_type num_non_zero, size_t num_system_dofs, const ConstView< size_t * > &active_dofs, const ConstView< size_t * > &node_freedom_map_table, const ConstView< size_t * > &num_nodes_per_element, const ConstView< size_t ** > &node_state_indices, const ConstView< size_t * > &base_active_dofs, const ConstView< size_t * > &target_active_dofs, const ConstView< size_t *[6]> &base_node_freedom_table, const ConstView< size_t *[6]> &target_node_freedom_table, const ConstView< Kokkos::pair< size_t, size_t > * > &row_range, const typename RowPtrType::const_type &row_ptrs)
Definition compute_col_inds.hpp:21
static RowPtrType invoke(size_t num_system_dofs, size_t num_dofs, const ConstView< size_t * > &active_dofs, const ConstView< size_t * > &node_freedom_map_table, const ConstView< size_t * > &num_nodes_per_element, const ConstView< size_t ** > &node_state_indices, const ConstView< size_t * > &base_active_dofs, const ConstView< size_t * > &target_active_dofs, const ConstView< size_t *[6]> &base_node_freedom_table, const ConstView< size_t *[6]> &target_node_freedom_table, const ConstView< Kokkos::pair< size_t, size_t > * > &row_range)
Definition compute_row_ptrs.hpp:23
The top level function object which creates the CRS matrix structure for the linear system to be solv...
Definition create_full_matrix.hpp:20
static CrsMatrixType invoke(size_t num_system_dofs, size_t num_dofs, const ConstView< size_t * > &base_active_dofs, const ConstView< size_t * > &target_active_dofs, const ConstView< size_t *[6]> &base_node_freedom_table, const ConstView< size_t *[6]> &target_node_freedom_table, const ConstView< Kokkos::pair< size_t, size_t > * > &row_range, const ConstView< size_t * > &active_dofs, const ConstView< size_t * > &node_freedom_map_table, const ConstView< size_t * > &num_nodes_per_element, const ConstView< size_t ** > &node_state_indices)
Definition create_full_matrix.hpp:27
Kokkos::View< ValueType, DeviceType > View
Definition create_full_matrix.hpp:23
typename View< ValueType >::const_type ConstView
Definition create_full_matrix.hpp:25
typename CrsMatrixType::device_type DeviceType
Definition create_full_matrix.hpp:21