GRINS-0.6.0
Classes | Namespaces | Functions
test_thermally_driven_flow.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_thermally_driven_flow.C:

Go to the source code of this file.

Classes

class  GRINS::ThermallyDrivenFlowTestBCFactory
 
class  GRINS::ZeroFluxBC
 

Namespaces

 GRINS
 GRINS namespace.
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 76 of file test_thermally_driven_flow.C.

References GRINS::SimulationBuilder::attach_bc_factory(), and GRINS::Simulation::run().

77 {
78 #ifdef GRINS_USE_GRVY_TIMERS
79  GRVY::GRVY_Timer_Class grvy_timer;
80  grvy_timer.Init("GRINS Timer");
81 #endif
82 
83  // Check command line count.
84  if( argc < 3 )
85  {
86  // TODO: Need more consistent error handling.
87  std::cerr << "Error: Must specify libMesh input file and solution file." << std::endl;
88  exit(1); // TODO: something more sophisticated for parallel runs?
89  }
90 
91  // libMesh input file should be first argument
92  std::string libMesh_input_filename = argv[1];
93 
94  // Create our GetPot object.
95  GetPot libMesh_inputfile( libMesh_input_filename );
96 
97 #ifdef GRINS_USE_GRVY_TIMERS
98  grvy_timer.BeginTimer("Initialize Solver");
99 #endif
100 
101  // Initialize libMesh library.
102  libMesh::LibMeshInit libmesh_init(argc, argv);
103 
104  GRINS::SimulationBuilder sim_builder;
105 
106  sim_builder.attach_bc_factory( std::tr1::shared_ptr<GRINS::BoundaryConditionsFactory>( new GRINS::ThermallyDrivenFlowTestBCFactory( libMesh_inputfile ) ) );
107 
108  GRINS::Simulation grins( libMesh_inputfile,
109  sim_builder,
110  libmesh_init.comm() );
111 
112 #ifdef GRINS_USE_GRVY_TIMERS
113  grvy_timer.EndTimer("Initialize Solver");
114 
115  // Attach GRVY timer to solver
116  grins.attach_grvy_timer( &grvy_timer );
117 #endif
118 
119  // Do solve here
120  grins.run();
121 
122  // Get equation systems to create ExactSolution object
123  std::tr1::shared_ptr<libMesh::EquationSystems> es = grins.get_equation_system();
124 
125  //es->write("foobar.xdr");
126 
127  // Create Exact solution object and attach exact solution quantities
128  libMesh::ExactSolution exact_sol(*es);
129 
130  libMesh::EquationSystems es_ref( es->get_mesh() );
131 
132  // Filename of file where comparison solution is stashed
133  std::string solution_file = std::string(argv[2]);
134  es_ref.read( solution_file );
135 
136  exact_sol.attach_reference_solution( &es_ref );
137 
138  // Compute error and get it in various norms
139  exact_sol.compute_error("GRINS", "u");
140  exact_sol.compute_error("GRINS", "v");
141 
142  if( (es->get_mesh()).mesh_dimension() == 3 )
143  exact_sol.compute_error("GRINS", "w");
144 
145  exact_sol.compute_error("GRINS", "p");
146  exact_sol.compute_error("GRINS", "T");
147 
148  double u_l2error = exact_sol.l2_error("GRINS", "u");
149  double u_h1error = exact_sol.h1_error("GRINS", "u");
150 
151  double v_l2error = exact_sol.l2_error("GRINS", "v");
152  double v_h1error = exact_sol.h1_error("GRINS", "v");
153 
154  double p_l2error = exact_sol.l2_error("GRINS", "p");
155  double p_h1error = exact_sol.h1_error("GRINS", "p");
156 
157  double T_l2error = exact_sol.l2_error("GRINS", "T");
158  double T_h1error = exact_sol.h1_error("GRINS", "T");
159 
160  double w_l2error = 0.0,
161  w_h1error = 0.0;
162 
163  if( (es->get_mesh()).mesh_dimension() == 3 )
164  {
165  w_l2error = exact_sol.l2_error("GRINS", "w");
166  w_h1error = exact_sol.h1_error("GRINS", "w");
167  }
168 
169  int return_flag = 0;
170 
171  // This is the tolerance of the iterative linear solver so
172  // it's unreasonable to expect anything better than this.
173  double tol = 8.0e-9;
174 
175  if( u_l2error > tol || u_h1error > tol ||
176  v_l2error > tol || v_h1error > tol ||
177  w_l2error > tol || w_h1error > tol ||
178  p_l2error > tol || p_h1error > tol ||
179  T_l2error > tol || T_h1error > tol )
180  {
181  return_flag = 1;
182 
183  std::cout << "Tolerance exceeded for thermally driven flow test." << std::endl
184  << "tolerance = " << tol << std::endl
185  << "u l2 error = " << u_l2error << std::endl
186  << "u h1 error = " << u_h1error << std::endl
187  << "v l2 error = " << v_l2error << std::endl
188  << "v h1 error = " << v_h1error << std::endl
189  << "w l2 error = " << w_l2error << std::endl
190  << "w h1 error = " << w_h1error << std::endl
191  << "p l2 error = " << p_l2error << std::endl
192  << "p h1 error = " << p_h1error << std::endl
193  << "T l2 error = " << T_l2error << std::endl
194  << "T h1 error = " << T_h1error << std::endl;
195  }
196 
197  return return_flag;
198 }
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