Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test/FEVbrMatrix/cxx_main.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Epetra: 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 
43 // Epetra_FEVbrMatrix Test program
44 
45 #include "Epetra_ConfigDefs.h"
46 
47 #include "Epetra_Map.h"
48 #include "ExecuteTestProblems.h"
49 
50 #ifdef EPETRA_MPI
51 #include "Epetra_MpiComm.h"
52 #else
53 #include "Epetra_SerialComm.h"
54 #endif
55 
56 #include "../epetra_test_err.h"
57 #include "Epetra_Version.h"
58 
59 int main(int argc, char *argv[]) {
60 
61  int ierr = 0;
62 
63 #ifdef EPETRA_MPI
64 
65  // Initialize MPI
66 
67  MPI_Init(&argc,&argv);
68 
69  Epetra_MpiComm Comm(MPI_COMM_WORLD);
70 
71 #else
72 
73  Epetra_SerialComm Comm;
74 
75 #endif
76 
77  bool verbose = false;
78 
79  // Check if we should print results to standard out
80  if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
81 
82  int verbose_int = verbose ? 1 : 0;
83  Comm.Broadcast(&verbose_int, 1, 0);
84  verbose = verbose_int==1 ? true : false;
85 
86  int MyPID = Comm.MyPID();
87  int NumProc = Comm.NumProc();
88 
89  if (verbose && MyPID==0)
90  cout << Epetra_Version() << endl << endl;
91 
92  if (verbose) cout << Comm <<endl;
93 
94  int NumVectors = 1;
95  int NumMyElements = 4;
96  int NumGlobalElements = NumMyElements*NumProc;
97  int IndexBase = 0;
98 
99  Epetra_Map Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
100 
101  EPETRA_TEST_ERR( quad1(Map, verbose), ierr);
102 
103  EPETRA_TEST_ERR( quad2(Map, verbose), ierr);
104 
105  EPETRA_TEST_ERR( MultiVectorTests(Map, NumVectors, verbose), ierr);
106 
107  bool preconstruct_graph = false;
108 
109  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);
110 
111  preconstruct_graph = true;
112 
113  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);
114 
115 #ifdef EPETRA_MPI
116  MPI_Finalize();
117 #endif
118 
119  return ierr;
120 }
121 
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
int quad1(const Epetra_Map &map, bool verbose)
#define EPETRA_TEST_ERR(a, b)
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
int quad2(const Epetra_Map &map, bool verbose)
int MultiVectorTests(const Epetra_Map &Map, int NumVectors, bool verbose)
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_SerialComm: The Epetra Serial Communication Class.
int main(int argc, char *argv[])
int Broadcast(double *MyVals, int Count, int Root) const
Epetra_SerialComm Broadcast function.
int four_quads(const Epetra_Comm &Comm, bool preconstruct_graph, bool verbose)