GRINS-0.6.0
Functions
suspended_cable_regression.C File Reference
#include "grins_config.h"
#include <iostream>
#include "grins/simulation_builder.h"
#include "grins/simulation.h"
#include "grins/math_constants.h"
#include "libmesh/parallel.h"
#include "libmesh/exact_solution.h"
Include dependency graph for suspended_cable_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 157 of file suspended_cable_regression.C.

References GRINS::Constants::pi.

Referenced by main().

159 {
160  libMesh::Real value = 0.0;
161 
162 
163  if( unknown_name == "u" )
164  {
165  value = -35*sin(GRINS::Constants::pi*p(0)/400.0);
166  }
167  else if( unknown_name == "w" )
168  {
169  value = -55*sin(GRINS::Constants::pi*p(0)/200.0);
170  }
171  else
172  {
173  value = 0.0;
174  }
175 
176  return value;
177 }
const libMesh::Real pi
int main ( int  argc,
char *  argv[] 
)

Definition at line 50 of file suspended_cable_regression.C.

References initial_values().

51 {
52 #ifdef GRINS_USE_GRVY_TIMERS
53  GRVY::GRVY_Timer_Class grvy_timer;
54  grvy_timer.Init("GRINS Timer");
55 #endif
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." << 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  // GetPot doesn't throw an error for a nonexistent file?
71  {
72  std::ifstream i(libMesh_input_filename.c_str());
73  if (!i)
74  {
75  std::cerr << "Error: Could not read from libMesh input file "
76  << libMesh_input_filename << std::endl;
77  exit(1);
78  }
79  }
80 
81  // Initialize libMesh library.
82  libMesh::LibMeshInit libmesh_init(argc, argv);
83 
84  libMesh::out << "Starting GRINS with command:\n";
85  for (int i=0; i != argc; ++i)
86  libMesh::out << argv[i] << ' ';
87  libMesh::out << std::endl;
88 
89  GRINS::SimulationBuilder sim_builder;
90 
91  GRINS::Simulation grins( libMesh_inputfile,
92  sim_builder,
93  libmesh_init.comm() );
94 
95  std::string system_name = libMesh_inputfile( "screen-options/system_name", "GRINS" );
96 
97  // Get equation systems
98  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
99  const libMesh::System& system = es->get_system(system_name);
100 
101  libMesh::Parameters &params = es->parameters;
102 
103  system.project_solution( initial_values, NULL, params );
104 
105  grins.run();
106 
107  //es->write("suspended_cable_test.xdr");
108 
109  // Create Exact solution object and attach exact solution quantities
110  libMesh::ExactSolution exact_sol(*es);
111 
112  libMesh::EquationSystems es_ref( es->get_mesh() );
113 
114  // Filename of file where comparison solution is stashed
115  std::string solution_file = std::string(argv[2]);
116  es_ref.read( solution_file );
117 
118  exact_sol.attach_reference_solution( &es_ref );
119 
120  // Compute error and get it in various norms
121  exact_sol.compute_error(system_name, "u");
122  exact_sol.compute_error(system_name, "v");
123  exact_sol.compute_error(system_name, "w");
124 
125  double u_l2error = exact_sol.l2_error(system_name, "u");
126  double u_h1error = exact_sol.h1_error(system_name, "u");
127 
128  double v_l2error = exact_sol.l2_error(system_name, "v");
129  double v_h1error = exact_sol.h1_error(system_name, "v");
130 
131  double w_l2error = exact_sol.l2_error(system_name, "w");
132  double w_h1error = exact_sol.h1_error(system_name, "w");
133 
134  int return_flag = 0;
135 
136  double tol = 5.0e-8;
137 
138  if( u_l2error > tol || u_h1error > tol ||
139  v_l2error > tol || v_h1error > tol ||
140  w_l2error > tol || w_h1error > tol )
141  {
142  return_flag = 1;
143 
144  std::cout << "Tolerance exceeded for suspended cable test." << std::endl
145  << "tolerance = " << tol << std::endl
146  << "u l2 error = " << u_l2error << std::endl
147  << "u h1 error = " << u_h1error << std::endl
148  << "v l2 error = " << v_l2error << std::endl
149  << "v h1 error = " << v_h1error << std::endl
150  << "w l2 error = " << w_l2error << std::endl
151  << "w h1 error = " << w_h1error << std::endl;
152  }
153 
154  return return_flag;
155 }
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