# Contents of /branches/arrexp_2137_win_merge/finley/src/Assemble_PDE_Single2_2D.c

Revision 2222 - (show annotations)
Tue Jan 20 04:52:39 2009 UTC (11 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 14901 byte(s)
```Saving work
```
 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 /* the shape functions for test and solution must be identical */ 19 20 21 /* -(A_{i,j} u_,j)_i-(B_{i} u)_i+C_{j} u_,j-D u_m and -(X_,i)_i + Y */ 22 23 /* in a 2D domain. The shape functions for test and solution must be identical */ 24 /* and row_NS == row_NN */ 25 26 /* Shape of the coefficients: */ 27 28 /* A = 2 x 2 */ 29 /* B = 2 */ 30 /* C = 2 */ 31 /* D = scalar */ 32 /* X = 2 */ 33 /* Y = scalar */ 34 35 36 /**************************************************************/ 37 38 39 #include "Assemble.h" 40 #include "Util.h" 41 #ifdef _OPENMP 42 #include 43 #endif 44 45 /**************************************************************/ 46 47 void Finley_Assemble_PDE_Single2_2D(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 2 52 index_t color; 53 dim_t e; 54 __const double *A_p, *B_p, *C_p, *D_p, *X_p, *Y_p; 55 double *EM_S, *EM_F, *Vol, *DSDX; 56 index_t *row_index; 57 register dim_t q, s,r; 58 register double rtmp00, rtmp01, rtmp10, rtmp11, rtmp, rtmp0, rtmp1; 59 bool_t add_EM_F, add_EM_S; 60 61 bool_t extendedA=isExpanded(A); 62 bool_t extendedB=isExpanded(B); 63 bool_t extendedC=isExpanded(C); 64 bool_t extendedD=isExpanded(D); 65 bool_t extendedX=isExpanded(X); 66 bool_t extendedY=isExpanded(Y); 67 double *F_p=(requireWrite(F), getSampleDataRW(F,0)); /* use comma, to get around the mixed code and declarations thing */ 68 double *S=p.row_jac->ReferenceElement->S; 69 dim_t len_EM_S=p.row_NN*p.col_NN; 70 dim_t len_EM_F=p.row_NN; 71 72 73 #pragma omp parallel private(color,EM_S, EM_F, Vol, DSDX, A_p, B_p, C_p, D_p, X_p, Y_p,row_index,q, s,r,rtmp00, rtmp01, rtmp10, rtmp11, rtmp, rtmp0, rtmp1,add_EM_F, add_EM_S) 74 { 75 void* ABuff=allocSampleBuffer(A); 76 void* BBuff=allocSampleBuffer(B); 77 void* CBuff=allocSampleBuffer(C); 78 void* DBuff=allocSampleBuffer(D); 79 void* XBuff=allocSampleBuffer(X); 80 void* YBuff=allocSampleBuffer(Y); 81 EM_S=THREAD_MEMALLOC(len_EM_S,double); 82 EM_F=THREAD_MEMALLOC(len_EM_F,double); 83 row_index=THREAD_MEMALLOC(p.row_NN,index_t); 84 85 if (!Finley_checkPtr(EM_S) && !Finley_checkPtr(EM_F) && !Finley_checkPtr(row_index) ) { 86 87 for (color=elements->minColor;color<=elements->maxColor;color++) { 88 /* open loop over all elements: */ 89 #pragma omp for private(e) schedule(static) 90 for(e=0;enumElements;e++){ 91 if (elements->Color[e]==color) { 92 Vol=&(p.row_jac->volume[INDEX2(0,e,p.numQuad)]); 93 DSDX=&(p.row_jac->DSDX[INDEX4(0,0,0,e,p.row_NN,DIM,p.numQuad)]); 94 for (q=0;qNodes[INDEX2(p.row_node[q],e,p.NN)]]; 279 if (add_EM_F) Finley_Util_AddScatter(p.row_NN,row_index,p.numEqu,EM_F,F_p, p.row_DOF_UpperBound); 280 if (add_EM_S) Finley_Assemble_addToSystemMatrix(Mat,p.row_NN,row_index,p.numEqu,p.col_NN,row_index,p.numComp,EM_S); 281 282 } /* end color check */ 283 } /* end element loop */ 284 } /* end color loop */ 285 286 THREAD_MEMFREE(EM_S); 287 THREAD_MEMFREE(EM_F); 288 THREAD_MEMFREE(row_index); 289 290 } /* end of pointer check */ 291 freeSampleBuffer(ABuff); 292 freeSampleBuffer(BBuff); 293 freeSampleBuffer(CBuff); 294 freeSampleBuffer(DBuff); 295 freeSampleBuffer(XBuff); 296 freeSampleBuffer(YBuff); 297 } /* end parallel region */ 298 } 299 /* 300 * \$Log\$ 301 */

 ViewVC Help Powered by ViewVC 1.1.26