WarpX
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ablastr::warn_manager::WarnManager Class Reference

#include <WarnManager.H>

Public Member Functions

 WarnManager (const WarnManager &)=delete
 
 WarnManager (WarnManager &&)=delete
 
WarnManageroperator= (const WarnManager &)=delete
 
WarnManageroperator= (const WarnManager &&)=delete
 
 ~WarnManager ()=default
 
void RecordWarning (const std::string &topic, const std::string &text, const WarnPriority &priority=WarnPriority::medium)
 This function records a warning message (recording a warning message is thread-safe) More...
 
std::string PrintLocalWarnings (const std::string &when) const
 This function prints all the warning messages collected on the present MPI rank (i.e., this is not a collective call). This function is mainly intended for debug purposes. More...
 
std::string PrintGlobalWarnings (const std::string &when) const
 This function prints all the warning messages collected by all the MPI ranks (i.e., this is a collective call). Only the I/O rank prints the message. More...
 
void SetAlwaysWarnImmediately (bool always_warn_immediately)
 Setter for the m_always_warn_immediately. More...
 
bool GetAlwaysWarnImmediatelyFlag () const
 Getter for the m_always_warn_immediately. More...
 
void SetAbortThreshold (std::optional< WarnPriority > abort_threshold)
 Setter for the m_abort_on_warning_threshold flag (pass std::nullopt in order to never abort) More...
 
std::optional< WarnPriorityGetAbortThreshold () const
 Getter for the m_abort_on_warning_threshold flag. More...
 
void debug_read_warnings_from_input (const amrex::ParmParse &params)
 This function reads warning messages from the inputfile. It is intended for debug&testing purposes. More...
 

Static Public Member Functions

static WarnManagerGetInstance ()
 

Static Public Attributes

static const int warn_line_size = 80
 
static const int warn_tab_size = 5
 

Private Member Functions

 WarnManager ()
 
std::string PrintWarnMsg (const ablastr::utils::msg_logger::MsgWithCounter &msg_with_counter) const
 This function generates a string for a single entry of the warning list for a MessageWithCounter struct (i.e., a warning message paired with a counter storing how many times the warning has been raised) More...
 
std::string PrintWarnMsg (const ablastr::utils::msg_logger::MsgWithCounterAndRanks &msg_with_counter_and_ranks) const
 This function generates a string for a single entry of the warning list for a MsgWithCounterAndRanks struct (i.e., a warning message paired with a counter storing how many times the warning has been raised and info on which ranks have raised the warning) More...
 

Static Private Member Functions

static std::string GetHeader (const std::string &when, int line_size, bool is_global)
 This function generates the header of the warning messages list. More...
 
static std::string MsgFormatter (const std::string &msg, int line_size, int tab_size)
 This function formats each line of a warning message text. More...
 

Private Attributes

int m_rank = 0
 
std::unique_ptr< ablastr::utils::msg_logger::Loggerm_p_logger
 
bool m_always_warn_immediately = false
 
std::optional< WarnPrioritym_abort_on_warning_threshold = std::nullopt
 

Detailed Description

The singleton class WarnManager manages warning messages, providing methods to record warnings, and print warning lists.

Constructor & Destructor Documentation

◆ WarnManager() [1/3]

ablastr::warn_manager::WarnManager::WarnManager ( const WarnManager )
delete

A singleton class should not be cloneable.

◆ WarnManager() [2/3]

ablastr::warn_manager::WarnManager::WarnManager ( WarnManager &&  )
delete

A singleton class should not be cloneable.

◆ ~WarnManager()

ablastr::warn_manager::WarnManager::~WarnManager ( )
default

Default destructor

◆ WarnManager() [3/3]

WarnManager::WarnManager ( )
private

The constructor.

Member Function Documentation

◆ debug_read_warnings_from_input()

void WarnManager::debug_read_warnings_from_input ( const amrex::ParmParse params)

This function reads warning messages from the inputfile. It is intended for debug&testing purposes.

Parameters
[in,out]paramsthe inputfile parser

◆ GetAbortThreshold()

std::optional< WarnPriority > WarnManager::GetAbortThreshold ( ) const

Getter for the m_abort_on_warning_threshold flag.

Returns
the m_abort_on_warning_threshold flag

◆ GetAlwaysWarnImmediatelyFlag()

bool WarnManager::GetAlwaysWarnImmediatelyFlag ( ) const

Getter for the m_always_warn_immediately.

Returns
the m_always_warn_immediately flag

◆ GetHeader()

std::string WarnManager::GetHeader ( const std::string &  when,
int  line_size,
bool  is_global 
)
staticprivate

This function generates the header of the warning messages list.

Parameters
[in]whena string to mark when the warnings are printed out (it appears in the warning list)
[in]line_sizemaximum line length to be used in formatting warning list
[in]is_globalflag: true if the header is for a global warning list, false otherwise
Returns
a string containing the header of the warning list

◆ GetInstance()

WarnManager & WarnManager::GetInstance ( )
static

◆ MsgFormatter()

std::string WarnManager::MsgFormatter ( const std::string &  msg,
int  line_size,
int  tab_size 
)
staticprivate

This function formats each line of a warning message text.

Parameters
[in]msgthe warning message text
[in]line_sizemaximum line length to be used in formatting warning list
[in]tab_sizetabulation size to be used in formatting warning list
Returns
a string containing the formatted warning message text

◆ operator=() [1/2]

WarnManager& ablastr::warn_manager::WarnManager::operator= ( const WarnManager &&  )
delete

A singleton class should not be assignable.

◆ operator=() [2/2]

WarnManager& ablastr::warn_manager::WarnManager::operator= ( const WarnManager )
delete

A singleton class should not be assignable.

◆ PrintGlobalWarnings()

std::string WarnManager::PrintGlobalWarnings ( const std::string &  when) const

This function prints all the warning messages collected by all the MPI ranks (i.e., this is a collective call). Only the I/O rank prints the message.

Parameters
[in]whena string to mark when the warnings are printed out (it appears in the warning list)
Returns
a string containing the "global" warning list

◆ PrintLocalWarnings()

std::string WarnManager::PrintLocalWarnings ( const std::string &  when) const

This function prints all the warning messages collected on the present MPI rank (i.e., this is not a collective call). This function is mainly intended for debug purposes.

Parameters
[in]whena string to mark when the warnings are printed out (it appears in the warning list)
Returns
a string containing the "local" warning list

◆ PrintWarnMsg() [1/2]

std::string WarnManager::PrintWarnMsg ( const ablastr::utils::msg_logger::MsgWithCounter msg_with_counter) const
private

This function generates a string for a single entry of the warning list for a MessageWithCounter struct (i.e., a warning message paired with a counter storing how many times the warning has been raised)

Parameters
[in]msg_with_countera MessageWithCounter
Returns
a string containing the warning message

◆ PrintWarnMsg() [2/2]

std::string WarnManager::PrintWarnMsg ( const ablastr::utils::msg_logger::MsgWithCounterAndRanks msg_with_counter_and_ranks) const
private

This function generates a string for a single entry of the warning list for a MsgWithCounterAndRanks struct (i.e., a warning message paired with a counter storing how many times the warning has been raised and info on which ranks have raised the warning)

Parameters
[in]msg_with_counter_and_ranksa MsgWithCounterAndRanks
Returns
a string containing the warning message

◆ RecordWarning()

void WarnManager::RecordWarning ( const std::string &  topic,
const std::string &  text,
const WarnPriority priority = WarnPriority::medium 
)

This function records a warning message (recording a warning message is thread-safe)

Parameters
[in]topica string to identify the topic of the warning (e.g., "parallelization", "pbc", "particles"...)
[in]textthe text of the warning message
[in]prioritypriority of the warning message ("medium" by default)

◆ SetAbortThreshold()

void WarnManager::SetAbortThreshold ( std::optional< WarnPriority abort_threshold)

Setter for the m_abort_on_warning_threshold flag (pass std::nullopt in order to never abort)

Parameters
[in]abort_thresholdnew value of the m_abort_on_warning_threshold flag

◆ SetAlwaysWarnImmediately()

void WarnManager::SetAlwaysWarnImmediately ( bool  always_warn_immediately)

Setter for the m_always_warn_immediately.

Parameters
[in]always_warn_immediatelynew value of the m_always_warn_immediately flag

Member Data Documentation

◆ m_abort_on_warning_threshold

std::optional<WarnPriority> ablastr::warn_manager::WarnManager::m_abort_on_warning_threshold = std::nullopt
private

◆ m_always_warn_immediately

bool ablastr::warn_manager::WarnManager::m_always_warn_immediately = false
private

◆ m_p_logger

std::unique_ptr<ablastr::utils::msg_logger::Logger> ablastr::warn_manager::WarnManager::m_p_logger
private

The Logger stores all the warning messages

◆ m_rank

int ablastr::warn_manager::WarnManager::m_rank = 0
private

◆ warn_line_size

const int ablastr::warn_manager::WarnManager::warn_line_size = 80
static

◆ warn_tab_size

const int ablastr::warn_manager::WarnManager::warn_tab_size = 5
static

The documentation for this class was generated from the following files: