/[escript]/trunk/dudley/src/Assemble_interpolate.cpp
ViewVC logotype

Contents of /trunk/dudley/src/Assemble_interpolate.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4346 - (show annotations)
Tue Apr 2 04:46:45 2013 UTC (6 years, 4 months ago) by jfenwick
File size: 5097 byte(s)
Bringing the changes from doubleplusgood branch.
Can't merge directly because svn doesn't transfer changes to renamed files (mutter grumble).
1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16 /************************************************************************************/
17
18 /* assemblage routines: interpolates nodal data in a data array onto elements (=integration points) */
19
20 /************************************************************************************/
21
22 #include "Assemble.h"
23 #include "Util.h"
24 #ifdef _OPENMP
25 #include <omp.h>
26 #endif
27
28 #include "ShapeTable.h"
29
30 /************************************************************************************/
31
32 void Dudley_Assemble_interpolate(Dudley_NodeFile * nodes, Dudley_ElementFile * elements, escriptDataC * data,
33 escriptDataC * interpolated_data)
34 {
35 __const double *data_array;
36 double *local_data = NULL;
37 bool_t reduced_integration = FALSE;
38 dim_t q, i, NS_DOF, NN, numNodes = 0, e, numQuad = 0;
39 dim_t numComps = getDataPointSize(data);
40 index_t *map = NULL;
41 const double *shapeFns = 0;
42 type_t data_type = getFunctionSpaceType(data);
43 size_t numComps_size;
44 Dudley_resetError();
45 if (nodes == NULL || elements == NULL)
46 return;
47 reduced_integration = Dudley_Assemble_reducedIntegrationOrder(interpolated_data);
48 NN = elements->numNodes;
49
50 /* set some parameter */
51
52 if (data_type == DUDLEY_NODES)
53 {
54 numNodes = Dudley_NodeFile_getNumNodes(nodes);
55 map = Dudley_NodeFile_borrowTargetNodes(nodes);
56 }
57 else if (data_type == DUDLEY_REDUCED_NODES)
58 {
59 numNodes = Dudley_NodeFile_getNumReducedNodes(nodes);
60 map = Dudley_NodeFile_borrowTargetReducedNodes(nodes);
61 }
62 else if (data_type == DUDLEY_DEGREES_OF_FREEDOM)
63 {
64 if (elements->MPIInfo->size > 1)
65 {
66 Dudley_setError(TYPE_ERROR,
67 "Dudley_Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
68 return;
69 }
70 numNodes = Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
71 map = Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
72 }
73 else if (data_type == DUDLEY_REDUCED_DEGREES_OF_FREEDOM)
74 {
75 if (elements->MPIInfo->size > 1)
76 {
77 Dudley_setError(TYPE_ERROR,
78 "Dudley_Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
79 return;
80 }
81 numNodes = Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
82 map = Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
83 }
84 else
85 {
86 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: Cannot interpolate data");
87 return;
88 }
89
90 numQuad = reduced_integration ? 1 : (elements->numDim + 1);
91 NS_DOF = elements->numDim + 1;
92
93 /* check the dimensions of interpolated_data and data */
94
95 if (!numSamplesEqual(interpolated_data, numQuad, elements->numElements))
96 {
97 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of output Data object");
98 }
99 else if (!numSamplesEqual(data, 1, numNodes))
100 {
101 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: illegal number of samples of input Data object");
102 }
103 else if (numComps != getDataPointSize(interpolated_data))
104 {
105 Dudley_setError(TYPE_ERROR,
106 "Dudley_Assemble_interpolate: number of components of input and interpolated Data do not match.");
107 }
108 else if (!isExpanded(interpolated_data))
109 {
110 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: expanded Data object is expected for output data.");
111 }
112
113 if (Dudley_noError() && !getQuadShape(elements->numDim, reduced_integration, &shapeFns))
114 {
115 Dudley_setError(TYPE_ERROR, "Dudley_Assemble_interpolate: unable to locate shape function.");
116 }
117
118 /* now we can start */
119
120 if (Dudley_noError())
121 {
122 requireWrite(interpolated_data);
123 #pragma omp parallel private(local_data, numComps_size)
124 {
125 local_data = NULL;
126 /* allocation of work arrays */
127 local_data = new double[NS_DOF * numComps];
128 if (!Dudley_checkPtr(local_data))
129 {
130 numComps_size = (size_t) numComps *sizeof(double);
131 /* open the element loop */
132 #pragma omp for private(e,q,i,data_array) schedule(static)
133 for (e = 0; e < elements->numElements; e++)
134 {
135 for (q = 0; q < NS_DOF; q++)
136 {
137 i = elements->Nodes[INDEX2(q, e, NN)];
138 data_array = getSampleDataRO(data, map[i]);
139 memcpy(&(local_data[INDEX3(0, q, 0, numComps, NS_DOF)]), data_array, numComps_size);
140 }
141 /* calculate interpolated_data=local_data*S */
142 Dudley_Util_SmallMatSetMult1(1, numComps, numQuad, getSampleDataRW(interpolated_data, e),
143 NS_DOF, local_data, /*basis->S */ shapeFns);
144 } /* end of element loop */
145 }
146 delete[] local_data;
147 } /* end of parallel region */
148 }
149 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/lapack2681/finley/src/Assemble_interpolate.cpp:2682-2741 /branches/pasowrap/dudley/src/Assemble_interpolate.cpp:3661-3674 /branches/py3_attempt2/dudley/src/Assemble_interpolate.cpp:3871-3891 /branches/restext/finley/src/Assemble_interpolate.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/Assemble_interpolate.cpp:3669-3791 /branches/stage3.0/finley/src/Assemble_interpolate.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/Assemble_interpolate.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/Assemble_interpolate.cpp:3517-3974 /release/3.0/finley/src/Assemble_interpolate.cpp:2591-2601 /trunk/dudley/src/Assemble_interpolate.cpp:4257-4344 /trunk/ripley/test/python/dudley/src/Assemble_interpolate.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26