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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2881 - (hide annotations)
Thu Jan 28 02:03:15 2010 UTC (9 years, 11 months ago) by jfenwick
File MIME type: text/plain
File size: 3630 byte(s)
Don't panic.
Updating copyright stamps

1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 ksteube 1312 /* assemblage routines: integrates data on quadrature points */
18 jgs 82
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 jfenwick 1981 /* type_t data_type=getFunctionSpaceType(data);*/
31 gross 2748 dim_t numQuadTotal;
32 jgs 123 dim_t numComps=getDataPointSize(data);
33 gross 1028 Finley_ElementFile_Jacobeans* jac=NULL;
34 ksteube 1312 Paso_MPI_rank my_mpi_rank;
35    
36 jgs 150 Finley_resetError();
37 gross 1028 if (nodes==NULL || elements==NULL) return;
38 ksteube 1312 my_mpi_rank = nodes->MPIInfo->rank;
39 jgs 82 /* set some parameter */
40 gross 1064 jac=Finley_ElementFile_borrowJacobeans(elements,nodes,FALSE,Finley_Assemble_reducedIntegrationOrder(data));
41 gross 777 if (Finley_noError()) {
42 gross 2748 numQuadTotal=jac->numQuadTotal;
43 gross 777 /* check the shape of the data */
44 gross 2748 if (! numSamplesEqual(data,numQuadTotal,elements->numElements)) {
45 gross 777 Finley_setError(TYPE_ERROR,"Finley_Assemble_integrate: illegal number of samples of integrant kernel Data object");
46     }
47     /* now we can start */
48 jgs 82
49 gross 777 if (Finley_noError()) {
50 gross 853 dim_t q,e,i;
51 gross 2748 __const double *data_array=NULL;
52 jfenwick 2271 double *out_local=NULL, rtmp;
53 gross 777 for (q=0;q<numComps;q++) out[q]=0;
54 gross 853 #pragma omp parallel private(q,i,rtmp,data_array,out_local)
55 gross 777 {
56 gross 853 out_local=THREAD_MEMALLOC(numComps,double);
57     if (! Finley_checkPtr(out_local) ) {
58     /* initialize local result */
59 jgs 82
60 gross 2748 for (i=0;i<numComps;i++) out_local[i]=0;
61 jgs 82
62 gross 853 /* 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 ksteube 1312 if (elements->Owner[e] == my_mpi_rank) {
68 jfenwick 2770 data_array=getSampleDataRO(data,e);
69 gross 2748 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 gross 853 }
72 ksteube 1312 }
73 gross 853 }
74     } else {
75     #pragma omp for private(e) schedule(static)
76     for(e=0;e<elements->numElements;e++) {
77 ksteube 1312 if (elements->Owner[e] == my_mpi_rank) {
78 jfenwick 2770 data_array=getSampleDataRO(data,e);
79 gross 853 rtmp=0.;
80 gross 2748 for (q=0;q<numQuadTotal;q++) rtmp+=jac->volume[INDEX2(q,e,numQuadTotal)];
81 gross 853 for (i=0;i<numComps;i++) out_local[i]+=data_array[i]*rtmp;
82 ksteube 1312 }
83 gross 853 }
84 gross 777 }
85 gross 853 /* add local results to global result */
86     #pragma omp critical
87     for (i=0;i<numComps;i++) out[i]+=out_local[i];
88 gross 777 }
89 gross 853 THREAD_MEMFREE(out_local);
90 gross 777 }
91 gross 2748 }
92     }
93 jgs 82 }
94    

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26