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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3205 - (show annotations)
Fri Sep 24 00:30:43 2010 UTC (8 years, 10 months ago) by jfenwick
File MIME type: text/plain
File size: 3647 byte(s)
Removing -total from field names

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 Dudley_Assemble_integrate(Dudley_NodeFile* nodes, Dudley_ElementFile* elements,escriptDataC* data,double* out) {
30 /* type_t data_type=getFunctionSpaceType(data);*/
31 dim_t numQuadTotal;
32 dim_t numComps=getDataPointSize(data);
33 Dudley_ElementFile_Jacobeans* jac=NULL;
34 Paso_MPI_rank my_mpi_rank;
35
36 Dudley_resetError();
37 if (nodes==NULL || elements==NULL) return;
38 my_mpi_rank = nodes->MPIInfo->rank;
39 /* set some parameter */
40 jac=Dudley_ElementFile_borrowJacobeans(elements,nodes,FALSE,Dudley_Assemble_reducedIntegrationOrder(data));
41 if (Dudley_noError()) {
42 numQuadTotal=jac->numQuad;
43 /* check the shape of the data */
44 if (! numSamplesEqual(data,numQuadTotal,elements->numElements)) {
45 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_integrate: illegal number of samples of integrant kernel Data object");
46 }
47 /* now we can start */
48
49 if (Dudley_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 (! Dudley_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 double vol=jac->absD[e]*jac->quadweight;
70 for (q=0;q<numQuadTotal;q++) {
71 for (i=0;i<numComps;i++) out_local[i]+=data_array[INDEX2(i,q,numComps)]*vol;
72 }
73 }
74 }
75 } else {
76 #pragma omp for private(e) schedule(static)
77 for(e=0;e<elements->numElements;e++) {
78 if (elements->Owner[e] == my_mpi_rank) {
79 double vol=jac->absD[e]*jac->quadweight;
80 data_array=getSampleDataRO(data,e);
81 rtmp=0.;
82 for (q=0;q<numQuadTotal;q++) rtmp+=vol;
83 for (i=0;i<numComps;i++) out_local[i]+=data_array[i]*rtmp;
84 }
85 }
86 }
87 /* add local results to global result */
88 #pragma omp critical
89 for (i=0;i<numComps;i++) out[i]+=out_local[i];
90 }
91 THREAD_MEMFREE(out_local);
92 }
93 }
94 }
95 }
96

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26