GRINS-0.6.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-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 #include "grins_config.h"
26 
27 #include <iostream>
28 
29 // GRINS
30 #include "grins/simulation.h"
32 
33 // GRVY
34 #ifdef HAVE_GRVY
35 #include "grvy.h"
36 #endif
37 
38 // libMesh
39 #include "libmesh/parallel.h"
40 #include "libmesh/exact_solution.h"
41 
42 // Function for getting initial temperature field
43 libMesh::Real
44 initial_values( const libMesh::Point& p, const libMesh::Parameters &params,
45  const std::string& system_name, const std::string& unknown_name );
46 
47 int run( int argc, char* argv[], const GetPot& input );
48 
49 int main(int argc, char* argv[])
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  return_flag = run( argc, argv, libMesh_inputfile );
73 
74  return return_flag;
75 }
76 
77 int run( int argc, char* argv[], const GetPot& input )
78 {
79 #ifdef USE_GRVY_TIMERS
80  grvy_timer.BeginTimer("Initialize Solver");
81 #endif
82 
83  // Initialize libMesh library.
84  libMesh::LibMeshInit libmesh_init(argc, argv);
85 
86  GRINS::SimulationBuilder sim_builder;
87 
88  GRINS::Simulation grins( input,
89  sim_builder,
90  libmesh_init.comm() );
91 
92  grins.run();
93 
94  // Get equation systems to create ExactSolution object
95  std::tr1::shared_ptr<libMesh::EquationSystems>
96  es = grins.get_equation_system();
97 
98  //es->write("foobar.xdr");
99 
100  // Create Exact solution object and attach exact solution quantities
101  libMesh::ExactSolution exact_sol(*es);
102 
103  libMesh::EquationSystems es_ref( es->get_mesh() );
104 
105  // Filename of file where comparison solution is stashed
106  std::string solution_file = std::string(argv[2]);
107  es_ref.read( solution_file );
108 
109  exact_sol.attach_reference_solution( &es_ref );
110 
111  // Compute error and get it in various norms
112  exact_sol.compute_error("StretchedElasticSheet", "u");
113  exact_sol.compute_error("StretchedElasticSheet", "v");
114  exact_sol.compute_error("StretchedElasticSheet", "w");
115 
116  double u_l2error = exact_sol.l2_error("StretchedElasticSheet", "u");
117  double u_h1error = exact_sol.h1_error("StretchedElasticSheet", "u");
118 
119  double v_l2error = exact_sol.l2_error("StretchedElasticSheet", "v");
120  double v_h1error = exact_sol.h1_error("StretchedElasticSheet", "v");
121 
122  double w_l2error = exact_sol.l2_error("StretchedElasticSheet", "w");
123  double w_h1error = exact_sol.h1_error("StretchedElasticSheet", "w");
124 
125  int return_flag = 0;
126 
127  double tol = 5.0e-8;
128 
129  if( u_l2error > tol || u_h1error > tol ||
130  v_l2error > tol || v_h1error > tol ||
131  w_l2error > tol || w_h1error > tol )
132  {
133  return_flag = 1;
134 
135  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
136  << "tolerance = " << tol << std::endl
137  << "u l2 error = " << u_l2error << std::endl
138  << "u h1 error = " << u_h1error << std::endl
139  << "v l2 error = " << v_l2error << std::endl
140  << "v h1 error = " << v_h1error << std::endl
141  << "w l2 error = " << w_l2error << std::endl
142  << "w h1 error = " << w_h1error << std::endl;
143  }
144 
145  return return_flag;
146 }
int main(int argc, char *argv[])
int run(int argc, char *argv[], const GetPot &input)
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