Epetra Package Browser (Single Doxygen Collection)  Development
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>
59 class Epetra_Import;
60 class Epetra_Export;
61 
63 
68 class 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 
84  Epetra_CrsGraphData(const Epetra_CrsGraphData& CrsGraphData);
85 
88 
90 
92 
98  void Print(std::ostream& os, int level = 3) const;
99 
101  Epetra_CrsGraphData& operator=(const Epetra_CrsGraphData& CrsGraphData);
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 
158  bool Filled_;
160  bool Sorted_;
172 
173  long long IndexBase_;
174 
175  long long NumGlobalEntries_;
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>
218  IndexData<int_type>& Data();
219 };
220 
221 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
222 
223 template<>
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),
234  SortedEntries_(),
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 
256  void Deallocate()
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 
273 template<>
275 {
276  int** Indices_;
277  std::vector< EntriesInOneRow<int> > SortedEntries_;
281 
282  IndexData(int NumMyBlockRows, bool AllocSorted)
283  :
284  Indices_(NULL),
285  SortedEntries_(),
286  TempColIndices_(NULL),
287  All_Indices_(0),
288  All_IndicesPlus1_(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 
304  void Deallocate()
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
321 template<>
322 inline Epetra_CrsGraphData::IndexData<long long>& Epetra_CrsGraphData::Data<long long>()
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 
331 template<>
332 inline Epetra_CrsGraphData::IndexData<int>& Epetra_CrsGraphData::Data<int>()
333 {
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_CrsGraphData::Exporter_
const Epetra_Export * Exporter_
Definition: Epetra_CrsGraphData.h:155
Epetra_CrsGraphData::IndexData
Definition: Epetra_CrsGraphData.h:210
Epetra_IntSerialDenseVector.h
Epetra_CrsGraphData::NumGlobalBlockCols_
long long NumGlobalBlockCols_
Definition: Epetra_CrsGraphData.h:177
Epetra_CrsGraphData::RowMap_
Epetra_BlockMap RowMap_
Definition: Epetra_CrsGraphData.h:149
Epetra_CrsGraphData::NumGlobalBlockDiagonals_
long long NumGlobalBlockDiagonals_
Definition: Epetra_CrsGraphData.h:178
Epetra_CrsGraphData::NoDiagonal_
bool NoDiagonal_
Definition: Epetra_CrsGraphData.h:168
Epetra_CrsMatrix::operator=
Epetra_CrsMatrix & operator=(const Epetra_CrsMatrix &src)
Assignment operator.
Definition: Epetra_CrsMatrix.cpp:262
Epetra_BlockMap::GlobalIndicesInt
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
Definition: Epetra_BlockMap.h:653
Epetra_Data
Epetra_Data: The Epetra Base Data Class.
Definition: Epetra_Data.h:73
Epetra_CrsGraphData::LL_data
IndexData< long long > * LL_data
Definition: Epetra_CrsGraphData.h:214
Epetra_CrsGraphData::NumMyDiagonals_
int NumMyDiagonals_
Definition: Epetra_CrsGraphData.h:198
Epetra_CrsGraphData::Filled_
bool Filled_
Definition: Epetra_CrsGraphData.h:158
Epetra_CrsGraphData::NumGlobalNonzeros_
long long NumGlobalNonzeros_
Definition: Epetra_CrsGraphData.h:191
Epetra_CrsGraphData::IndexData< int >::TempColIndices_
int * TempColIndices_
Definition: Epetra_CrsGraphData.h:278
Epetra_CrsGraphData::IndexData< int >::All_Indices_
Epetra_IntSerialDenseVector All_Indices_
Definition: Epetra_CrsGraphData.h:279
Epetra_CrsGraphData::GlobalConstantsComputed_
bool GlobalConstantsComputed_
Definition: Epetra_CrsGraphData.h:169
Epetra_CrsGraphData::IndexData< long long >::Allocate
void Allocate(int NumMyBlockRows, bool AllocSorted)
Definition: Epetra_CrsGraphData.h:246
Epetra_CrsGraphData::NumMyRows_
int NumMyRows_
Definition: Epetra_CrsGraphData.h:196
Epetra_CrsGraphData::IndexData< long long >::Deallocate
void Deallocate()
Definition: Epetra_CrsGraphData.h:256
Epetra_CrsGraphData::NumTempColIndices_
int NumTempColIndices_
Definition: Epetra_CrsGraphData.h:203
Epetra_CrsGraphData::IndexData< int >::Allocate
void Allocate(int NumMyBlockRows, bool AllocSorted)
Definition: Epetra_CrsGraphData.h:293
Epetra_CrsGraphData::DomainMap_
Epetra_BlockMap DomainMap_
Definition: Epetra_CrsGraphData.h:151
Epetra_CrsGraphData::NumGlobalBlockRows_
long long NumGlobalBlockRows_
Definition: Epetra_CrsGraphData.h:176
Epetra_CrsGraphData::NumGlobalEntries_
long long NumGlobalEntries_
Definition: Epetra_CrsGraphData.h:175
Epetra_CrsGraphData::IndicesAreLocal_
bool IndicesAreLocal_
Definition: Epetra_CrsGraphData.h:164
Epetra_CrsGraphData::NumMyNonzeros_
int NumMyNonzeros_
Definition: Epetra_CrsGraphData.h:195
Epetra_CrsGraphData::IndexData< int >::All_IndicesPlus1_
Epetra_IntSerialDenseVector All_IndicesPlus1_
Definition: Epetra_CrsGraphData.h:280
Epetra_CrsGraphData::NoRedundancies_
bool NoRedundancies_
Definition: Epetra_CrsGraphData.h:162
Epetra_CrsGraphData::NumIndicesPerRow_
Epetra_IntSerialDenseVector NumIndicesPerRow_
Definition: Epetra_CrsGraphData.h:205
Epetra_CrsGraphData::MaxNumNonzeros_
int MaxNumNonzeros_
Definition: Epetra_CrsGraphData.h:188
Epetra_LongLongSerialDenseVector
Epetra_LongLongSerialDenseVector: A class for constructing and using dense vectors.
Definition: Epetra_LongLongSerialDenseVector.h:90
Epetra_CrsGraphData::HaveColMap_
bool HaveColMap_
Definition: Epetra_CrsGraphData.h:157
Epetra_CrsGraphData::IndexOffset_
Epetra_IntSerialDenseVector IndexOffset_
Definition: Epetra_CrsGraphData.h:206
Epetra_CrsGraphData::MaxColDim_
int MaxColDim_
Definition: Epetra_CrsGraphData.h:185
Epetra_BlockMap::GlobalIndicesLongLong
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
Definition: Epetra_BlockMap.h:655
Epetra_CrsGraphData::NumGlobalCols_
long long NumGlobalCols_
Definition: Epetra_CrsGraphData.h:193
Epetra_CrsGraphData::IndexData< int >::Deallocate
void Deallocate()
Definition: Epetra_CrsGraphData.h:304
Epetra_CrsGraphData
Epetra_CrsGraphData: The Epetra CrsGraph Data Class.
Definition: Epetra_CrsGraphData.h:68
Epetra_CrsGraphData::Sorted_
bool Sorted_
Definition: Epetra_CrsGraphData.h:160
Epetra_CrsGraphData::NumMyEntries_
int NumMyEntries_
Definition: Epetra_CrsGraphData.h:179
Epetra_CrsGraphData::data
IndexData< int > * data
Definition: Epetra_CrsGraphData.h:210
Epetra_CrsMatrix
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
Definition: Epetra_CrsMatrix.h:173
Epetra_DataAccess.h
Epetra_DataAccess Mode enumerable type.
Epetra_CrsGraphData::IndexData< long long >::~IndexData
virtual ~IndexData()
Definition: Epetra_CrsGraphData.h:241
Epetra_LongLongSerialDenseVector.h
Epetra_CrsGraphData::NumMyBlockCols_
int NumMyBlockCols_
Definition: Epetra_CrsGraphData.h:181
Epetra_CrsMatrix::ColMap
const Epetra_Map & ColMap() const
Returns the Epetra_Map object that describes the set of column-indices that appear in each processor'...
Definition: Epetra_CrsMatrix.h:1230
Epetra_CrsGraphData::ColMap_
Epetra_BlockMap ColMap_
Definition: Epetra_CrsGraphData.h:150
Epetra_Data.h
Epetra_CrsGraphData::MaxNumIndices_
int MaxNumIndices_
Definition: Epetra_CrsGraphData.h:200
Epetra_DataAccess
Epetra_DataAccess
Definition: Epetra_DataAccess.h:55
Epetra_CrsGraphData::IndexBase_
long long IndexBase_
Definition: Epetra_CrsGraphData.h:173
Epetra_LongLongSerialDenseVector::Resize
int Resize(int Length_in)
Resize a Epetra_LongLongSerialDenseVector object.
Definition: Epetra_LongLongSerialDenseVector.h:156
Epetra_CrsGraphData::Importer_
const Epetra_Import * Importer_
Definition: Epetra_CrsGraphData.h:154
Epetra_BlockMap.h
Epetra_BlockMap
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
Definition: Epetra_BlockMap.h:194
Epetra_IntSerialDenseVector::Resize
int Resize(int Length_in)
Resize a Epetra_IntSerialDenseVector object.
Definition: Epetra_IntSerialDenseVector.h:153
Epetra_CrsGraphData::IndicesAreGlobal_
bool IndicesAreGlobal_
Definition: Epetra_CrsGraphData.h:163
Epetra_CrsGraphData::IndexData< long long >::Indices_
long long ** Indices_
Definition: Epetra_CrsGraphData.h:226
Epetra_CrsGraphData::EntriesInOneRow
Store some data for each row describing which entries of this row are nonzero.
Definition: Epetra_CrsGraphData.h:117
Epetra_CrsGraphData::IndexData< long long >::TempColIndices_
long long * TempColIndices_
Definition: Epetra_CrsGraphData.h:228
Epetra_FECrsGraph
Epetra Finite-Element CrsGraph.
Definition: Epetra_FECrsGraph.h:65
Epetra_CrsGraphData::UpperTriangular_
bool UpperTriangular_
Definition: Epetra_CrsGraphData.h:167
Epetra_ConfigDefs.h
Epetra_CrsGraphData::GlobalMaxNumIndices_
int GlobalMaxNumIndices_
Definition: Epetra_CrsGraphData.h:201
Epetra_IntSerialDenseVector
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
Definition: Epetra_IntSerialDenseVector.h:87
Epetra_CrsGraphData::IndexData< int >::SortedEntries_
std::vector< EntriesInOneRow< int > > SortedEntries_
Definition: Epetra_CrsGraphData.h:277
Epetra_CrsGraph
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs.
Definition: Epetra_CrsGraph.h:213
Epetra_CrsGraphData::NumMyBlockDiagonals_
int NumMyBlockDiagonals_
Definition: Epetra_CrsGraphData.h:182
Epetra_CrsGraphData::NumMyCols_
int NumMyCols_
Definition: Epetra_CrsGraphData.h:197
Epetra_CrsGraphData::IndexData< int >
Definition: Epetra_CrsGraphData.h:274
Epetra_CrsGraphData::GlobalMaxColDim_
int GlobalMaxColDim_
Definition: Epetra_CrsGraphData.h:187
Epetra_CrsGraphData::GlobalMaxNumNonzeros_
int GlobalMaxNumNonzeros_
Definition: Epetra_CrsGraphData.h:189
Epetra_CrsGraphData::NumMyBlockRows_
int NumMyBlockRows_
Definition: Epetra_CrsGraphData.h:180
Epetra_CrsGraphData::MaxRowDim_
int MaxRowDim_
Definition: Epetra_CrsGraphData.h:184
Epetra_CrsGraphData::LowerTriangular_
bool LowerTriangular_
Definition: Epetra_CrsGraphData.h:166
Epetra_CrsGraphData::NumGlobalRows_
long long NumGlobalRows_
Definition: Epetra_CrsGraphData.h:192
Epetra_CrsGraphData::IndexData< int >::IndexData
IndexData(int NumMyBlockRows, bool AllocSorted)
Definition: Epetra_CrsGraphData.h:282
Epetra_CrsGraphData::IndexData< int >::Indices_
int ** Indices_
Definition: Epetra_CrsGraphData.h:276
Epetra_CrsGraphData::EntriesInOneRow::entries_
std::vector< int_type > entries_
Storage for the column indices of this row.
Definition: Epetra_CrsGraphData.h:125
Epetra_CrsGraphData::IndexData< long long >::All_Indices_
Epetra_LongLongSerialDenseVector All_Indices_
Definition: Epetra_CrsGraphData.h:229
Epetra_CrsMatrix::RowMap
const Epetra_Map & RowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
Definition: Epetra_CrsMatrix.h:1166
Epetra_CrsGraphData::Allocated_
bool Allocated_
Definition: Epetra_CrsGraphData.h:159
Epetra_CrsGraphData::RangeMap_
Epetra_BlockMap RangeMap_
Definition: Epetra_CrsGraphData.h:152
Epetra_CrsGraphData::NumAllocatedIndicesPerRow_
Epetra_IntSerialDenseVector NumAllocatedIndicesPerRow_
Definition: Epetra_CrsGraphData.h:204
Epetra_CrsGraphData::IndexData< long long >::SortedEntries_
std::vector< EntriesInOneRow< long long > > SortedEntries_
Definition: Epetra_CrsGraphData.h:227
Epetra_CrsGraphData::IndexData< long long >
Definition: Epetra_CrsGraphData.h:224
Epetra_Export
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements.
Definition: Epetra_Export.h:62
Epetra_CrsGraphData::StaticProfile_
bool StaticProfile_
Definition: Epetra_CrsGraphData.h:170
Epetra_CrsMatrix::Print
virtual void Print(std::ostream &os) const
Print method.
Definition: Epetra_CrsMatrix.cpp:2891
Epetra_CrsGraphData::GlobalMaxRowDim_
int GlobalMaxRowDim_
Definition: Epetra_CrsGraphData.h:186
Epetra_CrsGraphData::NumGlobalDiagonals_
long long NumGlobalDiagonals_
Definition: Epetra_CrsGraphData.h:194
Epetra_CrsGraphData::CV_
Epetra_DataAccess CV_
Definition: Epetra_CrsGraphData.h:207
Epetra_Import
Epetra_Import: This class builds an import object for efficient importing of off-processor elements.
Definition: Epetra_Import.h:63
Epetra_CrsGraphData::IndicesAreContiguous_
bool IndicesAreContiguous_
Definition: Epetra_CrsGraphData.h:165
Epetra_CrsGraphData::StorageOptimized_
bool StorageOptimized_
Definition: Epetra_CrsGraphData.h:161
Epetra_CrsGraphData::IndexData< long long >::IndexData
IndexData(int NumMyBlockRows, bool AllocSorted)
Definition: Epetra_CrsGraphData.h:231
Epetra_CrsGraphData::SortGhostsAssociatedWithEachProcessor_
bool SortGhostsAssociatedWithEachProcessor_
Definition: Epetra_CrsGraphData.h:171