/[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 2748 - (show annotations)
Tue Nov 17 07:32:59 2009 UTC (10 years, 6 months ago) by gross
File MIME type: text/plain
File size: 3714 byte(s)
Macro elements are implemented now. VTK writer for macro elements still needs testing.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2009 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 Paso_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 void* buffer=allocSampleBuffer(data);
54 for (q=0;q<numComps;q++) out[q]=0;
55 #pragma omp parallel private(q,i,rtmp,data_array,out_local)
56 {
57 out_local=THREAD_MEMALLOC(numComps,double);
58 if (! Finley_checkPtr(out_local) ) {
59 /* initialize local result */
60
61 for (i=0;i<numComps;i++) out_local[i]=0;
62
63 /* open the element loop */
64
65 if (isExpanded(data)) {
66 #pragma omp for private(e) schedule(static)
67 for(e=0;e<elements->numElements;e++) {
68 if (elements->Owner[e] == my_mpi_rank) {
69 data_array=getSampleDataRO(data,e,buffer);
70 for (q=0;q<numQuadTotal;q++) {
71 for (i=0;i<numComps;i++) out_local[i]+=data_array[INDEX2(i,q,numComps)]*jac->volume[INDEX2(q,e,numQuadTotal)];
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 data_array=getSampleDataRO(data,e,buffer);
80 rtmp=0.;
81 for (q=0;q<numQuadTotal;q++) rtmp+=jac->volume[INDEX2(q,e,numQuadTotal)];
82 for (i=0;i<numComps;i++) out_local[i]+=data_array[i]*rtmp;
83 }
84 }
85 }
86 /* add local results to global result */
87 #pragma omp critical
88 for (i=0;i<numComps;i++) out[i]+=out_local[i];
89 }
90 THREAD_MEMFREE(out_local);
91 }
92 freeSampleBuffer(buffer);
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