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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2271 - (show annotations)
Mon Feb 16 05:08:29 2009 UTC (10 years, 2 months ago) by jfenwick
Original Path: trunk/finley/src/Assemble_interpolate.c
File MIME type: text/plain
File size: 6336 byte(s)
Merging version 2269 to trunk

1
2 /*******************************************************
3 *
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
14
15 /**************************************************************/
16
17 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration 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
30 void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
31 __const double *data_array;
32 double* local_data=NULL,*S=NULL;
33 index_t dof_offset, NN, NS;
34 bool_t reduced_integration=FALSE;
35 dim_t q,i,NS_DOF,NN_DOF,numNodes=0,e, numQuad;
36 Finley_RefElement* reference_element=NULL;
37 dim_t numComps=getDataPointSize(data);
38 index_t id[MAX_numNodes], *resort_nodes=0, *map=0;
39 type_t data_type=getFunctionSpaceType(data);
40 type_t type;
41 size_t numComps_size;
42 Finley_resetError();
43 #define NODES 0
44 #define REDUCED_NODES 3
45 #define DOF 1
46 #define REDUCED_DOF 2
47 if (nodes==NULL || elements==NULL) return;
48
49 NN=elements->numNodes;
50 NS=elements->ReferenceElement->Type->numShapes;
51 reduced_integration = Finley_Assemble_reducedIntegrationOrder(interpolated_data);
52 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 if (reduced_integration) {
60 reference_element=elements->ReferenceElementReducedOrder;
61 } else {
62 reference_element=elements->ReferenceElement;
63 }
64 numNodes=Finley_NodeFile_getNumNodes(nodes);
65 map=Finley_NodeFile_borrowTargetNodes(nodes);
66 } else if (data_type==FINLEY_REDUCED_NODES) {
67 type=REDUCED_NODES;
68 resort_nodes=elements->ReferenceElement->Type->linearNodes;
69 if (reduced_integration) {
70 reference_element=elements->LinearReferenceElementReducedOrder;
71 } else {
72 reference_element=elements->LinearReferenceElement;
73 }
74 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
75 map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
76 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
77 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 type=DOF;
82 resort_nodes=id;
83 if (reduced_integration) {
84 reference_element=elements->ReferenceElementReducedOrder;
85 } else {
86 reference_element=elements->ReferenceElement;
87 }
88 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
89 map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
90 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
91 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 type=REDUCED_DOF;
96 resort_nodes=elements->ReferenceElement->Type->linearNodes;
97 if (reduced_integration) {
98 reference_element=elements->LinearReferenceElementReducedOrder;
99 } else {
100 reference_element=elements->LinearReferenceElement;
101 }
102 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
103 map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
104 } else {
105 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
106 }
107 NN_DOF=reference_element->Type->numNodes;
108 NS_DOF=reference_element->Type->numShapes;
109 S=reference_element->S;
110 numQuad=reference_element->numQuadNodes;
111 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 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
121 } else if (! numSamplesEqual(data,1,numNodes)) {
122 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
123 } else if (numComps!=getDataPointSize(interpolated_data)) {
124 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
125 } else if (!isExpanded(interpolated_data)) {
126 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
127 }
128
129 /* now we can start */
130
131 if (Finley_noError()) {
132 void* buffer=allocSampleBuffer(data);
133 requireWrite(interpolated_data);
134 #pragma omp parallel private(local_data, numComps_size)
135 {
136
137 local_data=NULL;
138 /* allocation of work arrays */
139 local_data=THREAD_MEMALLOC(NS*numComps,double);
140 if (! Finley_checkPtr(local_data)) {
141
142 numComps_size=(size_t)numComps*sizeof(double);
143 /* 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 for (q=0;q<NS_DOF;q++) {
148 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
149 data_array=getSampleDataRO(data,map[i],buffer);
150 memcpy(local_data+q*numComps, data_array, numComps_size);
151 }
152 /* calculate interpolated_data=local_data*S */
153
154 Finley_Util_SmallMatMult(numComps,numQuad,getSampleDataRW(interpolated_data,e),NS_DOF,local_data,S);
155
156 } /* end of element loop */
157
158 }
159 THREAD_MEMFREE(local_data);
160 } /* end of parallel region */
161 freeSampleBuffer(buffer);
162 }
163 #undef NODES
164 #undef REDUCED_NODES
165 #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