/[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 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (14 years, 5 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Assemble_interpolate.c
File MIME type: text/plain
File size: 5644 byte(s)
Initial revision

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 int dof_offset,q,*resort_nodes,type,i,NS_DOF,NN_DOF,numNodes,e;
32 #define NODES 0
33 #define DOF 1
34 #define REDUCED_DOF 2
35 if (nodes==NULL || elements==NULL) return;
36 int NN=elements->ReferenceElement->Type->numNodes;
37 int NS=elements->ReferenceElement->Type->numShapes;
38 int numComps=getDataPointSize(data);
39 int data_type=getFunctionSpaceType(data);
40 int numQuad=elements->ReferenceElement->numQuadNodes;
41 int id[NN];
42 for (i=0;i<NN;i++) id[i]=i;
43
44 /* set some parameter */
45
46 if (data_type==FINLEY_NODES) {
47 type=NODES;
48 resort_nodes=id;
49 NN_DOF=elements->ReferenceElement->Type->numNodes;
50 NS_DOF=elements->ReferenceElement->Type->numShapes;
51 S=elements->ReferenceElement->S;
52 numNodes=nodes->numNodes;
53 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
54 type=DOF;
55 resort_nodes=id;
56 NN_DOF=elements->ReferenceElement->Type->numNodes;
57 NS_DOF=elements->ReferenceElement->Type->numShapes;
58 S=elements->ReferenceElement->S;
59 numNodes=nodes->numDegreesOfFreedom;
60 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
61 type=REDUCED_DOF;
62 resort_nodes=elements->ReferenceElement->Type->linearNodes;
63 NN_DOF=elements->LinearReferenceElement->Type->numNodes;
64 NS_DOF=elements->LinearReferenceElement->Type->numShapes;
65 S=elements->LinearReferenceElement->S;
66 numNodes=nodes->reducedNumDegreesOfFreedom;
67 } else {
68 Finley_ErrorCode=TYPE_ERROR;
69 sprintf(Finley_ErrorMsg,"Cannot interpolate data");
70 }
71
72 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
73 dof_offset=NN_DOF-NS_DOF;
74 } else {
75 dof_offset=0;
76 }
77
78 /* check the dimensions of interpolated_data and data */
79
80 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
81 Finley_ErrorCode=TYPE_ERROR;
82 sprintf(Finley_ErrorMsg,"illegal number of samples of output Data object");
83 } else if (! numSamplesEqual(data,1,numNodes)) {
84 Finley_ErrorCode=TYPE_ERROR;
85 sprintf(Finley_ErrorMsg,"illegal number of samples of input Data object");
86 } else if (numComps!=getDataPointSize(interpolated_data)) {
87 Finley_ErrorCode=TYPE_ERROR;
88 sprintf(Finley_ErrorMsg,"number of components of input and interpolated Data do not match.");
89 } else if (!isExpanded(interpolated_data)) {
90 Finley_ErrorCode=TYPE_ERROR;
91 sprintf(Finley_ErrorMsg,"expanded Data object is expected for output data.");
92 }
93
94 /* now we can start */
95
96 if (Finley_ErrorCode==NO_ERROR) {
97 #pragma omp parallel private(local_data)
98 {
99 local_data=NULL;
100 /* allocation of work arrays */
101 local_data=(double*) THREAD_MEMALLOC(NS*numComps*sizeof(double));
102 if (! Finley_checkPtr(local_data)) {
103
104 /* open the element loop */
105
106 #pragma omp for private(e,q,i,data_array) schedule(static)
107 for(e=0;e<elements->numElements;e++) {
108 /* gather local data into local_data(numComps,NS_DOF): */
109 switch (type) {
110 case NODES:
111 for (q=0;q<NS_DOF;q++) {
112 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
113 data_array=getSampleData(data,i);
114 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
115 break;
116 case DOF:
117 for (q=0;q<NS_DOF;q++) {
118 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
119 data_array=getSampleData(data,nodes->degreeOfFreedom[i]);
120 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
121 }
122 break;
123 case REDUCED_DOF:
124 for (q=0;q<NS_DOF;q++) {
125 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
126 data_array=getSampleData(data,nodes->reducedDegreeOfFreedom[i]);
127 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
128 }
129 break;
130 }
131
132 /* calculate interpolated_data=local_data*S */
133
134 Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
135
136 } /* end of element loop */
137
138 }
139 THREAD_MEMFREE(local_data);
140 }
141 }
142 }
143 #undef NODES
144 #undef DOF
145 #undef REDUCED_DOF
146 }
147 /*
148 * $Log$
149 * Revision 1.1 2004/10/26 06:53:57 jgs
150 * Initial revision
151 *
152 * Revision 1.2 2004/07/21 05:00:54 gross
153 * name changes in DataC
154 *
155 * Revision 1.1 2004/07/02 04:21:13 gross
156 * Finley C code has been included
157 *
158 *
159 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26