/[escript]/branches/domexper/dudley/src/Assemble_interpolate.c
ViewVC logotype

Annotation of /branches/domexper/dudley/src/Assemble_interpolate.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1387 - (hide annotations)
Fri Jan 11 07:45:26 2008 UTC (11 years, 3 months ago) by trankine
Original Path: temp/finley/src/Assemble_interpolate.c
File MIME type: text/plain
File size: 6234 byte(s)
Restore the trunk that existed before the windows changes were committed to the (now moved to branches) old trunk.
1 jgs 82
2 ksteube 1312 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15 jgs 82
16     /**************************************************************/
17    
18 ksteube 1312 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
19 jgs 82
20     /**************************************************************/
21    
22     #include "Assemble.h"
23     #include "Util.h"
24     #ifdef _OPENMP
25     #include <omp.h>
26     #endif
27    
28     /**************************************************************/
29    
30    
31     void Finley_Assemble_interpolate(Finley_NodeFile *nodes, Finley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
32     double* local_data=NULL,*S=NULL,*data_array;
33 gross 1028 index_t dof_offset,*resort_nodesi, NN, NS;
34 gross 1062 bool_t reduced_integration=FALSE;
35 gross 1028 dim_t q,i,NS_DOF,NN_DOF,numNodes,e, numQuad;
36 gross 1062 Finley_RefElement* reference_element=NULL;
37 gross 1028 dim_t numComps=getDataPointSize(data);
38 ksteube 1312 index_t id[MAX_numNodes], *resort_nodes, *map;
39 gross 1028 type_t data_type=getFunctionSpaceType(data);
40 jgs 123 type_t type;
41 ksteube 1312 size_t numComps_size;
42 gross 1028 Finley_resetError();
43 jgs 82 #define NODES 0
44 gross 1062 #define REDUCED_NODES 3
45 jgs 82 #define DOF 1
46     #define REDUCED_DOF 2
47     if (nodes==NULL || elements==NULL) return;
48 ksteube 1312
49     NN=elements->numNodes;
50 gross 1028 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 ksteube 1312 numNodes=Finley_NodeFile_getNumNodes(nodes);
65     map=Finley_NodeFile_borrowTargetNodes(nodes);
66 gross 1062 } else if (data_type==FINLEY_REDUCED_NODES) {
67     type=REDUCED_NODES;
68 ksteube 1312 resort_nodes=elements->ReferenceElement->Type->linearNodes;
69 gross 1062 if (reduced_integration) {
70     reference_element=elements->LinearReferenceElementReducedOrder;
71     } else {
72     reference_element=elements->LinearReferenceElement;
73     }
74 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedNodes(nodes);
75     map=Finley_NodeFile_borrowTargetReducedNodes(nodes);
76 jgs 82 } else if (data_type==FINLEY_DEGREES_OF_FREEDOM) {
77 ksteube 1312 if (elements->MPIInfo->size>1) {
78     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
79     return;
80     }
81 jgs 82 type=DOF;
82     resort_nodes=id;
83 gross 1062 if (reduced_integration) {
84     reference_element=elements->ReferenceElementReducedOrder;
85     } else {
86     reference_element=elements->ReferenceElement;
87     }
88 ksteube 1312 numNodes=Finley_NodeFile_getNumDegreesOfFreedom(nodes);
89     map=Finley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
90 jgs 82 } else if (data_type==FINLEY_REDUCED_DEGREES_OF_FREEDOM) {
91 ksteube 1312 if (elements->MPIInfo->size>1) {
92     Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
93     return;
94     }
95 jgs 82 type=REDUCED_DOF;
96     resort_nodes=elements->ReferenceElement->Type->linearNodes;
97 gross 1062 if (reduced_integration) {
98     reference_element=elements->LinearReferenceElementReducedOrder;
99     } else {
100     reference_element=elements->LinearReferenceElement;
101     }
102 ksteube 1312 numNodes=Finley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
103     map=Finley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
104 jgs 82 } else {
105 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: Cannot interpolate data");
106 jgs 82 }
107 gross 1062 NN_DOF=reference_element->Type->numNodes;
108     NS_DOF=reference_element->Type->numShapes;
109     S=reference_element->S;
110     numQuad=reference_element->numQuadNodes;
111 jgs 82 if (getFunctionSpaceType(interpolated_data)==FINLEY_CONTACT_ELEMENTS_2) {
112     dof_offset=NN_DOF-NS_DOF;
113     } else {
114     dof_offset=0;
115     }
116    
117     /* check the dimensions of interpolated_data and data */
118    
119     if (! numSamplesEqual(interpolated_data,numQuad,elements->numElements)) {
120 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of output Data object");
121 jgs 82 } else if (! numSamplesEqual(data,1,numNodes)) {
122 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: illegal number of samples of input Data object");
123 jgs 82 } else if (numComps!=getDataPointSize(interpolated_data)) {
124 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
125 jgs 82 } else if (!isExpanded(interpolated_data)) {
126 gross 1062 Finley_setError(TYPE_ERROR,"Finley_Assemble_interpolate: expanded Data object is expected for output data.");
127 jgs 82 }
128    
129     /* now we can start */
130    
131 jgs 150 if (Finley_noError()) {
132 ksteube 1312 #pragma omp parallel private(local_data, numComps_size)
133 jgs 82 {
134     local_data=NULL;
135     /* allocation of work arrays */
136 jgs 102 local_data=THREAD_MEMALLOC(NS*numComps,double);
137 jgs 82 if (! Finley_checkPtr(local_data)) {
138    
139 ksteube 1312 numComps_size=(size_t)numComps*sizeof(double);
140 jgs 82 /* open the element loop */
141    
142     #pragma omp for private(e,q,i,data_array) schedule(static)
143     for(e=0;e<elements->numElements;e++) {
144 ksteube 1312 for (q=0;q<NS_DOF;q++) {
145     i=elements->Nodes[INDEX2(resort_nodes[dof_offset+q],e,NN)];
146     data_array=getSampleData(data,map[i]);
147     memcpy(local_data+q*numComps, data_array, numComps_size);
148 jgs 82 }
149     /* calculate interpolated_data=local_data*S */
150    
151     Finley_Util_SmallMatMult(numComps,numQuad,getSampleData(interpolated_data,e),NS_DOF,local_data,S);
152    
153     } /* end of element loop */
154    
155     }
156     THREAD_MEMFREE(local_data);
157 jgs 102 } /* end of parallel region */
158 jgs 82 }
159     #undef NODES
160 gross 1062 #undef REDUCED_NODES
161 jgs 82 #undef DOF
162     #undef REDUCED_DOF
163     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26