/[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 1062 - (hide 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 jgs 150 /*
2 elspeth 616 ************************************************************
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 jgs 150 */
12 jgs 82
13     /**************************************************************/
14    
15     /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
16    
17     /**************************************************************/
18    
19 jgs 150 /* Author: gross@access.edu.au */
20     /* Version: $Id$ */
21 jgs 82
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 gross 1028 index_t dof_offset,*resort_nodesi, NN, NS;
36 gross 1062 bool_t reduced_integration=FALSE;
37 gross 1028 dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
38 gross 1062 Finley_RefElement* reference_element=NULL;
39 gross 1028 dim_t numComps=getDataPointSize(data);
40     index_t id[MAX_numNodes], *resort_nodes;
41     type_t data_type=getFunctionSpaceType(data);
42 jgs 123 type_t type;
43 gross 1028 Finley_resetError();
44 jgs 82 #define NODES 0
45 gross 1062 #define REDUCED_NODES 3
46 jgs 82 #define DOF 1
47     #define REDUCED_DOF 2
48     if (nodes==NULL || elements==NULL) return;
49 gross 1028 NN=elements->ReferenceElement->Type->numNodes;
50     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 jgs 82 numNodes=nodes->numNodes;
65 gross 1062 } 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 jgs 82 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
75     type=DOF;
76     resort_nodes=id;
77 gross 1062 if (reduced_integration) {
78     reference_element=elements->ReferenceElementReducedOrder;
79     } else {
80     reference_element=elements->ReferenceElement;
81     }
82 jgs 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 gross 1062 if (reduced_integration) {
87     reference_element=elements->LinearReferenceElementReducedOrder;
88     } else {
89     reference_element=elements->LinearReferenceElement;
90     }
91 jgs 82 numNodes=nodes->reducedNumDegreesOfFreedom;
92     } else {
93 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
94 jgs 82 }
95 gross 1062 NN_DOF=reference_element->Type->numNodes;
96     NS_DOF=reference_element->Type->numShapes;
97     S=reference_element->S;
98     numQuad=reference_element->numQuadNodes;
99 jgs 82 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 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
109 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
110 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
111 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
112 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
113 jgs 82 } else if (!isExpanded(interpolated_data)) {
114 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
115 jgs 82 }
116    
117     /* now we can start */
118    
119 jgs 150 if (Finley_noError()) {
120 jgs 82 #pragma omp parallel private(local_data)
121     {
122     local_data=NULL;
123     /* allocation of work arrays */
124 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
125 jgs 82 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 jgs 102 }
139 jgs 82 break;
140 gross 1062 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 jgs 82 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 jgs 102 } /* end of parallel region */
172 jgs 82 }
173     #undef NODES
174 gross 1062 #undef REDUCED_NODES
175 jgs 82 #undef DOF
176     #undef REDUCED_DOF
177     }
178     /*
179     * $Log$
180 jgs 150 * 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 jgs 123 * 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 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
190 jgs 97 * *** empty log message ***
191 jgs 123 * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
192     * some changes towards 64 integers in finley
193 jgs 82 *
194 jgs 123 * 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 jgs 97 *
197 jgs 82 *
198 jgs 123 *
199 jgs 82 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26