diff options
Diffstat (limited to 'packages/sundials/src/Arkode.hsc')
-rw-r--r-- | packages/sundials/src/Arkode.hsc | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/packages/sundials/src/Arkode.hsc b/packages/sundials/src/Arkode.hsc new file mode 100644 index 0000000..9db37b5 --- /dev/null +++ b/packages/sundials/src/Arkode.hsc | |||
@@ -0,0 +1,114 @@ | |||
1 | module Arkode where | ||
2 | |||
3 | import Foreign | ||
4 | import Foreign.C.Types | ||
5 | |||
6 | |||
7 | #include <stdio.h> | ||
8 | #include <sundials/sundials_nvector.h> | ||
9 | #include <sundials/sundials_matrix.h> | ||
10 | #include <nvector/nvector_serial.h> | ||
11 | #include <sunmatrix/sunmatrix_dense.h> | ||
12 | #include <arkode/arkode.h> | ||
13 | |||
14 | |||
15 | #def typedef struct _generic_N_Vector SunVector; | ||
16 | #def typedef struct _N_VectorContent_Serial SunContent; | ||
17 | |||
18 | #def typedef struct _generic_SUNMatrix SunMatrix; | ||
19 | #def typedef struct _SUNMatrixContent_Dense SunMatrixContent; | ||
20 | |||
21 | getContentMatrixPtr :: Storable a => Ptr b -> IO a | ||
22 | getContentMatrixPtr ptr = (#peek SunMatrix, content) ptr | ||
23 | |||
24 | getNRows :: Ptr b -> IO CInt | ||
25 | getNRows ptr = (#peek SunMatrixContent, M) ptr | ||
26 | putNRows :: CInt -> Ptr b -> IO () | ||
27 | putNRows nr ptr = (#poke SunMatrixContent, M) ptr nr | ||
28 | |||
29 | getNCols :: Ptr b -> IO CInt | ||
30 | getNCols ptr = (#peek SunMatrixContent, N) ptr | ||
31 | putNCols :: CInt -> Ptr b -> IO () | ||
32 | putNCols nc ptr = (#poke SunMatrixContent, N) ptr nc | ||
33 | |||
34 | getMatrixData :: Storable a => Ptr b -> IO a | ||
35 | getMatrixData ptr = (#peek SunMatrixContent, data) ptr | ||
36 | |||
37 | getContentPtr :: Storable a => Ptr b -> IO a | ||
38 | getContentPtr ptr = (#peek SunVector, content) ptr | ||
39 | |||
40 | getData :: Storable a => Ptr b -> IO a | ||
41 | getData ptr = (#peek SunContent, data) ptr | ||
42 | |||
43 | arkSMax :: Int | ||
44 | arkSMax = #const ARK_S_MAX | ||
45 | |||
46 | mIN_DIRK_NUM, mAX_DIRK_NUM :: Int | ||
47 | mIN_DIRK_NUM = #const MIN_DIRK_NUM | ||
48 | mAX_DIRK_NUM = #const MAX_DIRK_NUM | ||
49 | |||
50 | -- FIXME: We could just use inline-c instead | ||
51 | |||
52 | -- Butcher table accessors -- implicit | ||
53 | sDIRK_2_1_2 :: Int | ||
54 | sDIRK_2_1_2 = #const SDIRK_2_1_2 | ||
55 | bILLINGTON_3_3_2 :: Int | ||
56 | bILLINGTON_3_3_2 = #const BILLINGTON_3_3_2 | ||
57 | tRBDF2_3_3_2 :: Int | ||
58 | tRBDF2_3_3_2 = #const TRBDF2_3_3_2 | ||
59 | kVAERNO_4_2_3 :: Int | ||
60 | kVAERNO_4_2_3 = #const KVAERNO_4_2_3 | ||
61 | aRK324L2SA_DIRK_4_2_3 :: Int | ||
62 | aRK324L2SA_DIRK_4_2_3 = #const ARK324L2SA_DIRK_4_2_3 | ||
63 | cASH_5_2_4 :: Int | ||
64 | cASH_5_2_4 = #const CASH_5_2_4 | ||
65 | cASH_5_3_4 :: Int | ||
66 | cASH_5_3_4 = #const CASH_5_3_4 | ||
67 | sDIRK_5_3_4 :: Int | ||
68 | sDIRK_5_3_4 = #const SDIRK_5_3_4 | ||
69 | kVAERNO_5_3_4 :: Int | ||
70 | kVAERNO_5_3_4 = #const KVAERNO_5_3_4 | ||
71 | aRK436L2SA_DIRK_6_3_4 :: Int | ||
72 | aRK436L2SA_DIRK_6_3_4 = #const ARK436L2SA_DIRK_6_3_4 | ||
73 | kVAERNO_7_4_5 :: Int | ||
74 | kVAERNO_7_4_5 = #const KVAERNO_7_4_5 | ||
75 | aRK548L2SA_DIRK_8_4_5 :: Int | ||
76 | aRK548L2SA_DIRK_8_4_5 = #const ARK548L2SA_DIRK_8_4_5 | ||
77 | |||
78 | -- #define DEFAULT_DIRK_2 SDIRK_2_1_2 | ||
79 | -- #define DEFAULT_DIRK_3 ARK324L2SA_DIRK_4_2_3 | ||
80 | -- #define DEFAULT_DIRK_4 SDIRK_5_3_4 | ||
81 | -- #define DEFAULT_DIRK_5 ARK548L2SA_DIRK_8_4_5 | ||
82 | |||
83 | -- Butcher table accessors -- explicit | ||
84 | hEUN_EULER_2_1_2 :: Int | ||
85 | hEUN_EULER_2_1_2 = #const HEUN_EULER_2_1_2 | ||
86 | bOGACKI_SHAMPINE_4_2_3 :: Int | ||
87 | bOGACKI_SHAMPINE_4_2_3 = #const BOGACKI_SHAMPINE_4_2_3 | ||
88 | aRK324L2SA_ERK_4_2_3 :: Int | ||
89 | aRK324L2SA_ERK_4_2_3 = #const ARK324L2SA_ERK_4_2_3 | ||
90 | zONNEVELD_5_3_4 :: Int | ||
91 | zONNEVELD_5_3_4 = #const ZONNEVELD_5_3_4 | ||
92 | aRK436L2SA_ERK_6_3_4 :: Int | ||
93 | aRK436L2SA_ERK_6_3_4 = #const ARK436L2SA_ERK_6_3_4 | ||
94 | sAYFY_ABURUB_6_3_4 :: Int | ||
95 | sAYFY_ABURUB_6_3_4 = #const SAYFY_ABURUB_6_3_4 | ||
96 | cASH_KARP_6_4_5 :: Int | ||
97 | cASH_KARP_6_4_5 = #const CASH_KARP_6_4_5 | ||
98 | fEHLBERG_6_4_5 :: Int | ||
99 | fEHLBERG_6_4_5 = #const FEHLBERG_6_4_5 | ||
100 | dORMAND_PRINCE_7_4_5 :: Int | ||
101 | dORMAND_PRINCE_7_4_5 = #const DORMAND_PRINCE_7_4_5 | ||
102 | aRK548L2SA_ERK_8_4_5 :: Int | ||
103 | aRK548L2SA_ERK_8_4_5 = #const ARK548L2SA_ERK_8_4_5 | ||
104 | vERNER_8_5_6 :: Int | ||
105 | vERNER_8_5_6 = #const VERNER_8_5_6 | ||
106 | fEHLBERG_13_7_8 :: Int | ||
107 | fEHLBERG_13_7_8 = #const FEHLBERG_13_7_8 | ||
108 | |||
109 | -- #define DEFAULT_ERK_2 HEUN_EULER_2_1_2 | ||
110 | -- #define DEFAULT_ERK_3 BOGACKI_SHAMPINE_4_2_3 | ||
111 | -- #define DEFAULT_ERK_4 ZONNEVELD_5_3_4 | ||
112 | -- #define DEFAULT_ERK_5 CASH_KARP_6_4_5 | ||
113 | -- #define DEFAULT_ERK_6 VERNER_8_5_6 | ||
114 | -- #define DEFAULT_ERK_8 FEHLBERG_13_7_8 | ||