48 GetPot command_line(argc,argv);
50 if( !command_line.have_variable(
"input") )
52 std::cerr <<
"ERROR: Must specify input file on command line with input=<file>."
57 if( !command_line.have_variable(
"test_data_prefix") )
59 std::cerr <<
"ERROR: Must specify solution test data filename prefix on command line with test_data_prefix=<string>."
64 if( !command_line.have_variable(
"mesh_data_prefix") )
66 std::cerr <<
"ERROR: Must specify solution mesh data filename prefix on command line with test_data_prefix=<string>."
71 if( !command_line.have_variable(
"gold_data_prefix") )
73 std::cerr <<
"ERROR: Must specify solution gold data filename prefix on command line with gold_data_prefix=<string>."
78 if( !command_line.have_variable(
"gold_mesh_prefix") )
80 std::cerr <<
"ERROR: Must specify gold mesh data filename prefix on command line with gold_mesh_prefix=<string>."
85 if( !command_line.have_variable(
"vars") )
87 std::cerr <<
"ERROR: Must specify variables on command line with vars='var1 var2'"
92 if( !command_line.have_variable(
"norms") )
94 std::cerr <<
"ERROR: Must specify error norms on command line with norms='L2 H1'"
99 if( !command_line.have_variable(
"tol") )
101 std::cerr <<
"ERROR: Must specify test tolerance on command line with tol=<double>"
106 if( !command_line.have_variable(
"n_steps") )
108 std::cerr <<
"ERROR: Must specify n_steps on command line with n_steps=<int>"
116 unsigned int n_vars = command_line.vector_variable_size(
"vars");
117 std::vector<std::string> vars(n_vars);
118 for(
unsigned int v = 0; v < n_vars; v++ )
120 vars[v] = command_line(
"vars",
"DIE!", v);
124 unsigned int n_norms = command_line.vector_variable_size(
"norms");
125 std::vector<std::string> norms(n_norms);
126 for(
unsigned int n = 0; n < n_norms; n++ )
128 norms[n] = command_line(
"norms",
"DIE!", n);
129 if( norms[n] != std::string(
"L2") )
131 std::cerr <<
"ERROR: Invalid norm input " << norms[n] << std::endl
132 <<
" Valid values are: L2" << std::endl;
137 std::string input_filename = command_line(
"input",
"DIE!");
141 std::ifstream i(input_filename.c_str());
144 std::cerr <<
"Error: Could not read from input file "
145 << input_filename << std::endl;
151 GetPot input( input_filename );
154 libMesh::LibMeshInit libmesh_init(argc, argv);
156 std::string test_data_prefix = command_line(
"test_data_prefix",
"DIE!" );
157 std::string mesh_data_prefix = command_line(
"mesh_data_prefix",
"DIE!" );
159 std::string gold_data_prefix = command_line(
"gold_data_prefix",
"DIE!" );
160 std::string gold_mesh_prefix = command_line(
"gold_mesh_prefix",
"DIE!" );
162 unsigned int n_steps = command_line(
"n_steps", 0);
166 std::string system_name =
"GRINS-TEST";
168 for(
unsigned int s = 0; s < n_steps; s++ )
170 std::stringstream step_string;
174 std::string mesh_filename = mesh_data_prefix+
"."+step_string.str()+
"_mesh.xda";
176 std::ifstream i( mesh_filename.c_str());
179 std::cerr <<
"Error: Could not read from mesh_data file "
180 << mesh_filename << std::endl;
185 libMesh::Mesh mesh(libmesh_init.comm());
186 mesh.read(mesh_filename);
190 std::string test_data = test_data_prefix+
"."+step_string.str()+
".xdr";
193 std::ifstream i(test_data.c_str());
196 std::cerr <<
"Error: Could not read from test_data file "
197 << test_data << std::endl;
202 libMesh::EquationSystems es(mesh);
205 libMesh::EquationSystems::READ_HEADER |
206 libMesh::EquationSystems::READ_DATA |
207 libMesh::EquationSystems::READ_ADDITIONAL_DATA);
211 std::string gold_mesh_filename = gold_mesh_prefix+
"_mesh."+step_string.str()+
".exo";
213 std::ifstream i( gold_mesh_filename.c_str());
216 std::cerr <<
"Error: Could not read from gold_mesh file "
217 << gold_mesh_filename << std::endl;
222 libMesh::Mesh gold_mesh(libmesh_init.comm());
223 gold_mesh.read(gold_mesh_filename);
227 std::string gold_data = gold_data_prefix+
"."+step_string.str()+
".xdr";
230 std::ifstream i(gold_data.c_str());
233 std::cerr <<
"Error: Could not read from test_data file "
234 << gold_data << std::endl;
239 libMesh::EquationSystems es_gold(gold_mesh);
240 es_gold.read(gold_data,
242 libMesh::EquationSystems::READ_HEADER |
243 libMesh::EquationSystems::READ_DATA |
244 libMesh::EquationSystems::READ_ADDITIONAL_DATA);
247 libMesh::ExactSolution exact_sol(es);
249 exact_sol.attach_reference_solution( &es_gold );
252 for(
unsigned int v = 0; v < n_vars; v++ )
254 exact_sol.compute_error(system_name, vars[v]);
257 double tol = command_line(
"tol", 1.0e-10);
263 double exact_error = 0.0;
266 for(
unsigned int v = 0; v < n_vars; v++ )
268 for(
unsigned int n = 0; n < n_norms; n++ )
270 test_flag =
test_error_norm( exact_sol, system_name, vars[v], norms[n], exact_error, tol );
278 if( return_flag == 1 )
int test_error_norm(libMesh::ExactSolution &exact_sol, const std::string &system_name, const std::string &var, const std::string &norm, const libMesh::Real exact_error, const double tol)