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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 7011 - (show annotations)
Wed Jul 22 04:13:34 2020 UTC (9 months, 2 weeks ago) by uqaeller
File MIME type: text/plain
File size: 3129 byte(s)
Prototype for the builtin MUMPS solver.


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 /* Paso: shared components */
22
23 /****************************************************************************/
24
25 /* Author: Lutz Gross, l.gross@uq.edu.au */
26
27 /****************************************************************************/
28
29 #ifndef __PASO_SHAREDCOMPONENTS_H__
30 #define __PASO_SHAREDCOMPONENTS_H__
31
32 #include "Paso.h"
33
34 namespace paso {
35
36 struct SharedComponents;
37 typedef boost::shared_ptr<SharedComponents> SharedComponents_ptr;
38 typedef boost::shared_ptr<const SharedComponents> const_SharedComponents_ptr;
39
40 struct PASO_DLL_API SharedComponents
41 {
42 SharedComponents(dim_t localLength, const std::vector<int>& neighbours,
43 const index_t* sharedArray,
44 const std::vector<index_t>& offset,
45 index_t m = 1, index_t b = 0)
46 : local_length(localLength*m),
47 neighbour(neighbours),
48 offsetInShared(offset)
49 {
50 if (offset.empty()) {
51 numSharedComponents = 0;
52 } else {
53 numSharedComponents = offset[neighbours.size()] * m;
54 }
55 shared = new index_t[numSharedComponents];
56 if (!neighbours.empty() && !offset.empty()) {
57 if (m != 1) {
58 for (int i = 0; i < offsetInShared.size(); i++) {
59 offsetInShared[i] *= m;
60 }
61 }
62 #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 } else {
69 offsetInShared[neighbours.size()] = 0;
70 }
71 }
72
73 ~SharedComponents()
74 {
75 delete[] shared;
76 }
77
78 /// local array length shared
79 dim_t local_length;
80
81 /// list of the processors sharing values with this processor
82 std::vector<int> neighbour;
83
84 /// offsetInShared[i] points to the first input value in array shared
85 /// for processor i. Has length numNeighbors+1
86 std::vector<index_t> offsetInShared;
87
88 /// list of the (local) components which are shared with other processors.
89 /// Has length numSharedComponents
90 index_t* shared;
91
92 /// = offsetInShared[numNeighbours]
93 dim_t numSharedComponents;
94 };
95
96 } // namespace paso
97
98 #endif // __PASO_SHAREDCOMPONENTS_H__
99

  ViewVC Help
Powered by ViewVC 1.1.26