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

Contents of /trunk-mpi-branch/finley/src/Assemble_AverageElementData.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1223 - (show annotations)
Fri Aug 3 02:40:39 2007 UTC (11 years, 8 months ago) by gross
File MIME type: text/plain
File size: 4029 byte(s)
first attemt towards an improved MPI version.  

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

  ViewVC Help
Powered by ViewVC 1.1.26