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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (show annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 4973 byte(s)
Don't panic.
Updating copyright stamps

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * 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 2009 */
22 /* Author: artak@uq.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 Paso_Options_setDefaults(&options);
43 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 fprintf(stdout,"Test solver: BICGSTAB with JACOBI\n");
50 Paso_Options_setDefaults(&options);
51 A->solver=NULL;
52 options.verbose=TRUE;
53 options.method=PASO_BICGSTAB;
54 Paso_test_matrix(A,b,&options);
55
56 fprintf(stdout,"Test solver: GMRES with JACOBI\n");
57 Paso_Options_setDefaults(&options);
58 A->solver=NULL;
59 options.verbose=TRUE;
60 options.method=PASO_GMRES;
61 Paso_test_matrix(A,b,&options);
62
63 fprintf(stdout,"Test solver: PRES20 with JACOBI\n");
64 Paso_Options_setDefaults(&options);
65 A->solver=NULL;
66 options.verbose=TRUE;
67 options.method=PASO_PRES20;
68 Paso_test_matrix(A,b,&options);
69
70 fprintf(stdout,"Test solver: MINRES with JACOBI\n");
71 Paso_Options_setDefaults(&options);
72 A->solver=NULL;
73 options.verbose=TRUE;
74 options.method=PASO_MINRES;
75 Paso_test_matrix(A,b,&options);
76
77 fprintf(stdout,"Test solver: TFQMR with JACOBI\n");
78 Paso_Options_setDefaults(&options);
79 A->solver=NULL;
80 options.verbose=TRUE;
81 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 options.method=PASO_DEFAULT;
88 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 options.method=PASO_DEFAULT;
96 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 options.method=PASO_DEFAULT;
104 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 options.method=PASO_DEFAULT;
112 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 options.method=PASO_DEFAULT;
120 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 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 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

  ViewVC Help
Powered by ViewVC 1.1.26