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

Annotation of /trunk/finley/src/Assemble_AverageElementData.c

Parent Directory Parent Directory | Revision Log Revision Log


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

1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 ksteube 1312 /* assemblage routines: copies data between elements */
18 jgs 82
19     /**************************************************************/
20    
21 jgs 150 #include "Assemble.h"
22 jgs 82 #include "Util.h"
23     #ifdef _OPENMP
24     #include <omp.h>
25     #endif
26     /******************************************************************************************************/
27    
28    
29 gross 1116 void Finley_Assemble_AverageElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {
30     dim_t n,q, numElements, numQuad_in, numQuad_out, i;
31     double *in_array,*out_array, vol, volinv, *wq;
32     register double rtmp;
33 jgs 123 dim_t numComps=getDataPointSize(out);
34 ksteube 1312 size_t numComps_size;
35 phornby 1030
36 gross 1062 Finley_resetError();
37 phornby 1030 if( elements == NULL )
38     {
39     return;
40     }
41    
42     numElements=elements->numElements;
43 gross 1062 if (Finley_Assemble_reducedIntegrationOrder(in)) {
44 gross 1116 numQuad_in=elements->ReferenceElementReducedOrder->numQuadNodes;
45     wq=elements->ReferenceElementReducedOrder->QuadWeights;
46 gross 1062 } else {
47 gross 1116 numQuad_in=elements->ReferenceElement->numQuadNodes;
48     wq=elements->ReferenceElement->QuadWeights;
49 gross 1062 }
50 gross 1116 if (Finley_Assemble_reducedIntegrationOrder(out)) {
51     numQuad_out=elements->ReferenceElementReducedOrder->numQuadNodes;
52     } else {
53     numQuad_out=elements->ReferenceElement->numQuadNodes;
54     }
55 phornby 1030
56 jgs 82 /* check out and in */
57     if (numComps!=getDataPointSize(in)) {
58 gross 1116 Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: number of components of input and output Data do not match.");
59     } else if (!numSamplesEqual(in,numQuad_in,numElements)) {
60     Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: illegal number of samples of input Data object");
61     } else if (!numSamplesEqual(out,numQuad_out,numElements)) {
62     Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: illegal number of samples of output Data object");
63 jgs 82 } else if (!isExpanded(out)) {
64 gross 1116 Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: expanded Data object is expected for output data.");
65 jgs 82 }
66    
67     /* now we can start */
68    
69 jgs 150 if (Finley_noError()) {
70 jgs 82 if (isExpanded(in)) {
71 gross 1116 vol=0;
72     for (q=0; q< numQuad_in;++q) vol+=wq[q];
73     volinv=1./vol;
74     # pragma omp parallel for private(n, i, rtmp, q, in_array, out_array) schedule(static)
75     for (n=0;n<numElements;n++) {
76     in_array=getSampleData(in,n);
77     out_array=getSampleData(out,n);
78     for (i=0; i<numComps; ++i) {
79     rtmp=0;
80     for (q=0; q< numQuad_in;++q) rtmp+=in_array[INDEX2(i,q,numComps)]*wq[q];
81     rtmp*=volinv;
82     for (q=0; q< numQuad_out;++q) out_array[INDEX2(i,q,numComps)]=rtmp;
83     }
84     }
85 jgs 82 } else {
86 ksteube 1312 numComps_size=numComps*sizeof(double);
87 jgs 82 # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)
88     for (n=0;n<numElements;n++) {
89     in_array=getSampleData(in,n);
90     out_array=getSampleData(out,n);
91 ksteube 1312 for (q=0;q<numQuad_out;q++) memcpy(out_array+q*numComps,in_array,numComps_size);
92 jgs 82 }
93     }
94     }
95     return;
96     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26