/[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 2625 - (show annotations)
Fri Aug 21 06:30:25 2009 UTC (10 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 4670 byte(s)
Merging changes from new doco branch.
All docstrings are now in reStructured text.
A few email addresses have been fixes as well.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 2003 */
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_PCG;
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_PCG;
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_PCG;
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_PCG;
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_PCG;
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 }
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

  ViewVC Help
Powered by ViewVC 1.1.26