/[escript]/trunk/paso/src/SharedComponents.h
ViewVC logotype

Annotation of /trunk/paso/src/SharedComponents.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (21 months, 1 week ago) by jfenwick
File MIME type: text/plain
File size: 3053 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 ksteube 1313
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 6651 * Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
7     * Primary Business: Queensland, Australia
8 jfenwick 6112 * Licensed under the Apache License, version 2.0
9     * http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1811 *
11 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 ksteube 1313
17 ksteube 1811
18 caltinay 4810 /****************************************************************************/
19 ksteube 1313
20 caltinay 4873 /* Paso: shared components */
21 ksteube 1313
22 caltinay 4810 /****************************************************************************/
23 ksteube 1313
24 jfenwick 2608 /* Author: Lutz Gross, l.gross@uq.edu.au */
25 ksteube 1313
26 caltinay 4810 /****************************************************************************/
27 ksteube 1313
28 caltinay 4816 #ifndef __PASO_SHAREDCOMPONENTS_H__
29     #define __PASO_SHAREDCOMPONENTS_H__
30 ksteube 1313
31 caltinay 4869 #include "Paso.h"
32 ksteube 1313
33 caltinay 4816 namespace paso {
34 ksteube 1313
35 caltinay 4816 struct SharedComponents;
36     typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
37     typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
38 gross 1562
39 caltinay 4816 PASO_DLL_API
40     struct SharedComponents
41     {
42 caltinay 6172 SharedComponents(dim_t localLength, const std::vector<int>& neighbours,
43     const index_t* sharedArray,
44     const std::vector<index_t>& offset,
45 caltinay 6173 index_t m = 1, index_t b = 0)
46 caltinay 4816 : local_length(localLength*m),
47 caltinay 6172 neighbour(neighbours),
48 caltinay 6173 offsetInShared(offset)
49 caltinay 4816 {
50 caltinay 6172 if (offset.empty()) {
51 caltinay 4816 numSharedComponents = 0;
52     } else {
53 caltinay 6172 numSharedComponents = offset[neighbours.size()] * m;
54 caltinay 4816 }
55     shared = new index_t[numSharedComponents];
56 caltinay 6172 if (!neighbours.empty() && !offset.empty()) {
57     if (m != 1) {
58     for (int i = 0; i < offsetInShared.size(); i++) {
59     offsetInShared[i] *= m;
60 caltinay 4816 }
61     }
62 caltinay 6172 #pragma omp parallel for
63     for (dim_t i = 0; i < offset[neighbours.size()]; i++) {
64     const index_t itmp = m * sharedArray[i] + b;
65     for (dim_t j = 0; j < m; ++j)
66     shared[m*i+j] = itmp+j;
67     }
68 caltinay 4816 } else {
69 caltinay 6172 offsetInShared[neighbours.size()] = 0;
70 caltinay 4816 }
71     }
72 ksteube 1313
73 caltinay 4816 ~SharedComponents()
74     {
75     delete[] shared;
76     }
77 ksteube 1313
78 caltinay 4816 /// local array length shared
79     dim_t local_length;
80 ksteube 1313
81 caltinay 6172 /// list of the processors sharing values with this processor
82     std::vector<int> neighbour;
83 ksteube 1313
84 caltinay 6172 /// offsetInShared[i] points to the first input value in array shared
85 caltinay 4816 /// for processor i. Has length numNeighbors+1
86 caltinay 6172 std::vector<index_t> offsetInShared;
87 ksteube 1313
88 caltinay 4816 /// list of the (local) components which are shared with other processors.
89     /// Has length numSharedComponents
90     index_t* shared;
91 ksteube 1313
92 caltinay 6172 /// = offsetInShared[numNeighbours]
93 caltinay 4816 dim_t numSharedComponents;
94     };
95 phornby 2068
96 caltinay 4816 } // namespace paso
97 phornby 2068
98 caltinay 4816 #endif // __PASO_SHAREDCOMPONENTS_H__
99 ksteube 1313

  ViewVC Help
Powered by ViewVC 1.1.26