GRINS-0.6.0
Functions
test_ns_couette_flow_2d_x.C File Reference
#include "grins_config.h"
#include <iostream>
#include "grins/simulation.h"
#include "grins/simulation_builder.h"
#include "grins/multiphysics_sys.h"
#include "libmesh/exact_solution.h"
Include dependency graph for test_ns_couette_flow_2d_x.C:

Go to the source code of this file.

Functions

libMesh::Number exact_solution (const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)
 
libMesh::Gradient exact_derivative (const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)
 
int main (int argc, char *argv[])
 

Function Documentation

libMesh::Gradient exact_derivative ( const libMesh::Point &  p,
const libMesh::Parameters &  ,
const std::string &  ,
const std::string &   
)

Definition at line 146 of file test_ns_couette_flow_2d_x.C.

Referenced by main().

150 {
151  libMesh::Gradient g;
152 
153  // Hardcoded to velocity in input file.
154  g(0) = 0.0;
155  g(1) = 10.0;
156 
157 #if LIBMESH_DIM > 2
158  g(2) = 0.0;
159 #endif
160 
161  return g;
162 }
libMesh::Number exact_solution ( const libMesh::Point &  p,
const libMesh::Parameters &  ,
const std::string &  ,
const std::string &   
)

Definition at line 132 of file test_ns_couette_flow_2d_x.C.

Referenced by main().

136 {
137  const double y = p(1);
138 
139  // Hardcoded to velocity in input file.
140  libMesh::Number f = 10.0*y;
141 
142  return f;
143 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 55 of file test_ns_couette_flow_2d_x.C.

References exact_derivative(), exact_solution(), and GRINS::Simulation::run().

56 {
57 
58 #ifdef GRINS_USE_GRVY_TIMERS
59  GRVY::GRVY_Timer_Class grvy_timer;
60  grvy_timer.Init("GRINS Timer");
61 #endif
62 
63  // Check command line count.
64  if( argc < 2 )
65  {
66  // TODO: Need more consistent error handling.
67  std::cerr << "Error: Must specify libMesh input file." << std::endl;
68  exit(1); // TODO: something more sophisticated for parallel runs?
69  }
70 
71  // libMesh input file should be first argument
72  std::string libMesh_input_filename = argv[1];
73 
74  // Create our GetPot object.
75  GetPot libMesh_inputfile( libMesh_input_filename );
76 
77 #ifdef GRINS_USE_GRVY_TIMERS
78  grvy_timer.BeginTimer("Initialize Solver");
79 #endif
80 
81  // Initialize libMesh library.
82  libMesh::LibMeshInit libmesh_init(argc, argv);
83 
84  GRINS::SimulationBuilder sim_builder;
85 
86  GRINS::Simulation grins( libMesh_inputfile,
87  sim_builder,
88  libmesh_init.comm() );
89 
90 #ifdef GRINS_USE_GRVY_TIMERS
91  grvy_timer.EndTimer("Initialize Solver");
92 
93  // Attach GRVY timer to solver
94  grins.attach_grvy_timer( &grvy_timer );
95 #endif
96 
97  grins.run();
98 
99 #ifdef GRINS_USE_GRVY_TIMERS
100  grvy_timer.Finalize();
101 #endif
102 
103  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
104 
105  // Create Exact solution object and attach exact solution quantities
106  libMesh::ExactSolution exact_sol(*es);
107 
108  exact_sol.attach_exact_value(&exact_solution);
109  exact_sol.attach_exact_deriv(&exact_derivative);
110 
111  // Compute error and get it in various norms
112  exact_sol.compute_error("GRINS", "u");
113 
114  double l2error = exact_sol.l2_error("GRINS", "u");
115  double h1error = exact_sol.h1_error("GRINS", "u");
116 
117  int return_flag = 0;
118 
119  if( l2error > 1.0e-10 || h1error > 1.0e-10 )
120  {
121  return_flag = 1;
122 
123  std::cout << "Tolerance exceeded for Couette flow test." << std::endl
124  << "l2 error = " << l2error << std::endl
125  << "h1 error = " << h1error << std::endl;
126  }
127 
128  return return_flag;
129 }
libMesh::Number exact_solution(const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)
libMesh::Gradient exact_derivative(const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)

Generated on Mon Jun 22 2015 21:32:21 for GRINS-0.6.0 by  doxygen 1.8.9.1