Debian Codegraph @

packages/nox/test/epetra/NOX_Group/test.C

raw
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 "Teuchos_StandardCatchMacros.hpp"
28
29 int main(int argc, char *argv[]) {
30 // Initialize MPI
31 #ifdef HAVE_MPI
32 MPI_Init(&argc,&argv);
33 #endif
34
35 bool verbose = false;
36 bool success = false;
37 try {
38 // Create a communicator for Epetra objects
39 #ifdef HAVE_MPI
40 Epetra_MpiComm Comm( MPI_COMM_WORLD );
41 #else
42 Epetra_SerialComm Comm;
43 #endif
44
45 if (argc > 1)
46 if (argv[1][0]=='-' && argv[1][1]=='v')
47 verbose = true;
48
49 // Get the process ID and the total number of processors
50 int MyPID = Comm.MyPID();
51 #ifdef HAVE_MPI
52 int NumProc = Comm.NumProc();
53 #endif
54
55 // Set up the printing utilities
56 Teuchos::RCP<Teuchos::ParameterList> noxParamsPtr =
57 Teuchos::rcp(new Teuchos::ParameterList);
58 Teuchos::ParameterList& noxParams = *(noxParamsPtr.get());
59 // Only print output if the "-v" flag is set on the command line
60 Teuchos::ParameterList& printParams = noxParams.sublist("Printing");
61 printParams.set("MyPID", MyPID);
62 printParams.set("Output Precision", 5);
63 printParams.set("Output Processor", 0);
64 if( verbose )
65 printParams.set("Output Information",
66 NOX::Utils::OuterIteration +
67 NOX::Utils::OuterIterationStatusTest +
68 NOX::Utils::InnerIteration +
69 NOX::Utils::Parameters +
70 NOX::Utils::Details +
71 NOX::Utils::Warning +
72 NOX::Utils::TestDetails);
73 else
74 printParams.set("Output Information", NOX::Utils::Error +
75 NOX::Utils::TestDetails);
76
77 NOX::Utils printing(printParams);
78
79 // Identify the test problem
80 if (printing.isPrintType(NOX::Utils::TestDetails))
81 printing.out() << "Starting epetra/NOX_Group/NOX_Group.exe" << std::endl;
82
83 // Identify processor information
84 #ifdef HAVE_MPI
85 if (printing.isPrintType(NOX::Utils::TestDetails)) {
86 printing.out() << "Parallel Run" << std::endl;
87 printing.out() << "Number of processors = " << NumProc << std::endl;
88 printing.out() << "Print Process = " << MyPID << std::endl;
89 }
90 Comm.Barrier();
91 if (printing.isPrintType(NOX::Utils::TestDetails))
92 printing.out() << "Process " << MyPID << " is alive!" << std::endl;
93 Comm.Barrier();
94 #else
95 if (printing.isPrintType(NOX::Utils::TestDetails))
96 printing.out() << "Serial Run" << std::endl;
97 #endif
98
99 // *** Insert Testing Here!!! ***
100 success = true;
101
102 if (success)
103 printing.out() << "Test passed!" << std::endl;
104 else
105 printing.out() << "Test failed!" << std::endl;
106 }
107 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
108
109 #ifdef HAVE_MPI
110 MPI_Finalize();
111 #endif
112
113 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
114 }
115
116 /*
117 end of file test.C
118 */