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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

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 /* assemblage routines: copies data between elements */
18
19 /**************************************************************/
20
21 #include "Assemble.h"
22 #include "Util.h"
23 #ifdef _OPENMP
24 #include <omp.h>
25 #endif
26 /******************************************************************************************************/
27
28
29 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 dim_t numComps=getDataPointSize(out);
34 size_t numComps_size;
35
36 Finley_resetError();
37 if( elements == NULL )
38 {
39 return;
40 }
41
42 numElements=elements->numElements;
43 if (Finley_Assemble_reducedIntegrationOrder(in)) {
44 numQuad_in=elements->ReferenceElementReducedOrder->numQuadNodes;
45 wq=elements->ReferenceElementReducedOrder->QuadWeights;
46 } else {
47 numQuad_in=elements->ReferenceElement->numQuadNodes;
48 wq=elements->ReferenceElement->QuadWeights;
49 }
50 if (Finley_Assemble_reducedIntegrationOrder(out)) {
51 numQuad_out=elements->ReferenceElementReducedOrder->numQuadNodes;
52 } else {
53 numQuad_out=elements->ReferenceElement->numQuadNodes;
54 }
55
56 /* check out and in */
57 if (numComps!=getDataPointSize(in)) {
58 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 } else if (!isExpanded(out)) {
64 Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: expanded Data object is expected for output data.");
65 }
66
67 /* now we can start */
68
69 if (Finley_noError()) {
70 if (isExpanded(in)) {
71 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 } else {
86 numComps_size=numComps*sizeof(double);
87 # 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 for (q=0;q<numQuad_out;q++) memcpy(out_array+q*numComps,in_array,numComps_size);
92 }
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