/[escript]/trunk/esys2/finley/src/finleyC/SCSL/SCSL_iterative.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/SCSL/SCSL_iterative.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 97 - (show annotations)
Tue Dec 14 05:39:33 2004 UTC (14 years, 11 months ago) by jgs
File MIME type: text/plain
File size: 3935 byte(s)
*** empty log message ***

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: SystemMatrix: interface to SGI SCSL iterative solver */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003/04 */
10 /* Author: gross@access.edu.au */
11
12 /**************************************************************/
13
14 #include <stdlib.h>
15 #include "Finley.h"
16 #include "System.h"
17 #include "SCSL.h"
18 #if ITERATIVE_SOLVER == SGI_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 Finley_SCSL_iterative_free(Finley_SystemMatrix* A) {
27
28 }
29
30 /* call the iterative solver: */
31
32 void Finley_SCSL_iterative(Finley_SystemMatrix* A,
33 double* out,double* in,Finley_SolverOptions* options) {
34 #if ITERATIVE_SOLVER == SGI_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 Finley_ErrorCode=TYPE_ERROR;
40 sprintf(Finley_ErrorMsg,"SCSL linear solver can only be applied to block size 1.");
41 return;
42 }
43 switch(A->type) {
44 case CSR:
45 storage=0;
46 break;
47 case CSC:
48 storage=1;
49 break;
50 default:
51 Finley_ErrorCode=TYPE_ERROR;
52 sprintf(Finley_ErrorMsg,"Matrix type %d is not supported by SCSL iterative solver.",A->type);
53 return;
54 } /* switch A->type */
55
56 if (options->symmetric) {
57 switch (options->method) {
58 case ESCRIPT_PCG:
59 method=0;
60 break;
61 case ESCRIPT_CR:
62 method=1;
63 break;
64 default:
65 method=0;
66 break;
67 }
68 } else {
69 switch (options->method) {
70 case ESCRIPT_CGS:
71 method=10;
72 break;
73 case ESCRIPT_BICGSTAB:
74 method=11;
75 break;
76 default:
77 method=11;
78 break;
79 }
80 }
81 switch (options->preconditioner) {
82 case ESCRIPT_JACOBI:
83 precond=0;
84 break;
85 case ESCRIPT_SSOR:
86 precond=1;
87 break;
88 case ESCRIPT_ILU0:
89 if (options->symmetric) precond = 2;
90 else precond=0;
91 break;
92 case ESCRIPT_ILUT:
93 if (options->symmetric) precond = 3;
94 else precond=0;
95 break;
96 default:
97 precond=0;
98 break;
99 }
100 maxiters=options->iter_max;
101 convtol=options->tolerance;
102
103 drop_tolerance=options->drop_tolerance;
104 DIterative_DropTol(drop_tolerance);
105 drop_storage=options->drop_storage;
106 DIterative_DropStorage(drop_storage);
107
108 if (options->verbose) {
109 setenv("ITERATIVE_VERBOSE","1",1);
110 } else {
111 unsetenv("ITERATIVE_VERBOSE");
112 }
113 if (options->reordering==ESCRIPT_NO_REORDERING) {
114 sprintf(text2,"%d",0);
115 } else {
116 sprintf(text2,"%d",-1);
117 }
118 setenv("ITERATIVE_RCM",text2,1);
119 setenv("ITERATIVE_COPY","1",1);
120
121 time0=Finley_timer();
122 DIterative(A->num_rows,A->pattern->ptr,A->pattern->index,A->val,storage,out,in,method,precond,maxiters,convtol,&iters,&finalres);
123 options->iter=iters;
124 options->final_residual=finalres;
125 time0=Finley_timer()-time0;
126 if (options->verbose) {
127 printf("timing SCSL: solve: %.4e sec\n",time0);
128 if (iters>0) printf("timing: per iteration: %.4e sec\n",time0/iters);
129 }
130 #else
131 Finley_ErrorCode=SYSTEM_ERROR;
132 sprintf(Finley_ErrorMsg,"No SCSL iterative solver available.");
133 #endif
134 }
135 /*
136 * $Log$
137 * Revision 1.2 2004/12/14 05:39:31 jgs
138 * *** empty log message ***
139 *
140 * Revision 1.1.1.1.2.1 2004/11/12 06:58:20 gross
141 * a lot of changes to get the linearPDE class running: most important change is that there is no matrix format exposed to the user anymore. the format is chosen by the Domain according to the solver and symmetry
142 *
143 * Revision 1.1.1.1 2004/10/26 06:53:57 jgs
144 * initial import of project esys2
145 *
146 * Revision 1.1 2004/07/02 04:21:14 gross
147 * Finley C code has been included
148 *
149 *
150 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26