GRINS-0.6.0
Functions
low_mach_cavity_benchmark_regression.C File Reference
#include <iostream>
#include "grins/simulation.h"
#include "grins/simulation_builder.h"
Include dependency graph for low_mach_cavity_benchmark_regression.C:

Go to the source code of this file.

Functions

libMesh::Real initial_values (const libMesh::Point &p, const libMesh::Parameters &params, const std::string &system_name, const std::string &unknown_name)
 
int main (int argc, char *argv[])
 

Function Documentation

libMesh::Real initial_values ( const libMesh::Point &  p,
const libMesh::Parameters &  params,
const std::string &  system_name,
const std::string &  unknown_name 
)

Definition at line 128 of file low_mach_cavity_benchmark_regression.C.

Referenced by main().

130 {
131  libMesh::Real value = 0.0;
132 
133  if( unknown_name == "T" )
134  value = params.get<libMesh::Real>("T_init");
135 
136  else if( unknown_name == "p0" )
137  value = params.get<libMesh::Real>("p0_init");
138 
139  else
140  value = 0.0;
141 
142  return value;
143 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 38 of file low_mach_cavity_benchmark_regression.C.

References initial_values().

39 {
40  // Check command line count.
41  if( argc < 2 )
42  {
43  // TODO: Need more consistent error handling.
44  std::cerr << "Error: Must specify libMesh input file." << std::endl;
45  exit(1); // TODO: something more sophisticated for parallel runs?
46  }
47 
48  // libMesh input file should be first argument
49  std::string libMesh_input_filename = argv[1];
50 
51  // Create our GetPot object.
52  GetPot libMesh_inputfile( libMesh_input_filename );
53 
54  // Initialize libMesh library.
55  libMesh::LibMeshInit libmesh_init(argc, argv);
56 
57  // This is a tough problem to get to converge without PETSc
58  libmesh_example_requires
59  (libMesh::default_solver_package() != libMesh::LASPACK_SOLVERS,
60  "--enable-petsc");
61 
62  GRINS::SimulationBuilder sim_builder;
63 
64  GRINS::Simulation grins( libMesh_inputfile,
65  sim_builder,
66  libmesh_init.comm() );
67 
68  //FIXME: We need to move this to within the Simulation object somehow...
69  std::string restart_file = libMesh_inputfile( "restart-options/restart_file", "none" );
70 
71  if( restart_file == "none" )
72  {
73  // Asssign initial temperature value
74  std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
75  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
76  const libMesh::System& system = es->get_system(system_name);
77 
78  libMesh::Parameters &params = es->parameters;
79  libMesh::Real T_init = libMesh_inputfile("Physics/LowMachNavierStokes/T0", 0.0);
80  libMesh::Real p0_init = libMesh_inputfile("Physics/LowMachNavierStokes/p0", 0.0);
81 
82  libMesh::Real& dummy_T = params.set<libMesh::Real>("T_init");
83  dummy_T = T_init;
84 
85  libMesh::Real& dummy_p0 = params.set<libMesh::Real>("p0_init");
86  dummy_p0 = p0_init;
87 
88  system.project_solution( initial_values, NULL, params );
89  }
90 
91  grins.run();
92 
93  libMesh::Real qoi = grins.get_qoi_value(0);
94 
95  // Note that this is a *really* coarse mesh. This is just for testing
96  // and not even close to the real QoI for this problem.
97 
98  // Erroneous value from libMesh 0.9.2.2
99  // const libMesh::Real exact_qoi = 4.8158910676325055;
100 
101  // Value after libMesh 7acb6fc9 bugfix
102  const libMesh::Real exact_qoi = 4.8654229502012685;
103 
104  const libMesh::Real tol = 1.0e-9;
105 
106  int return_flag = 0;
107 
108  libMesh::Real rel_error = std::fabs( (qoi-exact_qoi)/exact_qoi );
109 
110  if( rel_error > tol )
111  {
112  // Skip this test until we know what changed
113  // return_flag = 1;
114  return_flag = 77;
115 
116  std::cerr << std::setprecision(16)
117  << std::scientific
118  << "Error: QoI value mismatch." << std::endl
119  << "Computed qoi = " << qoi << std::endl
120  << "Exact qoi = " << exact_qoi << std::endl
121  << "Relative error = " << rel_error << std::endl;
122  }
123 
124  return return_flag;
125 }
libMesh::Real initial_values(const libMesh::Point &p, const libMesh::Parameters &params, const std::string &system_name, const std::string &unknown_name)

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