34#ifdef OOMPH_HAS_UNISTDH
56 namespace ANSIEscapeCode
87 namespace DebugHelpers
111 while ((
pos =
file.find(
"/")) != std::string::npos)
168 namespace SecondInvariantHelper
177 for (
unsigned i = 0;
i <
n;
i++)
182 for (
unsigned j = 0;
j <
n;
j++)
206 std::string error_message =
"Assignment operator for class\n\n";
208 error_message +=
"\n\n";
209 error_message +=
"is deliberately broken to avoid the accidental \n";
210 error_message +=
"use of the inappropriate C++ default.\n";
211 error_message +=
"If you really need an assignment operator\n";
212 error_message +=
"for this class, write it yourself...\n";
223 std::string error_message =
"Copy constructor for class\n\n";
225 error_message +=
"\n\n";
226 error_message +=
"is deliberately broken to avoid the accidental\n";
227 error_message +=
"use of the inappropriate C++ default.\n";
229 "All function arguments should be passed by reference or\n";
231 "constant reference. If you really need a copy constructor\n";
232 error_message +=
"for this class, write it yourself...\n";
248 namespace CumulativeTimings
278 for (
unsigned i = 0;
i <
n;
i++)
316 std::string error_message =
"Problem opening output file.\n";
317 error_message +=
"I suspect you haven't created the output directory ";
319 error_message +=
"\n";
331 error_message +=
"and the Directory_must_exist flag is true.\n";
337 some_file <<
"Dummy file, opened to check if output directory "
339 some_file <<
"exists. Can be deleted...." << std::endl;
350 namespace StringConversion
355 std::string output(
input);
356 std::string::iterator
it;
357 for (
it = output.begin();
it != output.end(); ++
it)
368 std::string output(
input);
369 std::string::iterator
it;
370 for (
it = output.begin();
it != output.end(); ++
it)
386 std::stringstream
ss(
s);
412 namespace CommandLineArgs
433 std::map<std::string, ArgInfo<std::string>>
448 oomph_info <<
"with the following command line args: " << std::endl;
449 std::stringstream
str;
460 const std::string& doc)
470 const std::string& doc)
480 const std::string& doc)
490 const std::string& doc)
500 const std::string& doc)
518 return it->second.is_set;
529 return (
it->second).is_set;
540 return (
it->second).is_set;
551 return (
it->second).is_set;
562 return (
it->second).is_set;
577 outstream <<
it->first <<
" " <<
it->second.is_set << std::endl;
584 outstream <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
591 outstream <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
598 outstream <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
621 oomph_info <<
"Specified (and recognised) command line flags:\n";
622 oomph_info <<
"----------------------------------------------\n";
629 if (
it->second.is_set)
640 if (
it->second.is_set)
642 oomph_info <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
651 if (
it->second.is_set)
653 oomph_info <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
662 if (
it->second.is_set)
664 oomph_info <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
673 if (
it->second.is_set)
675 oomph_info <<
it->first <<
" " << *(
it->second.arg_pt) << std::endl;
687 oomph_info <<
"Available command line flags:\n";
688 oomph_info <<
"-----------------------------\n";
696 <<
it->second.doc << std::endl
706 <<
it->second.doc << std::endl
716 <<
it->second.doc << std::endl
726 <<
it->second.doc << std::endl
736 <<
it->second.doc << std::endl
753 <<
"Tried to read more command line arguments than\n"
754 <<
"specified. This tends to happen if a required argument\n"
755 <<
"to a command line flag was omitted, e.g. by running \n\n"
756 <<
" ./a.out -some_double \n\n rather than\n\n"
757 <<
" ./a.out -some_double 1.23 \n\n"
758 <<
"To aid the debugging I've output the available\n"
759 <<
"command line arguments above.\n";
782 <<
"NOTE: You entered --help or -help on the command line\n";
783 oomph_info <<
"so I'm going to tell you about this code's\n";
784 oomph_info <<
"available command line flags and then return.\n";
827 it->second.is_set =
true;
851 it->second.is_set =
true;
876 it->second.is_set =
true;
900 it->second.is_set =
true;
914 std::string error_message =
"Command line argument\n\n";
916 error_message +=
"\n\nwas not recognised. This may be legal\n";
917 error_message +=
"but seems sufficiently suspicious to flag up.\n";
918 error_message +=
"If it should have been recognised, make sure you\n";
919 error_message +=
"used the right number of \"-\" signs...\n";
923 error_message +=
"Throwing an error because you requested it with";
924 error_message +=
" throw_on_unrecognised_args option.";
1010 oomph_info <<
"Oomph-lib communicator is a duplicate of MPI_COMM_WORLD\n";
1014 oomph_info <<
"Oomph-lib communicator is MPI_COMM_WORLD\n";
1062 <<
"MPI has not been initialised.\n Call MPI_Helpers::init(...)";
1104 namespace ObsoleteCode
1115 oomph_info <<
"\n\n--------------------------------------------\n";
1116 oomph_info <<
"You are using obsolete code " << std::endl;
1117 oomph_info <<
"--------------------------------------------\n\n";
1118 oomph_info <<
"Enter: \"s\" to suppress further messages" << std::endl;
1119 oomph_info <<
" \"k\" to crash the code to allow a trace back in "
1123 oomph_info <<
" any other key to continue\n \n";
1126 "ObsoleteCode::FlagObsoleteCode=false;\n \n";
1127 oomph_info <<
" into your code to suppress these "
1150 oomph_info <<
"\n\n------------------------------------" << std::endl;
1152 oomph_info <<
"----------------------------------------" << std::endl;
1164 namespace TecplotNames
1191 namespace LeakCheckNames
1222 oomph_info <<
"\n Leak check: # of builds - # of deletes for the "
1223 "following objects: \n\n";
1224 oomph_info <<
"LeakCheckNames::QuadTree_build "
1226 oomph_info <<
"LeakCheckNames::QuadTreeForest_build "
1228 oomph_info <<
"LeakCheckNames::OcTree_build "
1230 oomph_info <<
"LeakCheckNames::OcTreeForest_build "
1232 oomph_info <<
"LeakCheckNames::RefineableQElement<2>_build "
1233 << LeakCheckNames::RefineableQElement<2>
_build << std::endl;
1234 oomph_info <<
"LeakCheckNames::RefineableQElement<3>_build "
1235 << LeakCheckNames::RefineableQElement<3>
_build << std::endl;
1236 oomph_info <<
"LeakCheckNames::MacroElement_build "
1238 oomph_info <<
"LeakCheckNames::HangInfo_build "
1242 oomph_info <<
"LeakCheckNames::GeomReference_build "
1244 oomph_info <<
"LeakCheckNames::AlgebraicNode_build "
1263 namespace PauseFlags
1279 <<
"to suppress further interruptions]\n";
1288 oomph_info <<
"\n[Suppressed pause message] \n";
1300 namespace TimingHelpers
1326 std::ostringstream
ss;
1343 ss << std::setw(2) << std::setfill(
'0');
1350 ss << std::setw(2) << std::setfill(
'0');
1379 namespace MemoryUsage
1418 the_file <<
"# My memory usage: \n";
1423#ifdef OOMPH_HAS_UNISTDH
1453 std::stringstream
tmp;
1468 "ps aux | awk 'BEGIN{sum=0}{sum+=$4}END{print sum}'";
1488 the_file <<
"# Total memory usage: \n";
1518 std::stringstream
tmp;
1548#ifdef OOMPH_HAS_UNISTDH
1580 the_file <<
"# Continuous output from top obtained with: \n";
1606 std::stringstream
tmp;
1613 std::stringstream
tmp;
1617 std::string
dollar =
"$";
1620 tmp <<
"echo \"#/bin/bash\" > run_continuous_top" <<
modifier <<
".bash; "
1623 <<
"\" > kill_continuous_top" <<
modifier
1624 <<
".bash; chmod a+x kill_continuous_top" <<
modifier <<
".bash; "
1626 <<
".bash; chmod a+x run_continuous_top" <<
modifier <<
".bash ";
1636 std::stringstream
tmp2;
1637 tmp2 <<
"./run_continuous_top" <<
modifier <<
".bash >> "
1664 std::stringstream
tmp;
1677 std::stringstream
tmp2;
1678 tmp2 <<
"./kill_continuous_top" <<
modifier <<
".bash >> "
1693 std::stringstream
tmp;
1694 tmp <<
" echo \"OOMPH-LIB EVENT: " <<
comment <<
"\" >> "
bool Directory_must_exist
Boolean flag to decide response if an output directory doesn't exist: If true, we terminate code exec...
std::string Directory
Directory name.
void set_directory(const std::string &directory)
Set output directory (we try to open a file in it to see if the directory exists – if it doesn't we'l...
MPI output modifier: Precedes every output by specification of the processor ID. Output can be restri...
OomphCommunicator *& communicator_pt()
Return pointer to communicator.
OomphCommunicator * Communicator_pt
Communicator.
virtual bool operator()(std::ostream &stream)
Precede the output by the processor ID but output everything.
bool Output_from_single_processor
Boolean to control if output is performed only on a single processor (default: false)
unsigned Output_rank
Rank of single processor that produces output (only used if Output_from_single_processor=true.
static void finalize()
finalize mpi (oomph-lib equivalent of MPI_Finalize()) Deletes the global oomph-lib communicator and f...
static void init(int argc, char **argv, const bool &make_duplicate_of_mpi_comm_world=true)
initialise mpi (oomph-libs equivalent of MPI_Init(...)) Initialises MPI and creates the global oomph-...
static OomphCommunicator * Communicator_pt
the global communicator
static bool mpi_has_been_initialised()
return true if MPI has been initialised
static bool MPI_has_been_initialised
Bool set to true if MPI has been initialised.
static OomphCommunicator * communicator_pt()
access to global communicator. This is the oomph-lib equivalent of MPI_COMM_WORLD
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
OutputModifier *& output_modifier_pt()
Access function for the output modifier pointer.
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
void set_text_effect(std::string text_effect)
Function to change text effect. NOTE: This assumes the user knows what they're doing/assigning; no er...
std::string Text_effect
Variable to decide on effects.
std::string Black
The code for each type of colour.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void setup(int argc, char **argv)
Set values.
void doc_available_flags()
Document available command line flags.
std::map< std::string, ArgInfo< bool > > Specified_command_line_flag
Map to indicate an input flag as having been set.
char ** Argv
Arguments themselves.
bool command_line_flag_has_been_set(const std::string &flag)
Check if command line flag has been set (value will have been assigned directly).
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
void check_arg_index(const int &argc, const int &arg_index)
Helper function to check if command line index is legal.
void doc_all_flags(std::ostream &outstream)
Document the values of all flags (specified or not).
std::map< std::string, ArgInfo< std::string > > Specified_command_line_string_pt
Map to associate an input flag with a string – specified via pointer.
std::map< std::string, ArgInfo< int > > Specified_command_line_int_pt
Map to associate an input flag with an int – specified via pointer.
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Parse command line, check for recognised flags and assign associated values.
std::map< std::string, ArgInfo< double > > Specified_command_line_double_pt
Map to associate an input flag with a double – specified via pointer.
int Argc
Number of arguments + 1.
void output()
Doc the command line arguments.
std::map< std::string, ArgInfo< unsigned > > Specified_command_line_unsigned_pt
Map to associate an input flag with an unsigned – specified via pointer.
void doc_specified_flags()
Document specified command line flags.
void reset()
Reset all timers.
double cumulative_time(const unsigned &i)
Report time accumulated by i-th timer.
void set_ntimers(const unsigned &ntimers)
Set number of timings that can be recorded in parallel.
Vector< clock_t > Timing
Cumulative timings.
void halt(const unsigned &i)
Halt i-th timer.
Vector< clock_t > Start_time
Start times of active timers.
void start(const unsigned &i)
(Re-)start i-th timer
std::string debug_string(const std::string &filename, const int &line_number, const std::string &message, const bool &shorten, const bool &start_on_new_line)
Return the concaternation of the initials of the input file name and line number. The make_new_line f...
long QuadTreeForest_build
long RefineableQElement< 2 > _build
void empty_top_file()
Function to empty file that records continuous output from top in file whose name is specified by Top...
std::string Top_output_filename
String containing name of file in which we document "continuous" output from "top" (or equivalent)– y...
bool Bypass_all_memory_usage_monitoring
Bool allowing quick bypassing of ALL operations related to memory usage monitoring – this allows the ...
void doc_total_memory_usage(const std::string &prefix_string)
Doc total memory usage, prepended by string (which allows identification from where the function is c...
void insert_comment_to_continous_top(const std::string &comment)
Insert comment into running continuous top output.
void doc_my_memory_usage(const std::string &prefix_string)
Doc my memory usage, prepended by string (which allows identification from where the function is call...
void empty_memory_usage_files()
Function to empty file that records total and local memory usage in appropriate files.
void run_continous_top(const std::string &comment)
Start running top continuously and output (append) into file specified by Top_output_filename....
std::string Top_system_string
String containing system command that runs "top" (or equivalent) "indefinitely" and writes to file sp...
void stop_continous_top(const std::string &comment)
Stop running top continuously. Note that this is again quite Linux specific and unlikely to work on o...
bool Suppress_mpi_synchronisation
Boolean to suppress synchronisation of doc memory usage on processors (via mpi barriers)....
void empty_total_memory_usage_file()
Function to empty file that records total memory usage in file whose name is specified by Total_memor...
std::string Total_memory_usage_system_string
String containing system command that obtains total memory usage. Default assignment for linux....
void doc_memory_usage(const std::string &prefix_string)
Doc total and local memory usage, prepended by string (which allows identification from where the fun...
std::string My_memory_usage_filename
String containing name of file in which we document my memory usage – you may want to change this to ...
void empty_my_memory_usage_file()
Function to empty file that records my memory usage in file whose name is specified by My_memory_usag...
std::string My_memory_usage_system_string
String containing system command that obtains memory usage of all processes. Default assignment for l...
std::string Total_memory_usage_filename
String containing name of file in which we document total memory usage – you may want to change this ...
void obsolete()
Output warning message.
bool FlagObsoleteCode
Flag up obsolete parts of the code.
bool PauseFlag
Flag to enable pausing code – pause the code by default.
double second_invariant(const DenseMatrix< double > &tensor)
Compute second invariant of tensor.
void 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....
std::string to_lower(const std::string &input)
Convert a string to lower case (outputs a copy).
std::string to_upper(const std::string &input)
Convert a string to upper case (outputs a copy).
Vector< std::string > colour
Tecplot colours.
void setup()
Setup namespace.
double timer()
returns the time in seconds after some point in past
std::string 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 ti...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
void pause(std::string message)
Pause and display message.
MPIOutputModifier oomph_mpi_output
Single (global) instantiation of the mpi output modifier.
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...