GRINS-0.6.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-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 // C++
27 #include <iostream>
28 
29 // GRINS
30 #include "grins/simulation.h"
32 
33 //libMesh
34 #include "libmesh/exact_solution.h"
35 
36 int main(int argc, char* argv[])
37 {
38  // Check command line count.
39  if( argc < 4 )
40  {
41  // TODO: Need more consistent error handling.
42  std::cerr << "Error: Must specify libMesh input file, regression file, and regression tolerance." << std::endl;
43  exit(1); // TODO: something more sophisticated for parallel runs?
44  }
45 
46  // libMesh input file should be first argument
47  std::string libMesh_input_filename = argv[1];
48 
49  // Create our GetPot object.
50  GetPot libMesh_inputfile( libMesh_input_filename );
51 
52  // Initialize libMesh library.
53  libMesh::LibMeshInit libmesh_init(argc, argv);
54 
55  GRINS::SimulationBuilder sim_builder;
56 
57  GRINS::Simulation grins( libMesh_inputfile,
58  sim_builder,
59  libmesh_init.comm() );
60 
61  grins.run();
62 
63  // Get equation systems to create ExactSolution object
64  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
65 
66  //es->write("foobar.xdr");
67 
68  // Create Exact solution object and attach exact solution quantities
69  libMesh::ExactSolution exact_sol(*es);
70 
71  libMesh::EquationSystems es_ref( es->get_mesh() );
72 
73  // Filename of file where comparison solution is stashed
74  std::string solution_file = std::string(argv[2]);
75  es_ref.read( solution_file );
76 
77  exact_sol.attach_reference_solution( &es_ref );
78 
79  std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
80 
81  // Compute error and get it in various norms
82  exact_sol.compute_error(system_name, "u");
83  exact_sol.compute_error(system_name, "v");
84 
85  exact_sol.compute_error(system_name, "p");
86 
87  double u_l2error = exact_sol.l2_error(system_name, "u");
88  double u_h1error = exact_sol.h1_error(system_name, "u");
89 
90  double v_l2error = exact_sol.l2_error(system_name, "v");
91  double v_h1error = exact_sol.h1_error(system_name, "v");
92 
93  double p_l2error = exact_sol.l2_error(system_name, "p");
94  double p_h1error = exact_sol.h1_error(system_name, "p");
95 
96  int return_flag = 0;
97 
98  // This is the tolerance of the iterative linear solver so
99  // it's unreasonable to expect anything better than this.
100  double tol = atof(argv[3]);
101 
102  if( u_l2error > tol || u_h1error > tol ||
103  v_l2error > tol || v_h1error > tol ||
104  p_l2error > tol || p_h1error > tol )
105  {
106  return_flag = 1;
107 
108  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
109  << "tolerance = " << tol << std::endl
110  << "u l2 error = " << u_l2error << std::endl
111  << "u h1 error = " << u_h1error << std::endl
112  << "v l2 error = " << v_l2error << std::endl
113  << "v h1 error = " << v_h1error << std::endl
114  << "p l2 error = " << p_l2error << std::endl
115  << "p h1 error = " << p_h1error << std::endl;
116  }
117 
118  return return_flag;
119 }
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