Namespaces | Functions | Variables
oomph_utilities.cc File Reference

Go to the source code of this file.

Namespaces

 oomph
 //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
 
 oomph::ANSIEscapeCode
 Contains an enumeration of the ANSI escape codes used for colouring text (when piped to the command line). Adapted from the guide on: https://stackoverflow.com/questions/2616906/how-do-i-output- coloured-text-to-a-linux-terminal?utm_medium=organic&utm_source= google_rich_qa&utm_campaign=google_rich_qa Here, \033 is the ESC character, ASCII 27. It is followed by [, then zero or more numbers separated by ;, and finally the letter m. The numbers describe the colour and format to switch to from that point onwards.
 
 oomph::DebugHelpers
 Namespace for debugging helpers. Currently only contains a function to prett-ify file name and line numbers (in red) to use when debugging. Makes it easy to identify where a std::cout statement was called.
 
 oomph::SecondInvariantHelper
 Helper namespace containing function that computes second invariant of tensor.
 
 oomph::BrokenCopy
 Namespace for error messages for broken copy constructors and assignment operators.
 
 oomph::CumulativeTimings
 /////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
 
 oomph::StringConversion
 Conversion functions for easily making strings (e.g. for filenames - to avoid stack smashing problems with cstrings and long filenames).
 
 oomph::CommandLineArgs
 Namespace for command line arguments.
 
 oomph::ObsoleteCode
 Namespace for flagging up obsolete parts of the code.
 
 oomph::TecplotNames
 Namespace for tecplot stuff.
 
 oomph::LeakCheckNames
 Namespace for leak check: Keep a running count of all instantiated objects – add your own if you want to...
 
 oomph::PauseFlags
 ////////////////////////////////////////////////////////////////////////
 
 oomph::TimingHelpers
 //////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
 
 oomph::MemoryUsage
 ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
 

Functions

void oomph::ANSIEscapeCode::set_text_effect (std::string text_effect)
 Function to change text effect. NOTE: This assumes the user knows what they're doing/assigning; no error checking done here... More...
 
std::string oomph::DebugHelpers::debug_string (const std::string &filename, const int &line, const bool &make_new_line)
 Return the concaternation of the initials of the input file name and line number. The make_new_line flag indicates whether the string starts with a "\n", i.e. a new line. More...
 
double oomph::SecondInvariantHelper::second_invariant (const DenseMatrix< double > &tensor)
 Compute second invariant of tensor. More...
 
void oomph::BrokenCopy::broken_assign (const std::string &class_name)
 Issue error message and terminate execution. More...
 
void oomph::BrokenCopy::broken_copy (const std::string &class_name)
 Issue error message and terminate execution. More...
 
void oomph::CumulativeTimings::start (const unsigned &i)
 (Re-)start i-th timer More...
 
void oomph::CumulativeTimings::halt (const unsigned &i)
 Halt i-th timer. More...
 
double oomph::CumulativeTimings::cumulative_time (const unsigned &i)
 Report time accumulated by i-th timer. More...
 
void oomph::CumulativeTimings::reset (const unsigned &i)
 Reset i-th timer. More...
 
void oomph::CumulativeTimings::reset ()
 Reset all timers. More...
 
void oomph::CumulativeTimings::set_ntimers (const unsigned &ntimers)
 Set number of timings that can be recorded in parallel. More...
 
std::string oomph::StringConversion::to_lower (const std::string &input)
 Convert a string to lower case (outputs a copy). More...
 
std::string oomph::StringConversion::to_upper (const std::string &input)
 Convert a string to upper case (outputs a copy). More...
 
void oomph::StringConversion::split_string (const std::string &s, char delim, Vector< std::string > &elems)
 Split a string, s, into a vector of strings where ever there is an instance of delimiter (i.e. is delimiter is " " will give a list of words). Note that mutliple delimiters in a row will give empty strings. More...
 
Vector< std::string > oomph::StringConversion::split_string (const std::string &s, char delim)
 Split a string, s, into a vector of strings where ever there is an instance of delimiter (i.e. is delimiter is " " will give a list of words). Note that mutliple delimiters in a row will give empty strings. Return by value. More...
 
void oomph::CommandLineArgs::setup (int argc, char **argv)
 Set values. More...
 
void oomph::CommandLineArgs::output ()
 Doc the command line arguments. More...
 
void oomph::CommandLineArgs::specify_command_line_flag (const std::string &command_line_flag, const std::string &doc)
 Specify possible argument-free command line flag. More...
 
void oomph::CommandLineArgs::specify_command_line_flag (const std::string &command_line_flag, double *arg_pt, const std::string &doc)
 Specify possible command line flag that specifies a double, accessed via pointer. More...
 
void oomph::CommandLineArgs::specify_command_line_flag (const std::string &command_line_flag, int *arg_pt, const std::string &doc)
 Specify possible command line flag that specifies an int, accessed via pointer. More...
 
void oomph::CommandLineArgs::specify_command_line_flag (const std::string &command_line_flag, unsigned *arg_pt, const std::string &doc)
 Specify possible command line flag that specifies an unsigned, accessed via pointer. More...
 
void oomph::CommandLineArgs::specify_command_line_flag (const std::string &command_line_flag, std::string *arg_pt, const std::string &doc)
 Specify possible command line flag that specifies a string, accessed via pointer. More...
 
bool oomph::CommandLineArgs::command_line_flag_has_been_set (const std::string &flag)
 Check if command line flag has been set (value will have been assigned directly). More...
 
void oomph::CommandLineArgs::doc_all_flags (std::ostream &outstream)
 Document the values of all flags (specified or not). More...
 
void oomph::CommandLineArgs::doc_specified_flags ()
 Document specified command line flags. More...
 
void oomph::CommandLineArgs::doc_available_flags ()
 Document available command line flags. More...
 
void oomph::CommandLineArgs::check_arg_index (const int &argc, const int &arg_index)
 Helper function to check if command line index is legal. More...
 
void oomph::CommandLineArgs::parse_and_assign (int argc, char *argv[], const bool &throw_on_unrecognised_args)
 Parse command line, check for recognised flags and assign associated values. More...
 
void oomph::CommandLineArgs::parse_and_assign (const bool &throw_on_unrecognised_args)
 Parse previously specified command line, check for recognised flags and assign associated values. More...
 
void oomph::ObsoleteCode::obsolete ()
 Output warning message. More...
 
void oomph::ObsoleteCode::obsolete (const std::string &message)
 Ouput a warning message with a string argument. More...
 
void oomph::TecplotNames::setup ()
 Setup namespace. More...
 
void oomph::LeakCheckNames::reset ()
 
void oomph::LeakCheckNames::doc ()
 
void oomph::pause (std::string message)
 Pause and display message. More...
 
double oomph::TimingHelpers::timer ()
 returns the time in seconds after some point in past More...
 
std::string oomph::TimingHelpers::convert_secs_to_formatted_string (const double &time_in_sec)
 Returns a nicely formatted string from an input time in seconds; the format depends on the size of time, e.g.: 86510 will be printed as 1d 1m:50 3710 will be printed as 1h:01:50 700 will be printed as 11m:40 59 will be printed as 59s. More...
 
void oomph::MemoryUsage::empty_my_memory_usage_file ()
 Function to empty file that records my memory usage in file whose name is specified by My_memory_usage_filename. More...
 
void oomph::MemoryUsage::doc_my_memory_usage (const std::string &prefix_string)
 Doc my memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by My_memory_usage_filename. Data is appended to that file; wipe it with empty_my_memory_usage_file(). Note: This requires getpid() which is defined in unistd.h so if you don't have that we won't build that function! More...
 
void oomph::MemoryUsage::empty_total_memory_usage_file ()
 Function to empty file that records total memory usage in file whose name is specified by Total_memory_usage_filename. More...
 
void oomph::MemoryUsage::doc_total_memory_usage (const std::string &prefix_string)
 Doc total memory usage, prepended by string (which allows identification from where the function is called, say) that records memory usage in file whose name is specified by Total_memory_usage_filename. Data is appended to that file; wipe it with empty_memory_usage_file(). More...
 
void oomph::MemoryUsage::empty_memory_usage_files ()
 Function to empty file that records total and local memory usage in appropriate files. More...
 
void oomph::MemoryUsage::doc_memory_usage (const std::string &prefix_string)
 Doc total and local memory usage, prepended by string (which allows identification from where the function is called, say). NOTE: Local memory usage only works if we have unistd.h header. More...
 
void oomph::MemoryUsage::empty_top_file ()
 Function to empty file that records continuous output from top in file whose name is specified by Top_output_filename. More...
 
void oomph::MemoryUsage::run_continous_top (const std::string &comment)
 Start running top continuously and output (append) into file specified by Top_output_filename. Wipe that file with empty_top_file() if you wish. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before starting. More...
 
void oomph::MemoryUsage::stop_continous_top (const std::string &comment)
 Stop running top continuously. Note that this is again quite Linux specific and unlikely to work on other operating systems. Insert optional comment into output file before stopping. More...
 
void oomph::MemoryUsage::insert_comment_to_continous_top (const std::string &comment)
 Insert comment into running continuous top output. More...
 

Variables

std::string oomph::ANSIEscapeCode::Text_effect = "1"
 Variable to decide on effects. More...
 
std::string oomph::ANSIEscapeCode::Black = "\033[" + Text_effect + ";30m"
 The code for each type of colour. More...
 
std::string oomph::ANSIEscapeCode::Red = "\033[" + Text_effect + ";31m"
 
std::string oomph::ANSIEscapeCode::Green = "\033[" + Text_effect + ";32m"
 
std::string oomph::ANSIEscapeCode::Yellow = "\033[" + Text_effect + ";33m"
 
std::string oomph::ANSIEscapeCode::Blue = "\033[" + Text_effect + ";34m"
 
std::string oomph::ANSIEscapeCode::Magenta = "\033[" + Text_effect + ";35m"
 
std::string oomph::ANSIEscapeCode::Cyan = "\033[" + Text_effect + ";36m"
 
std::string oomph::ANSIEscapeCode::Reset = "\033[0m"
 
Vector< clock_t > oomph::CumulativeTimings::Timing
 Cumulative timings. More...
 
Vector< clock_t > oomph::CumulativeTimings::Start_time
 Start times of active timers. More...
 
int oomph::CommandLineArgs::Argc
 Number of arguments + 1. More...
 
char ** oomph::CommandLineArgs::Argv
 Arguments themselves. More...
 
std::map< std::string, ArgInfo< bool > > oomph::CommandLineArgs::Specified_command_line_flag
 Map to indicate an input flag as having been set. More...
 
std::map< std::string, ArgInfo< double > > oomph::CommandLineArgs::Specified_command_line_double_pt
 Map to associate an input flag with a double – specified via pointer. More...
 
std::map< std::string, ArgInfo< int > > oomph::CommandLineArgs::Specified_command_line_int_pt
 Map to associate an input flag with an int – specified via pointer. More...
 
std::map< std::string, ArgInfo< unsigned > > oomph::CommandLineArgs::Specified_command_line_unsigned_pt
 Map to associate an input flag with an unsigned – specified via pointer. More...
 
std::map< std::string, ArgInfo< std::string > > oomph::CommandLineArgs::Specified_command_line_string_pt
 Map to associate an input flag with a string – specified via pointer. More...
 
MPIOutputModifier oomph::oomph_mpi_output
 Single (global) instantiation of the mpi output modifier. More...
 
bool oomph::ObsoleteCode::FlagObsoleteCode = true
 Flag up obsolete parts of the code. More...
 
Vector< std::string > oomph::TecplotNames::colour
 Tecplot colours. More...
 
long oomph::LeakCheckNames::QuadTree_build
 
long oomph::LeakCheckNames::OcTree_build
 
long oomph::LeakCheckNames::QuadTreeForest_build
 
long oomph::LeakCheckNames::OcTreeForest_build
 
long RefineableQElement< 2 > oomph::LeakCheckNames::_build
 
long oomph::LeakCheckNames::MacroElement_build
 
long oomph::LeakCheckNames::HangInfo_build
 
long oomph::LeakCheckNames::Node_build
 
long oomph::LeakCheckNames::GeomReference_build
 
long oomph::LeakCheckNames::AlgebraicNode_build
 
bool oomph::PauseFlags::PauseFlag = true
 Flag to enable pausing code – pause the code by default. More...
 
bool oomph::MemoryUsage::Suppress_mpi_synchronisation = true
 Boolean to suppress synchronisation of doc memory usage on processors (via mpi barriers). True (i.e. sync is suppressed) by default because not all processors may reach the relevant doc memory usage statements causing the code to hang). More...
 
std::string oomph::MemoryUsage::My_memory_usage_system_string = "ps aux"
 String containing system command that obtains memory usage of all processes. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
bool oomph::MemoryUsage::Bypass_all_memory_usage_monitoring = false
 Bool allowing quick bypassing of ALL operations related to memory usage monitoring – this allows the code to remain "instrumented" without incurring the heavy penalties associated with the system calls and i/o. Default setting: false. More...
 
std::string oomph::MemoryUsage::My_memory_usage_filename = "my_memory_usage.dat"
 String containing name of file in which we document my memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file() More...
 
std::string oomph::MemoryUsage::Total_memory_usage_system_string
 String containing system command that obtains total memory usage. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
std::string oomph::MemoryUsage::Total_memory_usage_filename = "memory_usage.dat"
 String containing name of file in which we document total memory usage – you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_memory_usage_file() More...
 
std::string oomph::MemoryUsage::Top_system_string = "while true; do top -b -n 2 ; done "
 String containing system command that runs "top" (or equivalent) "indefinitely" and writes to file specified in Top_output_filename. Default assignment for linux. [Disclaimer: works on my machine(s) – no guarantees for any other platform; linux or not. MH]. More...
 
std::string oomph::MemoryUsage::Top_output_filename = "top_output.dat"
 String containing name of file in which we document "continuous" output from "top" (or equivalent)– you may want to change this to allow different processors to write to separate files (especially in mpi context). Note that file is appended to so it ought to be emptied (either manually or by calling helper function empty_top_file() More...