Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test/FECrsMatrix_LL/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_FECrsMatrix Test routine
44 
45 #include "Epetra_Time.h"
46 #include "Epetra_Map.h"
47 #include "Epetra_FECrsMatrix.h"
48 #include "ExecuteTestProblems.h"
49 #ifdef EPETRA_MPI
50 #include "Epetra_MpiComm.h"
51 #include <mpi.h>
52 #else
53 #include "Epetra_SerialComm.h"
54 #endif
55 #include "../epetra_test_err.h"
56 #include "Epetra_Version.h"
57 
58 int main(int argc, char *argv[]) {
59 
60  int ierr = 0;
61 
62 #ifdef EPETRA_MPI
63 
64  // Initialize MPI
65 
66  MPI_Init(&argc,&argv);
67  Epetra_MpiComm Comm(MPI_COMM_WORLD);
68 
69 #else
70 
71  Epetra_SerialComm Comm;
72 
73 #endif
74 
75 // Comm.SetTracebackMode(0); // This should shut down any error tracing
76  bool verbose = false;
77 
78  // Check if we should print results to standard out
79  if (argc>1) if (argv[1][0]=='-' && argv[1][1]=='v') verbose = true;
80 
81 #ifdef EPETRA_MPI
82  int localverbose = verbose ? 1 : 0;
83  int globalverbose=0;
84  MPI_Allreduce(&localverbose, &globalverbose, 1, MPI_INT, MPI_SUM,
85  MPI_COMM_WORLD);
86  verbose = (globalverbose>0);
87 #endif
88 
89  int MyPID = Comm.MyPID();
90  int NumProc = Comm.NumProc();
91 
92  if (verbose && MyPID==0)
93  cout << Epetra_Version() << endl << endl;
94 
95  if (verbose) cout << Comm <<endl;
96 
97  // Redefine verbose to only print on PE 0
98  //if (verbose && rank!=0) verbose = false;
99 
100  int NumMyElements = 4;
101  long long NumGlobalElements = NumMyElements*NumProc;
102  long long IndexBase = 0;
103 
104  Epetra_Map Map(NumGlobalElements, NumMyElements, IndexBase, Comm);
105 
106  EPETRA_TEST_ERR( Drumm1(Map, verbose),ierr);
107 
108  EPETRA_TEST_ERR( Drumm2(Map, verbose),ierr);
109 
110  EPETRA_TEST_ERR( Drumm3(Map, verbose),ierr);
111 
112 
113  bool preconstruct_graph = false;
114 
115  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);
116 
117  preconstruct_graph = true;
118 
119  EPETRA_TEST_ERR( four_quads(Comm, preconstruct_graph, verbose), ierr);
120 
121  EPETRA_TEST_ERR( submatrix_formats(Comm, verbose), ierr);
122 
123  EPETRA_TEST_ERR( rectangular(Comm, verbose), ierr);
124 
125 #ifdef EPETRA_MPI
126  MPI_Finalize();
127 #endif
128 
129  return ierr;
130 }
131 
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
#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 Drumm1(const Epetra_Map &map, 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 Drumm3(const Epetra_Map &map, bool verbose)
int submatrix_formats(const Epetra_Comm &Comm, bool verbose)
int rectangular(const Epetra_Comm &Comm, bool verbose)
int Drumm2(const Epetra_Map &map, bool verbose)
int four_quads(const Epetra_Comm &Comm, bool preconstruct_graph, bool verbose)