/[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 2382 - (show annotations)
Tue Apr 14 03:48:22 2009 UTC (10 years, 5 months ago) by artak
File MIME type: text/plain
File size: 4534 byte(s)
Testing environment now mor flexible. Added a lot of options.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 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@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 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.method=PASO_BICGSTAB;
53 Paso_test_matrix(A,b,&options);
54
55 fprintf(stdout,"Test solver: GMRES with JACOBI\n");
56 Paso_Options_setDefaults(&options);
57 A->solver=NULL;
58 options.method=PASO_GMRES;
59 Paso_test_matrix(A,b,&options);
60
61 fprintf(stdout,"Test solver: PRES20 with JACOBI\n");
62 Paso_Options_setDefaults(&options);
63 A->solver=NULL;
64 options.method=PASO_PRES20;
65 Paso_test_matrix(A,b,&options);
66
67 fprintf(stdout,"Test solver: MINRES with JACOBI\n");
68 Paso_Options_setDefaults(&options);
69 A->solver=NULL;
70 options.method=PASO_MINRES;
71 Paso_test_matrix(A,b,&options);
72
73 fprintf(stdout,"Test solver: TFQMR with JACOBI\n");
74 Paso_Options_setDefaults(&options);
75 A->solver=NULL;
76 options.method=PASO_TFQMR;
77 Paso_test_matrix(A,b,&options);
78 }
79 else if (level==2) /* Preconditiones only with default solver*/
80 {
81 Paso_Options_setDefaults(&options);
82 options.method=PASO_PCG;
83 options.verbose=TRUE;
84 options.preconditioner=PASO_JACOBI;
85 fprintf(stdout,"Test preconditioner: PASO_DEFAULT with JACOBI\n");
86 Paso_test_matrix(A,b,&options);
87
88 Paso_Options_setDefaults(&options);
89 A->solver=NULL;
90 options.method=PASO_PCG;
91 options.verbose=TRUE;
92 fprintf(stdout,"Test preconditioner: PASO_DEFAULT with ILU\n");
93 options.preconditioner=PASO_ILU0;
94 Paso_test_matrix(A,b,&options);
95
96 Paso_Options_setDefaults(&options);
97 A->solver=NULL;
98 options.method=PASO_PCG;
99 options.verbose=TRUE;
100 fprintf(stdout,"Test preconditioner: PASO_DEFAULT with RILU\n");
101 options.preconditioner=PASO_RILU;
102 Paso_test_matrix(A,b,&options);
103
104 Paso_Options_setDefaults(&options);
105 A->solver=NULL;
106 options.method=PASO_PCG;
107 options.verbose=TRUE;
108 fprintf(stdout,"Test preconditioner: PASO_DEFAULT with GS\n");
109 options.preconditioner=PASO_GS;
110 Paso_test_matrix(A,b,&options);
111
112 Paso_Options_setDefaults(&options);
113 A->solver=NULL;
114 options.method=PASO_PCG;
115 options.verbose=TRUE;
116 fprintf(stdout,"Test preconditioner: PASO_DEFAULT with AMG\n");
117 options.preconditioner=PASO_AMG;
118 Paso_test_matrix(A,b,&options);
119
120 }
121 }
122
123 void Paso_test_matrix(Paso_SystemMatrix* A, double* b, Paso_Options* options ) {
124
125 dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
126 double *out=NULL;
127 out=MEMALLOC(n,double);
128
129 if (Paso_checkPtr(out)) {
130 fprintf(stderr,"Cannot allocate memory\n");
131 return;
132 }
133 Paso_solve(A,out,b,options);
134
135 MEMFREE(out);
136
137 }
138
139 void Paso_test_data(char *fileName_p, double* b, Paso_Options* options ) {
140
141 Paso_SystemMatrix* A=NULL;
142 dim_t n=Paso_SystemMatrix_getTotalNumRows(A);
143 double *out=MEMALLOC(n,double);
144 A=Paso_SystemMatrix_loadMM_toCSR(fileName_p);
145
146 if (Paso_checkPtr(out)) {
147 return;
148 }
149
150 Paso_solve(A,out,b,options);
151
152 Paso_SystemMatrix_free(A);
153 MEMFREE(out);
154 }
155

  ViewVC Help
Powered by ViewVC 1.1.26