source: CIVL/examples/mpi-omp/AMG2013/krylov/pcg.h

main
Last change on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 5.6 KB
Line 
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 * Preconditioned conjugate gradient (Omin) headers
19 *
20 *****************************************************************************/
21
22#ifndef HYPRE_KRYLOV_PCG_HEADER
23#define HYPRE_KRYLOV_PCG_HEADER
24
25/*--------------------------------------------------------------------------
26 *--------------------------------------------------------------------------*/
27
28/**
29 * @name Generic PCG Interface
30 *
31 * A general description of the interface goes here...
32 *
33 * @memo A generic PCG linear solver interface
34 * @version 0.1
35 * @author Jeffrey F. Painter
36 **/
37/*@{*/
38
39/*--------------------------------------------------------------------------
40 *--------------------------------------------------------------------------*/
41
42/*--------------------------------------------------------------------------
43 * hypre_PCGData and hypre_PCGFunctions
44 *--------------------------------------------------------------------------*/
45
46
47/**
48 * @name PCG structs
49 *
50 * Description...
51 **/
52/*@{*/
53
54/**
55 * The {\tt hypre\_PCGSFunctions} object ...
56 **/
57
58typedef struct
59{
60 char * (*CAlloc) ( int count, int elt_size );
61 int (*Free) ( char *ptr );
62 int (*CommInfo) ( void *A, int *my_id, int *num_procs );
63 void * (*CreateVector) ( void *vector );
64 int (*DestroyVector) ( void *vector );
65 void * (*MatvecCreate) ( void *A, void *x );
66 int (*Matvec) ( void *matvec_data, double alpha, void *A,
67 void *x, double beta, void *y );
68 int (*MatvecDestroy) ( void *matvec_data );
69 double (*InnerProd) ( void *x, void *y );
70 int (*CopyVector) ( void *x, void *y );
71 int (*ClearVector) ( void *x );
72 int (*ScaleVector) ( double alpha, void *x );
73 int (*Axpy) ( double alpha, void *x, void *y );
74
75 int (*precond)(void *vdata, void *A, void *b, void *x);
76 int (*precond_setup)(void *vdata, void *A, void *b, void *x);
77} hypre_PCGFunctions;
78
79/**
80 * The {\tt hypre\_PCGData} object ...
81 **/
82
83/*
84 Summary of Parameters to Control Stopping Test:
85 - Standard (default) error tolerance: |delta-residual|/|right-hand-side|<tol
86 where the norm is an energy norm wrt preconditioner, |r|=sqrt(<Cr,r>).
87 - two_norm!=0 means: the norm is the L2 norm, |r|=sqrt(<r,r>)
88 - rel_change!=0 means: if pass the other stopping criteria, also check the
89 relative change in the solution x.
90 - stop_crit!=0 means: pure absolute error tolerance rather than a pure relative
91 error tolerance on the residual. Never applies if rel_change!=0 or atolf!=0.
92 - atolf = absolute error tolerance factor to be used _together_ with the
93 relative error tolerance, |delta-residual| / ( atolf + |right-hand-side| ) < tol
94 - tol = relative error tolerance, as above
95 - cf_tol = convergence factor tolerance; if >0 used for special test
96 for slow convergence
97*/
98
99typedef struct
100{
101 double tol;
102 double atolf;
103 double cf_tol;
104 int max_iter;
105 int two_norm;
106 int rel_change;
107 int stop_crit;
108 int converged;
109
110 void *A;
111 void *p;
112 void *s;
113 void *r; /* ...contains the residual. This is currently kept permanently.
114 If that is ever changed, it still must be kept if logging>1 */
115
116 int owns_matvec_data; /* normally 1; if 0, don't delete it */
117 void *matvec_data;
118 void *precond_data;
119
120 hypre_PCGFunctions * functions;
121
122 /* log info (always logged) */
123 int num_iterations;
124 double rel_residual_norm;
125
126 int print_level; /* printing when print_level>0 */
127 int logging; /* extra computations for logging when logging>0 */
128 double *norms;
129 double *rel_norms;
130
131} hypre_PCGData;
132
133#define hypre_PCGDataOwnsMatvecData(pcgdata) ((pcgdata) -> owns_matvec_data)
134
135#ifdef __cplusplus
136extern "C" {
137#endif
138
139
140/**
141 * @name generic PCG Solver
142 *
143 * Description...
144 **/
145/*@{*/
146
147/**
148 * Description...
149 *
150 * @param param [IN] ...
151 **/
152
153hypre_PCGFunctions *
154hypre_PCGFunctionsCreate(
155 char * (*CAlloc) ( int count, int elt_size ),
156 int (*Free) ( char *ptr ),
157 int (*CommInfo) ( void *A, int *my_id, int *num_procs ),
158 void * (*CreateVector) ( void *vector ),
159 int (*DestroyVector) ( void *vector ),
160 void * (*MatvecCreate) ( void *A, void *x ),
161 int (*Matvec) ( void *matvec_data, double alpha, void *A,
162 void *x, double beta, void *y ),
163 int (*MatvecDestroy) ( void *matvec_data ),
164 double (*InnerProd) ( void *x, void *y ),
165 int (*CopyVector) ( void *x, void *y ),
166 int (*ClearVector) ( void *x ),
167 int (*ScaleVector) ( double alpha, void *x ),
168 int (*Axpy) ( double alpha, void *x, void *y ),
169 int (*PrecondSetup) ( void *vdata, void *A, void *b, void *x ),
170 int (*Precond) ( void *vdata, void *A, void *b, void *x )
171 );
172
173/**
174 * Description...
175 *
176 * @param param [IN] ...
177 **/
178
179void *
180hypre_PCGCreate( hypre_PCGFunctions *pcg_functions );
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif
Note: See TracBrowser for help on using the repository browser.