/[escript]/trunk/esys2/finley/src/finleyC/Solvers/Solver_preconditioner.c
ViewVC logotype

Contents of /trunk/esys2/finley/src/finleyC/Solvers/Solver_preconditioner.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: 3399 byte(s)
*** empty log message ***

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* Finley: SystemMatrix: sets-up the preconditioner */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia 2003/04 */
10 /* Author: gross@access.edu.au */
11
12 /**************************************************************/
13
14 #include "Finley.h"
15 #include "System.h"
16 #include "Solver.h"
17
18 /***********************************************************************************/
19
20 /* free space */
21
22 void Finley_Preconditioner_free(void* in) {
23 #if ITERATIVE_SOLVER == NO_LIB
24 if (in!=NULL) {
25 Finley_Solver_Preconditioner* prec=(Finley_Solver_Preconditioner*) in;
26 MEMFREE(prec->values);
27 MEMFREE(prec->mainDiag);
28 MEMFREE(prec->pivot);
29 MEMFREE(prec->color);
30 MEMFREE(prec);
31 }
32 #endif
33 }
34 /* call the iterative solver: */
35
36 void Finley_Solver_setPreconditioner(Finley_SystemMatrix* A,Finley_SolverOptions* options) {
37 #if ITERATIVE_SOLVER == NO_LIB
38 Finley_Solver_Preconditioner* prec=NULL;
39 if (A->iterative==NULL) {
40 /* allocate structure to hold preconditioner */
41 prec=MEMALLOC(1,Finley_Solver_Preconditioner);
42 if (Finley_checkPtr(prec)) return;
43 prec->type=UNKNOWN;
44 prec->numColors=0;
45
46 prec->values=NULL;
47 prec->mainDiag=NULL;
48 prec->pivot=NULL;
49 prec->color=NULL;
50
51 A->iterative=prec;
52 switch (options->preconditioner) {
53 default:
54 case ESCRIPT_JACOBI:
55 if (options->verbose) printf("Jacobi preconditioner is used.\n");
56 Finley_Solver_setJacobi(A);
57 prec->type=ESCRIPT_JACOBI;
58 break;
59 case ESCRIPT_ILU0:
60 if (options->verbose) printf("ILU(0) preconditioner is used.\n");
61 Finley_Solver_setILU0(A);
62 prec->type=ESCRIPT_ILU0;
63 break;
64 }
65 if (Finley_ErrorCode!=NO_ERROR) {
66 Finley_Preconditioner_free(prec);
67 A->iterative=NULL;
68 }
69 }
70 #endif
71 }
72
73 /* applies the preconditioner */
74 /* has to be called within a parallel reqion */
75 /* barrier synchronization is performed before the evaluation to make sure that the input vector is available */
76 void Finley_Solver_solvePreconditioner(Finley_SystemMatrix* A,double* x,double* b){
77 #if ITERATIVE_SOLVER == NO_LIB
78 Finley_Solver_Preconditioner* prec=(Finley_Solver_Preconditioner*) A->iterative;
79 #pragma omp barrier
80 switch (prec->type) {
81 default:
82 case ESCRIPT_JACOBI:
83 Finley_Solver_solveJacobi(A,x,b);
84 break;
85 case ESCRIPT_ILU0:
86 Finley_Solver_solveILU0(A,x,b);
87 break;
88 }
89 #endif
90
91 }
92
93 /*
94 * $Log$
95 * Revision 1.2 2004/12/14 05:39:32 jgs
96 * *** empty log message ***
97 *
98 * Revision 1.1.1.1.2.2 2004/11/24 01:37:17 gross
99 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
100 *
101 * Revision 1.1.1.1.2.1 2004/11/12 06:58:21 gross
102 * 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
103 *
104 * Revision 1.1.1.1 2004/10/26 06:53:58 jgs
105 * initial import of project esys2
106 *
107 * Revision 1.1 2004/07/02 04:21:14 gross
108 * Finley C code has been included
109 *
110 *
111 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26