/[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 1062 - (show annotations)
Mon Mar 26 06:17:53 2007 UTC (12 years, 6 months ago) by gross
File MIME type: text/plain
File size: 7761 byte(s)
reduced integration schemes are implemented now for grad, integrate, etc. Tests still to be added.
1 /*
2 ************************************************************
3 * Copyright 2006 by ACcESS MNRF *
4 * *
5 * http://www.access.edu.au *
6 * Primary Business: Queensland, Australia *
7 * Licensed under the Open Software License version 3.0 *
8 * http://www.opensource.org/licenses/osl-3.0.php *
9 * *
10 ************************************************************
11 */
12
13 /**************************************************************/
14
15 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
16
17 /**************************************************************/
18
19 /* Author: gross@access.edu.au */
20 /* Version: $Id$ */
21
22 /**************************************************************/
23
24 #include "Assemble.h"
25 #include "Util.h"
26 #ifdef _OPENMP
27 #include <omp.h>
28 #endif
29
30 /**************************************************************/
31
32
33 void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
34 double* local_data=NULL,*S=NULL,*data_array;
35 index_t dof_offset,*resort_nodesi, NN, NS;
36 bool_t reduced_integration=FALSE;
37 dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
38 Finley_RefElement* reference_element=NULL;
39 dim_t numComps=getDataPointSize(data);
40 index_t id[MAX_numNodes], *resort_nodes;
41 type_t data_type=getFunctionSpaceType(data);
42 type_t type;
43 Finley_resetError();
44 #define NODES 0
45 #define REDUCED_NODES 3
46 #define DOF 1
47 #define REDUCED_DOF 2
48 if (nodes==NULL || elements==NULL) return;
49 NN=elements->ReferenceElement->Type->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=nodes->numNodes;
65 } else if (data_type==FINLEY_REDUCED_NODES) {
66 type=REDUCED_NODES;
67 if (reduced_integration) {
68 reference_element=elements->LinearReferenceElementReducedOrder;
69 } else {
70 reference_element=elements->LinearReferenceElement;
71 }
72 /* TODO */
73 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: input from reduced nodes is not supported yet.");
74 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
75 type=DOF;
76 resort_nodes=id;
77 if (reduced_integration) {
78 reference_element=elements->ReferenceElementReducedOrder;
79 } else {
80 reference_element=elements->ReferenceElement;
81 }
82 numNodes=nodes->numDegreesOfFreedom;
83 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
84 type=REDUCED_DOF;
85 resort_nodes=elements->ReferenceElement->Type->linearNodes;
86 if (reduced_integration) {
87 reference_element=elements->LinearReferenceElementReducedOrder;
88 } else {
89 reference_element=elements->LinearReferenceElement;
90 }
91 numNodes=nodes->reducedNumDegreesOfFreedom;
92 } else {
93 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
94 }
95 NN_DOF=reference_element->Type->numNodes;
96 NS_DOF=reference_element->Type->numShapes;
97 S=reference_element->S;
98 numQuad=reference_element->numQuadNodes;
99 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
100 dof_offset=NN_DOF-NS_DOF;
101 } else {
102 dof_offset=0;
103 }
104
105 /* check the dimensions of interpolated_data and data */
106
107 if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
108 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
109 } else if (! numSamplesEqual(data,1,numNodes)) {
110 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
111 } else if (numComps!=getDataPointSize(interpolated_data)) {
112 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
113 } else if (!isExpanded(interpolated_data)) {
114 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
115 }
116
117 /* now we can start */
118
119 if (Finley_noError()) {
120 #pragma omp parallel private(local_data)
121 {
122 local_data=NULL;
123 /* allocation of work arrays */
124 local_data=THREAD_MEMALLOC(NS*numComps,double);
125 if (! Finley_checkPtr(local_data)) {
126
127 /* open the element loop */
128
129 #pragma omp for private(e,q,i,data_array) schedule(static)
130 for(e=0;e<elements->numElements;e++) {
131 /* gather local data into local_data(numComps,NS_DOF): */
132 switch (type) {
133 case NODES:
134 for (q=0;q<NS_DOF;q++) {
135 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
136 data_array=getSampleData(data,i);
137 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
138 }
139 break;
140 case REDUCED_NODES:
141 for (q=0;q<NS_DOF;q++) {
142 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
143 data_array=getSampleData(data,i); /* TODO */
144 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
145 }
146 break;
147 case DOF:
148 for (q=0;q<NS_DOF;q++) {
149 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
150 data_array=getSampleData(data,nodes->degreeOfFreedom[i]);
151 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
152 }
153 break;
154 case REDUCED_DOF:
155 for (q=0;q<NS_DOF;q++) {
156 i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
157 data_array=getSampleData(data,nodes->reducedDegreeOfFreedom[i]);
158 Finley_copyDouble(numComps,data_array,local_data+q*numComps);
159 }
160 break;
161 }
162
163 /* calculate interpolated_data=local_data*S */
164
165 Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
166
167 } /* end of element loop */
168
169 }
170 THREAD_MEMFREE(local_data);
171 } /* end of parallel region */
172 }
173 #undef NODES
174 #undef REDUCED_NODES
175 #undef DOF
176 #undef REDUCED_DOF
177 }
178 /*
179 * $Log$
180 * Revision 1.6 2005/09/15 03:44:21 jgs
181 * Merge of development branch dev-02 back to main trunk on 2005-09-15
182 *
183 * Revision 1.5.2.1 2005/09/07 06:26:18 gross
184 * the solver from finley are put into the standalone package paso now
185 *
186 * Revision 1.5 2005/07/08 04:07:48 jgs
187 * Merge of development branch back to main trunk on 2005-07-08
188 *
189 * Revision 1.4 2004/12/15 07:08:32 jgs
190 * *** empty log message ***
191 * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
192 * some changes towards 64 integers in finley
193 *
194 * Revision 1.1.1.1.2.2 2004/11/24 01:37:12 gross
195 * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
196 *
197 *
198 *
199 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26