GRINS-0.8.0
grins_flow_regression.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2017 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 // C++
27 #include <iostream>
28 
29 // GRINS
30 #include "grins/runner.h"
31 
32 //libMesh
33 #include "libmesh/exact_solution.h"
34 
35 int main(int argc, char* argv[])
36 {
37  // Check command line count.
38  if( argc < 4 )
39  {
40  // TODO: Need more consistent error handling.
41  std::cerr << "Error: Must specify libMesh input file, regression file, and regression tolerance." << std::endl;
42  exit(1); // TODO: something more sophisticated for parallel runs?
43  }
44 
45  GRINS::Runner grins(argc,argv);
46  grins.init();
47  grins.run();
48 
49  GRINS::Simulation & sim = grins.get_simulation();
50 
51  // Get equation systems to create ExactSolution object
52  GRINS::SharedPtr<libMesh::EquationSystems> es = sim.get_equation_system();
53 
54  //es->write("foobar.xdr");
55 
56  // Create Exact solution object and attach exact solution quantities
57  libMesh::ExactSolution exact_sol(*es);
58 
59  libMesh::EquationSystems es_ref( es->get_mesh() );
60 
61  // Filename of file where comparison solution is stashed
62  std::string solution_file = std::string(argv[2]);
63  es_ref.read( solution_file );
64 
65  exact_sol.attach_reference_solution( &es_ref );
66 
67  const GetPot & inputfile = grins.get_input_file();
68  std::string system_name = inputfile( "screen-options/system_name", "GRINS" );
69 
70  // Compute error and get it in various norms
71  exact_sol.compute_error(system_name, "u");
72  exact_sol.compute_error(system_name, "v");
73 
74  exact_sol.compute_error(system_name, "p");
75 
76  double u_l2error = exact_sol.l2_error(system_name, "u");
77  double u_h1error = exact_sol.h1_error(system_name, "u");
78 
79  double v_l2error = exact_sol.l2_error(system_name, "v");
80  double v_h1error = exact_sol.h1_error(system_name, "v");
81 
82  double p_l2error = exact_sol.l2_error(system_name, "p");
83  double p_h1error = exact_sol.h1_error(system_name, "p");
84 
85  int return_flag = 0;
86 
87  // This is the tolerance of the iterative linear solver so
88  // it's unreasonable to expect anything better than this.
89  double tol = atof(argv[3]);
90 
91  if( u_l2error > tol || u_h1error > tol ||
92  v_l2error > tol || v_h1error > tol ||
93  p_l2error > tol || p_h1error > tol )
94  {
95  return_flag = 1;
96 
97  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
98  << "tolerance = " << tol << std::endl
99  << "u l2 error = " << u_l2error << std::endl
100  << "u h1 error = " << u_h1error << std::endl
101  << "v l2 error = " << v_l2error << std::endl
102  << "v h1 error = " << v_h1error << std::endl
103  << "p l2 error = " << p_l2error << std::endl
104  << "p h1 error = " << p_h1error << std::endl;
105  }
106 
107  return return_flag;
108 }
void init()
Initialize the Simulation objects.
Definition: runner.C:53
SharedPtr< libMesh::EquationSystems > get_equation_system()
Definition: simulation.C:393
const GetPot & get_input_file() const
Definition: runner.h:60
Class to encapsulate initializing and running GRINS Simulation.
Definition: runner.h:47
int main(int argc, char *argv[])
void run()
Runs the simulation that was setup at construction time.
Definition: runner.C:104
Simulation & get_simulation()
Definition: runner.h:66

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1