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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (8 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 3630 byte(s)
Merging dudley and scons updates from branches

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: integrates data on quadrature points */
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_integrate(Finley_NodeFile* nodes, Finley_ElementFile* elements,escriptDataC* data,double* out) {
30 /* type_t data_type=getFunctionSpaceType(data);*/
31 dim_t numQuadTotal;
32 dim_t numComps=getDataPointSize(data);
33 Finley_ElementFile_Jacobeans* jac=NULL;
34 Esys_MPI_rank my_mpi_rank;
35
36 Finley_resetError();
37 if (nodes==NULL || elements==NULL) return;
38 my_mpi_rank = nodes->MPIInfo->rank;
39 /* set some parameter */
40 jac=Finley_ElementFile_borrowJacobeans(elements,nodes,FALSE,Finley_Assemble_reducedIntegrationOrder(data));
41 if (Finley_noError()) {
42 numQuadTotal=jac->numQuadTotal;
43 /* check the shape of the data */
44 if (! numSamplesEqual(data,numQuadTotal,elements->numElements)) {
45 Finley_setError(TYPE_ERROR,"Finley_Assemble_integrate: illegal number of samples of integrant kernel Data object");
46 }
47 /* now we can start */
48
49 if (Finley_noError()) {
50 dim_t q,e,i;
51 __const double *data_array=NULL;
52 double *out_local=NULL, rtmp;
53 for (q=0;q<numComps;q++) out[q]=0;
54 #pragma omp parallel private(q,i,rtmp,data_array,out_local)
55 {
56 out_local=THREAD_MEMALLOC(numComps,double);
57 if (! Finley_checkPtr(out_local) ) {
58 /* initialize local result */
59
60 for (i=0;i<numComps;i++) out_local[i]=0;
61
62 /* open the element loop */
63
64 if (isExpanded(data)) {
65 #pragma omp for private(e) schedule(static)
66 for(e=0;e<elements->numElements;e++) {
67 if (elements->Owner[e] == my_mpi_rank) {
68 data_array=getSampleDataRO(data,e);
69 for (q=0;q<numQuadTotal;q++) {
70 for (i=0;i<numComps;i++) out_local[i]+=data_array[INDEX2(i,q,numComps)]*jac->volume[INDEX2(q,e,numQuadTotal)];
71 }
72 }
73 }
74 } else {
75 #pragma omp for private(e) schedule(static)
76 for(e=0;e<elements->numElements;e++) {
77 if (elements->Owner[e] == my_mpi_rank) {
78 data_array=getSampleDataRO(data,e);
79 rtmp=0.;
80 for (q=0;q<numQuadTotal;q++) rtmp+=jac->volume[INDEX2(q,e,numQuadTotal)];
81 for (i=0;i<numComps;i++) out_local[i]+=data_array[i]*rtmp;
82 }
83 }
84 }
85 /* add local results to global result */
86 #pragma omp critical
87 for (i=0;i<numComps;i++) out[i]+=out_local[i];
88 }
89 THREAD_MEMFREE(out_local);
90 }
91 }
92 }
93 }
94

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26