/[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 201 - (hide annotations)
Wed Nov 23 04:10:21 2005 UTC (13 years, 11 months ago) by jgs
Original Path: trunk/finley/src/finley/Assemble_interpolate.c
File MIME type: text/plain
File size: 6770 byte(s)
copy finleyC and CPPAdapter to finley and finley/CPPAdapter to
facilitate scons builds

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     index_t id[NN];
50 jgs 82 for (i=0;i<NN;i++) id[i]=i;
51 jgs 150 Finley_resetError();
52 jgs 82
53     /* set some parameter */
54    
55     if (data_type==FINLEY_NODES) {
56     type=NODES;
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->numNodes;
62     } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
63     type=DOF;
64     resort_nodes=id;
65     NN_DOF=elements->ReferenceElement->Type->numNodes;
66     NS_DOF=elements->ReferenceElement->Type->numShapes;
67     S=elements->ReferenceElement->S;
68     numNodes=nodes->numDegreesOfFreedom;
69     } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
70     type=REDUCED_DOF;
71     resort_nodes=elements->ReferenceElement->Type->linearNodes;
72     NN_DOF=elements->LinearReferenceElement->Type->numNodes;
73     NS_DOF=elements->LinearReferenceElement->Type->numShapes;
74     S=elements->LinearReferenceElement->S;
75     numNodes=nodes->reducedNumDegreesOfFreedom;
76     } else {
77 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: Cannot interpolate data");
78 jgs 82 }
79    
80     if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
81     dof_offset=NN_DOF-NS_DOF;
82     } else {
83     dof_offset=0;
84     }
85    
86     /* check the dimensions of interpolated_data and data */
87    
88     if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
89 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: illegal number of samples of output Data object");
90 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
91 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: illegal number of samples of input Data object");
92 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
93 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: number of components of input and interpolated Data do not match.");
94 jgs 82 } else if (!isExpanded(interpolated_data)) {
95 jgs 150 Finley_setError(TYPE_ERROR,"__FILE__: expanded Data object is expected for output data.");
96 jgs 82 }
97    
98     /* now we can start */
99    
100 jgs 150 if (Finley_noError()) {
101 jgs 82 #pragma omp parallel private(local_data)
102     {
103     local_data=NULL;
104     /* allocation of work arrays */
105 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
106 jgs 82 if (! Finley_checkPtr(local_data)) {
107    
108     /* open the element loop */
109    
110     #pragma omp for private(e,q,i,data_array) schedule(static)
111     for(e=0;e<elements->numElements;e++) {
112     /* gather local data into local_data(numComps,NS_DOF): */
113     switch (type) {
114     case NODES:
115     for (q=0;q<NS_DOF;q++) {
116     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
117     data_array=getSampleData(data,i);
118     Finley_copyDouble(numComps,data_array,local_data+q*numComps);
119 jgs 102 }
120 jgs 82 break;
121     case DOF:
122     for (q=0;q<NS_DOF;q++) {
123     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
124     data_array=getSampleData(data,nodes->degreeOfFreedom[i]);
125     Finley_copyDouble(numComps,data_array,local_data+q*numComps);
126     }
127     break;
128     case REDUCED_DOF:
129     for (q=0;q<NS_DOF;q++) {
130     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
131     data_array=getSampleData(data,nodes->reducedDegreeOfFreedom[i]);
132     Finley_copyDouble(numComps,data_array,local_data+q*numComps);
133     }
134     break;
135     }
136    
137     /* calculate interpolated_data=local_data*S */
138    
139     Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
140    
141     } /* end of element loop */
142    
143     }
144     THREAD_MEMFREE(local_data);
145 jgs 102 } /* end of parallel region */
146 jgs 82 }
147     #undef NODES
148     #undef DOF
149     #undef REDUCED_DOF
150     }
151     /*
152     * $Log$
153 jgs 150 * Revision 1.6 2005/09/15 03:44:21 jgs
154     * Merge of development branch dev-02 back to main trunk on 2005-09-15
155     *
156     * Revision 1.5.2.1 2005/09/07 06:26:18 gross
157     * the solver from finley are put into the standalone package paso now
158     *
159 jgs 123 * Revision 1.5 2005/07/08 04:07:48 jgs
160     * Merge of development branch back to main trunk on 2005-07-08
161     *
162 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
163 jgs 97 * *** empty log message ***
164 jgs 123 * Revision 1.1.1.1.2.3 2005/06/29 02:34:48 gross
165     * some changes towards 64 integers in finley
166 jgs 82 *
167 jgs 123 * Revision 1.1.1.1.2.2 2004/11/24 01:37:12 gross
168     * some changes dealing with the integer overflow in memory allocation. Finley solves 4M unknowns now
169 jgs 97 *
170 jgs 82 *
171 jgs 123 *
172 jgs 82 */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26