include/meltpooldg/utilities/dof_monitor.hpp Source File

Developer Documentation: include/meltpooldg/utilities/dof_monitor.hpp Source File
Developer Documentation
dof_monitor.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <deal.II/base/convergence_table.h>
4
5namespace MeltPoolDG
6{
7 template <typename number>
9 {
10 private:
12 {
13 DoFStatistics(const unsigned int n_dofs = 0)
14 : n_calls(1)
15 , dofs_accumulated(n_dofs)
16 , dofs_min(n_dofs)
17 , dofs_max(n_dofs)
18 {}
19
20 unsigned int n_calls;
21 unsigned int dofs_accumulated;
22 unsigned int dofs_min;
23 unsigned int dofs_max;
24 };
25
26 public:
27 static void
28 add_n_dofs(const std::string label, const unsigned int n_dofs)
29 {
30 const auto ptr = stat_dofs.find(label);
31
32 if (ptr == stat_dofs.end())
33 {
34 stat_dofs[label] = DoFStatistics(n_dofs);
35 }
36 else
37 {
38 ptr->second.n_calls += 1;
39 ptr->second.dofs_accumulated += n_dofs;
40 ptr->second.dofs_min = std::min(ptr->second.dofs_min, n_dofs);
41 ptr->second.dofs_max = std::max(ptr->second.dofs_max, n_dofs);
42 }
43 }
44
45 template <typename StreamType>
46 static void
47 print(StreamType &ss)
48 {
49 dealii::ConvergenceTable table;
50
51 for (const auto &entry : stat_dofs)
52 {
53 table.add_value("label", entry.first);
54 table.add_value("no. calls", entry.second.n_calls);
55 table.add_value("n_dof avg",
56 static_cast<number>(entry.second.dofs_accumulated) /
57 entry.second.n_calls);
58 table.set_precision("n_dof avg", 2);
59 table.add_value("n_dof min", entry.second.dofs_min);
60 table.add_value("n_dof max", entry.second.dofs_max);
61 }
62
63 if (ss.is_active())
64 table.write_text(ss.get_stream(), dealii::TableHandler::TextOutputFormat::org_mode_table);
65 }
66
67
68 private:
69 inline static std::map<std::string, DoFStatistics> stat_dofs;
70 };
71} // namespace MeltPoolDG
Definition dof_monitor.hpp:9
static std::map< std::string, DoFStatistics > stat_dofs
Definition dof_monitor.hpp:69
static void print(StreamType &ss)
Definition dof_monitor.hpp:47
static void add_n_dofs(const std::string label, const unsigned int n_dofs)
Definition dof_monitor.hpp:28
Interface for a general preconditioner.
Definition boundary_condition_functions.hpp:17
Definition dof_monitor.hpp:12
unsigned int n_calls
Definition dof_monitor.hpp:20
unsigned int dofs_max
Definition dof_monitor.hpp:23
unsigned int dofs_accumulated
Definition dof_monitor.hpp:21
DoFStatistics(const unsigned int n_dofs=0)
Definition dof_monitor.hpp:13
unsigned int dofs_min
Definition dof_monitor.hpp:22