GRINS-0.8.0
Functions
grins_flow_regression.C File Reference
#include <iostream>
#include "grins/runner.h"
#include "libmesh/exact_solution.h"
Include dependency graph for grins_flow_regression.C:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 35 of file grins_flow_regression.C.

References GRINS::Simulation::get_equation_system(), GRINS::Runner::get_input_file(), GRINS::Runner::get_simulation(), GRINS::Runner::init(), and GRINS::Runner::run().

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 }
SharedPtr< libMesh::EquationSystems > get_equation_system()
Definition: simulation.C:393
Class to encapsulate initializing and running GRINS Simulation.
Definition: runner.h:47

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