Logbook  (07-04-2025)
Static problems
main.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 <deal.II/base/multithread_info.h>
15 
16 #include <iostream>
17 #include <string>
18 
19 #include "misc.hpp"
20 #include "solver.hpp"
21 
22 using namespace Misc;
23 
30 {
31 public:
32  MainOutputTableABC() = delete;
33  MainOutputTableABC(int dim)
34  : MainOutputTable(dim)
35  {
36  std::vector<std::string> order = { "d", "b", "m", "p", "r",
37  "ncells", "ndofs", "L2", "H1" };
38 
39  set_new_order(order);
40  }
41 
42  virtual void format() override
43  {
44  MainOutputTable::format();
45 
46  set_tex_caption("d", "d");
47  set_tex_caption("b", "b");
48  set_tex_caption("m", "m");
49  }
50 };
51 
58 class BatchABC : public SettingsABC
59 {
60 public:
61  void run()
62  {
63  if (nr_threads_max > 0)
64  MultithreadInfo::set_thread_limit(nr_threads_max);
65 
66  Assert(DIMENSION__ > 1, ExcInternalError());
67  Assert(DIMENSION__ < 4, ExcInternalError());
68 
69  const std::vector<std::string> bc_string = {
70  "neumann", // 0
71  "dirichlet", // 1
72  "abc" // 2
73  };
74 
75  std::string dir;
76 
77  dir = (DIMENSION__ == 2) ? "Data/ppc-" + bc_string[BC_TYPE__] + "/"
78  : "Data/shell-" + bc_string[BC_TYPE__] + "/";
79 
80  std::cout << "Program: abc\n"
81  << "Dimensions: " << DIMENSION__ << "\n"
82  << "Boundary condition: " << BC_TYPE__ << "\n"
83  << "Writing to: " << dir << "\n";
84 
85  MainOutputTableABC table_PHI(DIMENSION__);
86  for (unsigned int m = 1; m < 6; m++) {
87  std::cout << "--------------------------------------------\n"
88  << "--------------------------------------------\n";
89 
90  for (unsigned int p = 1; p < 4; p++) {
91  table_PHI.clear();
92  for (unsigned int r = 1; r < 4; r++) {
93  table_PHI.add_value("d", DIMENSION__);
94  table_PHI.add_value("b", BC_TYPE__);
95  table_PHI.add_value("m", m);
96  table_PHI.add_value("r", r);
97  table_PHI.add_value("p", p);
98 
99  SolverABC<DIMENSION__> problem(
100  m,
101  p,
102  2,
103  r,
104  dir + "solution_p" + std::to_string(p) + "_m" + std::to_string(m) +
105  "_r" + std::to_string(r));
106  problem.get_L2_norm();
107  table_PHI.add_value("ndofs", problem.get_n_dofs());
108  table_PHI.add_value("ncells", problem.get_n_cells());
109  table_PHI.add_value("L2", problem.get_L2_norm());
110  table_PHI.add_value("H1", problem.get_H1_norm());
111  }
112  table_PHI.save(dir + "table_PHI_m" + std::to_string(m) + "_p" +
113  std::to_string(p));
114  }
115  }
116  }
117 };
118 
119 int
120 main()
121 {
122  try {
123  BatchABC batch;
124  batch.run();
125  } catch (std::exception& exc) {
126  std::cerr << std::endl
127  << std::endl
128  << "----------------------------------------------------"
129  << std::endl;
130  std::cerr << "Exception on processing: " << std::endl
131  << exc.what() << std::endl
132  << "Aborting!" << std::endl
133  << "----------------------------------------------------"
134  << std::endl;
135  return 1;
136  } catch (...) {
137  std::cerr << std::endl
138  << std::endl
139  << "----------------------------------------------------"
140  << std::endl;
141  std::cerr << "Unknown exception!" << std::endl
142  << "Aborting!" << std::endl
143  << "----------------------------------------------------"
144  << std::endl;
145  return 1;
146  }
147 
148  return 0;
149 }
This is a wrap-around class. It contains the main loop of the program that implements the Asymptotic ...
Definition: main.cpp:59
An extended version of the convergence table used in Asymptotic boundary condition (abc/) numerical e...
Definition: main.cpp:30
The convergence table used in multiple numerical experiments.
Definition: misc.hpp:25
void save(std::string fname)
Saves the data in text and tex formats, and prints the data on screen.
Definition: misc.cpp:47
Global settings for the Asymptotic boundary conditions (abc/) numerical experiment.
Definition: settings.hpp:26
Implements the solver of the Asymptotic boundary condition (abc/) numerical experiment.
Definition: solver.hpp:41
double get_L2_norm() const
Returns error norm.
double get_H1_norm() const
Returns error norm.
unsigned int get_n_dofs() const
Returns the total amount of the degrees of freedom.
unsigned int get_n_cells() const
Returns the number of active cells in the mesh.