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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3125 - (show annotations)
Tue Aug 31 05:37:30 2010 UTC (8 years, 10 months ago) by gross
File MIME type: text/plain
File size: 3197 byte(s)
more code cleaning
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * 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
14
15 /**************************************************************/
16
17 /* Paso: jacobi preconditioner: */
18
19 /**************************************************************/
20
21 /* Copyrights by ACcESS Australia 2003, 2004, 2005 */
22 /* Author: Lutz Gross, l.gross@uq.edu.au */
23
24 /**************************************************************/
25
26 #include "Paso.h"
27 #include "Preconditioner.h"
28 #include "BlockOps.h"
29
30 /**************************************************************/
31
32 /* frees the Jacobi preconditioner */
33
34 void Paso_Preconditioner_Jacobi_free(Paso_Preconditioner_Jacobi * in) {
35 if (in!=NULL) {
36 MEMFREE(in->values);
37 MEMFREE(in->pivot);
38 MEMFREE(in);
39 }
40 }
41 Paso_Preconditioner_Jacobi* Paso_Preconditioner_Jacobi_alloc(Paso_SystemMatrix * A_p)
42 {
43 Paso_Preconditioner_Jacobi* jac=Paso_Preconditioner_LocalJacobi_alloc(A_p->mainBlock);
44 if (Paso_MPIInfo_noError(A_p->mpi_info)) {
45 return jac;
46 } else {
47 return NULL;
48 }
49 }
50
51 /**************************************************************/
52
53 /* Jacobi precondioner set up */
54
55 Paso_Preconditioner_Jacobi* Paso_Preconditioner_LocalJacobi_alloc(Paso_SparseMatrix * A_p) {
56 Paso_Preconditioner_Jacobi* out=NULL;
57 dim_t n = A_p->numCols;
58 dim_t n_block=A_p->row_block_size;
59 dim_t block_size=A_p->block_size;
60
61 /* check matrix is square */
62 if (A_p->col_block_size !=A_p->row_block_size) {
63 Paso_setError(TYPE_ERROR, "Paso_Solver_getJacobi: Jacobi preconditioner square block size.");
64 return NULL;
65 }
66
67 out=MEMALLOC(1,Paso_Preconditioner_Jacobi);
68 if (! Paso_checkPtr(out)) {
69 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 }
78 if (Paso_noError()) {
79 return out;
80 } else {
81 Paso_Preconditioner_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 void Paso_Preconditioner_Jacobi_solve(Paso_SystemMatrix * A_p, Paso_Preconditioner_Jacobi * prec, double * x, double * b) {
93 Paso_Preconditioner_LocalJacobi_solve( A_p->mainBlock, prec, x, b) ;
94 return;
95 }
96
97 void Paso_Preconditioner_LocalJacobi_solve(Paso_SparseMatrix * A_p, Paso_Preconditioner_Jacobi * prec, double * x, double * b) {
98 dim_t n = A_p->numCols;
99 dim_t n_block=A_p->row_block_size;
100 Paso_BlockOps_allMV(n_block,n,prec->values,prec->pivot,x,b);
101 return;
102 }
103

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26