GRINS-0.7.0
vorticity_qoi.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 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
31 #include "grins/simulation.h"
33 #include "grins/multiphysics_sys.h"
34 
35 //libMesh
36 #include "libmesh/exact_solution.h"
37 
38 // GRVY
39 #ifdef GRINS_HAVE_GRVY
40 #include "grvy.h"
41 #endif
42 
43 int main(int argc, char* argv[])
44 {
45 
46 #ifdef GRINS_USE_GRVY_TIMERS
47  GRVY::GRVY_Timer_Class grvy_timer;
48  grvy_timer.Init("GRINS Timer");
49 #endif
50 
51  // Check command line count.
52  if( argc < 2 )
53  {
54  // TODO: Need more consistent error handling.
55  std::cerr << "Error: Must specify libMesh input file." << std::endl;
56  exit(1); // TODO: something more sophisticated for iarallel runs?
57  }
58 
59  // libMesh input file should be first argument
60  std::string libMesh_input_filename = argv[1];
61 
62  // Create our GetPot object.
63  GetPot libMesh_inputfile( libMesh_input_filename );
64 
65 #ifdef GRINS_USE_GRVY_TIMERS
66  grvy_timer.BeginTimer("Initialize Solver");
67 #endif
68 
69  // Initialize libMesh library.
70  libMesh::LibMeshInit libmesh_init(argc, argv);
71 
72  GRINS::SimulationBuilder sim_builder;
73 
74  GRINS::Simulation grins( libMesh_inputfile,
75  sim_builder,
76  libmesh_init.comm() );
77 
78 #ifdef GRINS_USE_GRVY_TIMERS
79  grvy_timer.EndTimer("Initialize Solver");
80 
81  // Attach GRVY timer to solver
82  grins.attach_grvy_timer( &grvy_timer );
83 #endif
84 
85  // Solve
86  grins.run();
87 
88  libMesh::Number qoi = grins.get_qoi_value( 0 );
89 
90  int return_flag = 0;
91  const libMesh::Number exact_value = -0.5;
92  const libMesh::Number rel_error = std::fabs( (qoi - exact_value )/exact_value );
93  const libMesh::Number tol = 1.0e-11;
94  if( rel_error > tol )
95  {
96  std::cerr << "Computed voriticity QoI mismatch greater than tolerance." << std::endl
97  << "Computed value = " << qoi << std::endl
98  << "Exact value = " << exact_value << std::endl
99  << "Relative error = " << rel_error << std::endl
100  << "Tolerance = " << tol << std::endl;
101  return_flag = 1;
102  }
103 
104  return return_flag;
105 }
int main(int argc, char *argv[])
Definition: vorticity_qoi.C:43

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