Epetra Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Epetra_MapColoring.h
Go to the documentation of this file.
1
/*
2
//@HEADER
3
// ************************************************************************
4
//
5
// Epetra: Linear Algebra Services Package
6
// Copyright 2011 Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39
//
40
// ************************************************************************
41
//@HEADER
42
*/
43
44
#ifndef EPETRA_MAPCOLORING_H
45
#define EPETRA_MAPCOLORING_H
46
47
#include "
Epetra_ConfigDefs.h
"
48
#include "
Epetra_DistObject.h
"
49
#include "
Epetra_BlockMap.h
"
50
#include "
Epetra_Distributor.h
"
51
52
template
<
typename
value_type>
class
Epetra_HashTable
;
53
class
Epetra_Map
;
54
56
104
105
class
EPETRA_LIB_DLL_EXPORT
Epetra_MapColoring
:
public
Epetra_DistObject
{
106
107
public
:
108
110
111
123
Epetra_MapColoring
(
const
Epetra_BlockMap
&
Map
,
const
int
DefaultColor
= 0);
124
126
144
Epetra_MapColoring
(
const
Epetra_BlockMap
&
Map
,
int
*
ElementColors
,
const
int
DefaultColor
= 0);
145
147
148
Epetra_MapColoring
(
const
Epetra_MapColoring
& Source);
149
151
152
virtual
~Epetra_MapColoring
();
154
156
157
159
162
int
& operator [] (
int
LID) {
ListsAreValid_
=
false
;
return
ElementColors_
[LID];};
163
165
170
int
& operator () (
long
long
GID) {
ListsAreValid_
=
false
;
return
ElementColors_
[
Map
().
LID
(GID)];};
172
174
175
179
const
int
& operator [] (
int
LID)
const
{
return
ElementColors_
[LID];};
180
182
187
const
int
& operator () (
long
long
GID)
const
{
return
ElementColors_
[
Map
().
LID
(GID)];};
189
191
192
193
int
NumColors
()
const
{
if
(!
ListsAreValid_
)
GenerateLists
();
return
(
NumColors_
);};
194
196
int
MaxNumColors()
const
;
197
199
203
int
*
ListOfColors
()
const
{
if
(!
ListsAreValid_
)
GenerateLists
();
return
(
ListOfColors_
);};
204
206
int
DefaultColor
()
const
{
return
(
DefaultColor_
);};
207
209
int
NumElementsWithColor(
int
Color)
const
;
210
212
216
int
* ColorLIDList(
int
Color)
const
;
217
219
222
int
*
ElementColors
()
const
{
if
(!
ListsAreValid_
)
GenerateLists
();
return
(
ElementColors_
);};
223
225
227
234
Epetra_Map
* GenerateMap(
int
Color)
const
;
235
237
244
Epetra_BlockMap
* GenerateBlockMap(
int
Color)
const
;
246
248
249
251
virtual
void
Print(std::ostream & os)
const
;
253
254
private
:
255
int
Allocate(
int
* ElementColors,
int
Increment);
256
int
GenerateLists()
const
;
257
int
DeleteLists()
const
;
258
bool
InItemList(
int
ColorValue)
const
;
259
260
// Routines to implement Epetra_DistObject virtual methods
261
262
int
CheckSizes(
const
Epetra_SrcDistObject
& A);
263
int
CopyAndPermute(
const
Epetra_SrcDistObject
& Source,
264
int
NumSameIDs,
265
int
NumPermuteIDs,
266
int
* PermuteToLIDs,
267
int
* PermuteFromLIDs,
268
const
Epetra_OffsetIndex
* Indexor,
269
Epetra_CombineMode
CombineMode =
Zero
);
270
271
int
PackAndPrepare(
const
Epetra_SrcDistObject
& Source,
272
int
NumExportIDs,
273
int
* ExportLIDs,
274
int
& LenExports,
275
char
* & Exports,
276
int
& SizeOfPacket,
277
int
* Sizes,
278
bool
& VarSizes,
279
Epetra_Distributor
& Distor);
280
281
int
UnpackAndCombine(
const
Epetra_SrcDistObject
& Source,
282
int
NumImportIDs,
283
int
* ImportLIDs,
284
int
LenImports,
285
char
* Imports,
286
int
& SizeOfPacket,
287
Epetra_Distributor
& Distor,
288
Epetra_CombineMode
CombineMode,
289
const
Epetra_OffsetIndex
* Indexor );
290
291
292
struct
ListItem
{
293
int
ItemValue
;
294
ListItem
*
NextItem
;
295
296
ListItem
(
const
int
itemValue = 0,
ListItem
* nextItem = 0)
297
:
ItemValue
(itemValue),
NextItem
(nextItem){}
298
299
// Constructors commented out due to Intel v.7.1 compiler error (4/2005).
300
//ListItem(const Epetra_MapColoring::ListItem & Item); // Make these inaccessible
301
//ListItem & operator=(const Epetra_MapColoring::ListItem & Item);
302
};
303
304
int
DefaultColor_
;
305
mutable
Epetra_HashTable<int>
*
ColorIDs_
;
306
mutable
ListItem
*
FirstColor_
;
307
mutable
int
NumColors_
;
308
mutable
int
*
ListOfColors_
;
309
mutable
int
*
ColorCount_
;
310
mutable
int
*
ElementColors_
;
311
mutable
int
**
ColorLists_
;
312
bool
Allocated_
;
313
mutable
bool
ListsAreGenerated_
;
314
mutable
bool
ListsAreValid_
;
315
316
Epetra_MapColoring
&
operator=
(
const
Epetra_MapColoring
& Coloring);
// Make these inaccessible
317
318
template
<
typename
int
_type>
319
Epetra_Map
*
TGenerateMap
(
int
Color)
const
;
320
321
template
<
typename
int
_type>
322
Epetra_BlockMap
*
TGenerateBlockMap
(
int
Color)
const
;
323
};
324
325
#endif
/* EPETRA_MAPCOLORING_H */
Epetra_BlockMap.h
Epetra_CombineMode
Epetra_CombineMode
Definition
Epetra_CombineMode.h:64
Zero
@ Zero
Definition
Epetra_CombineMode.h:66
Epetra_ConfigDefs.h
Epetra_DistObject.h
Epetra_Distributor.h
Epetra_BlockMap
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
Definition
Epetra_BlockMap.h:194
Epetra_BlockMap::LID
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
Definition
Epetra_BlockMap.cpp:1218
Epetra_DistObject::Map
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.
Definition
Epetra_DistObject.h:192
Epetra_DistObject::Epetra_DistObject
Epetra_DistObject(const Epetra_BlockMap &Map)
Basic Epetra_DistObject constuctor.
Definition
Epetra_DistObject.cpp:54
Epetra_Distributor
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
Definition
Epetra_Distributor.h:61
Epetra_HashTable
Definition
Epetra_HashTable.h:51
Epetra_MapColoring::ListOfColors_
int * ListOfColors_
Definition
Epetra_MapColoring.h:308
Epetra_MapColoring::NumColors
int NumColors() const
Returns number of colors on the calling processor.
Definition
Epetra_MapColoring.h:193
Epetra_MapColoring::NumColors_
int NumColors_
Definition
Epetra_MapColoring.h:307
Epetra_MapColoring::operator=
Epetra_MapColoring & operator=(const Epetra_MapColoring &Coloring)
Epetra_MapColoring::TGenerateMap
Epetra_Map * TGenerateMap(int Color) const
Definition
Epetra_MapColoring.cpp:224
Epetra_MapColoring::ListOfColors
int * ListOfColors() const
Array of length NumColors() containing List of color values used in this coloring.
Definition
Epetra_MapColoring.h:203
Epetra_MapColoring::GenerateLists
int GenerateLists() const
Definition
Epetra_MapColoring.cpp:146
Epetra_MapColoring::DefaultColor
int DefaultColor() const
Returns default color.
Definition
Epetra_MapColoring.h:206
Epetra_MapColoring::TGenerateBlockMap
Epetra_BlockMap * TGenerateBlockMap(int Color) const
Definition
Epetra_MapColoring.cpp:263
Epetra_MapColoring::DefaultColor_
int DefaultColor_
Definition
Epetra_MapColoring.h:304
Epetra_MapColoring::ElementColors_
int * ElementColors_
Definition
Epetra_MapColoring.h:310
Epetra_MapColoring::FirstColor_
ListItem * FirstColor_
Definition
Epetra_MapColoring.h:306
Epetra_MapColoring::ColorIDs_
Epetra_HashTable< int > * ColorIDs_
Definition
Epetra_MapColoring.h:305
Epetra_MapColoring::ListsAreGenerated_
bool ListsAreGenerated_
Definition
Epetra_MapColoring.h:313
Epetra_MapColoring::ListsAreValid_
bool ListsAreValid_
Definition
Epetra_MapColoring.h:314
Epetra_MapColoring::Epetra_MapColoring
Epetra_MapColoring(const Epetra_BlockMap &Map, const int DefaultColor=0)
Epetra_MapColoring basic constructor.
Definition
Epetra_MapColoring.cpp:69
Epetra_MapColoring::ElementColors
int * ElementColors() const
Returns pointer to array of the colors associated with the LIDs on the calling processor.
Definition
Epetra_MapColoring.h:222
Epetra_MapColoring::ColorCount_
int * ColorCount_
Definition
Epetra_MapColoring.h:309
Epetra_MapColoring::Allocated_
bool Allocated_
Definition
Epetra_MapColoring.h:312
Epetra_MapColoring::ColorLists_
int ** ColorLists_
Definition
Epetra_MapColoring.h:311
Epetra_Map
Epetra_Map: A class for partitioning vectors and matrices.
Definition
Epetra_Map.h:119
Epetra_OffsetIndex
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
Definition
Epetra_OffsetIndex.h:60
Epetra_SrcDistObject
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
Definition
Epetra_SrcDistObject.h:63
Epetra_MapColoring::ListItem
Definition
Epetra_MapColoring.h:292
Epetra_MapColoring::ListItem::NextItem
ListItem * NextItem
Definition
Epetra_MapColoring.h:294
Epetra_MapColoring::ListItem::ListItem
ListItem(const int itemValue=0, ListItem *nextItem=0)
Definition
Epetra_MapColoring.h:296
Epetra_MapColoring::ListItem::ItemValue
int ItemValue
Definition
Epetra_MapColoring.h:293
Generated by
1.18.0