GRINS-0.6.0
grins.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 #include "grins_config.h"
27 
28 #include <iostream>
29 
30 // GRINS
32 #include "grins/simulation.h"
33 
34 // GRVY
35 #ifdef GRINS_HAVE_GRVY
36 #include "grvy.h"
37 #endif
38 
39 // libMesh
40 #include "libmesh/parallel.h"
41 
42 int main(int argc, char* argv[])
43 {
44 #ifdef GRINS_USE_GRVY_TIMERS
45  GRVY::GRVY_Timer_Class grvy_timer;
46  grvy_timer.Init("GRINS Timer");
47 #endif
48 
49  // Check command line count.
50  if( argc < 2 )
51  {
52  // TODO: Need more consistent error handling.
53  std::cerr << "Error: Must specify libMesh input file." << std::endl;
54  exit(1); // TODO: something more sophisticated for parallel runs?
55  }
56 
57  // libMesh input file should be first argument
58  std::string libMesh_input_filename = argv[1];
59 
60  // Initialize libMesh library.
61  libMesh::LibMeshInit libmesh_init(argc, argv);
62 
63  // Create our GetPot object.
64  GetPot libMesh_inputfile( libMesh_input_filename );
65 
66  GetPot command_line(argc,argv);
67 
68  // GetPot doesn't throw an error for a nonexistent file?
69  {
70  std::ifstream i(libMesh_input_filename.c_str());
71  if (!i)
72  {
73  std::cerr << "Error: Could not read from libMesh input file "
74  << libMesh_input_filename << std::endl;
75  exit(1);
76  }
77  }
78 
79 #ifdef GRINS_USE_GRVY_TIMERS
80  grvy_timer.BeginTimer("Initialize Solver");
81 #endif
82 
83  /* Echo GRINS version, libMesh version, and command */
84  libMesh::out << "=========================================================="
85  << std::endl;
86  libMesh::out << "GRINS Version: " << GRINS_BUILD_VERSION << std::endl
87  << "libMesh Version: " << LIBMESH_BUILD_VERSION << std::endl
88  << "Running with command:\n";
89 
90  for (int i=0; i != argc; ++i)
91  libMesh::out << argv[i] << ' ';
92 
93  libMesh::out << std::endl
94  << "=========================================================="
95  << std::endl;
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 }
int main(int argc, char *argv[])
Definition: grins.C:42
#define GRINS_BUILD_VERSION
Definition: grins_version.h:40

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1