GRINS-0.8.0
elastic_sheet_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-2017 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 #include "grins_config.h"
26 
27 #include <iostream>
28 
29 // GRINS
30 #include "grins/runner.h"
31 
32 // libMesh
33 #include "libmesh/parallel.h"
34 #include "libmesh/exact_solution.h"
35 
36 // Function for getting initial temperature field
37 libMesh::Real
38 initial_values( const libMesh::Point& p, const libMesh::Parameters &params,
39  const std::string& system_name, const std::string& unknown_name );
40 
41 int run( char* argv[], GRINS::Runner & grins );
42 
43 int main(int argc, char* argv[])
44 {
45  // Check command line count.
46  if( argc < 3 )
47  {
48  // TODO: Need more consistent error handling.
49  std::cerr << "Error: Must specify libMesh input file and exact solution file." << std::endl;
50  exit(1); // TODO: something more sophisticated for parallel runs?
51  }
52 
53  GRINS::Runner grins(argc,argv);
54 
55  int return_flag = 0;
56 
57  return_flag = run( argv, grins );
58 
59  return return_flag;
60 }
61 
62 int run( char* argv[], GRINS::Runner & grins )
63 {
64  grins.init();
65  grins.run();
66 
67  GRINS::Simulation & sim = grins.get_simulation();
68 
69  // Get equation systems to create ExactSolution object
70  GRINS::SharedPtr<libMesh::EquationSystems>
71  es = sim.get_equation_system();
72 
73  //es->write("foobar.xdr");
74 
75  // Create Exact solution object and attach exact solution quantities
76  libMesh::ExactSolution exact_sol(*es);
77 
78  libMesh::EquationSystems es_ref( es->get_mesh() );
79 
80  // Filename of file where comparison solution is stashed
81  std::string solution_file = std::string(argv[2]);
82  es_ref.read( solution_file );
83 
84  exact_sol.attach_reference_solution( &es_ref );
85 
86  // Compute error and get it in various norms
87  exact_sol.compute_error("StretchedElasticSheet", "u");
88  exact_sol.compute_error("StretchedElasticSheet", "v");
89  exact_sol.compute_error("StretchedElasticSheet", "w");
90 
91  double u_l2error = exact_sol.l2_error("StretchedElasticSheet", "u");
92  double u_h1error = exact_sol.h1_error("StretchedElasticSheet", "u");
93 
94  double v_l2error = exact_sol.l2_error("StretchedElasticSheet", "v");
95  double v_h1error = exact_sol.h1_error("StretchedElasticSheet", "v");
96 
97  double w_l2error = exact_sol.l2_error("StretchedElasticSheet", "w");
98  double w_h1error = exact_sol.h1_error("StretchedElasticSheet", "w");
99 
100  int return_flag = 0;
101 
102  double tol = 5.0e-8;
103 
104  if( u_l2error > tol || u_h1error > tol ||
105  v_l2error > tol || v_h1error > tol ||
106  w_l2error > tol || w_h1error > tol )
107  {
108  return_flag = 1;
109 
110  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
111  << "tolerance = " << tol << std::endl
112  << "u l2 error = " << u_l2error << std::endl
113  << "u h1 error = " << u_h1error << std::endl
114  << "v l2 error = " << v_l2error << std::endl
115  << "v h1 error = " << v_h1error << std::endl
116  << "w l2 error = " << w_l2error << std::endl
117  << "w h1 error = " << w_h1error << std::endl;
118  }
119 
120  return return_flag;
121 }
int main(int argc, char *argv[])
void init()
Initialize the Simulation objects.
Definition: runner.C:53
SharedPtr< libMesh::EquationSystems > get_equation_system()
Definition: simulation.C:393
libMesh::Real initial_values(const libMesh::Point &p, const libMesh::Parameters &params, const std::string &system_name, const std::string &unknown_name)
int run(char *argv[], GRINS::Runner &grins)
Class to encapsulate initializing and running GRINS Simulation.
Definition: runner.h:47
void run()
Runs the simulation that was setup at construction time.
Definition: runner.C:104
Simulation & get_simulation()
Definition: runner.h:66

Generated on Tue Dec 19 2017 12:47:29 for GRINS-0.8.0 by  doxygen 1.8.9.1