GRINS-0.6.0
low_mach_cavity_benchmark_regression.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 // C++
27 #include <iostream>
28 
29 // GRINS
30 #include "grins/simulation.h"
32 
33 // Function for getting initial temperature field
34 libMesh::Real
35 initial_values( const libMesh::Point& p, const libMesh::Parameters &params,
36  const std::string& system_name, const std::string& unknown_name );
37 
38 int main(int argc, char* argv[])
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 }
126 
127 libMesh::Real
128 initial_values( const libMesh::Point&, const libMesh::Parameters &params,
129  const std::string& , const std::string& unknown_name )
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[])
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:20 for GRINS-0.6.0 by  doxygen 1.8.9.1