/[escript]/branches/RW_WIN32/finley/src/finleyC/Assemble_interpolate.c
ViewVC logotype

Annotation of /branches/RW_WIN32/finley/src/finleyC/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 210 - (hide annotations)
Wed Nov 23 09:54:02 2005 UTC (15 years ago) by robwdcock
File MIME type: text/plain
File size: 6886 byte(s)
PARTIAL WIN32 BUILD SYSTEM AND PORT
+ All libraries now build under new build system. No unit test routines yet
+ Reversed some incorrect refactorings in Bruce.cpp

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26