/[escript]/trunk/paso/src/SCSL_iterative.c
ViewVC logotype

Contents of /trunk/paso/src/SCSL_iterative.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 415 - (show annotations)
Wed Jan 4 05:37:33 2006 UTC (13 years, 10 months ago) by gross
File MIME type: text/plain
File size: 4370 byte(s)
a better way of representing the matrix format type is introduced. this is needed for the Paradiso and UMFPACK interface
1 /* $Id: SCSL_iterative.c 150 2005-09-15 03:44:45Z jgs $ */
2
3 /**************************************************************/
4
5 /* Paso: SystemMatrix: interface to SGI SCSL iterative solver */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003,2004,2005 */
10 /* Author: gross@access.edu.au */
11
12 /**************************************************************/
13
14 #include <stdlib.h>
15 #include "Paso.h"
16 #include "SystemMatrix.h"
17 #include "SCSL.h"
18 #ifdef SCSL
19 #include <scsl_sparse.h>
20 #endif
21
22 /***********************************************************************************/
23
24 /* free any extra stuff possibly used by the SCSL library */
25
26 void Paso_SCSL_iterative_free(Paso_SystemMatrix* A) {
27
28 }
29
30 /* call the iterative solver: */
31
32 void Paso_SCSL_iterative(Paso_SystemMatrix* A,
33 double* out,double* in,Paso_Options* options) {
34 #ifdef SCSL
35 char text2[3];
36 int iters, method,precond,storage,maxiters;
37 double drop_tolerance,drop_storage,finalres,convtol,time0;
38 if (A->col_block_size!=1) {
39 Paso_setError(TYPE_ERROR,"Paso_SCSL_direct: linear solver can only be applied to block size 1.");
40 }
41 if (A->type & MATRIX_FORMAT_CSC) {
42 storage=1;
43 if (! (A->type & (MATRIX_FORMAT_CSC + MATRIX_FORMAT_BLK1)) )
44 Paso_setError(TYPE_ERROR,"Paso_SCSL_iterative: iterative solver in compressed sparse column requires a nonsymmetric storage scheme, block size 1 and index offset 0.");
45 } else {
46 storage=0;
47 if (! (A->type & MATRIX_FORMAT_BLK1) )
48 Paso_setError(TYPE_ERROR,"Paso_SCSL_iterative: iterative solver in compressed sparse row requires a nonsymmetric storage scheme, block size 1 and index offset 0.");
49 }
50
51 method=Paso_Options_getSolver(options->method,PASO_PASO,options->symmetric);
52 if (Paso_noError()) {
53 switch (method) {
54 case PASO_PCG:
55 method=0;
56 break;
57 case PASO_CR:
58 method=1;
59 break;
60 case PASO_CGS:
61 method=10;
62 break;
63 case PASO_BICGSTAB:
64 method=11;
65 break;
66 default:
67 method=11;
68 break;
69 }
70 switch (options->preconditioner) {
71 case PASO_JACOBI:
72 precond=0;
73 break;
74 case PASO_SSOR:
75 precond=1;
76 break;
77 case PASO_ILU0:
78 if (options->symmetric) precond = 2;
79 else precond=0;
80 break;
81 case PASO_ILUT:
82 if (options->symmetric) precond = 3;
83 else precond=0;
84 break;
85 default:
86 precond=0;
87 break;
88 }
89 maxiters=options->iter_max;
90 convtol=options->tolerance;
91
92 drop_tolerance=options->drop_tolerance;
93 DIterative_DropTol(drop_tolerance);
94 drop_storage=options->drop_storage;
95 DIterative_DropStorage(drop_storage);
96
97 /* this stuff does not work */
98 if (options->verbose) {
99 setenv("ITERATIVE_VERBOSE","1",1);
100 } else {
101 unsetenv("ITERATIVE_VERBOSE");
102 }
103 if (options->reordering==PASO_NO_REORDERING) {
104 sprintf(text2,"%d",0);
105 } else {
106 sprintf(text2,"%d",-1);
107 }
108 setenv("ITERATIVE_RCM",text2,1);
109 setenv("ITERATIVE_COPY","1",1);
110 /* oend of this stuff does not work */
111
112 time0=Paso_timer();
113 DIterative(A->num_rows,A->pattern->ptr,A->pattern->index,A->val,storage,out,in,method,precond,maxiters,convtol,&iters,&finalres);
114 options->iter=iters;
115 options->final_residual=finalres;
116 time0=Paso_timer()-time0;
117 if (options->verbose) {
118 printf("timing SCSL: solve: %.4e sec\n",time0);
119 if (iters>0) printf("timing: per iteration: %.4e sec\n",time0/iters);
120 }
121 }
122 #else
123 Paso_setError(SYSTEM_ERROR,"Paso_SCSL_iterative: SCSL not available.");
124 #endif
125 }
126
127 /*
128 * $Log$
129 * Revision 1.2 2005/09/15 03:44:40 jgs
130 * Merge of development branch dev-02 back to main trunk on 2005-09-15
131 *
132 * Revision 1.1.2.2 2005/09/07 00:59:08 gross
133 * some inconsistent renaming fixed to make the linking work.
134 *
135 * Revision 1.1.2.1 2005/09/05 06:29:49 gross
136 * These files have been extracted from finley to define a stand alone libray for iterative
137 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
138 * has not been tested yet.
139 *
140 *
141 */

  ViewVC Help
Powered by ViewVC 1.1.26