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

Go to the source code of this file.

Classes

class  AxiParabolicBCFactory
 

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 &  var 
)

Definition at line 206 of file test_axi_ns_poiseuille_flow.C.

Referenced by main().

210 {
211  const double r = p(0);
212 
213  libMesh::Gradient g;
214 
215  // Hardcoded to velocity in input file.
216  if( var == "z_vel" )
217  {
218  g(0) = -100.0/2.0*r;
219  g(1) = 0.0;
220  }
221 
222  return g;
223 }
libMesh::Number exact_solution ( const libMesh::Point &  p,
const libMesh::Parameters &  ,
const std::string &  ,
const std::string &  var 
)

Definition at line 186 of file test_axi_ns_poiseuille_flow.C.

Referenced by main().

190 {
191  const double r = p(0);
192 
193  const double r0 = 1.0;
194  const double mu = 1.0;
195  const double dpdx = -1.0;
196 
197  libMesh::Number f = 0;
198  // Hardcoded to velocity in input file.
199  if( var == "z_vel" ) f = -dpdx*100.0/(4.0*mu)*(r0*r0 - r*r);
200  else libmesh_assert(false);
201 
202  return f;
203 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 69 of file test_axi_ns_poiseuille_flow.C.

References GRINS::SimulationBuilder::attach_bc_factory(), exact_derivative(), exact_solution(), and GRINS::Simulation::get_equation_system().

70 {
71 #ifdef GRINS_USE_GRVY_TIMERS
72  GRVY::GRVY_Timer_Class grvy_timer;
73  grvy_timer.Init("GRINS Timer");
74 #endif
75 
76  // Check command line count.
77  if( argc < 2 )
78  {
79  // TODO: Need more consistent error handling.
80  std::cerr << "Error: Must specify libMesh input file." << std::endl;
81  exit(1); // TODO: something more sophisticated for parallel runs?
82  }
83 
84  // libMesh input file should be first argument
85  std::string libMesh_input_filename = argv[1];
86 
87  // Create our GetPot object.
88  GetPot libMesh_inputfile( libMesh_input_filename );
89 
90 #ifdef GRINS_USE_GRVY_TIMERS
91  grvy_timer.BeginTimer("Initialize Solver");
92 #endif
93 
94  // Initialize libMesh library.
95  libMesh::LibMeshInit libmesh_init(argc, argv);
96 
97  GRINS::SimulationBuilder sim_builder;
98 
99  std::tr1::shared_ptr<AxiParabolicBCFactory> bc_factory( new AxiParabolicBCFactory );
100 
101  sim_builder.attach_bc_factory(bc_factory);
102 
103  GRINS::Simulation grins( libMesh_inputfile,
104  sim_builder,
105  libmesh_init.comm() );
106 
107 #ifdef GRINS_USE_GRVY_TIMERS
108  grvy_timer.EndTimer("Initialize Solver");
109 
110  // Attach GRVY timer to solver
111  grins.attach_grvy_timer( &grvy_timer );
112 #endif
113 
114  // Get equation systems to create ExactSolution object
115  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
116 
117  // Do solve here
118  grins.run();
119 
120 
121  // Create Exact solution object and attach exact solution quantities
122  libMesh::ExactSolution exact_sol(*es);
123 
124  exact_sol.attach_exact_value(&exact_solution);
125  exact_sol.attach_exact_deriv(&exact_derivative);
126 
127  // Compute error and get it in various norms
128  exact_sol.compute_error("GRINS", "z_vel");
129 
130  double l2error = exact_sol.l2_error("GRINS", "z_vel");
131  double h1error = exact_sol.h1_error("GRINS", "z_vel");
132 
133  int return_flag = 0;
134 
135  double tol = 1.0e-9;
136 
137  if( l2error > tol || h1error > tol )
138  {
139  return_flag = 1;
140 
141  std::cout << "Tolerance exceeded for velocity in Poiseuille test." << std::endl
142  << "l2 error = " << l2error << std::endl
143  << "h1 error = " << h1error << std::endl;
144  }
145 
146  /*
147  // Compute error and get it in various norms
148  exact_sol.compute_error("GRINS", "p");
149 
150  l2error = exact_sol.l2_error("GRINS", "p");
151  h1error = exact_sol.h1_error("GRINS", "p");
152 
153  if( l2error > 1.0e-11 || h1error > 1.0e-11 )
154  {
155  return_flag = 1;
156 
157  std::cout << "Tolerance exceeded for pressure in Poiseuille test." << std::endl
158  << "l2 error = " << l2error << std::endl
159  << "h1 error = " << h1error << std::endl;
160  }
161  */
162 
163  return return_flag;
164 }
libMesh::Gradient exact_derivative(const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)
std::tr1::shared_ptr< libMesh::EquationSystems > get_equation_system()
Definition: simulation.C:422
libMesh::Number exact_solution(const libMesh::Point &p, const libMesh::Parameters &, const std::string &, const std::string &)
void attach_bc_factory(std::tr1::shared_ptr< BoundaryConditionsFactory > bc_factory)

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