GRINS-0.6.0
Functions
reacting_low_mach_regression.C File Reference
#include "grins_config.h"
#include <iostream>
#include "grins/simulation.h"
#include "grins/simulation_builder.h"
#include "libmesh/parallel.h"
#include "libmesh/exact_solution.h"
Include dependency graph for reacting_low_mach_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 run (int argc, char *argv[], const GetPot &input)
 
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 241 of file reacting_low_mach_regression.C.

Referenced by run().

243 {
244  libMesh::Real value = 0.0;
245 
246  if( unknown_name == "w_N2" )
247  value = params.get<libMesh::Real>("w_N2");
248 
249  else if( unknown_name == "w_N" )
250  value = params.get<libMesh::Real>("w_N");
251 
252  else if( unknown_name == "T" )
253  value = 300;
254 
255  else if( unknown_name == "u" )
256  {
257  const libMesh::Real y = p(1);
258  value = 1.0*(-y*y+1);
259  }
260 
261  else
262  value = 0.0;
263 
264  return value;
265 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 49 of file reacting_low_mach_regression.C.

References run().

50 {
51 #ifdef USE_GRVY_TIMERS
52  GRVY::GRVY_Timer_Class grvy_timer;
53  grvy_timer.Init("GRINS Timer");
54 #endif
55 
56  // Check command line count.
57  if( argc < 3 )
58  {
59  // TODO: Need more consistent error handling.
60  std::cerr << "Error: Must specify libMesh input file and exact solution file." << std::endl;
61  exit(1); // TODO: something more sophisticated for parallel runs?
62  }
63 
64  // libMesh input file should be first argument
65  std::string libMesh_input_filename = argv[1];
66 
67  // Create our GetPot object.
68  GetPot libMesh_inputfile( libMesh_input_filename );
69 
70  int return_flag = 0;
71 
72  std::string chem_lib = libMesh_inputfile("Physics/ReactingLowMachNavierStokes/thermochemistry_library", "DIE!");
73 
74  if( chem_lib == std::string("cantera") )
75  {
76 #ifdef GRINS_HAVE_CANTERA
77  return_flag = run(argc,argv,libMesh_inputfile);
78 #else
79  return_flag = 77;
80 #endif
81  }
82  else if( chem_lib == std::string("antioch") )
83  {
84 #ifdef GRINS_HAVE_ANTIOCH
85  return_flag = run(argc,argv,libMesh_inputfile);
86 #else
87  return_flag = 77;
88 #endif
89  }
90  else
91  {
92  return_flag = 1;
93  }
94 
95  return return_flag;
96 }
int run(int argc, char *argv[], const GetPot &input)
int run ( int  argc,
char *  argv[],
const GetPot &  input 
)

Definition at line 98 of file reacting_low_mach_regression.C.

References initial_values().

Referenced by main().

99 {
100 #ifdef USE_GRVY_TIMERS
101  grvy_timer.BeginTimer("Initialize Solver");
102 #endif
103 
104  // Initialize libMesh library.
105  libMesh::LibMeshInit libmesh_init(argc, argv);
106 
107  GRINS::SimulationBuilder sim_builder;
108 
109  GRINS::Simulation grins( input,
110  sim_builder,
111  libmesh_init.comm() );
112 
113  //FIXME: We need to move this to within the Simulation object somehow...
114  std::string restart_file = input( "restart-options/restart_file", "none" );
115 
116  if( restart_file == "none" )
117  {
118  // Asssign initial temperature value
119  std::string system_name = input( "screen-options/system_name", "GRINS" );
120  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
121  const libMesh::System& system = es->get_system(system_name);
122 
123  libMesh::Parameters &params = es->parameters;
124 
125  libMesh::Real& w_N2 = params.set<libMesh::Real>( "w_N2" );
126  w_N2 = input( "Physics/ReactingLowMachNavierStokes/bound_species_3", 0.0, 0 );
127 
128  libMesh::Real& w_N = params.set<libMesh::Real>( "w_N" );
129  w_N = input( "Physics/ReactingLowMachNavierStokes/bound_species_3", 0.0, 1 );
130 
131  system.project_solution( initial_values, NULL, params );
132  }
133 
134 #ifdef USE_GRVY_TIMERS
135  grvy_timer.EndTimer("Initialize Solver");
136 
137  // Attach GRVY timer to solver
138  grins.attach_grvy_timer( &grvy_timer );
139 #endif
140 
141  grins.run();
142 
143 #ifdef USE_GRVY_TIMERS
144  grvy_timer.Finalize();
145 
146  if( Parallel::Communicator_World.rank() == 0 ) grvy_timer.Summarize();
147 #endif
148 
149  // Get equation systems to create ExactSolution object
150  std::tr1::shared_ptr<libMesh::EquationSystems>
151  es = grins.get_equation_system();
152 
153  //es->write("foobar.xdr");
154 
155  // Create Exact solution object and attach exact solution quantities
156  libMesh::ExactSolution exact_sol(*es);
157 
158  libMesh::EquationSystems es_ref( es->get_mesh() );
159 
160  // Filename of file where comparison solution is stashed
161  std::string solution_file = std::string(argv[2]);
162  es_ref.read( solution_file );
163 
164  exact_sol.attach_reference_solution( &es_ref );
165 
166  // Compute error and get it in various norms
167  exact_sol.compute_error("GRINS", "u");
168  exact_sol.compute_error("GRINS", "v");
169 
170  if( (es->get_mesh()).mesh_dimension() == 3 )
171  exact_sol.compute_error("GRINS", "w");
172 
173  exact_sol.compute_error("GRINS", "p");
174  exact_sol.compute_error("GRINS", "T");
175  exact_sol.compute_error("GRINS", "w_N2");
176  exact_sol.compute_error("GRINS", "w_N");
177 
178  double u_l2error = exact_sol.l2_error("GRINS", "u");
179  double u_h1error = exact_sol.h1_error("GRINS", "u");
180 
181  double v_l2error = exact_sol.l2_error("GRINS", "v");
182  double v_h1error = exact_sol.h1_error("GRINS", "v");
183 
184  double p_l2error = exact_sol.l2_error("GRINS", "p");
185  double p_h1error = exact_sol.h1_error("GRINS", "p");
186 
187  double T_l2error = exact_sol.l2_error("GRINS", "T");
188  double T_h1error = exact_sol.h1_error("GRINS", "T");
189 
190  double wN_l2error = exact_sol.l2_error("GRINS", "w_N");
191  double wN_h1error = exact_sol.h1_error("GRINS", "w_N");
192 
193  double wN2_l2error = exact_sol.l2_error("GRINS", "w_N2");
194  double wN2_h1error = exact_sol.h1_error("GRINS", "w_N2");
195 
196  double w_l2error = 0.0,
197  w_h1error = 0.0;
198 
199  if( (es->get_mesh()).mesh_dimension() == 3 )
200  {
201  w_l2error = exact_sol.l2_error("GRINS", "w");
202  w_h1error = exact_sol.h1_error("GRINS", "w");
203  }
204 
205  int return_flag = 0;
206 
207  double tol = 1.5e-8;
208 
209  if( u_l2error > tol || u_h1error > tol ||
210  v_l2error > tol || v_h1error > tol ||
211  w_l2error > tol || w_h1error > tol ||
212  p_l2error > tol || p_h1error > tol ||
213  T_l2error > tol || T_h1error > tol ||
214  wN_l2error > tol || wN_h1error > tol ||
215  wN2_l2error > tol || wN2_h1error > tol )
216  {
217  return_flag = 1;
218 
219  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
220  << "tolerance = " << tol << std::endl
221  << "u l2 error = " << u_l2error << std::endl
222  << "u h1 error = " << u_h1error << std::endl
223  << "v l2 error = " << v_l2error << std::endl
224  << "v h1 error = " << v_h1error << std::endl
225  << "w l2 error = " << w_l2error << std::endl
226  << "w h1 error = " << w_h1error << std::endl
227  << "p l2 error = " << p_l2error << std::endl
228  << "p h1 error = " << p_h1error << std::endl
229  << "T l2 error = " << T_l2error << std::endl
230  << "T h1 error = " << T_h1error << std::endl
231  << "w_N l2 error = " << wN_l2error << std::endl
232  << "w_N h1 error = " << wN_h1error << std::endl
233  << "w_N2 l2 error = " << wN2_l2error << std::endl
234  << "w_N2 h1 error = " << wN2_h1error << std::endl;
235  }
236 
237  return return_flag;
238 }
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