GRINS-0.6.0
Functions
grins_flow_regression.C File Reference
#include <iostream>
#include "grins/simulation.h"
#include "grins/simulation_builder.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 36 of file grins_flow_regression.C.

References GRINS::Simulation::run().

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 }

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