/[escript]/trunk/paso/profiling/Paso_tests.c
ViewVC logotype

Annotation of /trunk/paso/profiling/Paso_tests.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (hide annotations)
Mon Jul 20 06:20:06 2009 UTC (12 years, 4 months ago) by jfenwick
File MIME type: text/plain
File size: 4674 byte(s)
Updating copyright notices
1 artak 2160
2     /*******************************************************
3     *
4 jfenwick 2548 * Copyright (c) 2003-2009 by University of Queensland
5 artak 2160 * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13    
14    
15     /**************************************************************/
16    
17     /* Paso: interface to the direct solvers */
18    
19     /**************************************************************/
20    
21     /* Copyrights by ACcESS Australia 2003 */
22     /* Author: artak@access.edu.au */
23    
24     /**************************************************************/
25    
26     #include "paso/Paso.h"
27     #include "paso/Solver.h"
28     #include "paso/SystemMatrix.h"
29     #include "paso/Options.h"
30     #include "Paso_tests.h"
31    
32    
33     /**************************************************************/
34    
35     void Paso_test_run(Paso_SystemMatrix* A,double* b,dim_t level) {
36    
37     Paso_Options options;
38     Paso_Options_setDefaults(&options);
39    
40     if(level==1) /* Solvers only*/
41     {
42 artak 2382 Paso_Options_setDefaults(&options);
43 artak 2160 options.method=PASO_PCG;
44     options.verbose=TRUE;
45     options.preconditioner=PASO_JACOBI;
46     fprintf(stdout,"Test solver: PCG with JACOBI\n");
47     Paso_test_matrix(A,b,&options);
48    
49 artak 2275 fprintf(stdout,"Test solver: BICGSTAB with JACOBI\n");
50 artak 2382 Paso_Options_setDefaults(&options);
51 artak 2275 A->solver=NULL;
52 artak 2490 options.verbose=TRUE;
53 artak 2275 options.method=PASO_BICGSTAB;
54     Paso_test_matrix(A,b,&options);
55    
56 artak 2160 fprintf(stdout,"Test solver: GMRES with JACOBI\n");
57 artak 2382 Paso_Options_setDefaults(&options);
58 artak 2160 A->solver=NULL;
59 artak 2490 options.verbose=TRUE;
60 artak 2160 options.method=PASO_GMRES;
61     Paso_test_matrix(A,b,&options);
62    
63     fprintf(stdout,"Test solver: PRES20 with JACOBI\n");
64 artak 2382 Paso_Options_setDefaults(&options);
65 artak 2160 A->solver=NULL;
66 artak 2490 options.verbose=TRUE;
67 artak 2160 options.method=PASO_PRES20;
68     Paso_test_matrix(A,b,&options);
69    
70     fprintf(stdout,"Test solver: MINRES with JACOBI\n");
71 artak 2382 Paso_Options_setDefaults(&options);
72 artak 2160 A->solver=NULL;
73 artak 2490 options.verbose=TRUE;
74 artak 2160 options.method=PASO_MINRES;
75     Paso_test_matrix(A,b,&options);
76    
77     fprintf(stdout,"Test solver: TFQMR with JACOBI\n");
78 artak 2382 Paso_Options_setDefaults(&options);
79 artak 2160 A->solver=NULL;
80 artak 2490 options.verbose=TRUE;
81 artak 2160 options.method=PASO_TFQMR;
82     Paso_test_matrix(A,b,&options);
83     }
84     else if (level==2) /* Preconditiones only with default solver*/
85     {
86     Paso_Options_setDefaults(&options);
87 artak 2382 options.method=PASO_PCG;
88 artak 2160 options.verbose=TRUE;
89     options.preconditioner=PASO_JACOBI;
90     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with JACOBI\n");
91     Paso_test_matrix(A,b,&options);
92    
93     Paso_Options_setDefaults(&options);
94     A->solver=NULL;
95 artak 2382 options.method=PASO_PCG;
96 artak 2160 options.verbose=TRUE;
97     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with ILU\n");
98     options.preconditioner=PASO_ILU0;
99     Paso_test_matrix(A,b,&options);
100    
101     Paso_Options_setDefaults(&options);
102     A->solver=NULL;
103 artak 2382 options.method=PASO_PCG;
104 artak 2160 options.verbose=TRUE;
105     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with RILU\n");
106     options.preconditioner=PASO_RILU;
107     Paso_test_matrix(A,b,&options);
108    
109     Paso_Options_setDefaults(&options);
110     A->solver=NULL;
111 artak 2382 options.method=PASO_PCG;
112 artak 2160 options.verbose=TRUE;
113     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with GS\n");
114     options.preconditioner=PASO_GS;
115     Paso_test_matrix(A,b,&options);
116    
117     Paso_Options_setDefaults(&options);
118     A->solver=NULL;
119 artak 2382 options.method=PASO_PCG;
120 artak 2160 options.verbose=TRUE;
121     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with AMG\n");
122     options.preconditioner=PASO_AMG;
123     Paso_test_matrix(A,b,&options);
124    
125     }
126     }
127    
128     void Paso_test_matrix(Paso_SystemMatrix* A, double* b, Paso_Options* options ) {
129    
130     dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
131     double *out=NULL;
132     out=MEMALLOC(n,double);
133    
134     if (Paso_checkPtr(out)) {
135     fprintf(stderr,"Cannot allocate memory\n");
136     return;
137     }
138     Paso_solve(A,out,b,options);
139    
140     MEMFREE(out);
141    
142     }
143    
144     void Paso_test_data(char *fileName_p, double* b, Paso_Options* options ) {
145    
146     Paso_SystemMatrix* A=NULL;
147     dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
148     double *out=MEMALLOC(n,double);
149     A=Paso_SystemMatrix_loadMM_toCSR(fileName_p);
150    
151     if (Paso_checkPtr(out)) {
152     return;
153     }
154    
155     Paso_solve(A,out,b,options);
156    
157     Paso_SystemMatrix_free(A);
158     MEMFREE(out);
159     }
160 artak 2275

  ViewVC Help
Powered by ViewVC 1.1.26