/[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 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (11 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 4973 byte(s)
Don't panic.
Updating copyright stamps

1 artak 2160
2     /*******************************************************
3     *
4 jfenwick 2881 * Copyright (c) 2003-2010 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 artak 2820 /* Copyrights by ACcESS Australia 2009 */
22 jfenwick 2625 /* Author: artak@uq.edu.au */
23 artak 2160
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 2820 options.method=PASO_DEFAULT;
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 2820 options.method=PASO_DEFAULT;
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 2820 options.method=PASO_DEFAULT;
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 2820 options.method=PASO_DEFAULT;
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 2820 options.method=PASO_DEFAULT;
120 artak 2160 options.verbose=TRUE;
121     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with AMG\n");
122     options.preconditioner=PASO_AMG;
123 artak 2820 Paso_test_matrix(A,b,&options);
124    
125     Paso_Options_setDefaults(&options);
126     A->solver=NULL;
127     options.method=PASO_DEFAULT;
128     options.verbose=TRUE;
129     fprintf(stdout,"Test preconditioner: PASO_DEFAULT with AMLI\n");
130     options.preconditioner=PASO_AMLI;
131 artak 2160 Paso_test_matrix(A,b,&options);
132    
133     }
134     }
135    
136     void Paso_test_matrix(Paso_SystemMatrix* A, double* b, Paso_Options* options ) {
137    
138     dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
139     double *out=NULL;
140     out=MEMALLOC(n,double);
141    
142     if (Paso_checkPtr(out)) {
143     fprintf(stderr,"Cannot allocate memory\n");
144     return;
145     }
146     Paso_solve(A,out,b,options);
147    
148     MEMFREE(out);
149    
150     }
151    
152     void Paso_test_data(char *fileName_p, double* b, Paso_Options* options ) {
153    
154     Paso_SystemMatrix* A=NULL;
155     dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
156     double *out=MEMALLOC(n,double);
157     A=Paso_SystemMatrix_loadMM_toCSR(fileName_p);
158    
159     if (Paso_checkPtr(out)) {
160     return;
161     }
162    
163     Paso_solve(A,out,b,options);
164    
165     Paso_SystemMatrix_free(A);
166     MEMFREE(out);
167     }
168 artak 2275

  ViewVC Help
Powered by ViewVC 1.1.26