EpetraExt Development
Loading...
Searching...
No Matches
EpetraExt_BlockUtility.h
Go to the documentation of this file.
1//@HEADER
2// ***********************************************************************
3//
4// EpetraExt: Epetra Extended - Linear Algebra Services Package
5// Copyright (2011) Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41
42#ifndef EPETRAEXT_BLOCKUTILITY_H
43#define EPETRAEXT_BLOCKUTILITY_H
44
45#if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46#ifdef __GNUC__
47#warning "The EpetraExt package is deprecated"
48#endif
49#endif
50
51#include <vector>
52
53#include <Epetra_ConfigDefs.h>
54#include <Epetra_CrsGraph.h>
55#include <Epetra_RowMatrix.h>
56
58
59namespace EpetraExt {
60
62 public:
63
71#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
72 static Epetra_Map * GenerateBlockMap( const Epetra_BlockMap & BaseMap, const int* RowIndices, int num_indices, const Epetra_Comm & GlobalComm, int Offset = 0 );
73#endif
74#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
75 static Epetra_Map * GenerateBlockMap( const Epetra_BlockMap & BaseMap, const long long* RowIndices, int num_indices, const Epetra_Comm & GlobalComm, long long Offset = 0 );
76#endif
77
85#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
86 static Epetra_Map * GenerateBlockMap( const Epetra_BlockMap & BaseMap, const std::vector<int> & RowIndices, const Epetra_Comm & GlobalComm, int Offset = 0 );
87#endif
88#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
89 static Epetra_Map * GenerateBlockMap( const Epetra_BlockMap & BaseMap, const std::vector<long long> & RowIndices, const Epetra_Comm & GlobalComm, long long Offset = 0 );
90#endif
91
99 static Epetra_Map * GenerateBlockMap( const Epetra_BlockMap & BaseMap, const Epetra_BlockMap& BlockMap, const Epetra_Comm & GlobalComm, int Offset = 0 );
100
102
111#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
112 static Epetra_CrsGraph * GenerateBlockGraph( const Epetra_CrsGraph & BaseGraph, const std::vector< std::vector<int> > & RowStencil, const std::vector<int> & RowIndices, const Epetra_Comm & GlobalComm );
113#endif
114#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
115 static Epetra_CrsGraph * GenerateBlockGraph( const Epetra_CrsGraph & BaseGraph, const std::vector< std::vector<long long> > & RowStencil, const std::vector<long long> & RowIndices, const Epetra_Comm & GlobalComm );
116#endif
117
118 // Nearly identical version yet using RowMatrix interface instead of CrsGraph
119#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
120 static Epetra_CrsGraph * GenerateBlockGraph( const Epetra_RowMatrix & BaseMatrix, const std::vector< std::vector<int> > & RowStencil, const std::vector<int> & RowIndices, const Epetra_Comm & GlobalComm );
121#endif
122
123#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
124 static Epetra_CrsGraph * GenerateBlockGraph( const Epetra_RowMatrix & BaseMatrix, const std::vector< std::vector<long long> > & RowStencil, const std::vector<long long> & RowIndices, const Epetra_Comm & GlobalComm );
125#endif
126
128 static Epetra_CrsGraph * GenerateBlockGraph( const Epetra_CrsGraph & BaseGraph, const Epetra_CrsGraph& LocalBlockGraph, const Epetra_Comm & GlobalComm );
129
131#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
132 static void GenerateRowStencil(const Epetra_CrsGraph& LocalBlockGraph, std::vector<int> RowIndices, std::vector< std::vector<int> >& RowStencil);
133#endif
134#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
135 static void GenerateRowStencil(const Epetra_CrsGraph& LocalBlockGraph, std::vector<long long> RowIndices, std::vector< std::vector<long long> >& RowStencil);
136#endif
137
139#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
140 static int CalculateOffset(const Epetra_BlockMap & BaseMap);
141#endif
142
143 static long long CalculateOffset64(const Epetra_BlockMap & BaseMap);
144
145private:
146
147 template<typename int_type>
148 static int_type TCalculateOffset(const Epetra_BlockMap & BaseMap);
149
150 template<typename int_type>
151 static Epetra_Map * TGenerateBlockMap( const Epetra_BlockMap & BaseMap, const int_type* RowIndices, int num_indices, const Epetra_Comm & GlobalComm, int_type Offset = 0);
152
153 template<typename int_type>
154 static Epetra_CrsGraph * TGenerateBlockGraph( const Epetra_CrsGraph & BaseGraph, const std::vector< std::vector<int_type> > & RowStencil, const std::vector<int_type> & RowIndices, const Epetra_Comm & GlobalComm );
155
156 template<typename int_type>
157 static Epetra_CrsGraph * TGenerateBlockGraph( const Epetra_RowMatrix & BaseMatrix, const std::vector< std::vector<int_type> > & RowStencil, const std::vector<int_type> & RowIndices, const Epetra_Comm & GlobalComm );
158
159 template<typename int_type>
160 static Epetra_CrsGraph * TGenerateBlockGraph( const Epetra_CrsGraph & BaseGraph, const Epetra_CrsGraph& LocalBlockGraph, const Epetra_Comm & GlobalComm );
161
162 template<typename int_type>
163 static void TGenerateRowStencil(const Epetra_CrsGraph& LocalBlockGraph, std::vector<int_type> RowIndices, std::vector< std::vector<int_type> >& RowStencil);
164};
165
166} //namespace EpetraExt
167
168#endif /* EPETRA_CRSMATRIX_H */
static void GenerateRowStencil(const Epetra_CrsGraph &LocalBlockGraph, std::vector< int > RowIndices, std::vector< std::vector< int > > &RowStencil)
Generate stencil arrays from a local block graph.
static Epetra_CrsGraph * GenerateBlockGraph(const Epetra_CrsGraph &BaseGraph, const std::vector< std::vector< int > > &RowStencil, const std::vector< int > &RowIndices, const Epetra_Comm &GlobalComm)
BlockCrsMatrix constuctor.
static int CalculateOffset(const Epetra_BlockMap &BaseMap)
Routine for calculating Offset for creating unique global IDs for Block representation.
static Epetra_Map * GenerateBlockMap(const Epetra_BlockMap &BaseMap, const int *RowIndices, int num_indices, const Epetra_Comm &GlobalComm, int Offset=0)
static long long CalculateOffset64(const Epetra_BlockMap &BaseMap)
static Epetra_CrsGraph * GenerateBlockGraph(const Epetra_RowMatrix &BaseMatrix, const std::vector< std::vector< long long > > &RowStencil, const std::vector< long long > &RowIndices, const Epetra_Comm &GlobalComm)
static Epetra_CrsGraph * GenerateBlockGraph(const Epetra_CrsGraph &BaseGraph, const std::vector< std::vector< long long > > &RowStencil, const std::vector< long long > &RowIndices, const Epetra_Comm &GlobalComm)
static Epetra_CrsGraph * GenerateBlockGraph(const Epetra_RowMatrix &BaseMatrix, const std::vector< std::vector< int > > &RowStencil, const std::vector< int > &RowIndices, const Epetra_Comm &GlobalComm)
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.