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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 123 - (show annotations)
Fri Jul 8 04:08:13 2005 UTC (14 years, 3 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Assemble_interpolate.c
File MIME type: text/plain
File size: 5930 byte(s)
Merge of development branch back to main trunk on 2005-07-08

1 /* $Id$ */
2
3 /**************************************************************/
4
5 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
6
7 /**************************************************************/
8
9 /* Copyrights by ACcESS Australia, 2003,2004 */
10 /* author: gross@access.edu.au */
11 /* Version: $Id$ */
12
13 /**************************************************************/
14
15 #include "Common.h"
16 #include "escript/Data/DataC.h"
17 #include "Finley.h"
18 #include "Assemble.h"
19 #include "NodeFile.h"
20 #include "ElementFile.h"
21 #include "Util.h"
22 #ifdef _OPENMP
23 #include <omp.h>
24 #endif
25
26 /**************************************************************/
27
28
29 void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
30 double* local_data=NULL,*S=NULL,*data_array;
31 index_t dof_offset,*resort_nodes;
32 dim_t q,i,NS_DOF,NN_DOF,numNodes,e;
33 type_t type;
34 #define NODES 0
35 #define DOF 1
36 #define REDUCED_DOF 2
37 if (nodes==NULL || elements==NULL) return;
38 dim_t NN=elements->ReferenceElement->Type->numNodes;
39 dim_t NS=elements->ReferenceElement->Type->numShapes;
40 dim_t numComps=getDataPointSize(data);
41 type_t data_type=getFunctionSpaceType(data);
42 dim_t numQuad=elements->ReferenceElement->numQuadNodes;
43 index_t id[NN];
44 for (i=0;i<NN;i++) id[i]=i;
45
46 /* set some parameter */
47
48 if (data_type==FINLEY_NODES) {
49 type=NODES;
50 resort_nodes=id;
51 NN_DOF=elements->ReferenceElement->Type->numNodes;
52 NS_DOF=elements->ReferenceElement->Type->numShapes;
53 S=elements->ReferenceElement->S;
54 numNodes=nodes->numNodes;
55 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
56 type=DOF;
57 resort_nodes=id;
58 NN_DOF=elements->ReferenceElement->Type->numNodes;
59 NS_DOF=elements->ReferenceElement->Type->numShapes;
60 S=elements->ReferenceElement->S;
61 numNodes=nodes->numDegreesOfFreedom;
62 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
63 type=REDUCED_DOF;
64 resort_nodes=elements->ReferenceElement->Type->linearNodes;
65 NN_DOF=elements->LinearReferenceElement->Type->numNodes;
66 NS_DOF=elements->LinearReferenceElement->Type->numShapes;
67 S=elements->LinearReferenceElement->S;
68 numNodes=nodes->reducedNumDegreesOfFreedom;
69 } else {
70 Finley_ErrorCode=TYPE_ERROR;
71 sprintf(Finley_ErrorMsg,"Cannot interpolate data");
72 }
73
74 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
75 dof_offset=NN_DOF-NS_DOF;
76 } else {
77 dof_offset=0;
78 }
79
80 /* check the dimensions of interpolated_data and data */
81
82 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
83 Finley_ErrorCode=TYPE_ERROR;
84 sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");
85 } else if (! numSamplesEqual(data,1,numNodes)) {
86 Finley_ErrorCode=TYPE_ERROR;
87 sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");
88 } else if (numComps!=getDataPointSize(interpolated_data)) {
89 Finley_ErrorCode=TYPE_ERROR;
90 sprintf(Finley_ErrorMsg,"number of components of input and interpolated Data do not match.");
91 } else if (!isExpanded(interpolated_data)) {
92 Finley_ErrorCode=TYPE_ERROR;
93 sprintf(Finley_ErrorMsg,"expanded Data object is expected for output data.");
94 }
95
96 /* now we can start */
97
98 if (Finley_ErrorCode==NO_ERROR) {
99 #pragma omp parallel private(local_data)
100 {
101 local_data=NULL;
102 /* allocation of work arrays */
103 local_data=THREAD_MEMALLOC(NS*numComps,double);
104 if (! Finley_checkPtr(local_data)) {
105
106 /* open the element loop */
107
108 #pragma omp for private(e,q,i,data_array) schedule(static)
109 for(e=0;e<elements->numElements;e++) {
110 /* gather local data into local_data(numComps,NS_DOF): */
111 switch (type) {
112 case NODES:
113 for (q=0;q<NS_DOF;q++) {
114 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
115 data_array=getSampleData(data,i);
116 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
117 }
118 break;
119 case DOF:
120 for (q=0;q<NS_DOF;q++) {
121 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
122 data_array=getSampleData(data,nodes->degreeOfFreedom[i]);
123 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
124 }
125 break;
126 case REDUCED_DOF:
127 for (q=0;q<NS_DOF;q++) {
128 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
129 data_array=getSampleData(data,nodes->reducedDegreeOfFreedom[i]);
130 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
131 }
132 break;
133 }
134
135 /* calculate interpolated_data=local_data*S */
136
137 Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
138
139 } /* end of element loop */
140
141 }
142 THREAD_MEMFREE(local_data);
143 } /* end of parallel region */
144 }
145 #undef NODES
146 #undef DOF
147 #undef REDUCED_DOF
148 }
149 /*
150 * $Log$
151 * Revision 1.5 2005/07/08 04:07:48 jgs
152 * Merge of development branch back to main trunk on 2005-07-08
153 *
154 * Revision 1.4 2004/12/15 07:08:32 jgs
155 * *** empty log message ***
156 * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
157 * some changes towards 64 integers in finley
158 *
159 * Revision 1.1.1.1.2.2 2004/11/24 01:37:12 gross
160 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
161 *
162 *
163 *
164 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26