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/timer.h>
15 #include <iostream>
16 #include <string>
17 
18 #include "misc.hpp"
19 #include "project_A_to_B.hpp"
20 #include "solver.hpp"
21 
22 #include "deal.II/base/multithread_info.h"
23 
24 using namespace Misc;
25 
31 class BatchSSOLI : public SettingsSSOLI
32 {
33 public:
34  void run()
35  {
36  if (nr_threads_max > 0)
37  MultithreadInfo::set_thread_limit(nr_threads_max);
38 
39  std::string dir = "Data/sphere/";
40  std::string fname;
41 
42  std::cout << "Program: ssol-i\n"
43  << "Dimensions: "
44  << "3\n"
45  << "Writing to: " << dir << "\n";
46 
47  MainOutputTable table_B(3);
48 
49  for (unsigned int p = 0; p < 3; p++) {
50  table_B.clear();
51 
52  for (unsigned int r = 6; r < 10; r++) {
53 
54  // Stage 0 -------------------------------------------------------------
55  std::cout << "Solving for A ...\n";
56 
57  fname =
58  dir + "solution_A_p" + std::to_string(p) + "_r" + std::to_string(r);
59 
61  std::cout << "Time table A \n";
62 
63  SolverSSOLI problem(p, 2, r, fname);
64 
65  problem.clear();
66 
67  // Stage 1 -------------------------------------------------------------
68  std::cout << "Projecting A in H(curl) to B in H(div) ...\n";
69 
70  fname =
71  dir + "solution_B_p" + std::to_string(p) + "_r" + std::to_string(r);
72 
73  table_B.add_value("r", r);
74  table_B.add_value("p", p);
75 
77  std::cout << "Time table B \n";
78 
79  ExactSolutionSSOLI_B exact_solution;
80 
81  ProjectAtoB projector(p,
82  2,
83  problem.get_tria(),
84  problem.get_dof_handler(),
85  problem.get_solution(),
86  fname,
87  &exact_solution,
91  true);
92 
93  table_B.add_value("ndofs", projector.get_n_dofs());
94  table_B.add_value("ncells", projector.get_n_cells());
95  table_B.add_value("L2", projector.get_L2_norm());
96  table_B.add_value("H1", 0.0);
97  }
98 
99  std::cout << "Table B\n";
100  table_B.save(dir + "table_B_p" + std::to_string(p));
101  }
102  }
103 };
104 
105 int
106 main()
107 {
108  try {
109  BatchSSOLI batch;
110  batch.run();
111  } catch (std::exception& exc) {
112  std::cerr << std::endl
113  << std::endl
114  << "----------------------------------------------------"
115  << std::endl;
116  std::cerr << "Exception on processing: " << std::endl
117  << exc.what() << std::endl
118  << "Aborting!" << std::endl
119  << "----------------------------------------------------"
120  << std::endl;
121  return 1;
122  } catch (...) {
123  std::cerr << std::endl
124  << std::endl
125  << "----------------------------------------------------"
126  << std::endl;
127  std::cerr << "Unknown exception!" << std::endl
128  << "Aborting!" << std::endl
129  << "----------------------------------------------------"
130  << std::endl;
131  return 1;
132  }
133  return 0;
134 }
This is a wrap-around class. It contains the main loop of the program that implements the Thin spheri...
Definition: main.cpp:32
Describes the exact solution, , of the Thin spherical coil (ssol-i/) numerical experiment.
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
const bool project_exact_solution
If set to true, the program will project the exact solution.
Definition: settings.hpp:80
const bool log_cg_convergence
If set to true, saves the residual at each iteration of the CG solver. The names of the files fit the...
Definition: settings.hpp:89
const bool print_time_tables
If set to true, the program will print time tables on the screen.
Definition: settings.hpp:70
Global settings for the Thin spherical coil (ssol-i/) numerical experiment.
Definition: settings.hpp:26
const bool print_time_tables
If set to true, the program will print time tables on the screen.
Definition: settings.hpp:85
Solves for the magnetic vector potential, , in the Thin spherical coil (ssol-i/) numerical experiment...
Definition: solver.hpp:44
const DoFHandler< dim > & get_dof_handler() const
Returns a reference to dof handler.
const Vector< double > & get_solution() const
Returns a reference to solution.
const Triangulation< dim > & get_tria() const
Returns a reference to triangulation.
void clear()
Releases computer memory associated with system matrix and right-hand side.