GRINS-0.6.0
Functions
test_ns_couette_flow_2d_y.C File Reference
#include "grins_config.h"
#include <iostream>
#include "grins/mesh_builder.h"
#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_y.C:

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 150 of file test_ns_couette_flow_2d_y.C.

Referenced by main().

154 {
155  libMesh::Gradient g;
156 
157  if( sys != "GRINS" || var != "v" )
158  std::cout << "sys = " << sys << ", var = " << var << std::endl;
159 
160  // Hardcoded to velocity in input file.
161  g(0) = 10.0;
162  g(1) = 0.0;
163 
164 #if LIBMESH_DIM > 2
165  g(2) = 0.0;
166 #endif
167 
168  return g;
169 }
libMesh::Number exact_solution ( const libMesh::Point &  p,
const libMesh::Parameters &  params,
const std::string &  sys,
const std::string &  var 
)

Definition at line 133 of file test_ns_couette_flow_2d_y.C.

Referenced by main().

137 {
138  const double x = p(0);
139 
140  if( sys != "GRINS" || var != "v" )
141  std::cout << "sys = " << sys << ", var = " << var << std::endl;
142 
143  // Hardcoded to velocity in input file.
144  libMesh::Number f = 10.0*x;
145 
146  return f;
147 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 56 of file test_ns_couette_flow_2d_y.C.

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

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

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