MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_Monitor.cpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// MueLu: A package for multigrid based preconditioning
4//
5// Copyright 2012 NTESS and the MueLu contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#include "MueLu_Monitor.hpp"
12
13namespace MueLu {
14PrintMonitor::PrintMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel)
15 : object_(object) {
16 tabbed = false;
17 if (object_.IsPrint(msgLevel)) {
18 // Print description and new indent
19 object_.GetOStream(msgLevel, 0) << msg << std::endl;
20 object_.getOStream()->pushTab();
21 tabbed = true;
22 }
23}
24
26 if (tabbed) object_.getOStream()->popTab();
27}
28
29Monitor::Monitor(const BaseClass& object, const std::string& msg, MsgType msgLevel, MsgType timerLevel)
30 : printMonitor_(object, msg + " (" + object.description() + ")", msgLevel)
31 , timerMonitor_(object, object.ShortClassName() + ": " + msg, timerLevel) {}
32
33Monitor::Monitor(const BaseClass& object, const std::string& msg, const std::string& label, MsgType msgLevel, MsgType timerLevel)
34 : printMonitor_(object, label + msg + " (" + object.description() + ")", msgLevel)
35 , timerMonitor_(object, label + object.ShortClassName() + ": " + msg, timerLevel) {}
36
37Monitor::~Monitor() = default;
38
39SubMonitor::SubMonitor(const BaseClass& object, const std::string& msg, MsgType msgLevel, MsgType timerLevel)
40 : printMonitor_(object, msg, msgLevel)
41 , timerMonitor_(object, object.ShortClassName() + ": " + msg, timerLevel) {}
42
43SubMonitor::SubMonitor(const BaseClass& object, const std::string& msg, const std::string& label, MsgType msgLevel, MsgType timerLevel)
44 : printMonitor_(object, label + msg, msgLevel)
45 , timerMonitor_(object, label + object.ShortClassName() + ": " + msg, timerLevel) {}
46
47SubMonitor::~SubMonitor() = default;
48
49FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string& msg, int levelID, MsgType msgLevel, MsgType timerLevel)
50 : Monitor(object, msg + " (total, level=" + Teuchos::Utils::toString(levelID) + ")", msgLevel, timerLevel) {
51}
52
53FactoryMonitor::FactoryMonitor(const BaseClass& object, const std::string& msg, const Level& level, MsgType msgLevel, MsgType timerLevel)
54 : Monitor(object, msg + " (total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel) {
55}
56
58
59SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string& msg, int levelID, MsgType msgLevel, MsgType timerLevel)
60 : SubMonitor(object, msg + " (sub, total, level=" + Teuchos::Utils::toString(levelID) + ")", msgLevel, timerLevel) {
61}
62
63SubFactoryMonitor::SubFactoryMonitor(const BaseClass& object, const std::string& msg, const Level& level, MsgType msgLevel, MsgType timerLevel)
64 : SubMonitor(object, msg + " (sub, total, level=" + Teuchos::Utils::toString(level.GetLevelID()) + ")", FormattingHelper::getColonLabel(level.getObjectLabel()), msgLevel, timerLevel) {
65}
66
68
69} // namespace MueLu
Base class for MueLu classes.
virtual std::string ShortClassName() const
Return the class name of the object, without template parameters and without namespace.
virtual std::string description() const
Return a simple one-line description of this object.
FactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=static_cast< MsgType >(Test|Runtime0), MsgType timerLevel=Timings0)
Constructor.
Class that holds all level-specific information.
TimeMonitor timerMonitor_
Records total time spent in this object and all its children, over all levels.
virtual ~Monitor()
Monitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime0, MsgType timerLevel=Timings0)
Constructor.
PrintMonitor printMonitor_
Manages printing.
const BaseClass & object_
SubFactoryMonitor(const BaseClass &object, const std::string &msg, int levelID, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
TimeMonitor timerMonitor_
PrintMonitor printMonitor_
SubMonitor(const BaseClass &object, const std::string &msg, MsgType msgLevel=Runtime1, MsgType timerLevel=Timings1)
Constructor.
Namespace for MueLu classes and methods.
std::string toString(const T &what)
Little helper function to convert non-string types to strings.