Logbook  (07-04-2025)
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 <iostream>
17 
18 using namespace std;
19 using namespace Misc;
20 
21 void
22 MainOutputTable::format()
23 {
24  set_precision("L2", 2);
25  set_precision("H1", 2);
26 
27  set_scientific("L2", true);
28  set_scientific("H1", true);
29 
30  // As in Step-51 line 1385.
31  evaluate_convergence_rates(
32  "L2", "ncells", ConvergenceTable::reduction_rate_log2, dimensions);
33  evaluate_convergence_rates(
34  "H1", "ncells", ConvergenceTable::reduction_rate_log2, dimensions);
35 
36  set_tex_caption("p", "p");
37  set_tex_caption("r", "r");
38  set_tex_caption("ncells", "nr. cells");
39  set_tex_caption("ndofs", "nr. dofs");
40  set_tex_caption("L2", "L2 norm");
41  set_tex_caption("H1", "H1 norm");
42 
43  set_column_order(new_order);
44 }
45 
46 void
47 MainOutputTable::save(std::string fname)
48 {
49  format();
50 
51  std::cout << "--------------------------------------------\n";
52  write_text(std::cout);
53  std::cout << "\n\n";
54 
55  // Save the table in text ...
56  {
57  std::ofstream ofs(fname + ".txt");
58  write_text(ofs);
59  }
60  // and tex formats.
61  {
62  std::ofstream ofs(fname + ".tex");
63  write_tex(ofs);
64  }
65 }