45 GetPot command_line(argc,argv);
47 if( !command_line.have_variable(
"input") )
49 std::cerr <<
"ERROR: Must specify input file on command line with input=<file>." << std::endl;
53 if( !command_line.have_variable(
"soln-data") )
55 std::cerr <<
"ERROR: Must specify solution data on command line with soln-data=<file>." << std::endl;
59 if( !command_line.have_variable(
"vars") )
61 std::cerr <<
"ERROR: Must specify variables on command line with vars='var1 var2'" << std::endl;
65 if( !command_line.have_variable(
"norms") )
67 std::cerr <<
"ERROR: Must specify error norms on command line with norms='L2 H1'" << std::endl;
71 if( !command_line.have_variable(
"tol") )
73 std::cerr <<
"ERROR: Must specify test tolerance on command line with tol=<tol>" << std::endl;
78 std::string libMesh_input_filename = command_line(
"input",
"DIE!");
81 std::ifstream i(libMesh_input_filename.c_str());
84 std::cerr <<
"Error: Could not read from libMesh input file "
85 << libMesh_input_filename << std::endl;
91 GetPot libMesh_inputfile( libMesh_input_filename );
94 libMesh::LibMeshInit libmesh_init(argc, argv);
101 libmesh_init.comm() );
107 std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
110 libMesh::ExactSolution exact_sol(*es);
112 libMesh::EquationSystems es_ref( es->get_mesh() );
115 std::string solution_file = command_line(
"soln-data",
"DIE!");
116 es_ref.read( solution_file );
118 exact_sol.attach_reference_solution( &es_ref );
121 unsigned int n_vars = command_line.vector_variable_size(
"vars");
122 std::vector<std::string> vars(n_vars);
123 for(
unsigned int v = 0; v < n_vars; v++ )
125 vars[v] = command_line(
"vars",
"DIE!", v);
129 unsigned int n_norms = command_line.vector_variable_size(
"norms");
130 std::vector<std::string> norms(n_norms);
131 for(
unsigned int n = 0; n < n_norms; n++ )
133 norms[n] = command_line(
"norms",
"DIE!", n);
134 if( norms[n] != std::string(
"L2") &&
135 norms[n] != std::string(
"H1") )
137 std::cerr <<
"ERROR: Invalid norm input " << norms[n] << std::endl
138 <<
" Valid values are: L2" << std::endl
139 <<
" H1" << std::endl;
143 const std::string& system_name = grins.get_multiphysics_system_name();
146 for(
unsigned int v = 0; v < n_vars; v++ )
148 exact_sol.compute_error(system_name, vars[v]);
153 double tol = command_line(
"tol", 1.0e-10);
156 for(
unsigned int v = 0; v < n_vars; v++ )
158 for(
unsigned int n = 0; n < n_norms; n++ )
160 test_error_norm( exact_sol, system_name, vars[v], norms[n], tol, return_flag );
void test_error_norm(libMesh::ExactSolution &exact_sol, const std::string &system_name, const std::string &var, const std::string &norm, const double tol, int &return_flag)