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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations)
Fri Jul 8 04:08:13 2005 UTC (13 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Assemble_integrate.c
File MIME type: text/plain
File size: 5581 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* assemblage routines: integrates data on quadrature points */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia, 2003,2004 */
10 /* author: gross@access.edu.au */
11 /* Version: $Id$ */
12
13 /**************************************************************/
14
15 #include "escript/Data/DataC.h"
16 #include "Finley.h"
17 #include "Assemble.h"
18 #include "NodeFile.h"
19 #include "ElementFile.h"
20 #include "Util.h"
21 #ifdef _OPENMP
22 #include <omp.h>
23 #endif
24
25 /**************************************************************/
26
27 void Finley_Assemble_integrate(Finley_NodeFile* nodes, Finley_ElementFile* elements,escriptDataC* data,double* out) {
28 type_t datacase;
29 index_t node_offset;
30 dim_t q,e,i;
31 double *local_X, *dVdv, *Vol,*out_local,*data_array,rtmp;
32 if (nodes==NULL || elements==NULL) return;
33 dim_t NN=elements->ReferenceElement->Type->numNodes;
34 dim_t NS=elements->ReferenceElement->Type->numShapes;
35 type_t data_type=getFunctionSpaceType(data);
36 dim_t numComps=getDataPointSize(data);
37 dim_t numQuad=elements->ReferenceElement->numQuadNodes;
38 dim_t numDim=nodes->numDim;
39 dim_t numDim_local=elements->ReferenceElement->Type->numDim;
40
41 /* set some parameter */
42
43 if (data_type==FINLEY_ELEMENTS) {
44 datacase=0;
45 node_offset=0;
46 } else if (data_type==FINLEY_FACE_ELEMENTS) {
47 datacase=1;
48 node_offset=0;
49 } else if (data_type==FINLEY_CONTACT_ELEMENTS_1) {
50 datacase=1;
51 node_offset=0;
52 } else if (data_type==FINLEY_CONTACT_ELEMENTS_2) {
53 datacase=1;
54 node_offset=NN-NS;
55 } else {
56 Finley_ErrorCode=TYPE_ERROR;
57 sprintf(Finley_ErrorMsg,"integration of data is not possible.");
58 }
59
60 /* check the shape of the data */
61
62 if (! numSamplesEqual(data,numQuad,elements->numElements)) {
63 Finley_ErrorCode=TYPE_ERROR;
64 sprintf(Finley_ErrorMsg,"illegal number of samples of integrant kernel Data object");
65 }
66
67 /* now we can start */
68
69 if (Finley_ErrorCode==NO_ERROR) {
70 for (q=0;q<numComps;q++) out[q]=0;
71 #pragma omp parallel private(local_X,dVdv,Vol,out_local,i)
72 {
73
74 /* allocation of work arrays */
75
76 local_X=dVdv=Vol=out_local=NULL;
77 out_local=THREAD_MEMALLOC(numComps,double);
78 dVdv=THREAD_MEMALLOC(numQuad*numDim_local*numDim,double);
79 Vol=THREAD_MEMALLOC(numQuad,double);
80 local_X=THREAD_MEMALLOC(NS*numDim,double);
81
82 if (! (Finley_checkPtr(Vol) || Finley_checkPtr(local_X) || Finley_checkPtr(dVdv) || Finley_checkPtr(out_local))) {
83
84 /* initialize local result */
85
86 for (i=0;i<numComps;i++) out_local[i]=0;
87
88 /* open the element loop */
89
90 #pragma omp for private(e,q,data_array,rtmp) schedule(static)
91 for(e=0;e<elements->numElements;e++) {
92 /* gather local coordinates of nodes into local_X: */
93 Finley_Util_Gather_double(NS,&(elements->Nodes[INDEX2(node_offset,e,NN)]),numDim,nodes->Coordinates,local_X);
94 /* calculate dVdv(i,j,q)=V(i,k)*DSDv(k,j,q) */
95 Finley_Util_SmallMatMult(numDim,numDim_local*numQuad,dVdv,NS,local_X,elements->ReferenceElement->dSdv);
96 /* calculate volume /area elements */
97 switch (datacase) {
98 case 0:
99 Finley_Util_DetOfSmallMat(numQuad,numDim,dVdv,Vol);
100 break;
101 case 1:
102 Finley_LengthOfNormalVector(numQuad,numDim,numDim_local,dVdv,Vol);
103 break;
104 }
105 /* out=out+ integrals */
106 data_array=getSampleData(data,e);
107 if (isExpanded(data)) {
108 for (q=0;q<numQuad;q++) {
109 rtmp=ABS(Vol[q])*elements->ReferenceElement->QuadWeights[q];
110 for (i=0;i<numComps;i++) out_local[i]+=data_array[INDEX2(i,q,numComps)]*rtmp;
111 }
112 } else {
113 rtmp=0.;
114 for (q=0;q<numQuad;q++) rtmp+=ABS(Vol[q])*elements->ReferenceElement->QuadWeights[q];
115 for (i=0;i<numComps;i++) out_local[i]+=data_array[i]*rtmp;
116 }
117 }
118
119 /* add local results to global result */
120 #pragma omp critical
121 for (i=0;i<numComps;i++) out[i]+=out_local[i];
122
123 }
124 THREAD_MEMFREE(local_X);
125 THREAD_MEMFREE(dVdv);
126 THREAD_MEMFREE(Vol);
127 THREAD_MEMFREE(out_local);
128 }
129 }
130 }
131
132 /*
133 * $Log$
134 * Revision 1.5 2005/07/08 04:07:48 jgs
135 * Merge of development branch back to main trunk on 2005-07-08
136 *
137 * Revision 1.4 2004/12/15 07:08:32 jgs
138 * *** empty log message ***
139 * Revision 1.1.1.1.2.2 2005/06/29 02:34:48 gross
140 * some changes towards 64 integers in finley
141 *
142 * Revision 1.1.1.1.2.1 2004/11/24 01:37:12 gross
143 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
144 *
145 *
146 *
147 */

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26