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

Contents of /trunk/finley/src/Assemble_PDE_System2_C.c

Parent Directory Parent Directory | Revision Log Revision Log


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

1
2 /*******************************************************
3 *
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
14
15 /**************************************************************/
16
17 /* assembles the system of numEq PDEs into the stiffness matrix S right hand side F */
18
19 /* D_{k,m} u_m and Y_k */
20
21 /* u has p.numComp components 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 = p.numEqu x p.numComp */
27 /* Y = p.numEqu */
28
29
30 /**************************************************************/
31
32 /* Author: gross@access.edu.au */
33 /* Version: $Id:$ */
34
35 /**************************************************************/
36
37
38 #include "Assemble.h"
39 #include "Util.h"
40 #ifdef _OPENMP
41 #include <omp.h>
42 #endif
43
44
45 /**************************************************************/
46
47 void Finley_Assemble_PDE_System2_C(Assemble_Parameters p, Finley_ElementFile* elements,
48 Paso_SystemMatrix* Mat, escriptDataC* F, escriptDataC* D, escriptDataC* Y) {
49
50 index_t color;
51 dim_t e;
52 double *EM_S, *EM_F, *Vol, *D_p, *Y_p;
53 index_t *row_index;
54 register dim_t q, s,r,k,m;
55 register double rtmp, rtmp_D;
56 bool_t add_EM_F, add_EM_S;
57
58 bool_t extendedD=isExpanded(D);
59 bool_t extendedY=isExpanded(Y);
60 double *F_p=getSampleData(F,0);
61 double *S=p.row_jac->ReferenceElement->S;
62
63
64 #pragma omp parallel private(color,EM_S, EM_F, Vol, D_p, Y_p,row_index,q, s,r,k,m,rtmp, rtmp_D,add_EM_F, add_EM_S)
65 {
66 EM_S=THREAD_MEMALLOC(p.row_NN*p.col_NN*p.numEqu*p.numComp,double);
67 EM_F=THREAD_MEMALLOC(p.row_NN*p.numEqu,double);
68 row_index=THREAD_MEMALLOC(p.row_NN,index_t);
69
70 if (!Finley_checkPtr(EM_S) && !Finley_checkPtr(EM_F) && !Finley_checkPtr(row_index) ) {
71
72 for (color=elements->minColor;color<=elements->maxColor;color++) {
73 /* open loop over all elements: */
74 #pragma omp for private(e) schedule(static)
75 for(e=0;e<elements->numElements;e++){
76 if (elements->Color[e]==color) {
77 Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]);
78 add_EM_F=FALSE;
79 add_EM_S=FALSE;
80 /************************************************************* */
81 /* process D */
82 /**************************************************************/
83 D_p=getSampleData(D,e);
84 if (NULL!=D_p) {
85 add_EM_S=TRUE;
86 if (extendedD) {
87 for (s=0;s<p.row_NS;s++) {
88 for (r=0;r<p.col_NS;r++) {
89 for (k=0;k<p.numEqu;k++) {
90 for (m=0;m<p.numComp;m++) {
91 rtmp=0;
92 for (q=0;q<p.numQuad;q++) {
93 rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*D_p[INDEX3(k,m,q,p.numEqu,p.numComp)]*S[INDEX2(r,q,p.row_NS)];
94 }
95 EM_S[INDEX4(k,m,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp;
96 EM_S[INDEX4(k,m,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
97 EM_S[INDEX4(k,m,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
98 EM_S[INDEX4(k,m,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp;
99 }
100 }
101 }
102 }
103 } else {
104 for (s=0;s<p.row_NS;s++) {
105 for (r=0;r<p.col_NS;r++) {
106 rtmp=0;
107 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*S[INDEX2(r,q,p.row_NS)];
108 for (k=0;k<p.numEqu;k++) {
109 for (m=0;m<p.numComp;m++) {
110 rtmp_D=rtmp*D_p[INDEX2(k,m,p.numEqu)];
111 EM_S[INDEX4(k,m,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
112 EM_S[INDEX4(k,m,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
113 EM_S[INDEX4(k,m,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
114 EM_S[INDEX4(k,m,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
115 }
116 }
117 }
118 }
119 }
120 }
121 /**************************************************************/
122 /* process Y: */
123 /**************************************************************/
124 Y_p=getSampleData(Y,e);
125 if (NULL!=Y_p) {
126 add_EM_F=TRUE;
127 if (extendedY) {
128 for (s=0;s<p.row_NS;s++) {
129 for (k=0;k<p.numEqu;k++) {
130 rtmp=0;
131 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*Y_p[INDEX2(k,q,p.numEqu)];
132 EM_F[INDEX2(k,s ,p.numEqu)]=-rtmp;
133 EM_F[INDEX2(k,s+p.row_NS,p.numEqu)]= rtmp;
134 }
135 }
136 } else {
137 for (s=0;s<p.row_NS;s++) {
138 rtmp=0;
139 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)];
140 for (k=0;k<p.numEqu;k++) {
141 rtmp_D=rtmp*Y_p[k];
142 EM_F[INDEX2(k,s ,p.numEqu)]=-rtmp_D;
143 EM_F[INDEX2(k,s+p.row_NS,p.numEqu)]= rtmp_D;
144 }
145 }
146 }
147 }
148 /***********************************************************************************************/
149 /* add the element matrices onto the matrix and right hand side */
150 /***********************************************************************************************/
151 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)]];
152 if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound);
153 if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S);
154
155 } /* end color check */
156 } /* end element loop */
157 } /* end color loop */
158
159 THREAD_MEMFREE(EM_S);
160 THREAD_MEMFREE(EM_F);
161 THREAD_MEMFREE(row_index);
162
163 } /* end of pointer check */
164 } /* end parallel region */
165 }
166 /*
167 * $Log$
168 */

  ViewVC Help
Powered by ViewVC 1.1.26