| [2aa6644] | 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | /******************************************************************************
|
|---|
| 17 | *
|
|---|
| 18 | * HYPRE_PCG interface
|
|---|
| 19 | *
|
|---|
| 20 | *****************************************************************************/
|
|---|
| 21 | #include "krylov.h"
|
|---|
| 22 |
|
|---|
| 23 | /*--------------------------------------------------------------------------
|
|---|
| 24 | * HYPRE_PCGCreate does not exist. Call the appropriate function which
|
|---|
| 25 | * also specifies the vector type, e.g. HYPRE_ParCSRPCGCreate
|
|---|
| 26 | *--------------------------------------------------------------------------*/
|
|---|
| 27 |
|
|---|
| 28 | /*--------------------------------------------------------------------------
|
|---|
| 29 | * HYPRE_PCGDestroy
|
|---|
| 30 | *--------------------------------------------------------------------------*/
|
|---|
| 31 |
|
|---|
| 32 | /*
|
|---|
| 33 | int
|
|---|
| 34 | HYPRE_PCGDestroy( HYPRE_Solver solver )*/
|
|---|
| 35 | /* >>> This is something we can't do without knowing the vector_type.
|
|---|
| 36 | We can't save it in and pull it out of solver because that isn't
|
|---|
| 37 | really a known struct. */
|
|---|
| 38 | /*
|
|---|
| 39 | {
|
|---|
| 40 | if ( vector_type=="ParCSR" ) {
|
|---|
| 41 | return HYPRE_ParCSRPCGDestroy( HYPRE_Solver solver );
|
|---|
| 42 | }
|
|---|
| 43 | else {
|
|---|
| 44 | return 0;
|
|---|
| 45 | }
|
|---|
| 46 | }*/
|
|---|
| 47 |
|
|---|
| 48 | /*--------------------------------------------------------------------------
|
|---|
| 49 | * HYPRE_PCGSetup
|
|---|
| 50 | *--------------------------------------------------------------------------*/
|
|---|
| 51 |
|
|---|
| 52 | int
|
|---|
| 53 | HYPRE_PCGSetup( HYPRE_Solver solver,
|
|---|
| 54 | HYPRE_Matrix A,
|
|---|
| 55 | HYPRE_Vector b,
|
|---|
| 56 | HYPRE_Vector x )
|
|---|
| 57 | {
|
|---|
| 58 | return( hypre_PCGSetup( solver,
|
|---|
| 59 | A,
|
|---|
| 60 | b,
|
|---|
| 61 | x ) );
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | /*--------------------------------------------------------------------------
|
|---|
| 65 | * HYPRE_PCGSolve
|
|---|
| 66 | *--------------------------------------------------------------------------*/
|
|---|
| 67 |
|
|---|
| 68 | int
|
|---|
| 69 | HYPRE_PCGSolve( HYPRE_Solver solver,
|
|---|
| 70 | HYPRE_Matrix A,
|
|---|
| 71 | HYPRE_Vector b,
|
|---|
| 72 | HYPRE_Vector x )
|
|---|
| 73 | {
|
|---|
| 74 | return( hypre_PCGSolve( (void *) solver,
|
|---|
| 75 | (void *) A,
|
|---|
| 76 | (void *) b,
|
|---|
| 77 | (void *) x ) );
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | /*--------------------------------------------------------------------------
|
|---|
| 81 | * HYPRE_PCGSetTol, HYPRE_PCGGetTol
|
|---|
| 82 | *--------------------------------------------------------------------------*/
|
|---|
| 83 |
|
|---|
| 84 | int
|
|---|
| 85 | HYPRE_PCGSetTol( HYPRE_Solver solver,
|
|---|
| 86 | double tol )
|
|---|
| 87 | {
|
|---|
| 88 | return( hypre_PCGSetTol( (void *) solver, tol ) );
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | int
|
|---|
| 92 | HYPRE_PCGGetTol( HYPRE_Solver solver,
|
|---|
| 93 | double * tol )
|
|---|
| 94 | {
|
|---|
| 95 | return( hypre_PCGGetTol( (void *) solver, tol ) );
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | /*--------------------------------------------------------------------------
|
|---|
| 99 | * HYPRE_PCGSetAbsoluteTolFactor, HYPRE_PCGGetAbsoluteTolFactor
|
|---|
| 100 | *--------------------------------------------------------------------------*/
|
|---|
| 101 |
|
|---|
| 102 | int
|
|---|
| 103 | HYPRE_PCGSetAbsoluteTolFactor( HYPRE_Solver solver,
|
|---|
| 104 | double abstolf )
|
|---|
| 105 | {
|
|---|
| 106 | return( hypre_PCGSetAbsoluteTolFactor( (void *) solver, abstolf ) );
|
|---|
| 107 | }
|
|---|
| 108 |
|
|---|
| 109 | int
|
|---|
| 110 | HYPRE_PCGGetAbsoluteTolFactor( HYPRE_Solver solver,
|
|---|
| 111 | double * abstolf )
|
|---|
| 112 | {
|
|---|
| 113 | return( hypre_PCGGetAbsoluteTolFactor( (void *) solver, abstolf ) );
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | /*--------------------------------------------------------------------------
|
|---|
| 117 | * HYPRE_PCGSetConvergenceFactorTol, HYPRE_PCGGetConvergenceFactorTol
|
|---|
| 118 | *--------------------------------------------------------------------------*/
|
|---|
| 119 |
|
|---|
| 120 | int
|
|---|
| 121 | HYPRE_PCGSetConvergenceFactorTol( HYPRE_Solver solver,
|
|---|
| 122 | double cf_tol )
|
|---|
| 123 | {
|
|---|
| 124 | return hypre_PCGSetConvergenceFactorTol( (void *) solver,
|
|---|
| 125 | cf_tol );
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | int
|
|---|
| 129 | HYPRE_PCGGetConvergenceFactorTol( HYPRE_Solver solver,
|
|---|
| 130 | double * cf_tol )
|
|---|
| 131 | {
|
|---|
| 132 | return hypre_PCGGetConvergenceFactorTol( (void *) solver,
|
|---|
| 133 | cf_tol );
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | /*--------------------------------------------------------------------------
|
|---|
| 137 | * HYPRE_PCGSetMaxIter, HYPRE_PCGGetMaxIter
|
|---|
| 138 | *--------------------------------------------------------------------------*/
|
|---|
| 139 |
|
|---|
| 140 | int
|
|---|
| 141 | HYPRE_PCGSetMaxIter( HYPRE_Solver solver,
|
|---|
| 142 | int max_iter )
|
|---|
| 143 | {
|
|---|
| 144 | return( hypre_PCGSetMaxIter( (void *) solver, max_iter ) );
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | int
|
|---|
| 148 | HYPRE_PCGGetMaxIter( HYPRE_Solver solver,
|
|---|
| 149 | int * max_iter )
|
|---|
| 150 | {
|
|---|
| 151 | return( hypre_PCGGetMaxIter( (void *) solver, max_iter ) );
|
|---|
| 152 | }
|
|---|
| 153 |
|
|---|
| 154 | /*--------------------------------------------------------------------------
|
|---|
| 155 | * HYPRE_PCGSetStopCrit, HYPRE_PCGGetStopCrit
|
|---|
| 156 | *--------------------------------------------------------------------------*/
|
|---|
| 157 |
|
|---|
| 158 | int
|
|---|
| 159 | HYPRE_PCGSetStopCrit( HYPRE_Solver solver,
|
|---|
| 160 | int stop_crit )
|
|---|
| 161 | {
|
|---|
| 162 | return( hypre_PCGSetStopCrit( (void *) solver, stop_crit ) );
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | int
|
|---|
| 166 | HYPRE_PCGGetStopCrit( HYPRE_Solver solver,
|
|---|
| 167 | int * stop_crit )
|
|---|
| 168 | {
|
|---|
| 169 | return( hypre_PCGGetStopCrit( (void *) solver, stop_crit ) );
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | /*--------------------------------------------------------------------------
|
|---|
| 173 | * HYPRE_PCGSetTwoNorm, HYPRE_PCGGetTwoNorm
|
|---|
| 174 | *--------------------------------------------------------------------------*/
|
|---|
| 175 |
|
|---|
| 176 | int
|
|---|
| 177 | HYPRE_PCGSetTwoNorm( HYPRE_Solver solver,
|
|---|
| 178 | int two_norm )
|
|---|
| 179 | {
|
|---|
| 180 | return( hypre_PCGSetTwoNorm( (void *) solver, two_norm ) );
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | int
|
|---|
| 184 | HYPRE_PCGGetTwoNorm( HYPRE_Solver solver,
|
|---|
| 185 | int * two_norm )
|
|---|
| 186 | {
|
|---|
| 187 | return( hypre_PCGGetTwoNorm( (void *) solver, two_norm ) );
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | /*--------------------------------------------------------------------------
|
|---|
| 191 | * HYPRE_PCGSetRelChange, HYPRE_PCGGetRelChange
|
|---|
| 192 | *--------------------------------------------------------------------------*/
|
|---|
| 193 |
|
|---|
| 194 | int
|
|---|
| 195 | HYPRE_PCGSetRelChange( HYPRE_Solver solver,
|
|---|
| 196 | int rel_change )
|
|---|
| 197 | {
|
|---|
| 198 | return( hypre_PCGSetRelChange( (void *) solver, rel_change ) );
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | int
|
|---|
| 202 | HYPRE_PCGGetRelChange( HYPRE_Solver solver,
|
|---|
| 203 | int * rel_change )
|
|---|
| 204 | {
|
|---|
| 205 | return( hypre_PCGGetRelChange( (void *) solver, rel_change ) );
|
|---|
| 206 | }
|
|---|
| 207 |
|
|---|
| 208 | /*--------------------------------------------------------------------------
|
|---|
| 209 | * HYPRE_PCGSetPrecond
|
|---|
| 210 | *--------------------------------------------------------------------------*/
|
|---|
| 211 |
|
|---|
| 212 | int
|
|---|
| 213 | HYPRE_PCGSetPrecond( HYPRE_Solver solver,
|
|---|
| 214 | HYPRE_PtrToSolverFcn precond,
|
|---|
| 215 | HYPRE_PtrToSolverFcn precond_setup,
|
|---|
| 216 | HYPRE_Solver precond_solver )
|
|---|
| 217 | {
|
|---|
| 218 | return( hypre_PCGSetPrecond( (void *) solver,
|
|---|
| [f02928c9] | 219 | (int (*)(void *, void *, void *, void *))precond, (int (*)(void *, void *, void *, void *))precond_setup,
|
|---|
| [2aa6644] | 220 | (void *) precond_solver ) );
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | /*--------------------------------------------------------------------------
|
|---|
| 224 | * HYPRE_PCGGetPrecond
|
|---|
| 225 | *--------------------------------------------------------------------------*/
|
|---|
| 226 |
|
|---|
| 227 | int
|
|---|
| 228 | HYPRE_PCGGetPrecond( HYPRE_Solver solver,
|
|---|
| 229 | HYPRE_Solver *precond_data_ptr )
|
|---|
| 230 | {
|
|---|
| 231 | return( hypre_PCGGetPrecond( (void *) solver,
|
|---|
| 232 | (HYPRE_Solver *) precond_data_ptr ) );
|
|---|
| 233 | }
|
|---|
| 234 |
|
|---|
| 235 | /*--------------------------------------------------------------------------
|
|---|
| 236 | * HYPRE_PCGSetLogging, HYPRE_PCGGetLogging
|
|---|
| 237 | * SetLogging sets both the print and log level, for backwards compatibility.
|
|---|
| 238 | * Soon the SetPrintLevel call should be deleted.
|
|---|
| 239 | *--------------------------------------------------------------------------*/
|
|---|
| 240 |
|
|---|
| 241 | int
|
|---|
| 242 | HYPRE_PCGSetLogging( HYPRE_Solver solver,
|
|---|
| 243 | int level )
|
|---|
| 244 | {
|
|---|
| 245 | return ( hypre_PCGSetLogging( (void *) solver, level ) );
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | int
|
|---|
| 249 | HYPRE_PCGGetLogging( HYPRE_Solver solver,
|
|---|
| 250 | int * level )
|
|---|
| 251 | {
|
|---|
| 252 | return ( hypre_PCGGetLogging( (void *) solver, level ) );
|
|---|
| 253 | }
|
|---|
| 254 |
|
|---|
| 255 | /*--------------------------------------------------------------------------
|
|---|
| 256 | * HYPRE_PCGSetPrintLevel, HYPRE_PCGGetPrintLevel
|
|---|
| 257 | *--------------------------------------------------------------------------*/
|
|---|
| 258 |
|
|---|
| 259 | int
|
|---|
| 260 | HYPRE_PCGSetPrintLevel( HYPRE_Solver solver,
|
|---|
| 261 | int level )
|
|---|
| 262 | {
|
|---|
| 263 | return( hypre_PCGSetPrintLevel( (void *) solver, level ) );
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | int
|
|---|
| 267 | HYPRE_PCGGetPrintLevel( HYPRE_Solver solver,
|
|---|
| 268 | int * level )
|
|---|
| 269 | {
|
|---|
| 270 | return( hypre_PCGGetPrintLevel( (void *) solver, level ) );
|
|---|
| 271 | }
|
|---|
| 272 |
|
|---|
| 273 | /*--------------------------------------------------------------------------
|
|---|
| 274 | * HYPRE_PCGGetNumIterations
|
|---|
| 275 | *--------------------------------------------------------------------------*/
|
|---|
| 276 |
|
|---|
| 277 | int
|
|---|
| 278 | HYPRE_PCGGetNumIterations( HYPRE_Solver solver,
|
|---|
| 279 | int *num_iterations )
|
|---|
| 280 | {
|
|---|
| 281 | return( hypre_PCGGetNumIterations( (void *) solver, num_iterations ) );
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | /*--------------------------------------------------------------------------
|
|---|
| 285 | * HYPRE_PCGGetConverged
|
|---|
| 286 | *--------------------------------------------------------------------------*/
|
|---|
| 287 |
|
|---|
| 288 | int
|
|---|
| 289 | HYPRE_PCGGetConverged( HYPRE_Solver solver,
|
|---|
| 290 | int *converged )
|
|---|
| 291 | {
|
|---|
| 292 | return( hypre_PCGGetConverged( (void *) solver, converged ) );
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | /*--------------------------------------------------------------------------
|
|---|
| 296 | * HYPRE_PCGGetFinalRelativeResidualNorm
|
|---|
| 297 | *--------------------------------------------------------------------------*/
|
|---|
| 298 |
|
|---|
| 299 | int
|
|---|
| 300 | HYPRE_PCGGetFinalRelativeResidualNorm( HYPRE_Solver solver,
|
|---|
| 301 | double *norm )
|
|---|
| 302 | {
|
|---|
| 303 | return( hypre_PCGGetFinalRelativeResidualNorm( (void *) solver, norm ) );
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | /*--------------------------------------------------------------------------
|
|---|
| 307 | * HYPRE_PCGGetResidual
|
|---|
| 308 | *--------------------------------------------------------------------------*/
|
|---|
| 309 |
|
|---|
| 310 | int HYPRE_PCGGetResidual( HYPRE_Solver solver, void **residual )
|
|---|
| 311 | {
|
|---|
| 312 | /* returns a pointer to the residual vector */
|
|---|
| 313 | return hypre_PCGGetResidual( (void *) solver, residual );
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|