Isorropia: Partitioning, Load Balancing and more
ispatest_epetra_utils.hpp
Go to the documentation of this file.
1 //@HEADER
2 //************************************************************************
3 //
4 // Isorropia: Partitioning and Load Balancing Package
5 // Copyright (2006) Sandia Corporation
6 //
7 //Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 //license for use of this work by or on behalf of the U.S. Government.
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 //************************************************************************
38 //@HEADER
39 
40 #ifndef _ispatest_epetra_test_utils_hpp_
41 #define _ispatest_epetra_test_utils_hpp_
42 
43 #include <Isorropia_ConfigDefs.hpp>
44 #include <string>
45 #include <vector>
46 #include <ostream>
47 
48 #ifdef HAVE_EPETRA
49 
50 class Epetra_CrsGraph;
51 class Epetra_RowMatrix;
52 class Epetra_LinearProblem;
53 class Epetra_CrsMatrix;
54 class Epetra_MultiVector;
55 class Epetra_Map;
56 class Epetra_BlockMap;
57 class Epetra_Comm;
58 
59 namespace ispatest {
60 
67 int fill_matrix(Epetra_CrsMatrix& matrix,
68  int numNonzerosPerRow,
69  bool verbose);
70 
76 int fill_graph(Epetra_CrsGraph& graph,
77  int numNonzerosPerRow,
78  bool verbose);
79 
91 bool test_matrix_vector_multiply(Epetra_CrsMatrix &A);
92 
102 bool test_row_matrix_vector_multiply(Epetra_RowMatrix &R);
103 
115 bool test_matrix_vector_multiply(Epetra_CrsGraph &G);
116 
131 bool test_matrix_vector_multiply(Epetra_LinearProblem &LP);
132 
138 Epetra_Map *map_from_blockmap(const Epetra_BlockMap &b);
139 
152 int readCoordFile(const std::string &fname,
153  std::vector<double> &x, std::vector<double> &y, std::vector<double> &z);
154 
162 Epetra_MultiVector *makeWeights(const Epetra_BlockMap &map, double (*wFunc)(const int, const int, const int, const int));
163 
166 double unitWeights(const int id, const int me, const int nids, const int nprocs);
167 
171 double veeWeights(const int id, const int me, const int nids, const int nprocs);
172 
175 double alternateWeights(const int id, const int me, const int nids, const int nprocs);
176 
180 Epetra_MultiVector *file2multivector(const Epetra_Comm &comm, const std::string &fname);
181 
185 int printMultiVector(const Epetra_MultiVector &mv, std::ostream &os,
186  const char *s, int max=1000);
187 
193 int printRowMatrix(const Epetra_RowMatrix &m, std::ostream &os,
194  const char *s, bool withGraphCuts, int max=1000);
195 
196 } //namespace ispatest
197 
198 #endif //HAVE_EPETRA
199 
200 #endif
201 
double veeWeights(const int id, const int me, const int nids, const int nprocs)
A function for makeWeights, weight is based on global ID, lower in the middle and higher at both ends...
int fill_graph(Epetra_CrsGraph &graph, int numNonzerosPerRow, bool verbose)
Fill a graph with the specified number of nonzeros per row.
Epetra_Map * map_from_blockmap(const Epetra_BlockMap &b)
Method to create an Epetra_Map from an Epetra_BlockMap, when using methods that require an Epetra_Map...
bool test_matrix_vector_multiply(Epetra_CrsMatrix &A)
Verify that a matrix is a valid Epetra_CrsMatrix by attempting to multiply with it.
int printMultiVector(const Epetra_MultiVector &mv, std::ostream &os, const char *s, int max=1000)
Print out the contents of the multivector by process, with optional title.
bool test_row_matrix_vector_multiply(Epetra_RowMatrix &R)
Verify that a matrix is a valid Epetra_RowMatrix by attempting to multiply with it.
int printRowMatrix(const Epetra_RowMatrix &m, std::ostream &os, const char *s, bool withGraphCuts, int max=1000)
Print out the contents of a small Epetra_RowMatrix, with optional title.
Epetra_MultiVector * makeWeights(const Epetra_BlockMap &map, double(*wFunc)(const int, const int, const int, const int))
Create a multivector of 1 dimensional weights with the same distribution as the supplied map...
int readCoordFile(const std::string &fname, std::vector< double > &x, std::vector< double > &y, std::vector< double > &z)
Read in the file &quot;fname&quot;.
double alternateWeights(const int id, const int me, const int nids, const int nprocs)
A function for makeWeights, weights alternate 1.0, 2.0, 1.0, etc.
Epetra_MultiVector * file2multivector(const Epetra_Comm &comm, const std::string &fname)
Read in a file of 1, 2 or 3 dimensional coordinates and create a multivector with a standard linear d...
int fill_matrix(Epetra_CrsMatrix &matrix, int numNonzerosPerRow, bool verbose)
Fill a matrix with the specified number of nonzeros per row, using matrix.InsertGlobalValues.
double unitWeights(const int id, const int me, const int nids, const int nprocs)
A function for makeWeights, returns 1.0 for the object&#39;s weight.