/[escript]/trunk/finley/src/Assemble_integrate.cpp
ViewVC logotype

Contents of /trunk/finley/src/Assemble_integrate.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6939 - (show annotations)
Mon Jan 20 03:37:18 2020 UTC (4 months, 1 week ago) by uqaeller
File size: 4070 byte(s)
Updated the copyright header.


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2020 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
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-2017 by Centre for Geoscience Computing (GeoComp)
14 * Development from 2019 by School of Earth and Environmental Sciences
15 **
16 *****************************************************************************/
17
18
19 /****************************************************************************
20
21 Assemblage routines: integrates data on quadrature points
22
23 *****************************************************************************/
24
25 #include "Assemble.h"
26 #include "Util.h"
27
28 #include <escript/index.h>
29 #include <escript/Utils.h>
30
31 namespace finley {
32
33 template<typename Scalar>
34 void Assemble_integrate(const NodeFile* nodes, const ElementFile* elements,
35 const escript::Data& data, Scalar* out)
36 {
37 if (!nodes || !elements)
38 return;
39
40 const int my_mpi_rank = nodes->MPIInfo->rank;
41 ElementFile_Jacobians* jac = elements->borrowJacobians(nodes, false,
42 util::hasReducedIntegrationOrder(data));
43
44 bool HavePointData = data.getFunctionSpace().getTypeCode() == Points;
45
46 const int numQuadTotal = jac->numQuadTotal;
47 // check the shape of the data
48 if (!data.numSamplesEqual(numQuadTotal, elements->numElements) && !HavePointData) {
49 throw escript::ValueError("Assemble_integrate: illegal number of samples of integrant kernel Data object");
50 }
51
52 const int numComps = data.getDataPointSize();
53 const Scalar zero = static_cast<Scalar>(0);
54
55 for (int q = 0; q < numComps; q++)
56 out[q] = zero;
57
58 #ifdef ESYS_MPI
59 if(HavePointData && escript::getMPIRankWorld() == 0)
60 #else
61 if(HavePointData)
62 #endif
63 out[0] += data.getNumberOfTaggedValues();
64 else
65 #pragma omp parallel
66 {
67 std::vector<Scalar> out_local(numComps);
68 {
69 if (data.actsExpanded()) {
70 #pragma omp for
71 for (index_t e = 0; e < elements->numElements; e++) {
72 if (elements->Owner[e] == my_mpi_rank) {
73 const Scalar* data_array = data.getSampleDataRO(e, zero);
74 for (int q = 0; q < numQuadTotal; q++) {
75 for (int i = 0; i < numComps; i++)
76 out_local[i] += data_array[INDEX2(i,q,numComps)]*jac->volume[INDEX2(q,e,numQuadTotal)];
77 }
78 }
79 }
80 } else {
81 #pragma omp for
82 for (index_t e = 0; e < elements->numElements; e++) {
83 if (elements->Owner[e] == my_mpi_rank) {
84 const Scalar* data_array = data.getSampleDataRO(e, zero);
85 double rtmp = 0.;
86 for (int q = 0; q < numQuadTotal; q++)
87 rtmp += jac->volume[INDEX2(q, e, numQuadTotal)];
88 for (int i = 0; i < numComps; i++)
89 out_local[i] += data_array[i] * rtmp;
90 }
91 }
92 }
93 }
94 // add local results to global result
95 #pragma omp critical
96 for (int i = 0; i < numComps; i++)
97 out[i] += out_local[i];
98 } // parallel section
99 }
100
101 // instantiate our two supported versions
102 template void Assemble_integrate<escript::DataTypes::real_t>(
103 const NodeFile* nodes, const ElementFile* elements,
104 const escript::Data& data, escript::DataTypes::real_t* out);
105 template void Assemble_integrate<escript::DataTypes::cplx_t>(
106 const NodeFile* nodes, const ElementFile* elements,
107 const escript::Data& data, escript::DataTypes::cplx_t* out);
108
109 } // namespace finley

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/finley/src/Assemble_integrate.cpp:5567-5588 /branches/lapack2681/finley/src/Assemble_integrate.cpp:2682-2741 /branches/pasowrap/finley/src/Assemble_integrate.cpp:3661-3674 /branches/py3_attempt2/finley/src/Assemble_integrate.cpp:3871-3891 /branches/restext/finley/src/Assemble_integrate.cpp:2610-2624 /branches/ripleygmg_from_3668/finley/src/Assemble_integrate.cpp:3669-3791 /branches/stage3.0/finley/src/Assemble_integrate.cpp:2569-2590 /branches/symbolic_from_3470/finley/src/Assemble_integrate.cpp:3471-3974 /branches/trilinos_from_5897/finley/src/Assemble_integrate.cpp:5898-6118 /release/3.0/finley/src/Assemble_integrate.cpp:2591-2601 /release/4.0/finley/src/Assemble_integrate.cpp:5380-5406 /trunk/finley/src/Assemble_integrate.cpp:4257-4344

  ViewVC Help
Powered by ViewVC 1.1.26