GRINS-0.7.0
Functions
grins.C File Reference
#include "grins_config.h"
#include <iostream>
#include "grins/simulation_builder.h"
#include "grins/simulation.h"
#include "libmesh/parallel.h"
Include dependency graph for grins.C:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 42 of file grins.C.

References GRINS::Simulation::run().

43 {
44  /* Echo GRINS version, libMesh version, and command */
45  libMesh::out << "=========================================================="
46  << std::endl;
47  libMesh::out << "GRINS Version: " << GRINS_BUILD_VERSION << std::endl
48  << "libMesh Version: " << LIBMESH_BUILD_VERSION << std::endl
49  << "Running with command:\n";
50 
51  for (int i=0; i != argc; ++i)
52  std::cout << argv[i] << ' ';
53 
54  std::cout << std::endl
55  << "=========================================================="
56  << std::endl;
57 
58 #ifdef GRINS_USE_GRVY_TIMERS
59  GRVY::GRVY_Timer_Class grvy_timer;
60  grvy_timer.Init("GRINS Timer");
61 #endif
62 
63  // Check command line count.
64  if( argc < 2 )
65  {
66  // TODO: Need more consistent error handling.
67  std::cerr << "Error: Must specify libMesh input file." << std::endl;
68  exit(1); // TODO: something more sophisticated for parallel runs?
69  }
70 
71  // libMesh input file should be first argument
72  std::string libMesh_input_filename = argv[1];
73 
74  // Initialize libMesh library.
75  libMesh::LibMeshInit libmesh_init(argc, argv);
76 
77  // Create our GetPot object.
78  GetPot libMesh_inputfile( libMesh_input_filename );
79 
80  GetPot command_line(argc,argv);
81 
82  // GetPot doesn't throw an error for a nonexistent file?
83  {
84  std::ifstream i(libMesh_input_filename.c_str());
85  if (!i)
86  {
87  std::cerr << "Error: Could not read from libMesh input file "
88  << libMesh_input_filename << std::endl;
89  exit(1);
90  }
91  }
92 
93 #ifdef GRINS_USE_GRVY_TIMERS
94  grvy_timer.BeginTimer("Initialize Solver");
95 #endif
96 
97  GRINS::SimulationBuilder sim_builder;
98 
99  GRINS::Simulation grins( libMesh_inputfile,
100  command_line,
101  sim_builder,
102  libmesh_init.comm() );
103 
104 #ifdef GRINS_USE_GRVY_TIMERS
105  grvy_timer.EndTimer("Initialize Solver");
106 
107  // Attach GRVY timer to solver
108  grins.attach_grvy_timer( &grvy_timer );
109 #endif
110 
111 grins.run();
112 
113 #ifdef GRINS_USE_GRVY_TIMERS
114  grvy_timer.Finalize();
115 
116  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
117 #endif
118 
119  return 0;
120 }

Generated on Thu Jun 2 2016 21:52:29 for GRINS-0.7.0 by  doxygen 1.8.10