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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3642 - (show annotations)
Thu Oct 27 03:41:51 2011 UTC (7 years, 5 months ago) by caltinay
File MIME type: text/plain
File size: 10682 byte(s)
Assorted spelling/comment fixes in paso.

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: updates A_CC <- ACC-ACF AFF^{-1} AFC */
18
19 /* no check of consistency of matrices !!!! */
20
21 /**************************************************************/
22
23 /* Copyrights by ACcESS Australia 2003,2004,2005 */
24 /* Author: Lutz Gross, l.gross@uq.edu.au */
25
26 /**************************************************************/
27
28 #include "Paso.h"
29 #include "SparseMatrix.h"
30 #include "Solver.h"
31
32 /**************************************************************/
33
34
35
36 void Paso_Solver_updateIncompleteSchurComplement(Paso_SparseMatrix* A_CC,Paso_SparseMatrix *A_CF,double* invA_FF,index_t* A_FF_pivot,Paso_SparseMatrix *A_FC) {
37
38 index_t iPtr_CC,*index_CC,col_CF,col_FC, *where_p,iPtr_CC_2,i,iPtr_CF,iPtr_FC;
39 dim_t index_CC_len;
40 bool_t set_A;
41 dim_t n_loc_rows=A_CC->numRows;
42 dim_t n_block=A_CC->row_block_size;
43 register double A_CF_11,A_CF_21,A_CF_31,A_CF_12,A_CF_22,A_CF_32,A_CF_13,A_CF_23,A_CF_33,
44 invA_FF_11,invA_FF_21,invA_FF_31,invA_FF_12,invA_FF_22,invA_FF_32,invA_FF_13,invA_FF_23,invA_FF_33,
45 A11=0,A21=0,A31=0,A12=0,A22=0,A32=0,A13=0,A23=0,A33=0,A_FC_11,A_FC_21,A_FC_31,A_FC_12,A_FC_22,A_FC_32,A_FC_13,A_FC_23,A_FC_33;
46 if (n_block==1) {
47 #pragma omp parallel for firstprivate(A11) private(i,iPtr_CC,index_CC,index_CC_len,col_CF,set_A,iPtr_CF,iPtr_FC,col_FC,where_p) schedule(static)
48 for (i = 0; i < n_loc_rows;++i) {
49 iPtr_CC=A_CC->pattern->ptr[i];
50 index_CC=&(A_CC->pattern->index[iPtr_CC]);
51 index_CC_len=(size_t)(A_CC->pattern->ptr[i+1]-A_CC->pattern->ptr[i]);
52 /* now we run through the columns of A_CF in row i */
53 for (iPtr_CF = A_CF->pattern->ptr[i]; iPtr_CF < A_CF->pattern->ptr[i + 1]; ++iPtr_CF) {
54 col_CF=A_CF->pattern->index[iPtr_CF];
55 set_A=TRUE;
56 for (iPtr_FC = A_FC->pattern->ptr[col_CF]; iPtr_FC < A_FC->pattern->ptr[col_CF + 1]; ++iPtr_FC) {
57 col_FC=A_FC->pattern->index[iPtr_FC];
58 /* is (i,col_FC) in the shape of A_CC ? */
59 where_p=(index_t*)bsearch(&col_FC,index_CC,index_CC_len,sizeof(index_t),Paso_comparIndex);
60 if (where_p!=NULL) {
61 if (set_A) {
62 A11=A_CF->val[iPtr_CF]*invA_FF[col_CF];
63 set_A=FALSE;
64 }
65 A_CC->val[iPtr_CC+(index_t)(where_p-index_CC)]-=A11*A_FC->val[iPtr_FC];
66 }
67 } /* end of iPtr_FC loop */
68 } /* end of iPtr_CF loop */
69 } /* end of irow loop */
70 } else if (n_block==2) {
71 #pragma omp parallel for firstprivate(A11,A21,A12,A22) private(i,iPtr_CC,index_CC,index_CC_len,iPtr_CF,col_CF,iPtr_FC,col_FC,where_p,iPtr_CC_2,set_A,A_CF_11,A_CF_21,A_CF_12,A_CF_22,invA_FF_11,invA_FF_21,invA_FF_12,invA_FF_22,A_FC_11,A_FC_21,A_FC_12,A_FC_22) schedule(static)
72 for (i = 0; i < n_loc_rows;++i) {
73 iPtr_CC=A_CC->pattern->ptr[i];
74 index_CC=&(A_CC->pattern->index[iPtr_CC]);
75 index_CC_len=(size_t)(A_CC->pattern->ptr[i+1]-A_CC->pattern->ptr[i]);
76 /* now we run through the columns of A_CF in row i */
77 for (iPtr_CF = A_CF->pattern->ptr[i]; iPtr_CF < A_CF->pattern->ptr[i + 1]; ++iPtr_CF) {
78 col_CF=A_CF->pattern->index[iPtr_CF];
79 set_A=TRUE;
80 for (iPtr_FC = A_FC->pattern->ptr[col_CF]; iPtr_FC < A_FC->pattern->ptr[col_CF + 1]; ++iPtr_FC) {
81 col_FC=A_FC->pattern->index[iPtr_FC];
82 /* is (i,col_FC) in the shape of A_CC ? */
83 where_p=(index_t*)bsearch(&col_FC,index_CC,index_CC_len,sizeof(index_t),Paso_comparIndex);
84 if (where_p!=NULL) {
85 iPtr_CC_2=iPtr_CC+(index_t)(where_p-index_CC);
86 /* this calculutes A_CF*invA_FF(i,col_CF) */
87 if (set_A) {
88 A_CF_11=A_CF->val[4*iPtr_CF ];
89 A_CF_21=A_CF->val[4*iPtr_CF+1];
90 A_CF_12=A_CF->val[4*iPtr_CF+2];
91 A_CF_22=A_CF->val[4*iPtr_CF+3];
92
93 invA_FF_11=invA_FF[4*col_CF ];
94 invA_FF_21=invA_FF[4*col_CF+1];
95 invA_FF_12=invA_FF[4*col_CF+2];
96 invA_FF_22=invA_FF[4*col_CF+3];
97
98 A11=A_CF_11*invA_FF_11+A_CF_12*invA_FF_21;
99 A21=A_CF_21*invA_FF_11+A_CF_22*invA_FF_21;
100 A12=A_CF_11*invA_FF_12+A_CF_12*invA_FF_22;
101 A22=A_CF_21*invA_FF_12+A_CF_22*invA_FF_22;
102
103 set_A=FALSE;
104 }
105
106 A_FC_11=A_FC->val[4*iPtr_FC ];
107 A_FC_21=A_FC->val[4*iPtr_FC+1];
108 A_FC_12=A_FC->val[4*iPtr_FC+2];
109 A_FC_22=A_FC->val[4*iPtr_FC+3];
110
111 A_CC->val[4*iPtr_CC_2 ]-=A11*A_FC_11+A12*A_FC_21;
112 A_CC->val[4*iPtr_CC_2+1]-=A21*A_FC_11+A22*A_FC_21;
113 A_CC->val[4*iPtr_CC_2+2]-=A11*A_FC_12+A12*A_FC_22;
114 A_CC->val[4*iPtr_CC_2+3]-=A21*A_FC_12+A22*A_FC_22;
115
116 }
117 } /* end of iPtr_FC loop */
118 } /* end of iPtr_CF loop */
119 } /* end of irow loop */
120 } else if (n_block==3) {
121 #pragma omp parallel for firstprivate(A11,A21,A31,A12,A22,A32,A13,A23,A33) private(i,iPtr_CC,index_CC,index_CC_len,iPtr_CF,col_CF,iPtr_FC,col_FC,where_p,iPtr_CC_2,set_A,A_CF_11,A_CF_21,A_CF_31,A_CF_12,A_CF_22,A_CF_32,A_CF_13,A_CF_23,A_CF_33,invA_FF_11,invA_FF_21,invA_FF_31,invA_FF_12,invA_FF_22,invA_FF_32,invA_FF_13,invA_FF_23,invA_FF_33,A_FC_11,A_FC_21,A_FC_31,A_FC_12,A_FC_22,A_FC_32,A_FC_13,A_FC_23,A_FC_33) schedule(static)
122 for (i = 0; i < n_loc_rows;++i) {
123 iPtr_CC=A_CC->pattern->ptr[i];
124 index_CC=&(A_CC->pattern->index[iPtr_CC]);
125 index_CC_len=(size_t)(A_CC->pattern->ptr[i+1]-A_CC->pattern->ptr[i]);
126 /* now we run through the columns of A_CF in row i */
127 for (iPtr_CF = A_CF->pattern->ptr[i]; iPtr_CF < A_CF->pattern->ptr[i + 1]; ++iPtr_CF) {
128 col_CF=A_CF->pattern->index[iPtr_CF];
129 set_A=TRUE;
130 for (iPtr_FC = A_FC->pattern->ptr[col_CF]; iPtr_FC < A_FC->pattern->ptr[col_CF + 1]; ++iPtr_FC) {
131 col_FC=A_FC->pattern->index[iPtr_FC];
132 /* is (i,col_FC) in the shape of A_CC ? */
133 where_p=(index_t*)bsearch(&col_FC,index_CC,index_CC_len,sizeof(index_t),Paso_comparIndex);
134 if (where_p!=NULL) {
135 iPtr_CC_2=iPtr_CC+(index_t)(where_p-index_CC);
136 /* this calculutes A_CF*invA_FF(i,col_CF) */
137 if (set_A) {
138 A_CF_11=A_CF->val[9*iPtr_CF ];
139 A_CF_21=A_CF->val[9*iPtr_CF+1];
140 A_CF_31=A_CF->val[9*iPtr_CF+2];
141 A_CF_12=A_CF->val[9*iPtr_CF+3];
142 A_CF_22=A_CF->val[9*iPtr_CF+4];
143 A_CF_32=A_CF->val[9*iPtr_CF+5];
144 A_CF_13=A_CF->val[9*iPtr_CF+6];
145 A_CF_23=A_CF->val[9*iPtr_CF+7];
146 A_CF_33=A_CF->val[9*iPtr_CF+8];
147
148 invA_FF_11=invA_FF[9*col_CF ];
149 invA_FF_21=invA_FF[9*col_CF+1];
150 invA_FF_31=invA_FF[9*col_CF+2];
151 invA_FF_12=invA_FF[9*col_CF+3];
152 invA_FF_22=invA_FF[9*col_CF+4];
153 invA_FF_32=invA_FF[9*col_CF+5];
154 invA_FF_13=invA_FF[9*col_CF+6];
155 invA_FF_23=invA_FF[9*col_CF+7];
156 invA_FF_33=invA_FF[9*col_CF+8];
157
158 A11=A_CF_11*invA_FF_11+A_CF_12*invA_FF_21+A_CF_13*invA_FF_31;
159 A21=A_CF_21*invA_FF_11+A_CF_22*invA_FF_21+A_CF_23*invA_FF_31;
160 A31=A_CF_31*invA_FF_11+A_CF_32*invA_FF_21+A_CF_33*invA_FF_31;
161 A12=A_CF_11*invA_FF_12+A_CF_12*invA_FF_22+A_CF_13*invA_FF_32;
162 A22=A_CF_21*invA_FF_12+A_CF_22*invA_FF_22+A_CF_23*invA_FF_32;
163 A32=A_CF_31*invA_FF_12+A_CF_32*invA_FF_22+A_CF_33*invA_FF_32;
164 A13=A_CF_11*invA_FF_13+A_CF_12*invA_FF_23+A_CF_13*invA_FF_33;
165 A23=A_CF_21*invA_FF_13+A_CF_22*invA_FF_23+A_CF_23*invA_FF_33;
166 A33=A_CF_31*invA_FF_13+A_CF_32*invA_FF_23+A_CF_33*invA_FF_33;
167
168 set_A=FALSE;
169 }
170
171 A_FC_11=A_FC->val[9*iPtr_FC ];
172 A_FC_21=A_FC->val[9*iPtr_FC+1];
173 A_FC_31=A_FC->val[9*iPtr_FC+2];
174 A_FC_12=A_FC->val[9*iPtr_FC+3];
175 A_FC_22=A_FC->val[9*iPtr_FC+4];
176 A_FC_32=A_FC->val[9*iPtr_FC+5];
177 A_FC_13=A_FC->val[9*iPtr_FC+6];
178 A_FC_23=A_FC->val[9*iPtr_FC+7];
179 A_FC_33=A_FC->val[9*iPtr_FC+8];
180
181 A_CC->val[9*iPtr_CC_2 ]-=A11*A_FC_11+A12*A_FC_21+A13*A_FC_31;
182 A_CC->val[9*iPtr_CC_2+1]-=A21*A_FC_11+A22*A_FC_21+A23*A_FC_31;
183 A_CC->val[9*iPtr_CC_2+2]-=A31*A_FC_11+A32*A_FC_21+A33*A_FC_31;
184 A_CC->val[9*iPtr_CC_2+3]-=A11*A_FC_12+A12*A_FC_22+A13*A_FC_32;
185 A_CC->val[9*iPtr_CC_2+4]-=A21*A_FC_12+A22*A_FC_22+A23*A_FC_32;
186 A_CC->val[9*iPtr_CC_2+5]-=A31*A_FC_12+A32*A_FC_22+A33*A_FC_32;
187 A_CC->val[9*iPtr_CC_2+6]-=A11*A_FC_13+A12*A_FC_23+A13*A_FC_33;
188 A_CC->val[9*iPtr_CC_2+7]-=A21*A_FC_13+A22*A_FC_23+A23*A_FC_33;
189 A_CC->val[9*iPtr_CC_2+8]-=A31*A_FC_13+A32*A_FC_23+A33*A_FC_33;
190
191 }
192 } /* end of iPtr_FC loop */
193 } /* end of iPtr_CF loop */
194 } /* end of irow loop */
195 }
196 }
197 /*
198 * $Log$
199 * Revision 1.2 2005/09/15 03:44:40 jgs
200 * Merge of development branch dev-02 back to main trunk on 2005-09-15
201 *
202 * Revision 1.1.2.1 2005/09/05 06:29:50 gross
203 * These files have been extracted from finley to define a stand alone libray for iterative
204 * linear solvers on the ALTIX. main entry through Paso_solve. this version compiles but
205 * has not been tested yet.
206 *
207 *
208 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26