$extrastylesheet
Classes | |
| struct | do_pow |
| struct | do_pow< 6, T > |
| struct | do_pow< 1, T > |
| struct | do_pow< 0, T > |
| class | ReverseBytes |
Functions | |
| std::string | get_timestamp () |
| uint32_t | hashword (const uint32_t *k, size_t length, uint32_t initval=0) |
| uint32_t | hashword2 (const uint32_t &first, const uint32_t &second, uint32_t initval=0) |
| uint64_t | hashword2 (const uint64_t first, const uint64_t second) |
| uint16_t | hashword2 (const uint16_t first, const uint16_t second) |
| uint64_t | hashword (const uint64_t *k, size_t length) |
| uint16_t | hashword (const uint16_t *k, size_t length) |
| template<typename T > | |
| T | string_to_enum (const std::string &s) |
| template<typename T > | |
| std::string | enum_to_string (const T e) |
| void | print_timestamp (std::ostream &target=std::cout) |
| std::string | system_info () |
| template<typename ForwardIter , typename T > | |
| void | iota (ForwardIter first, ForwardIter last, T value) |
| template<class InputIterator > | |
| bool | is_sorted (InputIterator first, InputIterator last) |
| template<class ForwardIterator , class T > | |
| ForwardIterator | binary_find (ForwardIterator first, ForwardIterator last, const T &value) |
| template<class ForwardIterator , class T , class Compare > | |
| ForwardIterator | binary_find (ForwardIterator first, ForwardIterator last, const T &value, Compare comp) |
| template<int N, typename T > | |
| T | pow (const T &x) |
| unsigned int | factorial (unsigned int n) |
| template<typename T > | |
| void | deallocate (std::vector< T > &vec) |
| std::string | complex_filename (const std::string &basename, unsigned int r_o_c=0) |
| void | prepare_complex_data (const std::vector< Complex > &source, std::vector< Real > &real_part, std::vector< Real > &imag_part) |
| ForwardIterator libMesh::Utility::binary_find | ( | ForwardIterator | first, |
| ForwardIterator | last, | ||
| const T & | value | ||
| ) |
The STL provides binary_search() which returns true/false depending on whether the searched-for value is found. Utility::binary_find() uses a binary search on a sorted range to return an iterator to the searched-for element, or "last" if the element is not found.
Definition at line 130 of file utility.h.
Referenced by libMesh::SerialMesh::stitching_helper(), and libMesh::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
{
ForwardIterator it = std::lower_bound(first, last, value);
return (it == last || value < *it) ? last : it;
}
| ForwardIterator libMesh::Utility::binary_find | ( | ForwardIterator | first, |
| ForwardIterator | last, | ||
| const T & | value, | ||
| Compare | comp | ||
| ) |
| std::string libMesh::Utility::complex_filename | ( | const std::string & | basename, |
| unsigned int | r_o_c = 0 |
||
| ) |
r_o_c = 0 the filename for output of the real part of complex data, and for r_o_c = 1 the filename for the imaginary part. Definition at line 83 of file utility.C.
References libMesh::Quality::name().
Referenced by libMesh::LegacyXdrIO::read_mgf_soln(), and libMesh::LegacyXdrIO::write_mgf_soln().
| void libMesh::Utility::deallocate | ( | std::vector< T > & | vec | ) |
A convenient method to truly empty a vector using the "swap trick"
Definition at line 224 of file utility.h.
References libMesh::swap().
Referenced by libMesh::Nemesis_IO::read().
{
std::vector<T>().swap(vec);
}
| std::string libMesh::Utility::enum_to_string | ( | const T | e | ) |
Takes the enumeration e of type T and returns the matching string.
Referenced by libMesh::LaspackLinearSolver< T >::adjoint_solve(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::AbaqusIO::assign_subdomain_ids(), libMesh::Elem::get_info(), libMesh::LinearSolver< T >::print_converged_reason(), libMesh::Elem::quality(), libMesh::AbaqusIO::read_elements(), libMesh::DofMap::reinit(), libMesh::PetscLinearSolver< T >::set_petsc_solver_type(), libMesh::SlepcEigenSolver< T >::set_slepc_solver_type(), libMesh::AztecLinearSolver< T >::set_solver_type(), libMesh::EigenSparseLinearSolver< T >::solve(), libMesh::LaspackLinearSolver< T >::solve(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::GMVIO::write_discontinuous_gmv(), and libMesh::ExodusII_IO_Helper::write_elements().
| unsigned int libMesh::Utility::factorial | ( | unsigned int | n | ) | [inline] |
A simple implementation of the factorial.
Definition at line 204 of file utility.h.
Referenced by libMesh::FE< Dim, T >::shape(), and libMesh::FE< Dim, T >::shape_deriv().
{
unsigned int factorial_n = 1;
if (n==0)
return factorial_n;
for (unsigned int i=1; i<n; i++)
factorial_n *= i+1;
return factorial_n;
}
| std::string libMesh::Utility::get_timestamp | ( | ) |
Definition at line 37 of file timestamp.C.
References libMesh::out.
Referenced by libMesh::PerfLog::get_info_header(), print_timestamp(), and system_info().
{
#ifdef LIBMESH_HAVE_LOCALE
// Create time_put "facet"
std::locale loc;
const std::time_put<char>& tp = std::use_facet <std::time_put<char> > (loc);
// Call C-style time getting functions
time_t now = time(NULL);
tm* tm_struct = localtime(&now);
// Date will eventually be stored in this ostringstream's string
std::ostringstream date_stream;
// See below for documentation on the use of the
// std::time_put::put() function
tp.put(date_stream, /*s*/
date_stream, /*str*/
date_stream.fill(), /*fill*/
tm_struct, /*tm*/
'c'); /*format*/
// Another way to use it is to totally customize the format...
// char pattern[]="%d %B %Y %I:%M:%S %p";
// tp.put(date_stream, /*s*/
// date_stream, /*str*/
// date_stream.fill(), /*fill*/
// tm_struct, /*tm*/
// pattern, /*format begin*/
// pattern+sizeof(pattern)-1); /*format end */
return date_stream.str();
#else
// C-stye code originally found here:
// http://people.sc.fsu.edu/~burkardt/cpp_src/timestamp/timestamp.C
// Author: John Burkardt, 24 September 2003
const unsigned int time_size = 40;
char time_buffer[time_size];
time_t now = time ( NULL );
tm* tm_struct = localtime ( &now );
// No more than time_size characters will be placed into the array. If the
// total number of resulting characters, including the terminating
// NUL character, is not more than time_size, strftime() returns the
// number of characters in the array, not counting the terminating
// NUL. Otherwise, zero is returned and the buffer contents are
// indeterminate.
size_t len = strftime ( time_buffer, time_size, "%c", tm_struct );
if (len != 0)
return std::string(time_buffer);
else
{
libMesh::out << "Error formatting time buffer, returning empty string!" << std::endl;
return std::string("");
}
#endif // LIBMESH_HAVE_LOCALE
}
| uint32_t libMesh::Utility::hashword | ( | const uint32_t * | k, |
| size_t | length, | ||
| uint32_t | initval = 0 |
||
| ) | [inline] |
Definition at line 132 of file hashword.h.
Referenced by libMesh::Elem::compute_key().
{
uint32_t a,b,c;
// Set up the internal state
a = b = c = 0xdeadbeef + ((static_cast<uint32_t>(length))<<2) + initval;
//------------------------------------------------- handle most of the key
while (length > 3)
{
a += k[0];
b += k[1];
c += k[2];
mix(a,b,c);
length -= 3;
k += 3;
}
//------------------------------------------- handle the last 3 uint32_t's
switch(length) // all the case statements fall through
{
case 3 : c+=k[2];
case 2 : b+=k[1];
case 1 : a+=k[0];
final(a,b,c);
default: // case 0: nothing left to add
break;
}
//------------------------------------------------------ report the result
return c;
}
| uint64_t libMesh::Utility::hashword | ( | const uint64_t * | k, |
| size_t | length | ||
| ) | [inline] |
Definition at line 205 of file hashword.h.
{
return fnv_64_buf(k, 8*length);
}
| uint16_t libMesh::Utility::hashword | ( | const uint16_t * | k, |
| size_t | length | ||
| ) | [inline] |
Definition at line 215 of file hashword.h.
{
// Three values that will be passed to final() after they are initialized.
uint32_t a = 0;
uint32_t b = 0;
uint32_t c = 0;
switch (length)
{
case 3:
{
// Cast the inputs to 32 bit integers and call final().
a = k[0];
b = k[1];
c = k[2];
break;
}
case 4:
{
// Combine the 4 16-bit inputs, "w, x, y, z" into two 32-bit
// inputs "wx" and "yz" using bit operations and call final.
a = ((k[0]<<16) | (k[1] & 0xffff)); // wx
b = ((k[2]<<16) | (k[3] & 0xffff)); // yz
break;
}
default:
libmesh_error_msg("Unsupported length: " << length);
}
// Result is returned in c
final(a,b,c);
return static_cast<uint16_t>(c);
}
| uint32_t libMesh::Utility::hashword2 | ( | const uint32_t & | first, |
| const uint32_t & | second, | ||
| uint32_t | initval = 0 |
||
| ) | [inline] |
Definition at line 170 of file hashword.h.
Referenced by libMesh::Elem::compute_key().
{
uint32_t a,b,c;
// Set up the internal state
a = b = c = 0xdeadbeef + 8 + initval;
b+=second;
a+=first;
final(a,b,c);
return c;
}
| uint64_t libMesh::Utility::hashword2 | ( | const uint64_t | first, |
| const uint64_t | second | ||
| ) | [inline] |
Definition at line 186 of file hashword.h.
{
// This isn't optimal (it would be nice to avoid this packing step)
// but we are going to go ahead and conform to the 32-bit
// hashword2() interface.
uint64_t k[2] = {first, second};
// len is the total number of bytes in two 64-bit ints
return fnv_64_buf(k, /*len=*/8*2);
}
| uint16_t libMesh::Utility::hashword2 | ( | const uint16_t | first, |
| const uint16_t | second | ||
| ) | [inline] |
Definition at line 198 of file hashword.h.
{
return static_cast<uint16_t>(first%65449 + (second<<5)%65449);
}
| void libMesh::Utility::iota | ( | ForwardIter | first, |
| ForwardIter | last, | ||
| T | value | ||
| ) |
Utility::iota is a duplication of the SGI STL extension std::iota. It simply assigns sequentially increasing values to a range. That is, it assigns value to *first, value + 1 to *(first + 1) and so on. In general, each iterator i in the range [first, last) is assigned value + (i - first).
Definition at line 58 of file utility.h.
Referenced by libMesh::PetscVector< T >::create_subvector(), and libMesh::PetscVector< T >::localize().
{
while (first != last)
{
*first = value++;
++first;
}
}
| bool libMesh::Utility::is_sorted | ( | InputIterator | first, |
| InputIterator | last | ||
| ) |
Utility::is_sorted mimics the behavior of the SGI STL extension std::is_sorted. Checks to see if the range [first,last) is sorted in non-decreasing order, ie. for each "i" in [first,last) *i <= *(i+1).
Definition at line 75 of file utility.h.
References libMesh::MeshTools::Subdivision::prev.
{
if ( first == last )
return true;
// "prev" always points to the entry just to the left of "first"
// [- - - - - -]
// ^ ^
// prev first
//
// [- - - - - -]
// ^ ^
// prev first
//
// [- - - - - -]
// ^ ^
// prev first
InputIterator prev( first );
for ( ++first; first != last; ++prev, ++first )
if ( *first < *prev ) // Note: this is the same as *prev > *first,
return false; // but we only require op< to be defined.
// If we haven't returned yet, it's sorted!
return true;
// A one-liner version using adjacent_find. This doesn't work for
// C-style arrays, since their pointers do not have a value_type.
//
// Works by checking to see if adjacent entries satisfy *i >
// *(i+1) and returns the first one which does. If "last" is
// returned, no such pair was found, and therefore the range must
// be in non-decreasing order.
//
// return (last ==
// std::adjacent_find(first, last,
// std::greater< typename InputIterator::value_type >()));
// A second one-linear attempt. This one checks for a **strictly
// increasing** (no duplicate entries) range. Also doesn't work
// with C-style arrays.
//
// return (last ==
// std::adjacent_find(first, last,
// std::not2(std::less<typename InputIterator::value_type>())));
}
| T libMesh::Utility::pow | ( | const T & | x | ) | [inline] |
Definition at line 194 of file utility.h.
References libMesh::Utility::do_pow< N, T >::apply().
Referenced by libMesh::FEHermite< Dim >::hermite_raw_shape_second_deriv(), libMesh::FE< Dim, T >::shape(), libMesh::FE< Dim, T >::shape_deriv(), and libMesh::FE< Dim, T >::shape_second_deriv().
{
return do_pow<N,T>::apply(x);
}
| void libMesh::Utility::prepare_complex_data | ( | const std::vector< Complex > & | source, |
| std::vector< Real > & | real_part, | ||
| std::vector< Real > & | imag_part | ||
| ) |
Prepare complex data for writing.
Definition at line 99 of file utility.C.
Referenced by libMesh::LegacyXdrIO::read_mgf_soln(), and libMesh::LegacyXdrIO::write_mgf_soln().
{
const unsigned int len = source.size();
real_part.resize(len);
imag_part.resize(len);
for (unsigned int i=0; i<len; i++)
{
real_part[i] = source[i].real();
imag_part[i] = source[i].imag();
}
}
| void libMesh::Utility::print_timestamp | ( | std::ostream & | target = std::cout | ) | [inline] |
Definition at line 37 of file timestamp.h.
References get_timestamp().
{
target << get_timestamp() << std::endl;
}
| T libMesh::Utility::string_to_enum | ( | const std::string & | s | ) |
Takes the string s and returns the matching enumeration of type T.
| std::string libMesh::Utility::system_info | ( | ) |
The system_info function returns information about the system you are running on.
Definition at line 45 of file utility.C.
References get_timestamp().
{
std::ostringstream oss;
std::string date = Utility::get_timestamp();
// Get system information
struct utsname sysInfo;
uname(&sysInfo);
// Get user information
#ifdef LIBMESH_HAVE_GETPWUID
struct passwd* p = getpwuid(getuid());
#endif
oss << '\n'
<< " ---------------------------------------------------------------------\n"
<< "| Time: " << date << '\n'
<< "| OS: " << sysInfo.sysname << '\n'
<< "| HostName: " << sysInfo.nodename << '\n'
<< "| OS Release " << sysInfo.release << '\n'
<< "| OS Version: " << sysInfo.version << '\n'
<< "| Machine: " << sysInfo.machine << '\n'
#ifdef LIBMESH_HAVE_GETPWUID
<< "| Username: " << p->pw_name << '\n'
#else
<< "| Username: " << "Unknown" << '\n'
#endif
<< " ---------------------------------------------------------------------\n";
return oss.str();
}