/[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 3224 - (hide annotations)
Wed Sep 29 05:19:37 2010 UTC (8 years, 6 months ago) by jfenwick
File MIME type: text/plain
File size: 5161 byte(s)
indent -linux -nce -i4 -bl -bli0 -l120

1 jgs 82
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4 jfenwick 2881 * Copyright (c) 2003-2010 by University of Queensland
5 ksteube 1811 * 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 jgs 82
14     /**************************************************************/
15    
16 gross 2748 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
17 jgs 82
18     /**************************************************************/
19    
20     #include "Assemble.h"
21     #include "Util.h"
22     #ifdef _OPENMP
23     #include <omp.h>
24     #endif
25    
26 jfenwick 3198 #include "ShapeTable.h"
27    
28 jgs 82 /**************************************************************/
29    
30 jfenwick 3224 void Dudley_Assemble_interpolate(Dudley_NodeFile * nodes, Dudley_ElementFile * elements, escriptDataC * data,
31     escriptDataC * interpolated_data)
32     {
33     __const double *data_array;
34     double *local_data = NULL;
35     bool_t reduced_integration = FALSE;
36     dim_t q, i, NS_DOF, NN, numNodes = 0, e, numQuad = 0;
37     dim_t numComps = getDataPointSize(data);
38     index_t *map = NULL;
39     const double *shapeFns = 0;
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)
49     return;
50     reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
51     NN = elements->numNodes;
52 jgs 82
53 jfenwick 3224 /* set some parameter */
54 jgs 82
55 jfenwick 3224 if (data_type == DUDLEY_NODES)
56     {
57     type = NODES;
58     numNodes = Dudley_NodeFile_getNumNodes(nodes);
59     map = Dudley_NodeFile_borrowTargetNodes(nodes);
60     }
61     else if (data_type == DUDLEY_REDUCED_NODES)
62     {
63     type = REDUCED_NODES;
64     numNodes = Dudley_NodeFile_getNumReducedNodes(nodes);
65     map = Dudley_NodeFile_borrowTargetReducedNodes(nodes);
66     }
67     else if (data_type == DUDLEY_DEGREES_OF_FREEDOM)
68     {
69     if (elements->MPIInfo->size > 1)
70     {
71     Dudley_setError(TYPE_ERROR,
72     "Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
73     return;
74     }
75     type = DOF;
76     numNodes = Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
77     map = Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
78     }
79     else if (data_type == DUDLEY_REDUCED_DEGREES_OF_FREEDOM)
80     {
81     if (elements->MPIInfo->size > 1)
82     {
83     Dudley_setError(TYPE_ERROR,
84     "Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
85     return;
86     }
87     type = REDUCED_DOF;
88     numNodes = Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
89     map = Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
90     }
91     else
92     {
93     Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: Cannot interpolate data");
94     return;
95     }
96 jgs 82
97 jfenwick 3224 numQuad = reduced_integration ? 1 : (elements->numDim + 1);
98     NS_DOF = elements->numDim + 1;
99 jfenwick 3198
100 jfenwick 3224 /* check the dimensions of interpolated_data and data */
101 jgs 82
102 jfenwick 3224 if (!numSamplesEqual(interpolated_data, numQuad, elements->numElements))
103     {
104     Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of output Data object");
105     }
106     else if (!numSamplesEqual(data, 1, numNodes))
107     {
108     Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of input Data object");
109     }
110     else if (numComps != getDataPointSize(interpolated_data))
111     {
112     Dudley_setError(TYPE_ERROR,
113     "Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
114     }
115     else if (!isExpanded(interpolated_data))
116     {
117     Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
118     }
119 jgs 82
120 jfenwick 3224 if (Dudley_noError() && !getQuadShape(elements->numDim, reduced_integration, &shapeFns))
121     {
122 jfenwick 3198 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: unable to locate shape function.");
123 jfenwick 3224 }
124 jfenwick 3198
125 jfenwick 3224 /* now we can start */
126 jfenwick 3198
127 jfenwick 3224 if (Dudley_noError())
128     {
129 jfenwick 3141 requireWrite(interpolated_data);
130 jfenwick 3224 #pragma omp parallel private(local_data, numComps_size)
131 jfenwick 3141 {
132 jfenwick 3224 local_data = NULL;
133 jfenwick 3141 /* allocation of work arrays */
134 jfenwick 3224 local_data = THREAD_MEMALLOC(NS_DOF * numComps, double);
135     if (!Dudley_checkPtr(local_data))
136 jfenwick 3141 {
137 jfenwick 3224 numComps_size = (size_t) numComps *sizeof(double);
138 jfenwick 3141 /* open the element loop */
139 jfenwick 3224 #pragma omp for private(e,q,i,data_array) schedule(static)
140     for (e = 0; e < elements->numElements; e++)
141 jfenwick 3141 {
142 jfenwick 3224 for (q = 0; q < NS_DOF; q++)
143     {
144     i = elements->Nodes[INDEX2(q, e, NN)];
145     data_array = getSampleDataRO(data, map[i]);
146     memcpy(&(local_data[INDEX3(0, q, 0, numComps, NS_DOF)]), data_array, numComps_size);
147     }
148     /* calculate interpolated_data=local_data*S */
149     Dudley_Util_SmallMatSetMult1(1, numComps, numQuad, getSampleDataRW(interpolated_data, e),
150     NS_DOF, local_data, /*basis->S */ shapeFns);
151     } /* end of element loop */
152 jfenwick 3141 }
153     THREAD_MEMFREE(local_data);
154 jfenwick 3224 } /* end of parallel region */
155     }
156     #undef NODES
157     #undef REDUCED_NODES
158     #undef DOF
159     #undef REDUCED_DOF
160 jgs 82 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26