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

Annotation of /trunk/esys2/finley/src/finleyC/System_add.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years, 7 months ago) by jgs
File MIME type: text/plain
File size: 2924 byte(s)
Initial revision

1 jgs 82 /* $Id$ */
2    
3     /**************************************************************/
4    
5     /* Finley: SystemMatrix and SystemVector */
6    
7     /* adds the matrix array[row_block_size,col_block_size,NN,NN] onto the matrix in. */
8     /* the rows/columns are given by */
9     /* ir+row_block_size*Nodes_row[Nodes[jr]] (ir=0:row_block_size; jr=0:NN_row). */
10     /* the routine has to be called from a parallel region */
11    
12     /* This routine assumes that in->row_block_size=in->col_block_size=1, i.e. */
13     /* array is fully packed. */
14     /* TODO: the case in->row_block_size!=1 */
15    
16     /**************************************************************/
17    
18     /* Copyrights by ACcESS Australia 2003/04 */
19     /* Author: gross@access.edu.au */
20    
21     /**************************************************************/
22    
23     #include "Finley.h"
24     #include "System.h"
25    
26     /**************************************************************/
27    
28     void Finley_SystemMatrix_add(Finley_SystemMatrix* in,int NN_row,maybelong* Nodes_row, int row_block_size,
29     int NN_col,maybelong* Nodes_col,int col_block_size, double* array) {
30     int kr,jr,jc,kc,ir,ic;
31     maybelong irow,icol,k;
32     switch(in->type) {
33     case CSR:
34     for (kr=0;kr<NN_row;kr++) {
35     jr=Nodes_row[kr];
36     for (ir=0;ir<row_block_size;ir++) {
37     irow=ir+row_block_size*jr;
38     for (kc=0;kc<NN_col;kc++) {
39     jc=Nodes_col[kc];
40     for (ic=0;ic<col_block_size;ic++) {
41     icol=ic+col_block_size*jc+INDEX_OFFSET;
42     for(k=in->ptr[irow]-PTR_OFFSET;k<in->ptr[irow+1]-PTR_OFFSET;k++) {
43     if (in->index[k]==icol) {
44     #pragma omp atomic
45     in->val[k]+=array[INDEX4(ir,ic,kr,kc,row_block_size,col_block_size,NN_row)];
46     break;
47     }
48     }
49     }
50     }
51     }
52     }
53     break;
54     case CSC:
55     for (kr=0;kr<NN_row;kr++) {
56     jr=Nodes_row[kr];
57     for (ir=0;ir<row_block_size;ir++) {
58     irow=ir+row_block_size*jr;
59     for (kc=0;kc<NN_col;kc++) {
60     jc=Nodes_col[kc];
61     for (ic=0;ic<col_block_size;ic++) {
62     icol=ic+col_block_size*jc+INDEX_OFFSET;
63     for(k=in->ptr[icol]-PTR_OFFSET;k<in->ptr[icol+1]-PTR_OFFSET;k++) {
64     if (in->index[k]==irow) {
65     #pragma omp atomic
66     in->val[k]+=array[INDEX4(ir,ic,kr,kc,row_block_size,col_block_size,NN_row)];
67     break;
68     }
69     }
70     }
71     }
72     }
73     }
74     break;
75     default:
76     Finley_ErrorCode=TYPE_ERROR;
77     sprintf(Finley_ErrorMsg,"Unknown matrix type.");
78     } /* switch in->type */
79     }
80     /*
81     * $Log$
82     * Revision 1.1 2004/10/26 06:53:57 jgs
83     * Initial revision
84     *
85     * Revision 1.1 2004/07/02 04:21:13 gross
86     * Finley C code has been included
87     *
88     *
89     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26