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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (hide annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 9 months ago) by trankine
File MIME type: text/plain
File size: 6826 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1 gross 798
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 gross 798 /**************************************************************/
17    
18     /* assembles a single PDEs into the stiffness matrix S right hand side F */
19    
20     /* D u_m and Y */
21    
22     /* in a 3D domain. The shape functions for test and solution must be identical */
23     /* and 2* row_NS == row_NN (contact elements) */
24    
25     /* Shape of the coefficients: */
26    
27     /* D = scalar */
28     /* Y = scalar */
29    
30    
31     /**************************************************************/
32    
33    
34     #include "Assemble.h"
35     #include "Util.h"
36 gross 853 #ifdef _OPENMP
37     #include <omp.h>
38     #endif
39 gross 798
40 gross 853
41 gross 798 /**************************************************************/
42    
43     void Finley_Assemble_PDE_Single2_C(Assemble_Parameters p, Finley_ElementFile* elements,
44     Paso_SystemMatrix* Mat, escriptDataC* F, escriptDataC* D, escriptDataC* Y) {
45    
46     index_t color;
47     dim_t e;
48 gross 853 double *EM_S, *EM_F, *Vol, *D_p, *Y_p;
49     index_t *row_index;
50     register dim_t q, s,r;
51     register double rtmp, rtmp_D;
52     bool_t add_EM_F, add_EM_S;
53    
54 gross 798 bool_t extendedD=isExpanded(D);
55     bool_t extendedY=isExpanded(Y);
56     double *F_p=getSampleData(F,0);
57     double *S=p.row_jac->ReferenceElement->S;
58    
59    
60 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)
61 gross 798 {
62 gross 853 EM_S=THREAD_MEMALLOC(p.row_NN*p.col_NN,double);
63     EM_F=THREAD_MEMALLOC(p.row_NN,double);
64     row_index=THREAD_MEMALLOC(p.row_NN,index_t);
65    
66     if (!Finley_checkPtr(EM_S) && !Finley_checkPtr(EM_F) && !Finley_checkPtr(row_index) ) {
67    
68     for (color=elements->minColor;color<=elements->maxColor;color++) {
69     /* open loop over all elements: */
70     #pragma omp for private(e) schedule(static)
71     for(e=0;e<elements->numElements;e++){
72     if (elements->Color[e]==color) {
73     Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]);
74     add_EM_F=FALSE;
75     add_EM_S=FALSE;
76     /************************************************************* */
77     /* process D */
78     /**************************************************************/
79     D_p=getSampleData(D,e);
80     if (NULL!=D_p) {
81     add_EM_S=TRUE;
82     if (extendedD) {
83     for (s=0;s<p.row_NS;s++) {
84     for (r=0;r<p.col_NS;r++) {
85     rtmp=0;
86     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)];
87     EM_S[INDEX4(0,0,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp;
88     EM_S[INDEX4(0,0,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
89     EM_S[INDEX4(0,0,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp;
90     EM_S[INDEX4(0,0,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp;
91     }
92     }
93     } else {
94     for (s=0;s<p.row_NS;s++) {
95     for (r=0;r<p.col_NS;r++) {
96     rtmp=0;
97     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*S[INDEX2(r,q,p.row_NS)];
98     rtmp_D=rtmp*D_p[0];
99     EM_S[INDEX4(0,0,s ,r ,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
100     EM_S[INDEX4(0,0,s ,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
101     EM_S[INDEX4(0,0,s+p.row_NS,r ,p.numEqu,p.numComp,p.row_NN)]=-rtmp_D;
102     EM_S[INDEX4(0,0,s+p.row_NS,r+p.col_NS,p.numEqu,p.numComp,p.row_NN)]= rtmp_D;
103     }
104     }
105     }
106     }
107     /**************************************************************/
108     /* process Y: */
109     /**************************************************************/
110     Y_p=getSampleData(Y,e);
111     if (NULL!=Y_p) {
112     add_EM_F=TRUE;
113     if (extendedY) {
114     for (s=0;s<p.row_NS;s++) {
115     rtmp=0;
116     for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)]*Y_p[q];
117     EM_F[INDEX2(0,s ,p.numEqu)]=-rtmp;
118     EM_F[INDEX2(0,s+p.row_NS,p.numEqu)]= rtmp;
119 gross 798 }
120 gross 853 } else {
121     for (s=0;s<p.row_NS;s++) {
122 gross 798 rtmp=0;
123 gross 853 for (q=0;q<p.numQuad;q++) rtmp+=Vol[q]*S[INDEX2(s,q,p.row_NS)];
124     rtmp_D=rtmp*Y_p[0];
125     EM_F[INDEX2(0,s ,p.numEqu)]=-rtmp_D;
126     EM_F[INDEX2(0,s+p.row_NS,p.numEqu)]= rtmp_D;
127 gross 798 }
128     }
129 gross 853 }
130     /***********************************************************************************************/
131     /* add the element matrices onto the matrix and right hand side */
132     /***********************************************************************************************/
133     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)]];
134    
135     if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound);
136     if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S);
137    
138     } /* end color check */
139     } /* end element loop */
140     } /* end color loop */
141    
142     THREAD_MEMFREE(EM_S);
143     THREAD_MEMFREE(EM_F);
144     THREAD_MEMFREE(row_index);
145 gross 798
146 gross 853 } /* end of pointer check */
147 gross 798 } /* end parallel region */
148     }
149     /*
150     * $Log$
151     */

  ViewVC Help
Powered by ViewVC 1.1.26