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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3090 - (show annotations)
Wed Aug 11 00:51:28 2010 UTC (9 years, 5 months ago) by jfenwick
File MIME type: text/plain
File size: 5988 byte(s)
Removed:
DUDLEY_CONTACT_ELEMENTS_1
DUDLEY_CONTACT_ELEMENTS_2
DUDLEY_REDUCED_CONTACT_ELEMENTS_1
DUDLEY_REDUCED_CONTACT_ELEMENTS_2

escript tests now query if the domain supports contact elements
before trying to use them.


1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 /**************************************************************/
16
17 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
18
19 /**************************************************************/
20
21 #include "Assemble.h"
22 #include "Util.h"
23 #ifdef _OPENMP
24 #include <omp.h>
25 #endif
26
27 /**************************************************************/
28
29
30 void Dudley_Assemble_interpolate(Dudley_NodeFile *nodes, Dudley_ElementFile* elements,escriptDataC* data,escriptDataC* interpolated_data) {
31 __const double *data_array;
32 double* local_data=NULL;
33 index_t dof_offset;
34 bool_t reduced_integration=FALSE;
35 dim_t q, i, NS_DOF, NN, numNodes=0, e, numQuad=0, numSub=0, isub, numShapesTotal2;
36 Dudley_ReferenceElement* reference_element=NULL;
37 Dudley_ShapeFunction *basis=NULL;
38 dim_t numComps=getDataPointSize(data);
39 index_t *resort_nodes=NULL, *map=NULL;
40 type_t data_type=getFunctionSpaceType(data);
41 type_t type;
42 size_t numComps_size;
43 Dudley_resetError();
44 #define NODES 0
45 #define REDUCED_NODES 3
46 #define DOF 1
47 #define REDUCED_DOF 2
48 if (nodes==NULL || elements==NULL) return;
49 reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
50 reference_element= Dudley_ReferenceElementSet_borrowReferenceElement(elements->referenceElementSet, reduced_integration);
51 NN=elements->numNodes;
52
53 /* set some parameter */
54
55 if (data_type==DUDLEY_NODES) {
56 type=NODES;
57 resort_nodes=reference_element->Type->subElementNodes;
58 numSub=reference_element->Type->numSubElements;
59 basis=reference_element->BasisFunctions;
60 numNodes=Dudley_NodeFile_getNumNodes(nodes);
61 map=Dudley_NodeFile_borrowTargetNodes(nodes);
62 dof_offset=reference_element->Type->offsets[0];
63 } else if (data_type==DUDLEY_REDUCED_NODES) {
64 type=REDUCED_NODES;
65 numSub=1;
66 resort_nodes=reference_element->Type->linearNodes;
67 basis=reference_element->LinearBasisFunctions;
68 numNodes=Dudley_NodeFile_getNumReducedNodes(nodes);
69 map=Dudley_NodeFile_borrowTargetReducedNodes(nodes);
70 dof_offset=reference_element->LinearType->offsets[0];
71 } else if (data_type==DUDLEY_DEGREES_OF_FREEDOM) {
72 if (elements->MPIInfo->size>1) {
73 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
74 return;
75 }
76 type=DOF;
77 numSub=reference_element->Type->numSubElements;
78 resort_nodes=reference_element->Type->subElementNodes;
79 basis=reference_element->BasisFunctions;
80 numNodes=Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
81 map=Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
82 dof_offset=reference_element->Type->offsets[0];
83 } else if (data_type==DUDLEY_REDUCED_DEGREES_OF_FREEDOM) {
84 if (elements->MPIInfo->size>1) {
85 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
86 return;
87 }
88 type=REDUCED_DOF;
89 numSub=1;
90 resort_nodes=reference_element->Type->linearNodes;
91 basis=reference_element->LinearBasisFunctions;
92 numNodes=Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
93 map=Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
94 dof_offset=reference_element->LinearType->offsets[0];
95 } else {
96 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: Cannot interpolate data");
97 return;
98 }
99
100 numQuad=basis->numQuadNodes;
101 numShapesTotal2=basis->Type->numShapes * reference_element->Type->numSides;
102 NS_DOF=basis->Type->numShapes;
103
104 /* check the dimensions of interpolated_data and data */
105
106 if (! numSamplesEqual(interpolated_data,numQuad*numSub,elements->numElements)) {
107 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: illegal number of samples of output Data object");
108 } else if (! numSamplesEqual(data,1,numNodes)) {
109 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: illegal number of samples of input Data object");
110 } else if (numComps!=getDataPointSize(interpolated_data)) {
111 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
112 } else if (!isExpanded(interpolated_data)) {
113 Dudley_setError(TYPE_ERROR,"Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
114 }
115
116 /* now we can start */
117
118 if (Dudley_noError()) {
119 requireWrite(interpolated_data);
120 #pragma omp parallel private(local_data, numComps_size, isub)
121 {
122 local_data=NULL;
123 /* allocation of work arrays */
124 local_data=THREAD_MEMALLOC(NS_DOF*numComps*numSub,double);
125 if (! Dudley_checkPtr(local_data)) {
126 numComps_size=(size_t)numComps*sizeof(double);
127 /* open the element loop */
128 #pragma omp for private(e,q,i,data_array,isub) schedule(static)
129 for(e=0;e<elements->numElements;e++) {
130 for (isub=0; isub<numSub; isub++) {
131 for (q=0;q<NS_DOF;q++) {
132 i=elements->Nodes[INDEX2(resort_nodes[INDEX2(dof_offset+q,isub,numShapesTotal2)],e,NN)];
133 data_array=getSampleDataRO(data,map[i]);
134 memcpy(&(local_data[INDEX3(0,q,isub, numComps,NS_DOF)]), data_array, numComps_size);
135 }
136 }
137 /* calculate interpolated_data=local_data*S */
138 Dudley_Util_SmallMatSetMult1(numSub,numComps,numQuad,getSampleDataRW(interpolated_data,e),NS_DOF,local_data,basis->S);
139 } /* end of element loop */
140 }
141 THREAD_MEMFREE(local_data);
142 } /* end of parallel region */
143 }
144 #undef NODES
145 #undef REDUCED_NODES
146 #undef DOF
147 #undef REDUCED_DOF
148 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26