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

Kynema API: /home/runner/work/kynema/kynema/kynema/src/solver/linear_solver/dss_numeric_superlu.hpp Source File
Kynema API
A flexible multibody structural dynamics code for wind turbines
Loading...
Searching...
No Matches
dss_numeric_superlu.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Kokkos_Core.hpp>
4
5#include "dss_algorithm.hpp"
7#include "slu_ddefs.h"
8
9namespace kynema::dss {
10template <typename CrsMatrixType>
11struct NumericFunction<Handle<Algorithm::SUPERLU>, CrsMatrixType> {
12 static void numeric(Handle<Algorithm::SUPERLU>& dss_handle, CrsMatrixType& A) {
13 auto num_rows = A.numRows();
14 auto num_cols = A.numCols();
15 auto num_non_zero = A.nnz();
16
17 auto values = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.values);
18 auto row_ptrs = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.row_map);
19 auto col_inds = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), A.graph.entries);
20
21 auto& options = dss_handle.get_options();
22 auto& stat = dss_handle.get_stat();
23 auto& L = dss_handle.get_L();
24 auto& U = dss_handle.get_U();
25 auto& Glu = dss_handle.get_Glu();
26 auto& perm_r = dss_handle.get_perm_r();
27 auto& perm_c = dss_handle.get_perm_c();
28 auto& etree = dss_handle.get_etree();
29
30 SuperMatrix Amatrix;
31 dCreate_CompCol_Matrix(
32 &Amatrix, num_rows, num_cols, num_non_zero, values.data(), col_inds.data(),
33 const_cast<int*>(row_ptrs.data()), SLU_NC, SLU_D, SLU_GE
34 );
35 constexpr auto relax = 1;
36 constexpr auto panel_size = 1;
37 auto info = 0;
38
39 SuperMatrix AC;
40 sp_preorder(&options, &Amatrix, perm_c.data(), etree.data(), &AC);
41 dgstrf(
42 &options, &AC, relax, panel_size, etree.data(), nullptr, 0, perm_c.data(), perm_r.data(),
43 &L, &U, &Glu, &stat, &info
44 );
45
46 Destroy_CompCol_Permuted(&AC);
47
48 options.Fact = SamePattern;
49 }
50};
51
52} // namespace kynema::dss
Definition dss_handle.hpp:10
Definition dss_algorithm.hpp:4
Algorithm
Definition dss_algorithm.hpp:6
static void numeric(Handle< Algorithm::SUPERLU > &dss_handle, CrsMatrixType &A)
Definition dss_numeric_superlu.hpp:12
Definition dss_numeric.hpp:8