/[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 102 - (hide annotations)
Wed Dec 15 07:08:39 2004 UTC (14 years, 11 months ago) by jgs
Original Path: trunk/esys2/finley/src/finleyC/Assemble_interpolate.c
File MIME type: text/plain
File size: 5528 byte(s)
*** empty log message ***

1 jgs 82 /* $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 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
102 jgs 82 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 jgs 102 }
116 jgs 82 break;
117     case DOF:
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,nodes->degreeOfFreedom[i]);
121     Finley_copyDouble(numComps,data_array,local_data+q*numComps);
122     }
123     break;
124     case REDUCED_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->reducedDegreeOfFreedom[i]);
128     Finley_copyDouble(numComps,data_array,local_data+q*numComps);
129     }
130     break;
131     }
132    
133     /* calculate interpolated_data=local_data*S */
134    
135     Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
136    
137     } /* end of element loop */
138    
139     }
140     THREAD_MEMFREE(local_data);
141 jgs 102 } /* end of parallel region */
142 jgs 82 }
143     #undef NODES
144     #undef DOF
145     #undef REDUCED_DOF
146     }
147     /*
148     * $Log$
149 jgs 102 * Revision 1.4 2004/12/15 07:08:32 jgs
150 jgs 97 * *** empty log message ***
151 jgs 82 *
152 jgs 97 *
153 jgs 82 *
154     */

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26