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

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