phaseflow
FEM solver for the Navier-Stokes-Boussinesq equations coupled with enthalpy-based phase change
 All Classes Namespaces Files Functions Variables Macros Pages
pf_verification.h
Go to the documentation of this file.
1 #ifndef _pf_verification_h_
2 #define _pf_verification_h_
3 
4 template<int dim>
5 void Phaseflow<dim>::append_verification_table()
6 {
7  assert(this->params.verification.enabled);
8 
9  Vector<float> difference_per_cell(triangulation.n_active_cells());
10 
11  VectorTools::integrate_difference(
12  this->dof_handler,
13  this->solution,
14  this->exact_solution_function,
15  difference_per_cell,
16  QGauss<dim>(dim + 1),
17  VectorTools::L2_norm);
18 
19  double L2_norm_error = difference_per_cell.l2_norm();
20 
21  VectorTools::integrate_difference(
22  this->dof_handler,
23  this->solution,
24  this->exact_solution_function,
25  difference_per_cell,
26  QGauss<dim>(dim + 1),
27  VectorTools::L1_norm);
28 
29  double L1_norm_error = difference_per_cell.l1_norm();
30 
31  this->verification_table.add_value("cells", this->triangulation.n_active_cells());
32  this->verification_table.add_value("dofs", this->dof_handler.n_dofs());
33  this->verification_table.add_value("L1_norm_error", L1_norm_error);
34  this->verification_table.add_value("L2_norm_error", L2_norm_error);
35 
36 }
37 
38 template<int dim>
39 void Phaseflow<dim>::write_verification_table()
40 {
41  const int precision = 14;
42 
43  this->verification_table.set_precision("cells", precision);
44  this->verification_table.set_scientific("cells", true);
45 
46  this->verification_table.set_precision("dofs", precision);
47  this->verification_table.set_scientific("dofs", true);
48 
49  this->verification_table.set_precision("L2_norm_error", precision);
50  this->verification_table.set_scientific("L2_norm_error", true);
51 
52  this->verification_table.set_precision("L1_norm_error", precision);
53  this->verification_table.set_scientific("L1_norm_error", true);
54 
55  std::ofstream out_file(this->verification_table_file_name, std::fstream::app);
56  assert(out_file.good());
57  this->verification_table.write_text(out_file);
58  out_file.close();
59 }
60 
61 #endif