https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SystemInfo Class Reference

#include <SystemInfo.h>

Public Member Functions

std::string getInfo () const
 
std::string getTimeStamp (std::time_t *time_stamp=NULL) const
 
std::string getExecutable () const
 
std::string getExecutableTimeStamp () const
 
std::string getExecutableTimeStamp (const std::string &exe) const
 

Detailed Description

Definition at line 15 of file SystemInfo.h.

Member Function Documentation

◆ getExecutable()

std::string SystemInfo::getExecutable ( ) const

Definition at line 139 of file SystemInfo.C.

140{
141 return Moose::getExec();
142}
std::string getExec()
Gets the full path to the running executable on Mac OS X and linux.

Referenced by getExecutableTimeStamp(), and to_json().

◆ getExecutableTimeStamp() [1/2]

std::string SystemInfo::getExecutableTimeStamp ( ) const

Definition at line 145 of file SystemInfo.C.

146{
147 const std::string exe = getExecutable();
148 return getExecutableTimeStamp(exe);
149}
std::string getExecutableTimeStamp() const
Definition SystemInfo.C:145
std::string getExecutable() const
Definition SystemInfo.C:139

Referenced by getExecutableTimeStamp(), getInfo(), and to_json().

◆ getExecutableTimeStamp() [2/2]

std::string SystemInfo::getExecutableTimeStamp ( const std::string &  exe) const

Definition at line 152 of file SystemInfo.C.

153{
154 struct stat attrib;
155 if (!stat(exe.c_str(), &attrib))
156 return getTimeStamp(&(attrib.st_mtime));
157 return "";
158}
std::string getTimeStamp(std::time_t *time_stamp=NULL) const
Definition SystemInfo.C:66

◆ getInfo()

std::string SystemInfo::getInfo ( ) const

Definition at line 29 of file SystemInfo.C.

30{
31 std::stringstream oss;
32 oss << std::left << "Framework Information:\n"
33 << std::setw(25) << "MOOSE Version: " << MOOSE_REVISION << '\n'
34 << std::setw(25) << "LibMesh Version: " << LIBMESH_BUILD_VERSION << '\n';
35#ifdef LIBMESH_DETECTED_PETSC_VERSION_MAJOR
36 oss << std::setw(25) << "PETSc Version: " << LIBMESH_DETECTED_PETSC_VERSION_MAJOR << '.'
37 << LIBMESH_DETECTED_PETSC_VERSION_MINOR << '.' << LIBMESH_DETECTED_PETSC_VERSION_SUBMINOR
38 << '\n';
39#endif
40#ifdef LIBMESH_DETECTED_SLEPC_VERSION_MAJOR
41 oss << std::setw(25) << "SLEPc Version: " << LIBMESH_DETECTED_SLEPC_VERSION_MAJOR << '.'
42 << LIBMESH_DETECTED_SLEPC_VERSION_MINOR << '.' << LIBMESH_DETECTED_SLEPC_VERSION_SUBMINOR
43 << '\n';
44#endif
45#ifdef MOOSE_LIBTORCH_ENABLED
46 oss << std::setw(25) << "Libtorch Version: " << TORCH_VERSION << '\n';
47#endif
48#ifdef MOOSE_MFEM_ENABLED
49 oss << std::setw(25) << "MFEM Version: " << MFEM_VERSION_STRING << '\n';
50#endif
51
52 // Current Time
53 oss << std::setw(25) << "Current Time: " << getTimeStamp() << "\n";
54
55 // Executable Timestamp
56 const std::string executable_time = getExecutableTimeStamp();
57 if (!executable_time.empty())
58 oss << std::setw(25) << "Executable Timestamp: " << executable_time << "\n";
59
60 oss << std::endl;
61 return oss.str();
62}

Referenced by ConsoleUtils::outputFrameworkInformation().

◆ getTimeStamp()

std::string SystemInfo::getTimeStamp ( std::time_t *  time_stamp = NULL) const

Definition at line 66 of file SystemInfo.C.

67{
68 struct tm * tm_struct;
69 std::time_t local_time;
70
71#ifdef LIBMESH_HAVE_LOCALE
72 // Create time_put "facet"
73 std::locale loc;
74 const std::time_put<char> & tp = std::use_facet<std::time_put<char>>(loc);
75
76 if (!time_stamp)
77 {
78 // Call C-style time getting functions
79 local_time = time(NULL);
80 time_stamp = &local_time;
81 }
82 tm_struct = std::localtime(time_stamp);
83
84 // Date will eventually be stored in this ostringstream's string
85 std::ostringstream date_stream;
86
87 // See below for documentation on the use of the
88 // std::time_put::put() function
89 tp.put(date_stream, /*s*/
90 date_stream, /*str*/
91 date_stream.fill(), /*fill*/
92 tm_struct, /*tm*/
93 'c'); /*format*/
94
95 // Another way to use it is to totally customize the format...
96 // char pattern[]="%d %B %Y %I:%M:%S %p";
97 // tp.put(date_stream, /*s*/
98 // date_stream, /*str*/
99 // date_stream.fill(), /*fill*/
100 // tm_struct, /*tm*/
101 // pattern, /*format begin*/
102 // pattern+sizeof(pattern)-1); /*format end */
103
104 return date_stream.str();
105#else
106 // C-stye code originally found here:
107 // http://people.sc.fsu.edu/~burkardt/cpp_src/timestamp/timestamp.C
108 // Author: John Burkardt, 24 September 2003
109 const unsigned int time_size = 40;
110 char time_buffer[time_size];
111
112 if (!time_stamp)
113 {
114 local_time = time(NULL);
115 time_stamp = &local_time;
116 }
117 tm_struct = std::localtime(time_stamp);
118
119 // No more than time_size characters will be placed into the array. If the
120 // total number of resulting characters, including the terminating
121 // NUL character, is not more than time_size, strftime() returns the
122 // number of characters in the array, not counting the terminating
123 // NUL. Otherwise, zero is returned and the buffer contents are
124 // indeterminate.
125 size_t len = strftime(time_buffer, time_size, "%c", tm_struct);
126
127 if (len != 0)
128 return std::string(time_buffer);
129 else
130 {
131 libMesh::out << "Error formatting time buffer, returning empty string!" << std::endl;
132 return std::string("");
133 }
134
135#endif // LIBMESH_HAVE_LOCALE
136}
OStreamProxy out(std::cout)

Referenced by getExecutableTimeStamp(), getInfo(), and to_json().


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