/[escript]/branches/doubleplusgood/dudley/src/Assemble_PDE_Single2_1D.cpp
ViewVC logotype

Annotation of /branches/doubleplusgood/dudley/src/Assemble_PDE_Single2_1D.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 798 - (hide annotations)
Fri Aug 4 01:05:36 2006 UTC (12 years, 8 months ago) by gross
Original Path: trunk/finley/src/Assemble_PDE_Single2_1D.c
File MIME type: text/plain
File size: 11058 byte(s)
Reimplementation of the assemblage with persistent jacobeans.
There are also a few changes to the tests which has now
dramatically reduced the memory demand.


1 gross 798 /*
2     ************************************************************
3     * Copyright 2006 by ACcESS MNRF *
4     * *
5     * http://www.access.edu.au *
6     * Primary Business: Queensland, Australia *
7     * Licensed under the Open Software License version 1.0 *
8     * http://www.opensource.org/licenses/osl-3.0.php *
9     * *
10     ************************************************************
11     */
12    
13     /**************************************************************/
14    
15     /* assembles the system of numEq PDEs into the stiffness matrix S right hand side F */
16     /* the shape functions for test and solution must be identical */
17    
18    
19     /* -(A_{i,j} u_,j)_i-(B_{i} u)_i+C_{j} u_,j-D u_m and -(X_,i)_i + Y */
20    
21     /* in a 1D domain. The shape functions for test and solution must be identical */
22     /* and row_NS == row_NN */
23    
24     /* Shape of the coefficients: */
25    
26     /* A = 1 x 1 */
27     /* B = 1 */
28     /* C = 1 */
29     /* D = scalar */
30     /* X = 1 */
31     /* Y = scalar */
32    
33    
34     /**************************************************************/
35    
36     /* Author: gross@access.edu.au */
37     /* Version: $Id:$ */
38    
39     /**************************************************************/
40    
41    
42     #include "Assemble.h"
43     #include "Util.h"
44    
45     /**************************************************************/
46    
47     void Finley_Assemble_PDE_Single2_1D(Assemble_Parameters p, Finley_ElementFile* elements,
48     Paso_SystemMatrix* Mat, escriptDataC* F,
49     escriptDataC* A, escriptDataC* B, escriptDataC* C, escriptDataC* D, escriptDataC* X, escriptDataC* Y) {
50    
51     #define DIM 1
52     index_t color;
53     dim_t e;
54     bool_t extendedA=isExpanded(A);
55     bool_t extendedB=isExpanded(B);
56     bool_t extendedC=isExpanded(C);
57     bool_t extendedD=isExpanded(D);
58     bool_t extendedX=isExpanded(X);
59     bool_t extendedY=isExpanded(Y);
60     double *F_p=getSampleData(F,0);
61     double *S=p.row_jac->ReferenceElement->S;
62     dim_t len_EM_S=p.row_NN*p.col_NN;
63     dim_t len_EM_F=p.row_NN;
64    
65    
66     #pragma omp parallel private(color)
67     {
68     double EM_S[len_EM_S], EM_F[len_EM_F];
69     index_t row_index[p.row_NN];
70     register dim_t q, s,r;
71     register double rtmp;
72     double *Vol, *DSDX, *A_p, *B_p, *C_p, *D_p, *X_p, *Y_p;
73     bool_t add_EM_F, add_EM_S;
74     #ifndef PASO_MPI
75     for (color=elements->minColor;color<=elements->maxColor;color++) {
76     /* open loop over all elements: */
77     #pragma omp for private(e) schedule(static)
78     for(e=0;e<elements->numElements;e++){
79     if (elements->Color[e]==color) {
80     #else
81     {
82     for(e=0;e<elements->numElements;e++) {
83     {
84     #endif
85     Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]);
86     DSDX=&(p.row_jac->DSDX[INDEX4(0,0,0,e,p.row_NN,DIM,p.numQuad)]);
87     for (q=0;q<len_EM_S;++q) EM_S[q]=0;
88     for (q=0;q<len_EM_F;++q) EM_F[q]=0;
89     add_EM_F=FALSE;
90     add_EM_S=FALSE;
91     /**************************************************************/
92     /* process A: */
93     /**************************************************************/
94     A_p=getSampleData(A,e);
95     if (NULL!=A_p) {
96     add_EM_S=TRUE;
97     if (extendedA) {
98     for (s=0;s<p.row_NS;s++) {
99     for (r=0;r<p.col_NS;r++) {
100     rtmp=0;
101     for (q=0;q<p.numQuad;q++) {
102     rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)]*A_p[INDEX3(0,0,q,DIM,DIM)]*DSDX[INDEX3(r,0,q,p.row_NN,DIM)];
103     }
104     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp;
105     }
106     }
107     } else {
108     for (s=0;s<p.row_NS;s++) {
109     for (r=0;r<p.col_NS;r++) {
110     rtmp=0;
111     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)]*DSDX[INDEX3(r,0,q,p.row_NN,DIM)];
112     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp*A_p[INDEX2(0,0,DIM)];
113     }
114     }
115     }
116     }
117     /**************************************************************/
118     /* process B: */
119     /**************************************************************/
120     B_p=getSampleData(B,e);
121     if (NULL!=B_p) {
122     add_EM_S=TRUE;
123     if (extendedB) {
124     for (s=0;s<p.row_NS;s++) {
125     for (r=0;r<p.col_NS;r++) {
126     rtmp=0;
127     for (q=0;q<p.numQuad;q++) {
128     rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)]*B_p[INDEX2(0,q,DIM)]*S[INDEX2(r,q,p.row_NS)];
129     }
130     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp;
131     }
132     }
133     } else {
134     for (s=0;s<p.row_NS;s++) {
135     for (r=0;r<p.col_NS;r++) {
136     rtmp=0;
137     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)]*S[INDEX2(r,q,p.row_NS)];
138     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp*B_p[0];
139     }
140     }
141     }
142     }
143     /**************************************************************/
144     /* process C: */
145     /**************************************************************/
146     C_p=getSampleData(C,e);
147     if (NULL!=C_p) {
148     add_EM_S=TRUE;
149     if (extendedC) {
150     for (s=0;s<p.row_NS;s++) {
151     for (r=0;r<p.col_NS;r++) {
152     rtmp=0;
153     for (q=0;q<p.numQuad;q++) {
154     rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*C_p[INDEX2(0,q,DIM)]*DSDX[INDEX3(r,0,q,p.row_NN,DIM)];
155     }
156     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp;
157     }
158     }
159     } else {
160     for (s=0;s<p.row_NS;s++) {
161     for (r=0;r<p.col_NS;r++) {
162     rtmp=0;
163     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*DSDX[INDEX3(r,0,q,p.row_NN,DIM)];
164     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp*C_p[0];
165     }
166     }
167     }
168     }
169     /************************************************************* */
170     /* process D */
171     /**************************************************************/
172     D_p=getSampleData(D,e);
173     if (NULL!=D_p) {
174     add_EM_S=TRUE;
175     if (extendedD) {
176     for (s=0;s<p.row_NS;s++) {
177     for (r=0;r<p.col_NS;r++) {
178     rtmp=0;
179     for (q=0;q<p.numQuad;q++) {
180     rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*D_p[q]*S[INDEX2(r,q,p.row_NS)];
181     }
182     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp;
183     }
184     }
185     } else {
186     for (s=0;s<p.row_NS;s++) {
187     for (r=0;r<p.col_NS;r++) {
188     rtmp=0;
189     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*S[INDEX2(r,q,p.row_NS)];
190     EM_S[INDEX4(0,0,s,r,p.numEqu,p.numComp,p.row_NN)]+=rtmp*D_p[0];
191     }
192     }
193     }
194     }
195     /**************************************************************/
196     /* process X: */
197     /**************************************************************/
198     X_p=getSampleData(X,e);
199     if (NULL!=X_p) {
200     add_EM_F=TRUE;
201     if (extendedX) {
202     for (s=0;s<p.row_NS;s++) {
203     rtmp=0;
204     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)]*X_p[INDEX2(0,q,DIM)];
205     EM_F[INDEX2(0,s,p.numEqu)]+=rtmp;
206     }
207     } else {
208     for (s=0;s<p.row_NS;s++) {
209     rtmp=0;
210     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*DSDX[INDEX3(s,0,q,p.row_NN,DIM)];
211     EM_F[INDEX2(0,s,p.numEqu)]+=rtmp*X_p[0];
212     }
213     }
214     }
215     /**************************************************************/
216     /* process Y: */
217     /**************************************************************/
218     Y_p=getSampleData(Y,e);
219     if (NULL!=Y_p) {
220     add_EM_F=TRUE;
221     if (extendedY) {
222     for (s=0;s<p.row_NS;s++) {
223     rtmp=0;
224     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*Y_p[q];
225     EM_F[INDEX2(0,s,p.numEqu)]+=rtmp;
226     }
227     } else {
228     for (s=0;s<p.row_NS;s++) {
229     rtmp=0;
230     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)];
231     EM_F[INDEX2(0,s,p.numEqu)]+=rtmp*Y_p[0];
232     }
233     }
234     }
235     /***********************************************************************************************/
236     /* add the element matrices onto the matrix and right hand side */
237     /***********************************************************************************************/
238     for (q=0;q<p.row_NN;q++) row_index[q]=p.row_DOF[elements->Nodes[INDEX2(p.row_node[q],e,p.NN)]];
239     if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound);
240     if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S);
241    
242     } /* end color check */
243     } /* end element loop */
244     } /* end color loop */
245     } /* end parallel region */
246     }
247     /*
248     * $Log$
249     */

  ViewVC Help
Powered by ViewVC 1.1.26