/[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 798 - (show annotations)
Fri Aug 4 01:05:36 2006 UTC (13 years, 2 months ago) by gross
File MIME type: text/plain
File size: 7161 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 /*
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 3.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
17 /* D_{k,m} u_m and Y_k */
18
19 /* u has p.numComp components in a 3D domain. The shape functions for test and solution must be identical */
20 /* and 2* row_NS == row_NN (contact elements) */
21
22 /* Shape of the coefficients: */
23
24 /* D = p.numEqu x p.numComp */
25 /* Y = p.numEqu */
26
27
28 /**************************************************************/
29
30 /* Author: gross@access.edu.au */
31 /* Version: $Id:$ */
32
33 /**************************************************************/
34
35
36 #include "Assemble.h"
37 #include "Util.h"
38
39 /**************************************************************/
40
41 void Finley_Assemble_PDE_System2_C(Assemble_Parameters p, Finley_ElementFile* elements,
42 Paso_SystemMatrix* Mat, escriptDataC* F, escriptDataC* D, escriptDataC* Y) {
43
44 index_t color;
45 dim_t e;
46 bool_t extendedD=isExpanded(D);
47 bool_t extendedY=isExpanded(Y);
48 double *F_p=getSampleData(F,0);
49 double *S=p.row_jac->ReferenceElement->S;
50
51
52 #pragma omp parallel private(color)
53 {
54 double EM_S[p.row_NN*p.col_NN*p.numEqu*p.numComp], EM_F[p.row_NN*p.numEqu];
55 index_t row_index[p.row_NN];
56 register dim_t q, s,r,k,m;
57 register double rtmp, rtmp_D;
58 double *Vol, *D_p, *Y_p;
59 bool_t add_EM_F, add_EM_S;
60 #ifndef PASO_MPI
61 for (color=elements->minColor;color<=elements->maxColor;color++) {
62 /* open loop over all elements: */
63 #pragma omp for private(e) schedule(static)
64 for(e=0;e<elements->numElements;e++){
65 if (elements->Color[e]==color) {
66 #else
67 {
68 for(e=0;e<elements->numElements;e++) {
69 {
70 #endif
71 Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]);
72 add_EM_F=FALSE;
73 add_EM_S=FALSE;
74 /************************************************************* */
75 /* process D */
76 /**************************************************************/
77 D_p=getSampleData(D,e);
78 if (NULL!=D_p) {
79 add_EM_S=TRUE;
80 if (extendedD) {
81 for (s=0;s<p.row_NS;s++) {
82 for (r=0;r<p.col_NS;r++) {
83 for (k=0;k<p.numEqu;k++) {
84 for (m=0;m<p.numComp;m++) {
85 rtmp=0;
86 for (q=0;q<p.numQuad;q++) {
87 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)];
88 }
89 EM_S[INDEX4(k,m,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp;
90 EM_S[INDEX4(k,m,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
91 EM_S[INDEX4(k,m,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
92 EM_S[INDEX4(k,m,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp;
93 }
94 }
95 }
96 }
97 } else {
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++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*S[INDEX2(r,q,p.row_NS)];
102 for (k=0;k<p.numEqu;k++) {
103 for (m=0;m<p.numComp;m++) {
104 rtmp_D=rtmp*D_p[INDEX2(k,m,p.numEqu)];
105 EM_S[INDEX4(k,m,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
106 EM_S[INDEX4(k,m,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
107 EM_S[INDEX4(k,m,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
108 EM_S[INDEX4(k,m,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
109 }
110 }
111 }
112 }
113 }
114 }
115 /**************************************************************/
116 /* process Y: */
117 /**************************************************************/
118 Y_p=getSampleData(Y,e);
119 if (NULL!=Y_p) {
120 add_EM_F=TRUE;
121 if (extendedY) {
122 for (s=0;s<p.row_NS;s++) {
123 for (k=0;k<p.numEqu;k++) {
124 rtmp=0;
125 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*Y_p[INDEX2(k,q,p.numEqu)];
126 EM_F[INDEX2(k,s ,p.numEqu)]=-rtmp;
127 EM_F[INDEX2(k,s+p.row_NS,p.numEqu)]= rtmp;
128 }
129 }
130 } else {
131 for (s=0;s<p.row_NS;s++) {
132 rtmp=0;
133 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)];
134 for (k=0;k<p.numEqu;k++) {
135 rtmp_D=rtmp*Y_p[k];
136 EM_F[INDEX2(k,s ,p.numEqu)]=-rtmp_D;
137 EM_F[INDEX2(k,s+p.row_NS,p.numEqu)]= rtmp_D;
138 }
139 }
140 }
141 }
142 /***********************************************************************************************/
143 /* add the element matrices onto the matrix and right hand side */
144 /***********************************************************************************************/
145 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)]];
146 if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound);
147 if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S);
148
149 } /* end color check */
150 } /* end element loop */
151 } /* end color loop */
152 } /* end parallel region */
153 }
154 /*
155 * $Log$
156 */

  ViewVC Help
Powered by ViewVC 1.1.26