1 /* 2 * ----------------------------------------------------------------- 3 * Programmer(s): Daniel Reynolds @ SMU 4 * Based on codes sundials_superlumt_impl.h and <solver>_superlumt.h 5 * written by Carol S. Woodward @ LLNL 6 * ----------------------------------------------------------------- 7 * SUNDIALS Copyright Start 8 * Copyright (c) 2002-2019, Lawrence Livermore National Security 9 * and Southern Methodist University. 10 * All rights reserved. 11 * 12 * See the top-level LICENSE and NOTICE files for details. 13 * 14 * SPDX-License-Identifier: BSD-3-Clause 15 * SUNDIALS Copyright End 16 * ----------------------------------------------------------------- 17 * This is the header file for the SuperLUMT implementation of the 18 * SUNLINSOL module, SUNLINSOL_SUPERLUMT. 19 * 20 * Note: 21 * - The definition of the generic SUNLinearSolver structure can 22 * be found in the header file sundials_linearsolver.h. 23 * ----------------------------------------------------------------- 24 */ 25 26 #ifndef _SUNLINSOL_SLUMT_H 27 #define _SUNLINSOL_SLUMT_H 28 29 #include <sundials/sundials_linearsolver.h> 30 #include <sundials/sundials_matrix.h> 31 #include <sundials/sundials_nvector.h> 32 #include <sunmatrix/sunmatrix_sparse.h> 33 34 /* Assume SuperLU_MT library was built with compatible index type */ 35 #if defined(SUNDIALS_INT64_T) 36 #define _LONGINT 37 #endif 38 39 #ifdef __cplusplus /* wrapper to enable C++ usage */ 40 extern "C" { 41 #endif 42 43 /* Default SuperLU_MT solver parameters */ 44 #define SUNSLUMT_ORDERING_DEFAULT 3 /* COLAMD */ 45 46 /* Interfaces to match 'realtype' with the correct SuperLUMT functions */ 47 #if defined(SUNDIALS_DOUBLE_PRECISION) 48 #ifndef _SLUMT_H 49 #define _SLUMT_H 50 #include "slu_mt_ddefs.h" 51 #endif 52 #define xgstrs dgstrs 53 #define pxgstrf pdgstrf 54 #define pxgstrf_init pdgstrf_init 55 #define xCreate_Dense_Matrix dCreate_Dense_Matrix 56 #define xCreate_CompCol_Matrix dCreate_CompCol_Matrix 57 #elif defined(SUNDIALS_SINGLE_PRECISION) 58 #ifndef _SLUMT_H 59 #define _SLUMT_H 60 #include "slu_mt_sdefs.h" 61 #endif 62 #define xgstrs sgstrs 63 #define pxgstrf psgstrf 64 #define pxgstrf_init psgstrf_init 65 #define xCreate_Dense_Matrix sCreate_Dense_Matrix 66 #define xCreate_CompCol_Matrix sCreate_CompCol_Matrix 67 #else /* incompatible sunindextype for SuperLUMT */ 68 #error Incompatible realtype for SuperLUMT 69 #endif 70 71 72 /* -------------------------------------------- 73 * SuperLUMT Implementation of SUNLinearSolver 74 * -------------------------------------------- */ 75 76 struct _SUNLinearSolverContent_SuperLUMT { 77 long int last_flag; 78 int first_factorize; 79 SuperMatrix *A, *AC, *L, *U, *B; 80 Gstat_t *Gstat; 81 sunindextype *perm_r, *perm_c; 82 sunindextype N; 83 int num_threads; 84 realtype diag_pivot_thresh; 85 int ordering; 86 superlumt_options_t *options; 87 }; 88 89 typedef struct _SUNLinearSolverContent_SuperLUMT *SUNLinearSolverContent_SuperLUMT; 90 91 92 /* ------------------------------------------- 93 * Exported Functions for SUNLINSOL_SUPERLUMT 94 * ------------------------------------------- */ 95 96 SUNDIALS_EXPORT SUNLinearSolver SUNLinSol_SuperLUMT(N_Vector y, 97 SUNMatrix A, 98 int num_threads); 99 SUNDIALS_EXPORT int SUNLinSol_SuperLUMTSetOrdering(SUNLinearSolver S, 100 int ordering_choice); 101 102 /* deprecated */ 103 SUNDIALS_EXPORT SUNLinearSolver SUNSuperLUMT(N_Vector y, SUNMatrix A, 104 int num_threads); 105 /* deprecated */ 106 SUNDIALS_EXPORT int SUNSuperLUMTSetOrdering(SUNLinearSolver S, 107 int ordering_choice); 108 109 SUNDIALS_EXPORT SUNLinearSolver_Type SUNLinSolGetType_SuperLUMT(SUNLinearSolver S); 110 SUNDIALS_EXPORT int SUNLinSolInitialize_SuperLUMT(SUNLinearSolver S); 111 SUNDIALS_EXPORT int SUNLinSolSetup_SuperLUMT(SUNLinearSolver S, SUNMatrix A); 112 SUNDIALS_EXPORT int SUNLinSolSolve_SuperLUMT(SUNLinearSolver S, SUNMatrix A, 113 N_Vector x, N_Vector b, realtype tol); 114 SUNDIALS_EXPORT long int SUNLinSolLastFlag_SuperLUMT(SUNLinearSolver S); 115 SUNDIALS_EXPORT int SUNLinSolSpace_SuperLUMT(SUNLinearSolver S, 116 long int *lenrwLS, 117 long int *leniwLS); 118 SUNDIALS_EXPORT int SUNLinSolFree_SuperLUMT(SUNLinearSolver S); 119 120 121 #ifdef __cplusplus 122 } 123 #endif 124 125 #endif 126