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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (hide annotations)
Mon Feb 16 05:08:29 2009 UTC (10 years, 9 months ago) by jfenwick
File MIME type: text/plain
File size: 6336 byte(s)
Merging version 2269 to trunk

1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 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 jgs 82
14 ksteube 1811
15 jgs 82 /**************************************************************/
16    
17 ksteube 1312 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration 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    
30     void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
31 jfenwick 2271 __const double *data_array;
32     double* local_data=NULL,*S=NULL;
33 phornby 1628 index_t dof_offset, NN, NS;
34 gross 1062 bool_t reduced_integration=FALSE;
35 jfenwick 1981 dim_t q,i,NS_DOF,NN_DOF,numNodes=0,e, numQuad;
36 gross 1062 Finley_RefElement* reference_element=NULL;
37 gross 1028 dim_t numComps=getDataPointSize(data);
38 jfenwick 1981 index_t id[MAX_numNodes], *resort_nodes=0, *map=0;
39 gross 1028 type_t data_type=getFunctionSpaceType(data);
40 jgs 123 type_t type;
41 ksteube 1312 size_t numComps_size;
42 gross 1028 Finley_resetError();
43 jgs 82 #define NODES 0
44 gross 1062 #define REDUCED_NODES 3
45 jgs 82 #define DOF 1
46     #define REDUCED_DOF 2
47     if (nodes==NULL || elements==NULL) return;
48 ksteube 1312
49     NN=elements->numNodes;
50 gross 1028 NS=elements->ReferenceElement->Type->numShapes;
51 gross 1062 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
52 jgs 82 for (i=0;i<NN;i++) id[i]=i;
53    
54     /* set some parameter */
55    
56     if (data_type==FINLEY_NODES) {
57     type=NODES;
58     resort_nodes=id;
59 gross 1062 if (reduced_integration) {
60     reference_element=elements->ReferenceElementReducedOrder;
61     } else {
62     reference_element=elements->ReferenceElement;
63     }
64 ksteube 1312 numNodes=Finley_NodeFile_getNumNodes(nodes);
65     map=Finley_NodeFile_borrowTargetNodes(nodes);
66 gross 1062 } else if (data_type==FINLEY_REDUCED_NODES) {
67     type=REDUCED_NODES;
68 ksteube 1312 resort_nodes=elements->ReferenceElement->Type->linearNodes;
69 gross 1062 if (reduced_integration) {
70     reference_element=elements->LinearReferenceElementReducedOrder;
71     } else {
72     reference_element=elements->LinearReferenceElement;
73     }
74 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
75     map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
76 jgs 82 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
77 ksteube 1312 if (elements->MPIInfo->size>1) {
78     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
79     return;
80     }
81 jgs 82 type=DOF;
82     resort_nodes=id;
83 gross 1062 if (reduced_integration) {
84     reference_element=elements->ReferenceElementReducedOrder;
85     } else {
86     reference_element=elements->ReferenceElement;
87     }
88 ksteube 1312 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
89     map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
90 jgs 82 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
91 ksteube 1312 if (elements->MPIInfo->size>1) {
92     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
93     return;
94     }
95 jgs 82 type=REDUCED_DOF;
96     resort_nodes=elements->ReferenceElement->Type->linearNodes;
97 gross 1062 if (reduced_integration) {
98     reference_element=elements->LinearReferenceElementReducedOrder;
99     } else {
100     reference_element=elements->LinearReferenceElement;
101     }
102 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
103     map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
104 jgs 82 } else {
105 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
106 jgs 82 }
107 gross 1062 NN_DOF=reference_element->Type->numNodes;
108     NS_DOF=reference_element->Type->numShapes;
109     S=reference_element->S;
110     numQuad=reference_element->numQuadNodes;
111 jgs 82 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
112     dof_offset=NN_DOF-NS_DOF;
113     } else {
114     dof_offset=0;
115     }
116    
117     /* check the dimensions of interpolated_data and data */
118    
119     if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
120 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
121 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
122 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
123 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
124 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
125 jgs 82 } else if (!isExpanded(interpolated_data)) {
126 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
127 jgs 82 }
128    
129     /* now we can start */
130    
131 jgs 150 if (Finley_noError()) {
132 jfenwick 2271 void* buffer=allocSampleBuffer(data);
133     requireWrite(interpolated_data);
134 ksteube 1312 #pragma omp parallel private(local_data, numComps_size)
135 jgs 82 {
136 jfenwick 2271
137 jgs 82 local_data=NULL;
138     /* allocation of work arrays */
139 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
140 jgs 82 if (! Finley_checkPtr(local_data)) {
141    
142 ksteube 1312 numComps_size=(size_t)numComps*sizeof(double);
143 jgs 82 /* open the element loop */
144    
145     #pragma omp for private(e,q,i,data_array) schedule(static)
146     for(e=0;e<elements->numElements;e++) {
147 ksteube 1312 for (q=0;q<NS_DOF;q++) {
148     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
149 jfenwick 2271 data_array=getSampleDataRO(data,map[i],buffer);
150 ksteube 1312 memcpy(local_data+q*numComps, data_array, numComps_size);
151 jgs 82 }
152     /* calculate interpolated_data=local_data*S */
153    
154 jfenwick 2271 Finley_Util_SmallMatMult(numComps,numQuad,getSampleDataRW(interpolated_data,e),NS_DOF,local_data,S);
155 jgs 82
156     } /* end of element loop */
157    
158     }
159     THREAD_MEMFREE(local_data);
160 jgs 102 } /* end of parallel region */
161 jfenwick 2271 freeSampleBuffer(buffer);
162 jgs 82 }
163     #undef NODES
164 gross 1062 #undef REDUCED_NODES
165 jgs 82 #undef DOF
166     #undef REDUCED_DOF
167     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26