/[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 4286 - (show annotations)
Thu Mar 7 04:28:11 2013 UTC (6 years, 1 month ago) by caltinay
File MIME type: text/plain
File size: 5139 byte(s)
Assorted spelling fixes.

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

  ViewVC Help
Powered by ViewVC 1.1.26