/[escript]/branches/arrayview_from_1695_trunk/finley/src/Assemble_AverageElementData.c
ViewVC logotype

Annotation of /branches/arrayview_from_1695_trunk/finley/src/Assemble_AverageElementData.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1388 - (hide annotations)
Fri Jan 11 07:45:58 2008 UTC (11 years, 7 months ago) by trankine
Original Path: trunk/finley/src/Assemble_AverageElementData.c
File MIME type: text/plain
File size: 3716 byte(s)
And get the *(&(*&(* name right
1 jgs 82
2 ksteube 1312 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 82 /**************************************************************/
17    
18 ksteube 1312 /* assemblage routines: copies data between elements */
19 jgs 82
20     /**************************************************************/
21    
22 jgs 150 #include "Assemble.h"
23 jgs 82 #include "Util.h"
24     #ifdef _OPENMP
25     #include <omp.h>
26     #endif
27     /******************************************************************************************************/
28    
29    
30 gross 1116 void Finley_Assemble_AverageElementData(Finley_ElementFile* elements,escriptDataC* out,escriptDataC* in) {
31     dim_t n,q, numElements, numQuad_in, numQuad_out, i;
32     double *in_array,*out_array, vol, volinv, *wq;
33     register double rtmp;
34 jgs 123 dim_t numComps=getDataPointSize(out);
35 ksteube 1312 size_t numComps_size;
36 phornby 1030
37 gross 1062 Finley_resetError();
38 phornby 1030 if( elements == NULL )
39     {
40     return;
41     }
42    
43     numElements=elements->numElements;
44 gross 1062 if (Finley_Assemble_reducedIntegrationOrder(in)) {
45 gross 1116 numQuad_in=elements->ReferenceElementReducedOrder->numQuadNodes;
46     wq=elements->ReferenceElementReducedOrder->QuadWeights;
47 gross 1062 } else {
48 gross 1116 numQuad_in=elements->ReferenceElement->numQuadNodes;
49     wq=elements->ReferenceElement->QuadWeights;
50 gross 1062 }
51 gross 1116 if (Finley_Assemble_reducedIntegrationOrder(out)) {
52     numQuad_out=elements->ReferenceElementReducedOrder->numQuadNodes;
53     } else {
54     numQuad_out=elements->ReferenceElement->numQuadNodes;
55     }
56 phornby 1030
57 jgs 82 /* check out and in */
58     if (numComps!=getDataPointSize(in)) {
59 gross 1116 Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: number of components of input and output Data do not match.");
60     } else if (!numSamplesEqual(in,numQuad_in,numElements)) {
61     Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: illegal number of samples of input Data object");
62     } else if (!numSamplesEqual(out,numQuad_out,numElements)) {
63     Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: illegal number of samples of output Data object");
64 jgs 82 } else if (!isExpanded(out)) {
65 gross 1116 Finley_setError(TYPE_ERROR,"Finley_Assemble_AverageElementData: expanded Data object is expected for output data.");
66 jgs 82 }
67    
68     /* now we can start */
69    
70 jgs 150 if (Finley_noError()) {
71 jgs 82 if (isExpanded(in)) {
72 gross 1116 vol=0;
73     for (q=0; q< numQuad_in;++q) vol+=wq[q];
74     volinv=1./vol;
75     # pragma omp parallel for private(n, i, rtmp, q, in_array, out_array) schedule(static)
76     for (n=0;n<numElements;n++) {
77     in_array=getSampleData(in,n);
78     out_array=getSampleData(out,n);
79     for (i=0; i<numComps; ++i) {
80     rtmp=0;
81     for (q=0; q< numQuad_in;++q) rtmp+=in_array[INDEX2(i,q,numComps)]*wq[q];
82     rtmp*=volinv;
83     for (q=0; q< numQuad_out;++q) out_array[INDEX2(i,q,numComps)]=rtmp;
84     }
85     }
86 jgs 82 } else {
87 ksteube 1312 numComps_size=numComps*sizeof(double);
88 jgs 82 # pragma omp parallel for private(q,n,out_array,in_array) schedule(static)
89     for (n=0;n<numElements;n++) {
90     in_array=getSampleData(in,n);
91     out_array=getSampleData(out,n);
92 ksteube 1312 for (q=0;q<numQuad_out;q++) memcpy(out_array+q*numComps,in_array,numComps_size);
93 jgs 82 }
94     }
95     }
96     return;
97     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26