/[escript]/branches/domexper/dudley/src/Assemble_AverageElementData.c
ViewVC logotype

Contents of /branches/domexper/dudley/src/Assemble_AverageElementData.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3152 - (show annotations)
Fri Sep 3 05:48:31 2010 UTC (9 years, 2 months ago) by jfenwick
File MIME type: text/plain
File size: 3843 byte(s)
Collapsed duplicate fields
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 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 Dudley_Assemble_AverageElementData(Dudley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {
30 dim_t n,q, numElements, numQuad_in, numQuad_out, i;
31 __const double *in_array;
32 double *out_array, vol, volinv, *wq;
33 register double rtmp;
34 dim_t numComps=getDataPointSize(out);
35 size_t numComps_size;
36
37 Dudley_resetError();
38 if( elements == NULL )
39 {
40 return;
41 }
42
43 numElements=elements->numElements;
44 if (Dudley_Assemble_reducedIntegrationOrder(in)) {
45 numQuad_in=elements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->numQuadNodes;
46 wq=elements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->QuadWeights;
47 } else {
48 numQuad_in=elements->referenceElementSet->referenceElement->BasisFunctions->numQuadNodes;
49 wq=elements->referenceElementSet->referenceElement->BasisFunctions->QuadWeights;
50 }
51 if (Dudley_Assemble_reducedIntegrationOrder(out)) {
52 numQuad_out=elements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->numQuadNodes;
53 } else {
54 numQuad_out=elements->referenceElementSet->referenceElement->BasisFunctions->numQuadNodes;
55 }
56
57 /* check out and in */
58 if (numComps!=getDataPointSize(in)) {
59 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_AverageElementData: number of components of input and output Data do not match.");
60 } else if (!numSamplesEqual(in,numQuad_in,numElements)) {
61 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_AverageElementData: illegal number of samples of input Data object");
62 } else if (!numSamplesEqual(out,numQuad_out,numElements)) {
63 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_AverageElementData: illegal number of samples of output Data object");
64 } else if (!isExpanded(out)) {
65 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_AverageElementData: expanded Data object is expected for output data.");
66 }
67
68 /* now we can start */
69
70 if (Dudley_noError()) {
71 if (isExpanded(in)) {
72 vol=0;
73 for (q=0; q< numQuad_in;++q) vol+=wq[q];
74 volinv=1./vol;
75 requireWrite(out);
76 #pragma omp parallel private(n, i, rtmp, q, in_array, out_array)
77 {
78 # pragma omp for schedule(static)
79 for (n=0;n<numElements;n++) {
80 in_array=getSampleDataRO(in,n);
81 out_array=getSampleDataRW(out,n);
82 for (i=0; i<numComps; ++i) {
83 rtmp=0;
84 for (q=0; q< numQuad_in;++q) rtmp+=in_array[INDEX2(i,q,numComps)]*wq[q];
85 rtmp*=volinv;
86 for (q=0; q< numQuad_out;++q) out_array[INDEX2(i,q,numComps)]=rtmp;
87 }
88 }
89 }
90 } else {
91 numComps_size=numComps*sizeof(double);
92 requireWrite(out);
93 #pragma omp parallel private(q,n,out_array,in_array)
94 {
95 # pragma omp for schedule(static)
96 for (n=0;n<numElements;n++) {
97 in_array=getSampleDataRO(in,n);
98 out_array=getSampleDataRW(out,n);
99 for (q=0;q<numQuad_out;q++) memcpy(out_array+q*numComps,in_array,numComps_size);
100 }
101 }
102 }
103 }
104 return;
105 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26