/[escript]/branches/trilinos_from_5897/dudley/src/Assemble_interpolate.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/Assemble_interpolate.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5963 - (show annotations)
Mon Feb 22 06:59:27 2016 UTC (3 years, 3 months ago) by caltinay
File size: 5869 byte(s)
sync and fix.

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

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/dudley/src/Assemble_interpolate.cpp:5567-5588 /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 /release/4.0/dudley/src/Assemble_interpolate.cpp:5380-5406 /trunk/dudley/src/Assemble_interpolate.cpp:4257-4344,5898-5962 /trunk/ripley/test/python/dudley/src/Assemble_interpolate.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26