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 "project_THETA_to_B.hpp"
21 #include "project_THETA_to_H.hpp"
22 #include "solver.hpp"
23 
24 using namespace Misc;
25 
32 class BatchSLDII : public SettingsSLDII
33 {
34 public:
35  void run()
36  {
37  if (nr_threads_max > 0)
38  MultithreadInfo::set_thread_limit(nr_threads_max);
39 
40  Assert(DIMENSION__ > 1, ExcInternalError());
41  Assert(DIMENSION__ < 4, ExcInternalError());
42 
43  std::string fname;
44  std::string dir = (DIMENSION__ == 2) ? "Data/square/" : "Data/cube/";
45 
46  std::cout << "----------------------------------------\n"
47  << "Program: sld-ii\n"
48  << "Version: 1.0\n"
49  << "Dimension = " << DIMENSION__ << "\n"
50  << "Writing to: " << dir << "\n";
51 
52  MainOutputTable table_THETA(DIMENSION__);
53  MainOutputTable table_H(DIMENSION__);
54 
55  for (unsigned int p = 1; p < 4; p++) {
56  table_THETA.clear();
57  table_H.clear();
58 
59 #if DIMENSION__ == 2
60  for (unsigned int r = 10; r < 14; r++)
61 #endif
62 #if DIMENSION__ == 3
63  for (unsigned int r = 5; r < 9; r++)
64 #endif
65  {
66  table_THETA.add_value("r", r);
67  table_THETA.add_value("p", p);
68 
69  fname = dir + "solution_THETA_p" + std::to_string(p) + "_r" +
70  std::to_string(r);
71 
72  SolverSLDII<DIMENSION__> problem(p, 2, r, fname);
73  table_THETA.add_value("ndofs", problem.get_n_dofs());
74  table_THETA.add_value("ncells", problem.get_n_cells());
75  table_THETA.add_value("L2", problem.get_L2_norm());
76  table_THETA.add_value("H1", problem.get_H1_norm());
77 
78  problem.clear();
79 
80  {
81  table_H.add_value("r", r);
82  table_H.add_value("p", p);
83 
84  fname = dir + "solution_H_p" + std::to_string(p) + "_r" +
85  std::to_string(r);
86 
88  std::cout << "Time table H \n";
89 
90  ExactSolutionSLDII_H<DIMENSION__> exact_solution;
91 
92  ProjectTHETAtoH<DIMENSION__> projector(
93  p - 1,
94  problem.get_mapping_degree(),
95  problem.get_tria(),
96  problem.get_dof_handler(),
97  problem.get_solution(),
98  fname,
99  &exact_solution,
100  false,
104  true);
105 
106  table_H.add_value("ndofs", projector.get_n_dofs());
107  table_H.add_value("ncells", projector.get_n_cells());
108  table_H.add_value("L2", projector.get_L2_norm());
109  table_H.add_value("H1", 0.0);
110  }
111  }
112  // Saving convergence tables
113  std::cout << "Table THETA\n";
114  table_THETA.save(dir + "table_THETA_p" + std::to_string(p));
115 
116  std::cout << "Table H\n";
117  table_H.save(dir + "table_H_p" + std::to_string(p));
118  }
119  }
120 };
121 
122 int
123 main()
124 {
125  try {
126  BatchSLDII batch;
127  batch.run();
128  } catch (std::exception& exc) {
129  std::cerr << std::endl
130  << std::endl
131  << "----------------------------------------------------"
132  << std::endl;
133  std::cerr << "Exception on processing: " << std::endl
134  << exc.what() << std::endl
135  << "Aborting!" << std::endl
136  << "----------------------------------------------------"
137  << std::endl;
138  return 1;
139  } catch (...) {
140  std::cerr << std::endl
141  << std::endl
142  << "----------------------------------------------------"
143  << std::endl;
144  std::cerr << "Unknown exception!" << std::endl
145  << "Aborting!" << std::endl
146  << "----------------------------------------------------"
147  << std::endl;
148  return 1;
149  }
150  return 0;
151 }
This is a wrap-around class. It contains the main loop of the program that implements the Magnetostat...
Definition: main.cpp:33
Describes exact solution, , of the Magnetostatic shield - 2 (sld-ii/) numerical experiment in two and...
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 Magnetostatic shield - 2 (sld-ii/) numerical experiment.
Definition: settings.hpp:32
const bool print_time_tables
If set to true, the program will print time tables on the screen.
Definition: settings.hpp:167
Implements the Magnetostatic shield - 2 (sld-ii/) numerical experiment.
Definition: solver.hpp:42
const Triangulation< dim > & get_tria() const
Returns a reference to triangulation.
const Vector< double > & get_solution() const
Returns a reference to the solution.
double get_L2_norm() const
Returns error norm.
void clear()
Releases computer memory associated with the system matrix and right-hand side.
const DoFHandler< dim > & get_dof_handler() const
Returns a reference to dof handler.
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.
unsigned int get_mapping_degree() const
Returns degree of the interpolating Lagrange polynomials used for mapping from the reference cell to ...