/[escript]/trunk/finley/src/Assemble_PDE_Single2_C.c
ViewVC logotype

Annotation of /trunk/finley/src/Assemble_PDE_Single2_C.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years ago) by ksteube
File MIME type: text/plain
File size: 6791 byte(s)
Copyright updated in all files

1 gross 798
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 ksteube 1312
14 ksteube 1811
15 gross 798 /**************************************************************/
16    
17     /* assembles a single PDEs into the stiffness matrix S right hand side F */
18    
19     /* D u_m and Y */
20    
21     /* in a 3D domain. The shape functions for test and solution must be identical */
22     /* and 2* row_NS == row_NN (contact elements) */
23    
24     /* Shape of the coefficients: */
25    
26     /* D = scalar */
27     /* Y = scalar */
28    
29    
30     /**************************************************************/
31    
32    
33     #include "Assemble.h"
34     #include "Util.h"
35 gross 853 #ifdef _OPENMP
36     #include <omp.h>
37     #endif
38 gross 798
39 gross 853
40 gross 798 /**************************************************************/
41    
42     void Finley_Assemble_PDE_Single2_C(Assemble_Parameters p, Finley_ElementFile* elements,
43     Paso_SystemMatrix* Mat, escriptDataC* F, escriptDataC* D, escriptDataC* Y) {
44    
45     index_t color;
46     dim_t e;
47 gross 853 double *EM_S, *EM_F, *Vol, *D_p, *Y_p;
48     index_t *row_index;
49     register dim_t q, s,r;
50     register double rtmp, rtmp_D;
51     bool_t add_EM_F, add_EM_S;
52    
53 gross 798 bool_t extendedD=isExpanded(D);
54     bool_t extendedY=isExpanded(Y);
55     double *F_p=getSampleData(F,0);
56     double *S=p.row_jac->ReferenceElement->S;
57    
58    
59 gross 853 #pragma omp parallel private(color,EM_S, EM_F, Vol, D_p, Y_p,row_index,q, s,r,rtmp, rtmp_D,add_EM_F, add_EM_S)
60 gross 798 {
61 gross 853 EM_S=THREAD_MEMALLOC(p.row_NN*p.col_NN,double);
62     EM_F=THREAD_MEMALLOC(p.row_NN,double);
63     row_index=THREAD_MEMALLOC(p.row_NN,index_t);
64    
65     if (!Finley_checkPtr(EM_S) && !Finley_checkPtr(EM_F) && !Finley_checkPtr(row_index) ) {
66    
67     for (color=elements->minColor;color<=elements->maxColor;color++) {
68     /* open loop over all elements: */
69     #pragma omp for private(e) schedule(static)
70     for(e=0;e<elements->numElements;e++){
71     if (elements->Color[e]==color) {
72     Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]);
73     add_EM_F=FALSE;
74     add_EM_S=FALSE;
75     /************************************************************* */
76     /* process D */
77     /**************************************************************/
78     D_p=getSampleData(D,e);
79     if (NULL!=D_p) {
80     add_EM_S=TRUE;
81     if (extendedD) {
82     for (s=0;s<p.row_NS;s++) {
83     for (r=0;r<p.col_NS;r++) {
84     rtmp=0;
85     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*D_p[q]*S[INDEX2(r,q,p.row_NS)];
86     EM_S[INDEX4(0,0,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp;
87     EM_S[INDEX4(0,0,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
88     EM_S[INDEX4(0,0,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
89     EM_S[INDEX4(0,0,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp;
90     }
91     }
92     } else {
93     for (s=0;s<p.row_NS;s++) {
94     for (r=0;r<p.col_NS;r++) {
95     rtmp=0;
96     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*S[INDEX2(r,q,p.row_NS)];
97     rtmp_D=rtmp*D_p[0];
98     EM_S[INDEX4(0,0,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
99     EM_S[INDEX4(0,0,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
100     EM_S[INDEX4(0,0,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
101     EM_S[INDEX4(0,0,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
102     }
103     }
104     }
105     }
106     /**************************************************************/
107     /* process Y: */
108     /**************************************************************/
109     Y_p=getSampleData(Y,e);
110     if (NULL!=Y_p) {
111     add_EM_F=TRUE;
112     if (extendedY) {
113     for (s=0;s<p.row_NS;s++) {
114     rtmp=0;
115     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*Y_p[q];
116     EM_F[INDEX2(0,s ,p.numEqu)]=-rtmp;
117     EM_F[INDEX2(0,s+p.row_NS,p.numEqu)]= rtmp;
118 gross 798 }
119 gross 853 } else {
120     for (s=0;s<p.row_NS;s++) {
121 gross 798 rtmp=0;
122 gross 853 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)];
123     rtmp_D=rtmp*Y_p[0];
124     EM_F[INDEX2(0,s ,p.numEqu)]=-rtmp_D;
125     EM_F[INDEX2(0,s+p.row_NS,p.numEqu)]= rtmp_D;
126 gross 798 }
127     }
128 gross 853 }
129     /***********************************************************************************************/
130     /* add the element matrices onto the matrix and right hand side */
131     /***********************************************************************************************/
132     for (q=0;q<p.row_NN;q++) row_index[q]=p.row_DOF[elements->Nodes[INDEX2(p.row_node[q],e,p.row_NN)]];
133    
134     if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound);
135     if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S);
136    
137     } /* end color check */
138     } /* end element loop */
139     } /* end color loop */
140    
141     THREAD_MEMFREE(EM_S);
142     THREAD_MEMFREE(EM_F);
143     THREAD_MEMFREE(row_index);
144 gross 798
145 gross 853 } /* end of pointer check */
146 gross 798 } /* end parallel region */
147     }
148     /*
149     * $Log$
150     */

  ViewVC Help
Powered by ViewVC 1.1.26