| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// NOX: An Object-Oriented Nonlinear Solver Package |
| 4 |
// |
| 5 |
// Copyright 2002 NTESS and the NOX contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
// NOX headers |
| 11 |
#include "NOX.H" // Required headers |
| 12 |
#include "NOX_Epetra.H" // Epetra Interface headers |
| 13 |
#include "NOX_TestError.H" // Test Suite headers |
| 14 |
|
| 15 |
// Trilinos headers |
| 16 |
#ifdef HAVE_MPI |
| 17 |
#include "Epetra_MpiComm.h" |
| 18 |
#else |
| 19 |
#include "Epetra_SerialComm.h" |
| 20 |
#endif |
| 21 |
#include "Epetra_Map.h" |
| 22 |
#include "Epetra_Vector.h" |
| 23 |
#include "Epetra_RowMatrix.h" |
| 24 |
#include "Epetra_CrsMatrix.h" |
| 25 |
#include "Epetra_Map.h" |
| 26 |
#include "Epetra_LinearProblem.h" |
| 27 |
#include "AztecOO.h" |
| 28 |
#include "Teuchos_StandardCatchMacros.hpp" |
| 29 |
|
| 30 |
int main(int argc, char *argv[]) { |
| 31 |
// Initialize MPI |
| 32 |
#ifdef HAVE_MPI |
| 33 |
MPI_Init(&argc,&argv); |
| 34 |
#endif |
| 35 |
|
| 36 |
// Create a communicator for Epetra objects |
| 37 |
#ifdef HAVE_MPI |
| 38 |
Epetra_MpiComm Comm( MPI_COMM_WORLD ); |
| 39 |
#else |
| 40 |
Epetra_SerialComm Comm; |
| 41 |
#endif |
| 42 |
|
| 43 |
bool verbose = false; |
| 44 |
if (argc > 1) |
| 45 |
if (argv[1][0]=='-' && argv[1][1]=='v') |
| 46 |
verbose = true; |
| 47 |
|
| 48 |
bool success = true; |
| 49 |
try { |
| 50 |
// Get the process ID and the total number of processors |
| 51 |
int MyPID = Comm.MyPID(); |
| 52 |
#ifdef HAVE_MPI |
| 53 |
int NumProc = Comm.NumProc(); |
| 54 |
#endif |
| 55 |
|
| 56 |
// Set up the printing utilities |
| 57 |
Teuchos::RCP<Teuchos::ParameterList> noxParamsPtr = |
| 58 |
Teuchos::rcp(new Teuchos::ParameterList); |
| 59 |
Teuchos::ParameterList& noxParams = *(noxParamsPtr.get()); |
| 60 |
// Only print output if the "-v" flag is set on the command line |
| 61 |
Teuchos::ParameterList& printParams = noxParams.sublist("Printing"); |
| 62 |
printParams.set("MyPID", MyPID); |
| 63 |
printParams.set("Output Precision", 5); |
| 64 |
printParams.set("Output Processor", 0); |
| 65 |
if( verbose ) |
| 66 |
printParams.set("Output Information", |
| 67 |
NOX::Utils::OuterIteration + |
| 68 |
NOX::Utils::OuterIterationStatusTest + |
| 69 |
NOX::Utils::InnerIteration + |
| 70 |
NOX::Utils::Parameters + |
| 71 |
NOX::Utils::Details + |
| 72 |
NOX::Utils::Warning + |
| 73 |
NOX::Utils::TestDetails); |
| 74 |
else |
| 75 |
printParams.set("Output Information", NOX::Utils::Error + |
| 76 |
NOX::Utils::TestDetails); |
| 77 |
|
| 78 |
NOX::Utils printing(printParams); |
| 79 |
|
| 80 |
// Identify the test problem |
| 81 |
if (printing.isPrintType(NOX::Utils::TestDetails)) |
| 82 |
printing.out() << "Starting epetra/NOX_NewTest/NOX_NewTest.exe" << std::endl; |
| 83 |
|
| 84 |
// Identify processor information |
| 85 |
#ifdef HAVE_MPI |
| 86 |
if (printing.isPrintType(NOX::Utils::TestDetails)) { |
| 87 |
printing.out() << "Parallel Run" << std::endl; |
| 88 |
printing.out() << "Number of processors = " << NumProc << std::endl; |
| 89 |
printing.out() << "Print Process = " << MyPID << std::endl; |
| 90 |
} |
| 91 |
Comm.Barrier(); |
| 92 |
if (printing.isPrintType(NOX::Utils::TestDetails)) |
| 93 |
printing.out() << "Process " << MyPID << " is alive!" << std::endl; |
| 94 |
Comm.Barrier(); |
| 95 |
#else |
| 96 |
if (printing.isPrintType(NOX::Utils::TestDetails)) |
| 97 |
printing.out() << "Serial Run" << std::endl; |
| 98 |
#endif |
| 99 |
|
| 100 |
// *** Insert your testing here! *** |
| 101 |
|
| 102 |
// Final return value (0 = successfull, non-zero = failure) |
| 103 |
int status = 0; |
| 104 |
|
| 105 |
// Summarize test results |
| 106 |
if (status == 0) |
| 107 |
{ |
| 108 |
success = true; |
| 109 |
printing.out() << "Test passed!" << std::endl; |
| 110 |
} |
| 111 |
else |
| 112 |
{ |
| 113 |
success = false; |
| 114 |
printing.out() << "Test failed!" << std::endl; |
| 115 |
} |
| 116 |
} |
| 117 |
TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success); |
| 118 |
|
| 119 |
#ifdef HAVE_MPI |
| 120 |
MPI_Finalize(); |
| 121 |
#endif |
| 122 |
return ( success ? EXIT_SUCCESS : EXIT_FAILURE ); |
| 123 |
} |
| 124 |
|
| 125 |
/* |
| 126 |
end of file test.C |
| 127 |
*/ |