Logbook  (23-11-2026)
Static problems
misc.cpp
1 /******************************************************************************
2  * Copyright (C) Siarhei Uzunbajakau, 2023.
3  *
4  * This program is free software. You can use, modify, and redistribute it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation, either version 3 or (at your option) any later version.
7  * This program is distributed without any warranty.
8  *
9  * Refer to COPYING.LESSER for more details.
10  ******************************************************************************/
11 
12 #define BOOST_ALLOW_DEPRECATED_HEADERS
13 
14 #include "misc.hpp"
15 
16 #include <fstream>
17 #include <iostream>
18 
19 using namespace std;
20 using namespace Misc;
21 
22 void
23 MainOutputTable::format()
24 {
25  set_precision("L2", 2);
26  set_precision("H1", 2);
27 
28  set_scientific("L2", true);
29  set_scientific("H1", true);
30 
31  // As in Step-51 line 1385.
32  evaluate_convergence_rates(
33  "L2", "ncells", ConvergenceTable::reduction_rate_log2, dimensions);
34  evaluate_convergence_rates(
35  "H1", "ncells", ConvergenceTable::reduction_rate_log2, dimensions);
36 
37  set_tex_caption("p", "p");
38  set_tex_caption("r", "r");
39  set_tex_caption("ncells", "nr. cells");
40  set_tex_caption("ndofs", "nr. dofs");
41  set_tex_caption("L2", "L2 norm");
42  set_tex_caption("H1", "H1 norm");
43 
44  set_column_order(new_order);
45 }
46 
47 void
48 MainOutputTable::save(std::string fname)
49 {
50  format();
51 
52  std::cout << "--------------------------------------------\n";
53  write_text(std::cout);
54  std::cout << "\n\n";
55 
56  // Save the table in text ...
57  {
58  std::ofstream ofs(fname + ".txt");
59  write_text(ofs);
60  }
61  // and tex formats.
62  {
63  std::ofstream ofs(fname + ".tex");
64  write_tex(ofs);
65  }
66 }