Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
containers
Lists
SortableList
ParSortableList.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::ParSortableList
26
27
Description
28
Implementation of PSRS parallel sorting routine.
29
30
From "On the Versatility of Parallel Sorting by Regular Sampling"
31
Xiaobo Li et. all.
32
33
Construct from list of things to sort (uses SortableList, 'thing' should
34
implement >, ==).
35
36
Will contain sorted data and in
37
- indices() the original indices
38
- procs() the original processor id.
39
40
Can also be constructed from size, filled at ease and then sort()'ed.
41
42
SourceFiles
43
ParSortableList.C
44
45
\*---------------------------------------------------------------------------*/
46
47
#ifndef ParSortableList_H
48
#define ParSortableList_H
49
50
#include <
OpenFOAM/labelList.H
>
51
52
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54
namespace
Foam
55
{
56
57
58
/*---------------------------------------------------------------------------*\
59
Class ParSortableListName Declaration
60
\*---------------------------------------------------------------------------*/
61
62
TemplateName
(ParSortableList);
63
64
65
/*---------------------------------------------------------------------------*\
66
Class ParSortableList Declaration
67
\*---------------------------------------------------------------------------*/
68
69
template
<
class
Type>
70
class
ParSortableList
71
:
72
public
ParSortableListName,
73
public
List
<Type>
74
{
75
// Private data
76
77
//- Original indices
78
labelList
indices_;
79
80
//- Processor numbers
81
labelList
procs_;
82
83
84
// Private class
85
86
//- Private class for sorting. Sorts on value_.
87
class
taggedValue
88
{
89
// Private data
90
91
//- Value
92
Type value_;
93
94
//- Index
95
label index_;
96
97
//- Proc
98
label procID_;
99
100
101
public
:
102
103
// Constructors
104
105
taggedValue()
106
{}
107
108
// Member Functions
109
110
const
Type& value()
const
111
{
112
return
value_;
113
}
114
115
Type& value()
116
{
117
return
value_;
118
}
119
120
label index()
const
121
{
122
return
index_;
123
}
124
125
label& index()
126
{
127
return
index_;
128
}
129
130
label procID()
const
131
{
132
return
procID_;
133
}
134
135
label& procID()
136
{
137
return
procID_;
138
}
139
};
140
141
142
// Private Member Functions
143
144
//- Write for debugging
145
void
write(
const
List<Type>
& elems,
Ostream
& os)
const
;
146
147
//- Copy into dest, setting indices and processor no.
148
void
copyInto
149
(
150
const
List<Type>
& values,
151
const
labelList
&
indices
,
152
const
label fromProcNo,
153
label& destI,
154
List<taggedValue>
& dest
155
)
const
;
156
157
//- Calculate pivots.
158
void
getPivots(
const
List<Type>
& elems,
List<Type>
& pivots)
const
;
159
160
//- If destProc != myProcNo send & clear values and indices
161
void
checkAndSend
162
(
163
List<Type>
& values,
164
labelList
& indices,
165
const
label bufSize,
166
const
label destProcI
167
)
const
;
168
169
170
public
:
171
172
// Constructors
173
174
//- Construct from List, sorting the elements.
175
ParSortableList
(
const
UList<Type>
&);
176
177
//- Construct given size. Sort later on.
178
ParSortableList
(
const
label
size
);
179
180
181
// Member Functions
182
183
//- (stable) sort the list (if changed after construction time)
184
void
sort
();
185
186
//- Return the list of sorted point indices
187
const
labelList
&
indices
()
const
188
{
189
return
indices_;
190
}
191
192
//- Return the list of processor number
193
const
labelList
&
procs
()
const
194
{
195
return
procs_;
196
}
197
};
198
199
200
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202
}
// End namespace Foam
203
204
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206
#ifdef NoRepository
207
# include <
OpenFOAM/ParSortableList.C
>
208
#endif
209
210
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212
#endif
213
214
// ************************ vim: set sw=4 sts=4 et: ************************ //