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

Contents of /branches/trilinos_from_5897/dudley/src/Assemble_AverageElementData.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: 3593 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: averages data
20
21 *****************************************************************************/
22
23 #include "Assemble.h"
24 #include "ShapeTable.h"
25 #include "Util.h"
26
27 namespace dudley {
28
29 void Assemble_AverageElementData(Dudley_ElementFile* elements, escript::Data* out, const escript::Data* in)
30 {
31 if (!elements)
32 return;
33
34 double wq;
35 int numQuad_in, numQuad_out;
36 if (Assemble_reducedIntegrationOrder(in)) {
37 numQuad_in = QuadNums[elements->numDim][0];
38 wq = QuadWeight[elements->numDim][0];
39 } else {
40 numQuad_in = QuadNums[elements->numDim][1];
41 wq = QuadWeight[elements->numDim][1];
42 }
43 if (Assemble_reducedIntegrationOrder(out)) {
44 numQuad_out = QuadNums[elements->numDim][0];
45 } else {
46 numQuad_out = QuadNums[elements->numDim][1];
47 }
48
49 const int numComps = out->getDataPointSize();
50 const dim_t numElements = elements->numElements;
51
52 // check out and in
53 if (numComps != in->getDataPointSize()) {
54 throw DudleyException("Assemble_AverageElementData: number of components of input and output Data do not match.");
55 } else if (!in->numSamplesEqual(numQuad_in, numElements)) {
56 throw DudleyException("Assemble_AverageElementData: illegal number of samples of input Data object");
57 } else if (!out->numSamplesEqual(numQuad_out, numElements)) {
58 throw DudleyException("Assemble_AverageElementData: illegal number of samples of output Data object");
59 } else if (!out->actsExpanded()) {
60 throw DudleyException("Assemble_AverageElementData: expanded Data object is expected for output data.");
61 } else {
62 out->requireWrite();
63 if (in->actsExpanded()) {
64 const double vol = wq * numQuad_in;
65 const double volinv = 1. / vol;
66 #pragma omp parallel for
67 for (index_t n = 0; n < numElements; n++) {
68 const double* in_array = in->getSampleDataRO(n);
69 double* out_array = out->getSampleDataRW(n);
70 for (int i = 0; i < numComps; ++i) {
71 double rtmp = 0.;
72 for (int q = 0; q < numQuad_in; ++q)
73 rtmp += in_array[INDEX2(i, q, numComps)] * wq;
74 rtmp *= volinv;
75 for (int q = 0; q < numQuad_out; ++q)
76 out_array[INDEX2(i, q, numComps)] = rtmp;
77 }
78 }
79 } else { // constant data
80 const size_t numComps_size = numComps * sizeof(double);
81 #pragma omp parallel for
82 for (index_t n = 0; n < numElements; n++) {
83 const double* in_array = in->getSampleDataRO(n);
84 double* out_array = out->getSampleDataRW(n);
85 for (int q = 0; q < numQuad_out; q++)
86 memcpy(out_array + q * numComps, in_array, numComps_size);
87 }
88 }
89 }
90 }
91
92 } // namespace dudley
93

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26