libMesh::Utility Namespace Reference
Classes | |
| struct | do_pow |
| struct | do_pow< 6, T > |
| struct | do_pow< 1, T > |
| struct | do_pow< 0, T > |
| class | ReverseBytes |
Functions | |
| template<> | |
| ElemType | string_to_enum< ElemType > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< ElemType > (const ElemType e) |
| template<> | |
| Order | string_to_enum< Order > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< Order > (const Order o) |
| template<> | |
| FEFamily | string_to_enum< FEFamily > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< FEFamily > (const FEFamily f) |
| template<> | |
| InfMapType | string_to_enum< InfMapType > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< InfMapType > (const InfMapType i) |
| template<> | |
| QuadratureType | string_to_enum< QuadratureType > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< QuadratureType > (const QuadratureType i) |
| template<> | |
| PreconditionerType | string_to_enum< PreconditionerType > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< PreconditionerType > (const PreconditionerType i) |
| template<> | |
| Elem::RefinementState | string_to_enum< Elem::RefinementState > (const std::string &s) |
| template<> | |
| std::string | enum_to_string< Elem::RefinementState > (const Elem::RefinementState i) |
| 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<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) |
Function Documentation
| ForwardIterator libMesh::Utility::binary_find | ( | ForwardIterator | first, | |
| ForwardIterator | last, | |||
| const T & | value | |||
| ) | [inline] |
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::TetGenMeshInterface::triangulate_conformingDelaunayMesh_carvehole().
| std::string libMesh::Utility::complex_filename | ( | const std::string & | basename, | |
| unsigned int | r_o_c = 0 | |||
| ) |
- Returns:
- for
r_o_c= 0 the filename for output of the real part of complex data, and forr_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 | ) | [inline] |
A convenient method to truly empty a vector using the "swap trick"
Definition at line 214 of file utility.h.
References swap().
Referenced by libMesh::Nemesis_IO::read().
00215 { 00216 std::vector<T>().swap(vec); 00217 }
| std::string libMesh::Utility::enum_to_string | ( | const T | e | ) | [inline] |
Takes the enumeration e of type T and returns the matching string.
Referenced by libMesh::AbaqusIO::assign_sideset_ids(), libMesh::Elem::get_info(), and libMesh::DofMap::reinit().
| std::string libMesh::Utility::enum_to_string< Elem::RefinementState > | ( | const Elem::RefinementState | i | ) | [inline] |
| std::string libMesh::Utility::enum_to_string< ElemType > | ( | const ElemType | e | ) | [inline] |
Referenced by libMesh::MeshTools::Modification::all_tri().
| std::string libMesh::Utility::enum_to_string< FEFamily > | ( | const FEFamily | f | ) | [inline] |
Referenced by libMesh::System::get_info().
| std::string libMesh::Utility::enum_to_string< InfMapType > | ( | const InfMapType | i | ) | [inline] |
Referenced by libMesh::System::get_info().
| std::string libMesh::Utility::enum_to_string< Order > | ( | const Order | o | ) | [inline] |
Referenced by libMesh::System::get_info().
| std::string libMesh::Utility::enum_to_string< PreconditionerType > | ( | const PreconditionerType | i | ) | [inline] |
| std::string libMesh::Utility::enum_to_string< QuadratureType > | ( | const QuadratureType | i | ) | [inline] |
| unsigned int libMesh::Utility::factorial | ( | unsigned int | n | ) | [inline] |
A simple implementation of the factorial.
Definition at line 194 of file utility.h.
Referenced by libMesh::FE< Dim, T >::shape(), and libMesh::FE< Dim, T >::shape_deriv().
| std::string libMesh::Utility::get_timestamp | ( | ) |
Referenced by libMesh::PerfLog::get_info_header(), print_timestamp(), and system_info().
| uint16_t libMesh::Utility::hashword | ( | const uint16_t * | k, | |
| size_t | length | |||
| ) | [inline] |
Definition at line 183 of file hashword.h.
00184 { 00185 // "big" prime number 00186 const uint16_t bp = 257; 00187 00188 uint16_t c = 0; 00189 uint16_t shift=0; 00190 for (size_t i=0; i != length; ++i) 00191 { 00192 c = static_cast<uint16_t> 00193 (c + static_cast<uint16_t>(k[i] << shift) % bp); 00194 shift = static_cast<uint16_t>(shift+3); 00195 } 00196 00197 return c; 00198 }
| uint64_t libMesh::Utility::hashword | ( | const uint64_t * | k, | |
| size_t | length | |||
| ) | [inline] |
Definition at line 165 of file hashword.h.
| uint32_t libMesh::Utility::hashword | ( | const uint32_t * | k, | |
| size_t | length, | |||
| uint32_t | initval = 0 | |||
| ) | [inline] |
Definition at line 92 of file hashword.h.
Referenced by libMesh::Elem::compute_key().
00093 { 00094 uint32_t a,b,c; 00095 00096 // Set up the internal state 00097 a = b = c = 0xdeadbeef + ((static_cast<uint32_t>(length))<<2) + initval; 00098 00099 //------------------------------------------------- handle most of the key 00100 while (length > 3) 00101 { 00102 a += k[0]; 00103 b += k[1]; 00104 c += k[2]; 00105 mix(a,b,c); 00106 length -= 3; 00107 k += 3; 00108 } 00109 00110 //------------------------------------------- handle the last 3 uint32_t's 00111 switch(length) // all the case statements fall through 00112 { 00113 case 3 : c+=k[2]; 00114 case 2 : b+=k[1]; 00115 case 1 : a+=k[0]; 00116 final(a,b,c); 00117 default: // case 0: nothing left to add 00118 break; 00119 } 00120 00121 //------------------------------------------------------ report the result 00122 return c; 00123 }
| uint16_t libMesh::Utility::hashword2 | ( | const uint16_t | first, | |
| const uint16_t | second | |||
| ) | [inline] |
Definition at line 155 of file hashword.h.
| uint64_t libMesh::Utility::hashword2 | ( | const uint64_t | first, | |
| const uint64_t | second | |||
| ) | [inline] |
Definition at line 146 of file hashword.h.
| uint32_t libMesh::Utility::hashword2 | ( | const uint32_t & | first, | |
| const uint32_t & | second, | |||
| uint32_t | initval = 0 | |||
| ) | [inline] |
Definition at line 130 of file hashword.h.
Referenced by libMesh::Elem::compute_key().
| void libMesh::Utility::iota | ( | ForwardIter | first, | |
| ForwardIter | last, | |||
| T | value | |||
| ) | [inline] |
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().
| bool libMesh::Utility::is_sorted | ( | InputIterator | first, | |
| InputIterator | last | |||
| ) | [inline] |
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.
00076 { 00077 if ( first == last ) 00078 return true; 00079 00080 // "prev" always points to the entry just to the left of "first" 00081 // [- - - - - -] 00082 // ^ ^ 00083 // prev first 00084 // 00085 // [- - - - - -] 00086 // ^ ^ 00087 // prev first 00088 // 00089 // [- - - - - -] 00090 // ^ ^ 00091 // prev first 00092 InputIterator prev( first ); 00093 for ( ++first; first != last; ++prev, ++first ) 00094 if ( *first < *prev ) // Note: this is the same as *prev > *first, 00095 return false; // but we only require op< to be defined. 00096 00097 // If we haven't returned yet, it's sorted! 00098 return true; 00099 00100 00101 // A one-liner version using adjacent_find. This doesn't work for 00102 // C-style arrays, since their pointers do not have a value_type. 00103 // 00104 // Works by checking to see if adjacent entries satisfy *i > 00105 // *(i+1) and returns the first one which does. If "last" is 00106 // returned, no such pair was found, and therefore the range must 00107 // be in non-decreasing order. 00108 // 00109 // return (last == 00110 // std::adjacent_find(first, last, 00111 // std::greater< typename InputIterator::value_type >())); 00112 00113 // A second one-linear attempt. This one checks for a **strictly 00114 // increasing** (no duplicate entries) range. Also doesn't work 00115 // with C-style arrays. 00116 // 00117 // return (last == 00118 // std::adjacent_find(first, last, 00119 // std::not2(std::less<typename InputIterator::value_type>()))); 00120 }
| T libMesh::Utility::pow | ( | const T & | x | ) | [inline] |
Definition at line 184 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().
| 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().
| void libMesh::Utility::print_timestamp | ( | std::ostream & | target = std::cout |
) | [inline] |
Definition at line 37 of file timestamp.h.
References get_timestamp().
00038 { 00039 target << get_timestamp() << std::endl; 00040 }
| T libMesh::Utility::string_to_enum | ( | const std::string & | s | ) | [inline] |
Takes the string s and returns the matching enumeration of type T.
| Elem::RefinementState libMesh::Utility::string_to_enum< Elem::RefinementState > | ( | const std::string & | s | ) | [inline] |
| ElemType libMesh::Utility::string_to_enum< ElemType > | ( | const std::string & | s | ) | [inline] |
| FEFamily libMesh::Utility::string_to_enum< FEFamily > | ( | const std::string & | s | ) | [inline] |
| InfMapType libMesh::Utility::string_to_enum< InfMapType > | ( | const std::string & | s | ) | [inline] |
| Order libMesh::Utility::string_to_enum< Order > | ( | const std::string & | s | ) | [inline] |
| PreconditionerType libMesh::Utility::string_to_enum< PreconditionerType > | ( | const std::string & | s | ) | [inline] |
| QuadratureType libMesh::Utility::string_to_enum< QuadratureType > | ( | const std::string & | s | ) | [inline] |
Referenced by libMesh::QBase::build().
| 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().
00046 { 00047 std::ostringstream oss; 00048 00049 std::string date = Utility::get_timestamp(); 00050 00051 // Get system information 00052 struct utsname sysInfo; 00053 uname(&sysInfo); 00054 00055 // Get user information 00056 #ifdef LIBMESH_HAVE_GETPWUID 00057 struct passwd* p = getpwuid(getuid()); 00058 #endif 00059 00060 00061 oss << '\n' 00062 << " ---------------------------------------------------------------------\n" 00063 << "| Time: " << date << '\n' 00064 << "| OS: " << sysInfo.sysname << '\n' 00065 << "| HostName: " << sysInfo.nodename << '\n' 00066 << "| OS Release " << sysInfo.release << '\n' 00067 << "| OS Version: " << sysInfo.version << '\n' 00068 << "| Machine: " << sysInfo.machine << '\n' 00069 #ifdef LIBMESH_HAVE_GETPWUID 00070 << "| Username: " << p->pw_name << '\n' 00071 #else 00072 << "| Username: " << "Unknown" << '\n' 00073 #endif 00074 << " ---------------------------------------------------------------------\n"; 00075 00076 return oss.str(); 00077 }
Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:49 UTC
Hosted By: