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

Kynema API: /home/runner/work/kynema/kynema/kynema/src/solver/solver.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
solver.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include <KokkosSparse.hpp>
6#include <Kokkos_Core.hpp>
7
12
13#include "Kynema_config.h"
14
15namespace kynema {
16
20template <typename DeviceType>
21struct Solver {
22 // Define some types for the solver to make the code more readable
24#ifdef KOKKOS_ENABLE_CUDA
25 static constexpr bool use_device =
26 std::is_same<typename DeviceType::execution_space, Kokkos::Cuda>::value;
27#if defined(Kynema_ENABLE_CUDSS)
29#elif defined(Kynema_ENABLE_CUSOLVERSP)
31#else
33#endif
34#else
35 static constexpr bool use_device = false;
37#endif
38
39#if defined(Kynema_ENABLE_KLU)
41#elif defined(Kynema_ENABLE_SUPERLU)
43#elif defined(Kynema_ENABLE_MKL)
45#elif defined(Kynema_ENABLE_SUPERLU_MT)
47#elif defined(Kynema_ENABLE_UMFPACK)
49#else
51#endif
52
53 static constexpr dss::Algorithm algorithm =
55
56 static_assert(algorithm != dss::Algorithm::NONE);
57
59#if defined(Kynema_ENABLE_MKL)
60 using IndexType = std::conditional<algorithm == dss::Algorithm::MKL, MKL_INT, int>::type;
61#else
62 using IndexType = int;
63#endif
64
65 using CrsMatrixType = KokkosSparse::CrsMatrix<ValueType, IndexType, DeviceType, void, IndexType>;
66 using MultiVectorType = Kokkos::View<ValueType* [1], Kokkos::LayoutLeft, DeviceType>;
67
68 template <typename value_type>
69 using View = Kokkos::View<value_type, DeviceType>;
70 template <typename value_type>
72
73 size_t num_system_nodes; //< Number of system nodes
74 size_t num_system_dofs; //< Number of system degrees of freedom
75 size_t num_dofs; //< Number of degrees of freedom
76
77 CrsMatrixType A; //< System matrix
78 MultiVectorType b; //< System RHS
79 MultiVectorType x; //< System solution
80
81 HandleType handle; //< Handle for internal information needed for the selected linear solver
82
83 std::vector<double> convergence_err; //< The convergence history of the solver
84
102 const ConstView<size_t*>& node_IDs, const ConstView<size_t*>& active_dofs,
103 const ConstView<size_t*>& node_freedom_map_table,
104 const ConstView<size_t*>& num_nodes_per_element,
105 const ConstView<size_t**>& node_state_indices, size_t num_constraint_dofs,
106 const ConstView<size_t*>& base_active_dofs, const ConstView<size_t*>& target_active_dofs,
109 const ConstView<Kokkos::pair<size_t, size_t>*>& constraint_row_range
110 )
112 num_system_dofs(solver::ComputeNumSystemDofs<DeviceType>(active_dofs)),
114 A(solver::CreateFullMatrix<CrsMatrixType>::invoke(
115 num_system_dofs, num_dofs, base_active_dofs, target_active_dofs,
117 constraint_row_range, active_dofs, node_freedom_map_table, num_nodes_per_element,
118 node_state_indices
119 )),
123 }
124};
125
126} // namespace kynema
Algorithm
Definition dss_algorithm.hpp:6
void symbolic_factorization(DSSHandleType &dss_handle, CrsMatrixType &A)
Definition dss_symbolic.hpp:45
Definition calculate_constraint_output.hpp:8
This object manages the assembly and solution of linear system arising from the generalized-alpha bas...
Definition solver.hpp:21
size_t num_system_nodes
Definition solver.hpp:73
Kokkos::View< ValueType *[1], Kokkos::LayoutLeft, DeviceType > MultiVectorType
Definition solver.hpp:66
MultiVectorType x
Definition solver.hpp:79
double ValueType
Definition solver.hpp:23
MultiVectorType b
Definition solver.hpp:78
int IndexType
Definition solver.hpp:62
Solver(const ConstView< size_t * > &node_IDs, 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, size_t num_constraint_dofs, const ConstView< size_t * > &base_active_dofs, const ConstView< size_t * > &target_active_dofs, const ConstView< size_t *[6]> &constraint_base_node_freedom_table, const ConstView< size_t *[6]> &constraint_target_node_freedom_table, const ConstView< Kokkos::pair< size_t, size_t > * > &constraint_row_range)
Constructs the sparse matrix structure for the provided connectivity information and performs the spa...
Definition solver.hpp:101
static constexpr dss::Algorithm algorithm_host
Definition solver.hpp:50
std::vector< double > convergence_err
Definition solver.hpp:83
static constexpr dss::Algorithm algorithm_device
Definition solver.hpp:36
CrsMatrixType A
Definition solver.hpp:77
static constexpr bool use_device
Definition solver.hpp:35
size_t num_dofs
Definition solver.hpp:75
static constexpr dss::Algorithm algorithm
Definition solver.hpp:53
HandleType handle
Definition solver.hpp:81
size_t num_system_dofs
Definition solver.hpp:74
typename View< value_type >::const_type ConstView
Definition solver.hpp:71
Kokkos::View< value_type, DeviceType > View
Definition solver.hpp:69
KokkosSparse::CrsMatrix< ValueType, IndexType, DeviceType, void, IndexType > CrsMatrixType
Definition solver.hpp:65