25 #include "grins_config.h"
34 #include "libmesh/parallel.h"
35 #include "libmesh/exact_solution.h"
39 initial_values(
const libMesh::Point& p,
const libMesh::Parameters ¶ms,
40 const std::string& system_name,
const std::string& unknown_name );
42 int run(
int argc,
char* argv[],
const GetPot& input, GetPot& command_line );
45 const std::string& system_name,
46 const std::string& var,
47 const std::string& norm,
51 int main(
int argc,
char* argv[])
53 GetPot command_line(argc,argv);
55 if( !command_line.have_variable(
"input") )
57 std::cerr <<
"ERROR: Must specify input file on command line with input=<file>." << std::endl;
61 if( !command_line.have_variable(
"soln-data") )
63 std::cerr <<
"ERROR: Must specify solution data on command line with soln-data=<file>." << std::endl;
67 if( !command_line.have_variable(
"vars") )
69 std::cerr <<
"ERROR: Must specify variables on command line with vars='var1 var2'" << std::endl;
73 if( !command_line.have_variable(
"norms") )
75 std::cerr <<
"ERROR: Must specify error norms on command line with norms='L2 H1'" << std::endl;
79 if( !command_line.have_variable(
"tol") )
81 std::cerr <<
"ERROR: Must specify test tolerance on command line with tol=<tol>" << std::endl;
86 std::string libMesh_input_filename = command_line(
"input",
"DIE!");
89 std::ifstream i(libMesh_input_filename.c_str());
92 std::cerr <<
"Error: Could not read from libMesh input file "
93 << libMesh_input_filename << std::endl;
99 GetPot libMesh_inputfile( libMesh_input_filename );
103 std::string chem_lib = libMesh_inputfile(
"Physics/ReactingLowMachNavierStokes/thermochemistry_library",
"DIE!");
105 if( chem_lib == std::string(
"cantera") )
107 #ifdef GRINS_HAVE_CANTERA
108 return_flag =
run(argc,argv,libMesh_inputfile,command_line);
113 else if( chem_lib == std::string(
"antioch") )
115 #ifdef GRINS_HAVE_ANTIOCH
116 return_flag =
run(argc,argv,libMesh_inputfile,command_line);
129 int run(
int argc,
char* argv[],
const GetPot& input, GetPot& command_line )
132 libMesh::LibMeshInit libmesh_init(argc, argv);
138 libmesh_init.comm() );
141 std::string restart_file = input(
"restart-options/restart_file",
"none" );
143 if( restart_file ==
"none" )
146 std::string system_name = input(
"screen-options/system_name",
"GRINS" );
147 std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
148 const libMesh::System& system = es->get_system(system_name);
150 libMesh::Parameters ¶ms = es->parameters;
152 libMesh::Real& w_N2 = params.set<libMesh::Real>(
"w_N2" );
153 w_N2 = input(
"Physics/ReactingLowMachNavierStokes/bound_species_0", 0.0, 0.0 );
155 libMesh::Real& w_N = params.set<libMesh::Real>(
"w_N" );
156 w_N = input(
"Physics/ReactingLowMachNavierStokes/bound_species_0", 0.0, 1.0 );
164 std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
167 libMesh::ExactSolution exact_sol(*es);
169 libMesh::EquationSystems es_ref( es->get_mesh() );
172 std::string solution_file = command_line(
"soln-data",
"DIE!");
173 es_ref.read( solution_file );
175 exact_sol.attach_reference_solution( &es_ref );
178 unsigned int n_vars = command_line.vector_variable_size(
"vars");
179 std::vector<std::string> vars(n_vars);
180 for(
unsigned int v = 0; v < n_vars; v++ )
182 vars[v] = command_line(
"vars",
"DIE!", v);
186 unsigned int n_norms = command_line.vector_variable_size(
"norms");
187 std::vector<std::string> norms(n_norms);
188 for(
unsigned int n = 0; n < n_norms; n++ )
190 norms[n] = command_line(
"norms",
"DIE!", n);
191 if( norms[n] != std::string(
"L2") &&
192 norms[n] != std::string(
"H1") )
194 std::cerr <<
"ERROR: Invalid norm input " << norms[n] << std::endl
195 <<
" Valid values are: L2" << std::endl
196 <<
" H1" << std::endl;
200 const std::string& system_name = grins.get_multiphysics_system_name();
203 for(
unsigned int v = 0; v < n_vars; v++ )
205 exact_sol.compute_error(system_name, vars[v]);
210 double tol = command_line(
"tol", 1.0e-10);
213 for(
unsigned int v = 0; v < n_vars; v++ )
215 for(
unsigned int n = 0; n < n_norms; n++ )
217 test_error_norm( exact_sol, system_name, vars[v], norms[n], tol, return_flag );
226 const std::string& ,
const std::string& unknown_name )
228 libMesh::Real value = 0.0;
230 if( unknown_name ==
"w_N2" )
231 value = params.get<libMesh::Real>(
"w_N2");
233 else if( unknown_name ==
"w_N" )
234 value = params.get<libMesh::Real>(
"w_N");
236 else if( unknown_name ==
"T" )
239 else if( unknown_name ==
"u" )
241 const libMesh::Real x = p(0);
242 value = 1.0*(-x*x+1);
252 const std::string& system_name,
253 const std::string& var,
254 const std::string& norm,
265 std::cout <<
"==========================================================" << std::endl
266 <<
"Checking variable " << var <<
" using error norm " << norm <<
" with tol " << tol <<
"...";
268 if( norm == std::string(
"L2") )
270 error = exact_sol.l2_error(system_name, var);
272 else if( norm == std::string(
"H1") )
274 error = exact_sol.h1_error(system_name, var);
278 std::cerr <<
"ERROR: Invalid norm " << norm << std::endl;
286 std::cerr <<
"Tolerance exceeded for generic regression test!" << std::endl
287 <<
"tolerance = " << tol << std::endl
288 <<
"norm of error = " << error << std::endl
289 <<
"norm type = " << norm << std::endl
290 <<
"var = " << var << std::endl;
294 std::cout <<
"PASSED!" << std::endl
295 <<
"==========================================================" << std::endl;
libMesh::Real initial_values(const libMesh::Point &p, const libMesh::Parameters ¶ms, const std::string &system_name, const std::string &unknown_name)
int run(int argc, char *argv[], const GetPot &input, GetPot &command_line)
int main(int argc, char *argv[])
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)