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

Annotation of /trunk/paso/src/Jacobi.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3120 - (hide annotations)
Mon Aug 30 10:48:00 2010 UTC (9 years, 7 months ago) by gross
File MIME type: text/plain
File size: 3057 byte(s)
first iteration on Paso code clean up
1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 dhawcroft 631
14 ksteube 1811
15 jgs 150 /**************************************************************/
16    
17     /* Paso: jacobi preconditioner: */
18    
19     /**************************************************************/
20    
21     /* Copyrights by ACcESS Australia 2003, 2004, 2005 */
22 jfenwick 2608 /* Author: Lutz Gross, l.gross@uq.edu.au */
23 jgs 150
24     /**************************************************************/
25    
26 gross 700 #include "Paso.h"
27 gross 3120 #include "Preconditioner.h"
28     #include "BlockOps.h"
29 jgs 150
30     /**************************************************************/
31    
32     /* frees the Jacobi preconditioner */
33    
34     void Paso_Solver_Jacobi_free(Paso_Solver_Jacobi * in) {
35     if (in!=NULL) {
36     MEMFREE(in->values);
37     MEMFREE(in->pivot);
38     MEMFREE(in);
39     }
40     }
41 gross 3094 Paso_Solver_Jacobi* Paso_Solver_getJacobi(Paso_SystemMatrix * A_p)
42     {
43     Paso_Solver_Jacobi* jac=Paso_Solver_getLocalJacobi(A_p->mainBlock);
44     if (Paso_MPIInfo_noError(A_p->mpi_info)) {
45     return jac;
46     } else {
47     return NULL;
48     }
49     }
50 jgs 150
51     /**************************************************************/
52    
53     /* Jacobi precondioner set up */
54    
55 gross 3094 Paso_Solver_Jacobi* Paso_Solver_getLocalJacobi(Paso_SparseMatrix * A_p) {
56 jgs 150 Paso_Solver_Jacobi* out=NULL;
57 ksteube 1312 dim_t n = A_p->numCols;
58 jgs 150 dim_t n_block=A_p->row_block_size;
59     dim_t block_size=A_p->block_size;
60 gross 3094
61 jgs 150 /* check matrix is square */
62     if (A_p->col_block_size !=A_p->row_block_size) {
63 gross 432 Paso_setError(TYPE_ERROR, "Paso_Solver_getJacobi: Jacobi preconditioner square block size.");
64 jgs 150 return NULL;
65     }
66 gross 3094
67 jgs 150 out=MEMALLOC(1,Paso_Solver_Jacobi);
68     if (! Paso_checkPtr(out)) {
69 gross 3094 out->values = MEMALLOC( ((size_t) n) * ((size_t) block_size),double);
70     out->pivot = MEMALLOC( ((size_t) n) * ((size_t) n_block), index_t);
71    
72    
73     if (! ( Paso_checkPtr(out->values) || Paso_checkPtr(out->pivot) )) {
74     Paso_SparseMatrix_invMain(A_p, out->values, out->pivot );
75     }
76    
77 jgs 150 }
78     if (Paso_noError()) {
79     return out;
80     } else {
81     Paso_Solver_Jacobi_free(out);
82     return NULL;
83     }
84     }
85     /**************************************************************/
86    
87     /* applies Jacobi preconditioner */
88    
89     /* should be called within a parallel region */
90     /* barrier synconization should be performed to make sure that the input vector available */
91    
92 gross 3094 void Paso_Solver_solveJacobi(Paso_SystemMatrix * A_p, Paso_Solver_Jacobi * prec, double * x, double * b) {
93     Paso_Solver_solveLocalJacobi( A_p->mainBlock, prec, x, b) ;
94     return;
95     }
96    
97     void Paso_Solver_solveLocalJacobi(Paso_SparseMatrix * A_p, Paso_Solver_Jacobi * prec, double * x, double * b) {
98     dim_t n = A_p->numCols;
99     dim_t n_block=A_p->row_block_size;
100 gross 3120 Paso_BlockOps_allMV(n_block,n,prec->values,prec->pivot,x,b);
101 jgs 150 return;
102     }
103    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26