1 /******************************************************************************
2  * Copyright 1998-2019 Lawrence Livermore National Security, LLC and other
3  * HYPRE Project Developers. See the top-level COPYRIGHT file for details.
4  *
5  * SPDX-License-Identifier: (Apache-2.0 OR MIT)
6  ******************************************************************************/
7 
8 /******************************************************************************
9  *
10  * HYPRE_LGMRES interface
11  *
12  *****************************************************************************/
13 #include "krylov.h"
14 
15 /*--------------------------------------------------------------------------
16  * HYPRE_LGMRESDestroy
17  *--------------------------------------------------------------------------*/
18 /* to do, not trivial */
19 /*
20 HYPRE_Int
21 HYPRE_ParCSRLGMRESDestroy( HYPRE_Solver solver )
22 {
23    return( hypre_LGMRESDestroy( (void *) solver ) );
24 }
25 */
26 
27 /*--------------------------------------------------------------------------
28  * HYPRE_LGMRESSetup
29  *--------------------------------------------------------------------------*/
30 
31 HYPRE_Int
HYPRE_LGMRESSetup(HYPRE_Solver solver,HYPRE_Matrix A,HYPRE_Vector b,HYPRE_Vector x)32 HYPRE_LGMRESSetup( HYPRE_Solver solver,
33                         HYPRE_Matrix A,
34                         HYPRE_Vector b,
35                         HYPRE_Vector x      )
36 {
37    return( hypre_LGMRESSetup( solver,
38                              A,
39                              b,
40                              x ) );
41 }
42 
43 /*--------------------------------------------------------------------------
44  * HYPRE_LGMRESSolve
45  *--------------------------------------------------------------------------*/
46 
47 HYPRE_Int
HYPRE_LGMRESSolve(HYPRE_Solver solver,HYPRE_Matrix A,HYPRE_Vector b,HYPRE_Vector x)48 HYPRE_LGMRESSolve( HYPRE_Solver solver,
49                         HYPRE_Matrix A,
50                         HYPRE_Vector b,
51                         HYPRE_Vector x      )
52 {
53    return( hypre_LGMRESSolve( solver,
54                              A,
55                              b,
56                              x ) );
57 }
58 
59 /*--------------------------------------------------------------------------
60  * HYPRE_LGMRESSetKDim, HYPRE_LGMRESGetKDim
61  *--------------------------------------------------------------------------*/
62 
63 HYPRE_Int
HYPRE_LGMRESSetKDim(HYPRE_Solver solver,HYPRE_Int k_dim)64 HYPRE_LGMRESSetKDim( HYPRE_Solver solver,
65                           HYPRE_Int             k_dim    )
66 {
67    return( hypre_LGMRESSetKDim( (void *) solver, k_dim ) );
68 }
69 
70 HYPRE_Int
HYPRE_LGMRESGetKDim(HYPRE_Solver solver,HYPRE_Int * k_dim)71 HYPRE_LGMRESGetKDim( HYPRE_Solver solver,
72                           HYPRE_Int           * k_dim    )
73 {
74    return( hypre_LGMRESGetKDim( (void *) solver, k_dim ) );
75 }
76 /*--------------------------------------------------------------------------
77  * HYPRE_LGMRESSetAugDim, HYPRE_LGMRESGetAugDim
78  *--------------------------------------------------------------------------*/
79 
80 HYPRE_Int
HYPRE_LGMRESSetAugDim(HYPRE_Solver solver,HYPRE_Int aug_dim)81 HYPRE_LGMRESSetAugDim( HYPRE_Solver solver,
82                           HYPRE_Int             aug_dim    )
83 {
84    return( hypre_LGMRESSetAugDim( (void *) solver, aug_dim ) );
85 }
86 
87 HYPRE_Int
HYPRE_LGMRESGetAugDim(HYPRE_Solver solver,HYPRE_Int * aug_dim)88 HYPRE_LGMRESGetAugDim( HYPRE_Solver solver,
89                           HYPRE_Int           * aug_dim    )
90 {
91    return( hypre_LGMRESGetAugDim( (void *) solver, aug_dim ) );
92 }
93 
94 /*--------------------------------------------------------------------------
95  * HYPRE_LGMRESSetTol, HYPRE_LGMRESGetTol
96  *--------------------------------------------------------------------------*/
97 
98 HYPRE_Int
HYPRE_LGMRESSetTol(HYPRE_Solver solver,HYPRE_Real tol)99 HYPRE_LGMRESSetTol( HYPRE_Solver solver,
100                          HYPRE_Real         tol    )
101 {
102    return( hypre_LGMRESSetTol( (void *) solver, tol ) );
103 }
104 
105 HYPRE_Int
HYPRE_LGMRESGetTol(HYPRE_Solver solver,HYPRE_Real * tol)106 HYPRE_LGMRESGetTol( HYPRE_Solver solver,
107                          HYPRE_Real       * tol    )
108 {
109    return( hypre_LGMRESGetTol( (void *) solver, tol ) );
110 }
111 /*--------------------------------------------------------------------------
112  * HYPRE_LGMRESSetAbsoluteTol, HYPRE_LGMRESGetAbsoluteTol
113  *--------------------------------------------------------------------------*/
114 
115 HYPRE_Int
HYPRE_LGMRESSetAbsoluteTol(HYPRE_Solver solver,HYPRE_Real a_tol)116 HYPRE_LGMRESSetAbsoluteTol( HYPRE_Solver solver,
117                          HYPRE_Real         a_tol    )
118 {
119    return( hypre_LGMRESSetAbsoluteTol( (void *) solver, a_tol ) );
120 }
121 
122 HYPRE_Int
HYPRE_LGMRESGetAbsoluteTol(HYPRE_Solver solver,HYPRE_Real * a_tol)123 HYPRE_LGMRESGetAbsoluteTol( HYPRE_Solver solver,
124                          HYPRE_Real       * a_tol    )
125 {
126    return( hypre_LGMRESGetAbsoluteTol( (void *) solver, a_tol ) );
127 }
128 
129 /*--------------------------------------------------------------------------
130  * HYPRE_LGMRESSetConvergenceFactorTol, HYPRE_LGMRESGetConvergenceFactorTol
131  *--------------------------------------------------------------------------*/
132 
133 HYPRE_Int
HYPRE_LGMRESSetConvergenceFactorTol(HYPRE_Solver solver,HYPRE_Real cf_tol)134 HYPRE_LGMRESSetConvergenceFactorTol( HYPRE_Solver solver,
135                          HYPRE_Real         cf_tol    )
136 {
137    return( hypre_LGMRESSetConvergenceFactorTol( (void *) solver, cf_tol ) );
138 }
139 
140 HYPRE_Int
HYPRE_LGMRESGetConvergenceFactorTol(HYPRE_Solver solver,HYPRE_Real * cf_tol)141 HYPRE_LGMRESGetConvergenceFactorTol( HYPRE_Solver solver,
142                          HYPRE_Real       * cf_tol    )
143 {
144    return( hypre_LGMRESGetConvergenceFactorTol( (void *) solver, cf_tol ) );
145 }
146 
147 /*--------------------------------------------------------------------------
148  * HYPRE_LGMRESSetMinIter, HYPRE_LGMRESGetMinIter
149  *--------------------------------------------------------------------------*/
150 
151 HYPRE_Int
HYPRE_LGMRESSetMinIter(HYPRE_Solver solver,HYPRE_Int min_iter)152 HYPRE_LGMRESSetMinIter( HYPRE_Solver solver,
153                              HYPRE_Int          min_iter )
154 {
155    return( hypre_LGMRESSetMinIter( (void *) solver, min_iter ) );
156 }
157 
158 HYPRE_Int
HYPRE_LGMRESGetMinIter(HYPRE_Solver solver,HYPRE_Int * min_iter)159 HYPRE_LGMRESGetMinIter( HYPRE_Solver solver,
160                              HYPRE_Int        * min_iter )
161 {
162    return( hypre_LGMRESGetMinIter( (void *) solver, min_iter ) );
163 }
164 
165 /*--------------------------------------------------------------------------
166  * HYPRE_LGMRESSetMaxIter, HYPRE_LGMRESGetMaxIter
167  *--------------------------------------------------------------------------*/
168 
169 HYPRE_Int
HYPRE_LGMRESSetMaxIter(HYPRE_Solver solver,HYPRE_Int max_iter)170 HYPRE_LGMRESSetMaxIter( HYPRE_Solver solver,
171                              HYPRE_Int          max_iter )
172 {
173    return( hypre_LGMRESSetMaxIter( (void *) solver, max_iter ) );
174 }
175 
176 HYPRE_Int
HYPRE_LGMRESGetMaxIter(HYPRE_Solver solver,HYPRE_Int * max_iter)177 HYPRE_LGMRESGetMaxIter( HYPRE_Solver solver,
178                              HYPRE_Int        * max_iter )
179 {
180    return( hypre_LGMRESGetMaxIter( (void *) solver, max_iter ) );
181 }
182 
183 
184 
185 /*--------------------------------------------------------------------------
186  * HYPRE_LGMRESSetPrecond
187  *--------------------------------------------------------------------------*/
188 
189 HYPRE_Int
HYPRE_LGMRESSetPrecond(HYPRE_Solver solver,HYPRE_PtrToSolverFcn precond,HYPRE_PtrToSolverFcn precond_setup,HYPRE_Solver precond_solver)190 HYPRE_LGMRESSetPrecond( HYPRE_Solver          solver,
191                              HYPRE_PtrToSolverFcn  precond,
192                              HYPRE_PtrToSolverFcn  precond_setup,
193                              HYPRE_Solver          precond_solver )
194 {
195    return( hypre_LGMRESSetPrecond( (void *) solver,
196 								   (HYPRE_Int (*)(void*, void*, void*, void*))precond,
197 								   (HYPRE_Int (*)(void*, void*, void*, void*))precond_setup,
198 								   (void *) precond_solver ) );
199 }
200 
201 /*--------------------------------------------------------------------------
202  * HYPRE_LGMRESGetPrecond
203  *--------------------------------------------------------------------------*/
204 
205 HYPRE_Int
HYPRE_LGMRESGetPrecond(HYPRE_Solver solver,HYPRE_Solver * precond_data_ptr)206 HYPRE_LGMRESGetPrecond( HYPRE_Solver  solver,
207                              HYPRE_Solver *precond_data_ptr )
208 {
209    return( hypre_LGMRESGetPrecond( (void *)     solver,
210                                   (HYPRE_Solver *) precond_data_ptr ) );
211 }
212 
213 /*--------------------------------------------------------------------------
214  * HYPRE_LGMRESSetPrintLevel, HYPRE_LGMRESGetPrintLevel
215  *--------------------------------------------------------------------------*/
216 
217 HYPRE_Int
HYPRE_LGMRESSetPrintLevel(HYPRE_Solver solver,HYPRE_Int level)218 HYPRE_LGMRESSetPrintLevel( HYPRE_Solver solver,
219                         HYPRE_Int          level )
220 {
221    return( hypre_LGMRESSetPrintLevel( (void *) solver, level ) );
222 }
223 
224 HYPRE_Int
HYPRE_LGMRESGetPrintLevel(HYPRE_Solver solver,HYPRE_Int * level)225 HYPRE_LGMRESGetPrintLevel( HYPRE_Solver solver,
226                         HYPRE_Int        * level )
227 {
228    return( hypre_LGMRESGetPrintLevel( (void *) solver, level ) );
229 }
230 
231 /*--------------------------------------------------------------------------
232  * HYPRE_LGMRESSetLogging, HYPRE_LGMRESGetLogging
233  *--------------------------------------------------------------------------*/
234 
235 HYPRE_Int
HYPRE_LGMRESSetLogging(HYPRE_Solver solver,HYPRE_Int level)236 HYPRE_LGMRESSetLogging( HYPRE_Solver solver,
237                      HYPRE_Int          level )
238 {
239    return( hypre_LGMRESSetLogging( (void *) solver, level ) );
240 }
241 
242 HYPRE_Int
HYPRE_LGMRESGetLogging(HYPRE_Solver solver,HYPRE_Int * level)243 HYPRE_LGMRESGetLogging( HYPRE_Solver solver,
244                      HYPRE_Int        * level )
245 {
246    return( hypre_LGMRESGetLogging( (void *) solver, level ) );
247 }
248 
249 /*--------------------------------------------------------------------------
250  * HYPRE_LGMRESGetNumIterations
251  *--------------------------------------------------------------------------*/
252 
253 HYPRE_Int
HYPRE_LGMRESGetNumIterations(HYPRE_Solver solver,HYPRE_Int * num_iterations)254 HYPRE_LGMRESGetNumIterations( HYPRE_Solver  solver,
255                                    HYPRE_Int                *num_iterations )
256 {
257    return( hypre_LGMRESGetNumIterations( (void *) solver, num_iterations ) );
258 }
259 
260 /*--------------------------------------------------------------------------
261  * HYPRE_LGMRESGetConverged
262  *--------------------------------------------------------------------------*/
263 
264 HYPRE_Int
HYPRE_LGMRESGetConverged(HYPRE_Solver solver,HYPRE_Int * converged)265 HYPRE_LGMRESGetConverged( HYPRE_Solver  solver,
266                          HYPRE_Int                *converged )
267 {
268    return( hypre_LGMRESGetConverged( (void *) solver, converged ) );
269 }
270 
271 /*--------------------------------------------------------------------------
272  * HYPRE_LGMRESGetFinalRelativeResidualNorm
273  *--------------------------------------------------------------------------*/
274 
275 HYPRE_Int
HYPRE_LGMRESGetFinalRelativeResidualNorm(HYPRE_Solver solver,HYPRE_Real * norm)276 HYPRE_LGMRESGetFinalRelativeResidualNorm( HYPRE_Solver  solver,
277                                                HYPRE_Real         *norm   )
278 {
279    return( hypre_LGMRESGetFinalRelativeResidualNorm( (void *) solver, norm ) );
280 }
281 
282 /*--------------------------------------------------------------------------
283  * HYPRE_LGMRESGetResidual
284  *--------------------------------------------------------------------------*/
285 
HYPRE_LGMRESGetResidual(HYPRE_Solver solver,void * residual)286 HYPRE_Int HYPRE_LGMRESGetResidual( HYPRE_Solver solver, void *residual )
287 {
288    /* returns a pointer to the residual vector */
289    return hypre_LGMRESGetResidual( (void *) solver, (void **) residual );
290 }
291 
292