Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Test.C
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <sstream>
4 
5 #include "Global.H"
6 #include "Profiler.H"
7 #include "COMM.H"
8 
12 class TestComLine : public ComLineObject
13 {
14 public:
16  : ComLineObject()
17  {};
18  TestComLine(const char *args[])
19  : ComLineObject(args)
20  {};
21  void Initialize(){
22  AddOption('h',"help");
23  AddOption('p',"partition",2,"number");
24  AddOption('v',"verb",1,"level");
25  AddOption('c',"clone",2,"number");
26  AddOption('a',"assembly");
27  AddOption('m',"mesh");
28  AddOption('d',"debug");
29  AddOption('k',"checking");
30  AddOption('r',"reorient");
31  AddOption('g',"generate");
32  AddOption('s',"sparse");
33  AddOption('t',"metis");
34  AddOption('n',"renumber");
35  AddArgument("input",1);
36  AddHelp("metis","Metis testing stub.");
37  AddHelp("sparse","Write out the sparse matrix for visualization.");
38  AddHelp("clone","Generate <number> of partitions identical to the input mesh.");
39  AddHelp("generate","Generate a uniform mesh with N nodes and quit.");
40  AddHelp("checking","Paranoid and insanely verbose dumping of all important arrays to Log.");
41  AddHelp("partition","Performs Metis partitioning of input mesh into <number> partitions.");
42  AddHelp("assembly","Performs assembly test.");
43  AddHelp("mesh","Performs mesh tests.");
44  AddHelp("help","Prints this long version of help.");
45  AddHelp("verb","Makes the test more verbose. Default level is 1.");
46  AddHelp("config","Specifies the name of the configuration file.");
47  AddHelp("out","Specifies the name of the output file.");
48  AddHelp("renumber","Uses ParMETIS to do optimal graph reordering.");
49  AddArgHelp("input","Mode dependent arguments");
50  std::ostringstream Ostr;
51  // Ostr << "Use fixed problem size in scalability analysis. Only makes"
52  // << "\n\t\tsense when scalability mode is enabled.";
53  // Ostr.str("");
54  Ostr << "Test tool for exercising the mesh library.";
55  _description.assign(Ostr.str());
56  };
57 };
58 
59 typedef Global::ParallelGlobalObj<Comm::CommunicatorObject,std::string,int,Profiler::ProfilerObj> TestGlobal;
60 
61 class TestProgram : public Global::Program<TestGlobal,TestComLine>
62 {
63 protected:
64  std::string sverb, spart, sclone;
67 
68 public:
70  Global::Program<TestGlobal,TestComLine>()
71  {};
72  TestProgram(int nargs,char **args) :
73  Global::Program<TestGlobal,TestComLine>(nargs,args)
74  {};
75  virtual int Initialize()
76  {
77  int retval = Global::Program<TestGlobal,TestComLine>::Initialize();
78  sverb = _command_line.GetOption("verb");
79  spart = _command_line.GetOption("partition");
80  sclone = _command_line.GetOption("clone");
81  do_part = !_command_line.GetOption("partition").empty();
82  do_meshtest = !_command_line.GetOption("mesh").empty();
83  do_assem = !_command_line.GetOption("assembly").empty();
84  do_orient = !_command_line.GetOption("reorient").empty();
85  debug = !_command_line.GetOption("debug").empty();
86  do_check = !_command_line.GetOption("checking").empty();
87  do_gen = !_command_line.GetOption("generate").empty();
88  do_clone = !_command_line.GetOption("clone").empty();
89  do_renum = !_command_line.GetOption("renumber").empty();
90  do_dump = !_command_line.GetOption("sparse").empty();
91  if(!_command_line.GetOption("help").empty()){
92  if(_OutStream)
93  *_OutStream << _command_line.LongUsage() << std::endl;
94  _communicator.SetExit(1);
95  }
96  if(_communicator.Check())
97  return(1);
98  if(retval){
99  if(_ErrStream)
100  *_ErrStream << _command_line.ErrorReport() << std::endl
101  << std::endl << _command_line.ShortUsage() << std::endl;
102  _communicator.SetExit(1);
103  }
104  if(_communicator.Check())
105  return(1);
106  return(0);
107  };
108 };
109 
110 
111 int main(int argc,char *argv[])
112 {
113  TestProgram MyProgram(argc,argv);
114  if(MyProgram.Initialize())
115  return(1);
116  MyProgram.OutStream() << "Calling RUN." << std::endl;
117  MyProgram.StdOut("Testing\n");
118  if(MyProgram.Run())
119  return(1);
120  std::cout << "Calling Finalize." << std::endl;
121  if(MyProgram.Finalize())
122  return(1);
123  std::cout << "All done." << std::endl;
124  return(0);
125 }
126 
std::string sclone
Definition: Test.C:64
TestComLine(const char *args[])
Definition: Test.C:18
TestProgram()
Definition: Test.C:69
A struct that holds all the global program data.
bool do_renum
Definition: Test.C:66
bool do_clone
Definition: Test.C:66
bool do_gen
Definition: Test.C:66
TestProgram(int nargs, char **args)
Definition: Test.C:72
virtual int Initialize()
Definition: Test.C:75
bool do_assem
Definition: Test.C:65
bool do_check
Definition: Test.C:66
bool do_part
Definition: Test.C:65
struct globarg Program
bool do_dump
Definition: Test.C:66
int main(int argc, char *argv[])
Definition: blastest.C:94
ComLineObject for testing app.
Definition: Test.C:12
std::string spart
Definition: Test.C:64
Global::ParallelGlobalObj< Comm::CommunicatorObject, std::string, int, Profiler::ProfilerObj > TestGlobal
Definition: Test.C:59
bool do_orient
Definition: Test.C:65
bool do_meshtest
Definition: Test.C:65
TestComLine()
Definition: Test.C:15
std::string sverb
Definition: Test.C:64
void Initialize()
Definition: Test.C:21
bool debug
Definition: Test.C:65