25 #include "grins_config.h"
33 #include "libmesh/exact_solution.h"
36 const std::string& system_name,
37 const std::string& var,
38 const std::string& norm,
42 int main(
int argc,
char* argv[])
48 if( !command_line.have_variable(
"soln-data") )
50 std::cerr <<
"ERROR: Must specify solution data on command line with soln-data=<file>." << std::endl;
54 if( !command_line.have_variable(
"vars") )
56 std::cerr <<
"ERROR: Must specify variables on command line with vars='var1 var2'" << std::endl;
60 if( !command_line.have_variable(
"norms") )
62 std::cerr <<
"ERROR: Must specify error norms on command line with norms='L2 H1'" << std::endl;
66 if( !command_line.have_variable(
"tol") )
68 std::cerr <<
"ERROR: Must specify test tolerance on command line with tol=<tol>" << std::endl;
75 inputfile.have_variable(
"soln-data");
76 inputfile.have_variable(
"vars");
77 inputfile.have_variable(
"norms");
78 inputfile.have_variable(
"tol");
79 inputfile.have_variable(
"qois");
93 libMesh::ExactSolution exact_sol(*es);
95 libMesh::EquationSystems es_ref( es->get_mesh() );
98 std::string solution_file = command_line(
"soln-data",
"DIE!");
99 es_ref.read( solution_file );
101 exact_sol.attach_reference_solution( &es_ref );
104 unsigned int n_vars = command_line.vector_variable_size(
"vars");
105 std::vector<std::string> vars(n_vars);
106 for(
unsigned int v = 0; v < n_vars; v++ )
108 vars[v] = command_line(
"vars",
"DIE!", v);
112 unsigned int n_norms = command_line.vector_variable_size(
"norms");
113 std::vector<std::string> norms(n_norms);
114 for(
unsigned int n = 0; n < n_norms; n++ )
116 norms[n] = command_line(
"norms",
"DIE!", n);
117 if( norms[n] != std::string(
"L2") &&
118 norms[n] != std::string(
"H1") )
120 std::cerr <<
"ERROR: Invalid norm input " << norms[n] << std::endl
121 <<
" Valid values are: L2" << std::endl
122 <<
" H1" << std::endl;
129 for(
unsigned int v = 0; v < n_vars; v++ )
131 exact_sol.compute_error(system_name, vars[v]);
136 double tol = command_line(
"tol", 1.0e-10);
139 for(
unsigned int v = 0; v < n_vars; v++ )
141 for(
unsigned int n = 0; n < n_norms; n++ )
143 test_error_norm( exact_sol, system_name, vars[v], norms[n], tol, return_flag );
148 unsigned int n_qoi_vals = command_line.vector_variable_size(
"qois");
149 for(
unsigned int n = 0; n < n_qoi_vals; n++ )
152 std::cout <<
"==========================================================" << std::endl
153 <<
"Checking qoi " << n <<
" with tol " << tol <<
"...";
155 libMesh::Number gold_qoi = command_line(
"qois", libMesh::Number(0), n);
157 libMesh::Number computed_qoi =
160 double error = computed_qoi - gold_qoi;
162 if (std::abs(error) > tol)
164 std::cerr <<
"Tolerance exceeded for generic regression test!" << std::endl
165 <<
"tolerance = " << tol << std::endl
166 <<
"error = " << error << std::endl
167 <<
"qoi index = " << n << std::endl;
171 std::cout <<
"PASSED!" << std::endl
172 <<
"==========================================================" << std::endl;
181 const std::string& system_name,
182 const std::string& var,
183 const std::string& norm,
194 std::cout <<
"==========================================================" << std::endl
195 <<
"Checking variable " << var <<
" using error norm " << norm <<
" with tol " << tol <<
"...";
197 if( norm == std::string(
"L2") )
199 error = exact_sol.l2_error(system_name, var);
201 else if( norm == std::string(
"H1") )
203 error = exact_sol.h1_error(system_name, var);
207 std::cerr <<
"ERROR: Invalid norm " << norm << std::endl;
215 std::cerr <<
"Tolerance exceeded for generic regression test!" << std::endl
216 <<
"tolerance = " << tol << std::endl
217 <<
"norm of error = " << error << std::endl
218 <<
"norm type = " << norm << std::endl
219 <<
"var = " << var << std::endl;
223 std::cout <<
"PASSED!" << std::endl
224 <<
"==========================================================" << std::endl;
void init()
Initialize the Simulation objects.
SharedPtr< libMesh::EquationSystems > get_equation_system()
const GetPot & get_input_file() const
const GetPot & get_command_line() const
MultiphysicsSystem * get_multiphysics_system()
int main(int argc, char *argv[])
const std::string & get_multiphysics_system_name() const
Class to encapsulate initializing and running GRINS Simulation.
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)
void run()
Runs the simulation that was setup at construction time.
Simulation & get_simulation()