/[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 6009 - (show annotations)
Wed Mar 2 04:13:26 2016 UTC (3 years, 1 month ago) by caltinay
File size: 4774 byte(s)
Much needed sync with trunk...

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
20 (=integration points)
21
22 *****************************************************************************/
23
24 #include "Assemble.h"
25 #include "ShapeTable.h"
26 #include "Util.h"
27
28 namespace dudley {
29
30 void Assemble_interpolate(Dudley_NodeFile* nodes,
31 Dudley_ElementFile* elements,
32 const escript::Data* data,
33 escript::Data* interpolated_data)
34 {
35 if (!nodes || !elements)
36 return;
37
38 const int data_type = data->getFunctionSpace().getTypeCode();
39 const bool reduced_integration = Assemble_reducedIntegrationOrder(interpolated_data);
40
41 dim_t numNodes = 0;
42 index_t *map = NULL;
43
44 if (data_type == DUDLEY_NODES) {
45 numNodes = Dudley_NodeFile_getNumNodes(nodes);
46 map = Dudley_NodeFile_borrowTargetNodes(nodes);
47 } else if (data_type == DUDLEY_REDUCED_NODES) {
48 numNodes = Dudley_NodeFile_getNumReducedNodes(nodes);
49 map = Dudley_NodeFile_borrowTargetReducedNodes(nodes);
50 } else if (data_type == DUDLEY_DEGREES_OF_FREEDOM) {
51 if (elements->MPIInfo->size > 1) {
52 throw DudleyException("Assemble_interpolate: for more than one processor DEGREES_OF_FREEDOM data are not accepted as input.");
53 }
54 numNodes = Dudley_NodeFile_getNumDegreesOfFreedom(nodes);
55 map = Dudley_NodeFile_borrowTargetDegreesOfFreedom(nodes);
56 } else if (data_type == DUDLEY_REDUCED_DEGREES_OF_FREEDOM) {
57 if (elements->MPIInfo->size > 1) {
58 throw DudleyException("Assemble_interpolate: for more than one processor REDUCED_DEGREES_OF_FREEDOM data are not accepted as input.");
59 }
60 numNodes = Dudley_NodeFile_getNumReducedDegreesOfFreedom(nodes);
61 map = Dudley_NodeFile_borrowTargetReducedDegreesOfFreedom(nodes);
62 } else {
63 throw DudleyException("Assemble_interpolate: Cannot interpolate data");
64 }
65
66 const dim_t numComps = data->getDataPointSize();
67 const int NN = elements->numNodes;
68 const int numQuad = reduced_integration ? 1 : (elements->numDim + 1);
69 const int NS_DOF = elements->numDim + 1;
70 const double *shapeFns = NULL;
71
72 // check the dimensions of interpolated_data and data
73 if (!interpolated_data->numSamplesEqual(numQuad, elements->numElements)) {
74 throw DudleyException("Assemble_interpolate: illegal number of samples of output Data object");
75 } else if (!data->numSamplesEqual(1, numNodes)) {
76 throw DudleyException("Assemble_interpolate: illegal number of samples of input Data object");
77 } else if (numComps != interpolated_data->getDataPointSize()) {
78 throw DudleyException("Assemble_interpolate: number of components of input and interpolated Data do not match.");
79 } else if (!interpolated_data->actsExpanded()) {
80 throw DudleyException("Assemble_interpolate: expanded Data object is expected for output data.");
81 }
82
83 if (!getQuadShape(elements->numDim, reduced_integration, &shapeFns)) {
84 throw DudleyException("Assemble_interpolate: unable to locate shape function.");
85 }
86
87 interpolated_data->requireWrite();
88 #pragma omp parallel
89 {
90 std::vector<double> local_data(NS_DOF * numComps);
91 const size_t numComps_size = numComps *sizeof(double);
92 /* open the element loop */
93 #pragma omp for
94 for (index_t e = 0; e < elements->numElements; e++) {
95 for (int q = 0; q < NS_DOF; q++) {
96 const index_t i = elements->Nodes[INDEX2(q, e, NN)];
97 const double* data_array = data->getSampleDataRO(map[i]);
98 memcpy(&local_data[INDEX3(0, q, 0, numComps, NS_DOF)],
99 data_array, numComps_size);
100 }
101 // calculate interpolated_data=local_data*S
102 Dudley_Util_SmallMatSetMult1(1, numComps, numQuad,
103 interpolated_data->getSampleDataRW(e), NS_DOF,
104 &local_data[0], shapeFns);
105 } // end of element loop
106 } // end of parallel region
107 }
108
109 } // namespace dudley
110

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-6007 /trunk/ripley/test/python/dudley/src/Assemble_interpolate.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26