Epetra Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Epetra_CrsGraphData.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_CRSGRAPHDATA_H
45#define EPETRA_CRSGRAPHDATA_H
46
47#include "Epetra_ConfigDefs.h"
48#include "Epetra_Data.h"
49#include "Epetra_DataAccess.h"
50#include "Epetra_BlockMap.h"
52
53#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
55#endif
56
57// include STL vector
58#include <vector>
59class Epetra_Import;
60class Epetra_Export;
61
63
67
68class EPETRA_LIB_DLL_EXPORT Epetra_CrsGraphData : public Epetra_Data {
69 friend class Epetra_CrsGraph;
70 friend class Epetra_FECrsGraph;
71 friend class Epetra_CrsMatrix;
72 private:
73
75
76
78 Epetra_CrsGraphData(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, bool StaticProfile);
79
81 Epetra_CrsGraphData(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, bool StaticProfile);
82
85
88
90
92
98 void Print(std::ostream& os, int level = 3) const;
99
102
104
105
116 template<typename int_type>
118 {
119 public:
125 std::vector<int_type> entries_;
126
131 void AddEntry (const int_type col_num);
132
136 void AddEntries (const int n_cols,
137 const int_type *col_nums);
138 };
139
141 int MakeImportExport();
142
144 int ReAllocateAndCast(char*& UserPtr, int& Length, const int IntPacketSizeTimesNumTrans);
145
147
148 // Defined by CrsGraph::FillComplete and related
153
156
172
173 long long IndexBase_;
174
183
190
192 long long NumGlobalRows_;
193 long long NumGlobalCols_;
199
202
208
209 template<typename int_type>
210 struct IndexData;
211
213#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
215#endif
216
217 template<typename int_type>
219};
220
221#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
222
223template<>
225{
226 long long** Indices_;
227 std::vector< EntriesInOneRow<long long> > SortedEntries_;
228 long long* TempColIndices_;
230
231 IndexData(int NumMyBlockRows, bool AllocSorted)
232 :
233 Indices_(NULL),
235 TempColIndices_(NULL),
236 All_Indices_(0)
237 {
238 Allocate(NumMyBlockRows, AllocSorted);
239 }
240
241 virtual ~IndexData()
242 {
243 Deallocate();
244 }
245
246 void Allocate(int NumMyBlockRows, bool AllocSorted)
247 {
248 Deallocate();
249
250 if(AllocSorted)
251 SortedEntries_.resize(NumMyBlockRows);
252 if(NumMyBlockRows > 0)
253 Indices_ = new long long *[NumMyBlockRows];
254 }
255
257 {
258 delete[] Indices_;
259 Indices_ = 0;
260
261 std::vector< EntriesInOneRow<long long> > empty;
262 SortedEntries_.swap(empty);
263
264 delete [] TempColIndices_;
265 TempColIndices_ = 0;
266
267 All_Indices_.Resize(0);
268 }
269};
270
271#endif
272
273template<>
275{
276 int** Indices_;
277 std::vector< EntriesInOneRow<int> > SortedEntries_;
281
282 IndexData(int NumMyBlockRows, bool AllocSorted)
283 :
284 Indices_(NULL),
286 TempColIndices_(NULL),
287 All_Indices_(0),
289 {
290 Allocate(NumMyBlockRows, AllocSorted);
291 }
292
293 void Allocate(int NumMyBlockRows, bool AllocSorted)
294 {
295 Deallocate();
296
297 if(AllocSorted)
298 SortedEntries_.resize(NumMyBlockRows);
299
300 if(NumMyBlockRows > 0)
301 Indices_ = new int *[NumMyBlockRows];
302 }
303
305 {
306 delete[] Indices_;
307 Indices_ = 0;
308
309 std::vector< EntriesInOneRow<int> > empty;
310 SortedEntries_.swap(empty);
311
312 delete [] TempColIndices_;
313 TempColIndices_ = 0;
314
315 All_Indices_.Resize(0);
316 All_IndicesPlus1_.Resize(0);
317 }
318};
319
320#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
321template<>
323{
325 return *LL_data;
326 else
327 throw "Epetra_CrsGraphData::Data<long long>: Map indices not long long or are local";
328}
329#endif
330
331template<>
333{
334 if(RowMap_.GlobalIndicesInt() || (RowMap_.GlobalIndicesLongLong() && !IndicesAreGlobal_))
335 return *data;
336 else
337 throw "Epetra_CrsGraphData::Data<int>: Map indices not int or are global long long";
338}
339
340
341#endif /* EPETRA_CRSGRAPHDATA_H */
Epetra_DataAccess Mode enumerable type.
Epetra_DataAccess
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
IndexData< long long > * LL_data
int ReAllocateAndCast(char *&UserPtr, int &Length, const int IntPacketSizeTimesNumTrans)
called by PackAndPrepare
void Print(std::ostream &os, int level=3) const
Outputs state of almost all data members. (primarily used for testing purposes).
IndexData< int > * data
Epetra_CrsGraphData & operator=(const Epetra_CrsGraphData &CrsGraphData)
Epetra_CrsGraphData assignment operator (not defined)
IndexData< int_type > & Data()
Epetra_CrsGraphData(const Epetra_CrsGraphData &CrsGraphData)
Epetra_CrsGraphData copy constructor (not defined).
const Epetra_Import * Importer_
Epetra_IntSerialDenseVector NumIndicesPerRow_
Epetra_IntSerialDenseVector NumAllocatedIndicesPerRow_
int MakeImportExport()
called by FillComplete (and TransformToLocal)
Epetra_CrsGraphData(Epetra_DataAccess CV, const Epetra_BlockMap &RowMap, bool StaticProfile)
Epetra_CrsGraphData Default Constructor.
const Epetra_Export * Exporter_
Epetra_IntSerialDenseVector IndexOffset_
Epetra_Data()
Epetra_Data Serial Constructor.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
Store some data for each row describing which entries of this row are nonzero.
void AddEntry(const int_type col_num)
Add the given column number to this line.
void AddEntries(const int n_cols, const int_type *col_nums)
Add many entries to one row.
std::vector< int_type > entries_
Storage for the column indices of this row.
Epetra_IntSerialDenseVector All_IndicesPlus1_
Epetra_IntSerialDenseVector All_Indices_
IndexData(int NumMyBlockRows, bool AllocSorted)
std::vector< EntriesInOneRow< int > > SortedEntries_
void Allocate(int NumMyBlockRows, bool AllocSorted)
Epetra_LongLongSerialDenseVector All_Indices_
std::vector< EntriesInOneRow< long long > > SortedEntries_
IndexData(int NumMyBlockRows, bool AllocSorted)
void Allocate(int NumMyBlockRows, bool AllocSorted)