Reference documentation for deal.II version Git a0b41b6d0f 2020-02-26 20:08:13 -0600
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
utilities.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_utilities_h
17 #define dealii_utilities_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/exceptions.h>
22 
23 #include <functional>
24 #include <string>
25 #include <tuple>
26 #include <type_traits>
27 #include <typeinfo>
28 #include <utility>
29 #include <vector>
30 
31 #ifdef DEAL_II_WITH_TRILINOS
32 # include <Epetra_Comm.h>
33 # include <Epetra_Map.h>
34 # include <Teuchos_Comm.hpp>
35 # include <Teuchos_RCP.hpp>
36 # ifdef DEAL_II_WITH_MPI
37 # include <Epetra_MpiComm.h>
38 # else
39 # include <Epetra_SerialComm.h>
40 # endif
41 #endif
42 
43 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
44 
45 #include <boost/archive/binary_iarchive.hpp>
46 #include <boost/archive/binary_oarchive.hpp>
47 #include <boost/core/demangle.hpp>
48 #include <boost/serialization/array.hpp>
49 #include <boost/serialization/complex.hpp>
50 #include <boost/serialization/vector.hpp>
51 
52 #ifdef DEAL_II_WITH_ZLIB
53 # include <boost/iostreams/device/back_inserter.hpp>
54 # include <boost/iostreams/filter/gzip.hpp>
55 # include <boost/iostreams/filtering_stream.hpp>
56 # include <boost/iostreams/stream.hpp>
57 #endif
58 
59 DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
60 
61 DEAL_II_NAMESPACE_OPEN
62 
63 // forward declare Point
64 #ifndef DOXYGEN
65 template <int dim, typename Number>
66 class Point;
67 #endif
68 
77 namespace Utilities
78 {
85  std::string
87 
104  template <int dim, typename Number>
105  std::vector<std::array<std::uint64_t, dim>>
107  const std::vector<Point<dim, Number>> &points,
108  const int bits_per_dim = 64);
109 
113  template <int dim>
114  std::vector<std::array<std::uint64_t, dim>>
116  const std::vector<std::array<std::uint64_t, dim>> &points,
117  const int bits_per_dim = 64);
118 
134  template <int dim>
135  std::uint64_t
136  pack_integers(const std::array<std::uint64_t, dim> &index,
137  const int bits_per_dim);
138 
153  std::string
154  compress(const std::string &input);
155 
171  std::string
172  decompress(const std::string &compressed_input);
173 
195  std::string
196  int_to_string(const unsigned int value,
197  const unsigned int digits = numbers::invalid_unsigned_int);
198 
210  template <typename number>
211  std::string
212  to_string(const number value,
213  const unsigned int digits = numbers::invalid_unsigned_int);
214 
221  unsigned int
222  needed_digits(const unsigned int max_number);
223 
234  template <typename Number>
235  Number
236  truncate_to_n_digits(const Number number, const unsigned int n_digits);
237 
242  int
243  string_to_int(const std::string &s);
244 
256  std::string
257  dim_string(const int dim, const int spacedim);
258 
263  std::vector<int>
264  string_to_int(const std::vector<std::string> &s);
265 
270  double
271  string_to_double(const std::string &s);
272 
273 
278  std::vector<double>
279  string_to_double(const std::vector<std::string> &s);
280 
281 
324  std::vector<std::string>
325  split_string_list(const std::string &s, const std::string &delimiter = ",");
326 
327 
332  std::vector<std::string>
333  split_string_list(const std::string &s, const char delimiter);
334 
335 
345  std::vector<std::string>
346  break_text_into_lines(const std::string &original_text,
347  const unsigned int width,
348  const char delimiter = ' ');
349 
354  bool
355  match_at_string_start(const std::string &name, const std::string &pattern);
356 
365  std::pair<int, unsigned int>
366  get_integer_at_position(const std::string &name, const unsigned int position);
367 
372  std::string
373  replace_in_string(const std::string &input,
374  const std::string &from,
375  const std::string &to);
376 
382  std::string
383  trim(const std::string &input);
384 
410  double
411  generate_normal_random_number(const double a, const double sigma);
412 
422  template <class T>
423  std::string
424  type_to_string(const T &t);
425 
434  template <int N, typename T>
435  T
436  fixed_power(const T t);
437 
462  template <int a, int N>
463  struct DEAL_II_DEPRECATED fixed_int_power
464  {
465  static const int value = a * fixed_int_power<a, N - 1>::value;
466  };
467 
475  template <int a>
476  struct DEAL_II_DEPRECATED fixed_int_power<a, 0>
477  {
478  static const int value = 1;
479  };
480 
486  constexpr unsigned int
487  pow(const unsigned int base, const int iexp)
488  {
489 #if defined(DEBUG) && defined(DEAL_II_WITH_CXX14) && \
490  defined(DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
491  // Up to __builtin_expect this is the same code as in the 'Assert' macro.
492  // The call to __builtin_expect turns out to be problematic.
493  if (!(iexp >= 0))
494  ::deal_II_exceptions::internals::issue_error_noreturn(
496  __FILE__,
497  __LINE__,
498  __PRETTY_FUNCTION__,
499  "iexp>=0",
500  "ExcMessage(\"The exponent must not be negative!\")",
501  ExcMessage("The exponent must not be negative!"));
502 #endif
503  // The "exponentiation by squaring" algorithm used below has to be
504  // compressed to one statement due to C++11's restrictions on constexpr
505  // functions. A more descriptive version would be:
506  //
507  // <code>
508  // if (iexp <= 0)
509  // return 1;
510  //
511  // // if the current exponent is not divisible by two,
512  // // we need to account for that.
513  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
514  //
515  // // a^b = (a*a)^(b/2) for b even
516  // // a^b = a*(a*a)^((b-1)/2 for b odd
517  // return prefactor * ::Utilities::pow(base*base, iexp/2);
518  // </code>
519 
520  return iexp <= 0 ? 1 :
521  (((iexp % 2 == 1) ? base : 1) *
522  ::Utilities::pow(base * base, iexp / 2));
523  }
524 
546  template <typename Iterator, typename T>
547  Iterator
548  lower_bound(Iterator first, Iterator last, const T &val);
549 
550 
556  template <typename Iterator, typename T, typename Comp>
557  Iterator
558  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
559 
565  std::vector<unsigned int>
566  reverse_permutation(const std::vector<unsigned int> &permutation);
567 
573  std::vector<unsigned int>
574  invert_permutation(const std::vector<unsigned int> &permutation);
575 
581  std::vector<unsigned long long int>
582  reverse_permutation(const std::vector<unsigned long long int> &permutation);
583 
589  std::vector<unsigned long long int>
590  invert_permutation(const std::vector<unsigned long long int> &permutation);
591 
609  template <typename T>
610  size_t
611  pack(const T & object,
612  std::vector<char> &dest_buffer,
613  const bool allow_compression = true);
614 
625  template <typename T>
626  std::vector<char>
627  pack(const T &object, const bool allow_compression = true);
628 
661  template <typename T>
662  T
663  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
664 
675  template <typename T>
676  T
677  unpack(const std::vector<char>::const_iterator &cbegin,
678  const std::vector<char>::const_iterator &cend,
679  const bool allow_compression = true);
680 
715  template <typename T, int N>
716  void
717  unpack(const std::vector<char> &buffer,
718  T (&unpacked_object)[N],
719  const bool allow_compression = true);
720 
731  template <typename T, int N>
732  void
733  unpack(const std::vector<char>::const_iterator &cbegin,
734  const std::vector<char>::const_iterator &cend,
735  T (&unpacked_object)[N],
736  const bool allow_compression = true);
737 
795  template <typename To, typename From>
796  std::unique_ptr<To>
797  dynamic_unique_cast(std::unique_ptr<From> &&p)
798  {
799  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
800  // and then release the pointer from the old
801  // owner
802  if (To *cast = dynamic_cast<To *>(p.get()))
803  {
804  std::unique_ptr<To> result(cast);
805  p.release();
806  return result;
807  }
808  else
809  throw std::bad_cast();
810  }
811 
817  namespace System
818  {
826  double
827  get_cpu_load();
828 
862  const std::string
864 
869  struct MemoryStats
870  {
874  unsigned long int VmPeak;
875 
879  unsigned long int VmSize;
880 
884  unsigned long int VmHWM;
885 
890  unsigned long int VmRSS;
891  };
892 
893 
898  void
900 
901 
905  std::string
906  get_hostname();
907 
908 
912  std::string
913  get_time();
914 
919  std::string
920  get_date();
921 
936  void
937  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
938  } // namespace System
939 
940 
941 #ifdef DEAL_II_WITH_TRILINOS
942 
947  namespace Trilinos
948  {
958  const Epetra_Comm &
959  comm_world();
960 
970  const Epetra_Comm &
971  comm_self();
972 
981  const Teuchos::RCP<const Teuchos::Comm<int>> &
983 
1016  Epetra_Comm *
1017  duplicate_communicator(const Epetra_Comm &communicator);
1018 
1041  void
1042  destroy_communicator(Epetra_Comm &communicator);
1043 
1052  unsigned int
1053  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
1054 
1061  unsigned int
1062  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
1063 
1074  Epetra_Map
1075  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1076  } // namespace Trilinos
1077 
1078 #endif
1079 
1080 
1081 } // namespace Utilities
1082 
1083 
1084 // --------------------- inline functions
1085 
1086 namespace Utilities
1087 {
1088  template <int N, typename T>
1089  inline T
1090  fixed_power(const T x)
1091  {
1092  Assert(
1093  !std::is_integral<T>::value || (N >= 0),
1094  ExcMessage(
1095  "The non-type template parameter N must be a non-negative integer for integral type T"));
1096 
1097  if (N == 0)
1098  return T(1.);
1099  else if (N < 0)
1100  return T(1.) / fixed_power<-N>(x);
1101  else
1102  // Use exponentiation by squaring:
1103  return ((N % 2 == 1) ? x * fixed_power<N / 2>(x * x) :
1104  fixed_power<N / 2>(x * x));
1105  }
1106 
1107 
1108 
1109  template <class T>
1110  inline std::string
1111  type_to_string(const T &t)
1112  {
1113  return boost::core::demangle(typeid(t).name());
1114  }
1115 
1116 
1117 
1118  template <typename Iterator, typename T>
1119  inline Iterator
1120  lower_bound(Iterator first, Iterator last, const T &val)
1121  {
1122  return Utilities::lower_bound(first, last, val, std::less<T>());
1123  }
1124 
1125 
1126 
1127  template <typename Iterator, typename T, typename Comp>
1128  inline Iterator
1129  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1130  {
1131  // verify that the two iterators are properly ordered. since
1132  // we need operator- for the iterator type anyway, do the
1133  // test as follows, rather than via 'last >= first'
1134  Assert(last - first >= 0,
1135  ExcMessage(
1136  "The given iterators do not satisfy the proper ordering."));
1137 
1138  unsigned int len = static_cast<unsigned int>(last - first);
1139 
1140  if (len == 0)
1141  return first;
1142 
1143  while (true)
1144  {
1145  // if length equals 8 or less,
1146  // then do a rolled out
1147  // search. use a switch without
1148  // breaks for that and roll-out
1149  // the loop somehow
1150  if (len < 8)
1151  {
1152  switch (len)
1153  {
1154  case 7:
1155  if (!comp(*first, val))
1156  return first;
1157  ++first;
1158  DEAL_II_FALLTHROUGH;
1159  case 6:
1160  if (!comp(*first, val))
1161  return first;
1162  ++first;
1163  DEAL_II_FALLTHROUGH;
1164  case 5:
1165  if (!comp(*first, val))
1166  return first;
1167  ++first;
1168  DEAL_II_FALLTHROUGH;
1169  case 4:
1170  if (!comp(*first, val))
1171  return first;
1172  ++first;
1173  DEAL_II_FALLTHROUGH;
1174  case 3:
1175  if (!comp(*first, val))
1176  return first;
1177  ++first;
1178  DEAL_II_FALLTHROUGH;
1179  case 2:
1180  if (!comp(*first, val))
1181  return first;
1182  ++first;
1183  DEAL_II_FALLTHROUGH;
1184  case 1:
1185  if (!comp(*first, val))
1186  return first;
1187  return first + 1;
1188  default:
1189  // indices seem
1190  // to not be
1191  // sorted
1192  // correctly!? or
1193  // did len
1194  // become==0
1195  // somehow? that
1196  // shouldn't have
1197  // happened
1198  Assert(false, ExcInternalError());
1199  }
1200  }
1201 
1202 
1203 
1204  const unsigned int half = len >> 1;
1205  const Iterator middle = first + half;
1206 
1207  // if the value is larger than
1208  // that pointed to by the
1209  // middle pointer, then the
1210  // insertion point must be
1211  // right of it
1212  if (comp(*middle, val))
1213  {
1214  first = middle + 1;
1215  len -= half + 1;
1216  }
1217  else
1218  len = half;
1219  }
1220  }
1221 
1222 
1223  // --------------------- non-inline functions
1224 
1225  template <typename T>
1226  size_t
1227  pack(const T & object,
1228  std::vector<char> &dest_buffer,
1229  const bool allow_compression)
1230  {
1231  // the data is never compressed when we can't use zlib.
1232  (void)allow_compression;
1233 
1234  std::size_t size = 0;
1235 
1236  // see if the object is small and copyable via memcpy. if so, use
1237  // this fast path. otherwise, we have to go through the BOOST
1238  // serialization machinery
1239  //
1240  // we have to work around the fact that GCC 4.8.x claims to be C++
1241  // conforming, but is not actually as it does not implement
1242  // std::is_trivially_copyable.
1243 #if __GNUG__ && __GNUC__ < 5
1244  if (__has_trivial_copy(T) && sizeof(T) < 256)
1245 #else
1246 # ifdef DEAL_II_WITH_CXX17
1247  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1248 # else
1249  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1250 # endif
1251 #endif
1252  {
1253  const std::size_t previous_size = dest_buffer.size();
1254  dest_buffer.resize(previous_size + sizeof(T));
1255 
1256  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1257 
1258  size = sizeof(T);
1259  }
1260  else
1261  {
1262  // use buffer as the target of a compressing
1263  // stream into which we serialize the current object
1264  const std::size_t previous_size = dest_buffer.size();
1265 #ifdef DEAL_II_WITH_ZLIB
1266  if (allow_compression)
1267  {
1268  boost::iostreams::filtering_ostream out;
1269  out.push(
1270  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1271  boost::iostreams::gzip::default_compression)));
1272  out.push(boost::iostreams::back_inserter(dest_buffer));
1273 
1274  boost::archive::binary_oarchive archive(out);
1275  archive << object;
1276  out.flush();
1277  }
1278  else
1279 #endif
1280  {
1281  std::ostringstream out;
1282  boost::archive::binary_oarchive archive(out);
1283  archive << object;
1284 
1285  const std::string &s = out.str();
1286  dest_buffer.reserve(dest_buffer.size() + s.size());
1287  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1288  }
1289 
1290  size = dest_buffer.size() - previous_size;
1291  }
1292 
1293  return size;
1294  }
1295 
1296 
1297  template <typename T>
1298  std::vector<char>
1299  pack(const T &object, const bool allow_compression)
1300  {
1301  std::vector<char> buffer;
1302  pack<T>(object, buffer, allow_compression);
1303  return buffer;
1304  }
1305 
1306 
1307  template <typename T>
1308  T
1309  unpack(const std::vector<char>::const_iterator &cbegin,
1310  const std::vector<char>::const_iterator &cend,
1311  const bool allow_compression)
1312  {
1313  T object;
1314 
1315  // the data is never compressed when we can't use zlib.
1316  (void)allow_compression;
1317 
1318  // see if the object is small and copyable via memcpy. if so, use
1319  // this fast path. otherwise, we have to go through the BOOST
1320  // serialization machinery
1321  //
1322  // we have to work around the fact that GCC 4.8.x claims to be C++
1323  // conforming, but is not actually as it does not implement
1324  // std::is_trivially_copyable.
1325 #if __GNUG__ && __GNUC__ < 5
1326  if (__has_trivial_copy(T) && sizeof(T) < 256)
1327 #else
1328 # ifdef DEAL_II_WITH_CXX17
1329  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1330 # else
1331  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1332 # endif
1333 #endif
1334  {
1335  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1336  std::memcpy(&object, &*cbegin, sizeof(T));
1337  }
1338  else
1339  {
1340  std::string decompressed_buffer;
1341 
1342  // first decompress the buffer
1343 #ifdef DEAL_II_WITH_ZLIB
1344  if (allow_compression)
1345  {
1346  boost::iostreams::filtering_ostream decompressing_stream;
1347  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1348  decompressing_stream.push(
1349  boost::iostreams::back_inserter(decompressed_buffer));
1350  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1351  }
1352  else
1353 #endif
1354  {
1355  decompressed_buffer.assign(cbegin, cend);
1356  }
1357 
1358  // then restore the object from the buffer
1359  std::istringstream in(decompressed_buffer);
1360  boost::archive::binary_iarchive archive(in);
1361 
1362  archive >> object;
1363  }
1364 
1365  return object;
1366  }
1367 
1368 
1369  template <typename T>
1370  T
1371  unpack(const std::vector<char> &buffer, const bool allow_compression)
1372  {
1373  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1374  }
1375 
1376 
1377  template <typename T, int N>
1378  void
1379  unpack(const std::vector<char>::const_iterator &cbegin,
1380  const std::vector<char>::const_iterator &cend,
1381  T (&unpacked_object)[N],
1382  const bool allow_compression)
1383  {
1384  // see if the object is small and copyable via memcpy. if so, use
1385  // this fast path. otherwise, we have to go through the BOOST
1386  // serialization machinery
1387  //
1388  // we have to work around the fact that GCC 4.8.x claims to be C++
1389  // conforming, but is not actually as it does not implement
1390  // std::is_trivially_copyable.
1391  if (
1392 #if __GNUG__ && __GNUC__ < 5
1393  __has_trivial_copy(T)
1394 #else
1395  std::is_trivially_copyable<T>()
1396 #endif
1397  && sizeof(T) * N < 256)
1398  {
1399  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1400  ExcInternalError());
1401  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1402  }
1403  else
1404  {
1405  std::string decompressed_buffer;
1406 
1407  // first decompress the buffer
1408  (void)allow_compression;
1409 #ifdef DEAL_II_WITH_ZLIB
1410  if (allow_compression)
1411  {
1412  boost::iostreams::filtering_ostream decompressing_stream;
1413  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1414  decompressing_stream.push(
1415  boost::iostreams::back_inserter(decompressed_buffer));
1416  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1417  }
1418  else
1419 #endif
1420  {
1421  decompressed_buffer.assign(cbegin, cend);
1422  }
1423 
1424  // then restore the object from the buffer
1425  std::istringstream in(decompressed_buffer);
1426  boost::archive::binary_iarchive archive(in);
1427 
1428  archive >> unpacked_object;
1429  }
1430  }
1431 
1432 
1433  template <typename T, int N>
1434  void
1435  unpack(const std::vector<char> &buffer,
1436  T (&unpacked_object)[N],
1437  const bool allow_compression)
1438  {
1439  unpack<T, N>(buffer.cbegin(),
1440  buffer.cend(),
1441  unpacked_object,
1442  allow_compression);
1443  }
1444 
1445 } // namespace Utilities
1446 
1447 
1448 DEAL_II_NAMESPACE_CLOSE
1449 
1450 #ifndef DOXYGEN
1451 namespace boost
1452 {
1453  namespace serialization
1454  {
1455  // Provides boost and c++11 with a way to serialize tuples and pairs
1456  // automatically
1457  template <int N>
1458  struct Serialize
1459  {
1460  template <class Archive, typename... Args>
1461  static void
1462  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1463  {
1464  ar &std::get<N - 1>(t);
1465  Serialize<N - 1>::serialize(ar, t, version);
1466  }
1467  };
1468 
1469  template <>
1470  struct Serialize<0>
1471  {
1472  template <class Archive, typename... Args>
1473  static void
1474  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1475  {
1476  (void)ar;
1477  (void)t;
1478  (void)version;
1479  }
1480  };
1481 
1482  template <class Archive, typename... Args>
1483  void
1484  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1485  {
1486  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1487  }
1488  } // namespace serialization
1489 } // namespace boost
1490 #endif
1491 
1492 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1120
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:660
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:1119
static const unsigned int invalid_unsigned_int
Definition: types.h:187
Number truncate_to_n_digits(const Number number, const unsigned int n_digits)
Definition: utilities.cc:537
std::uint64_t pack_integers(const std::array< std::uint64_t, dim > &index, const int bits_per_dim)
Definition: utilities.cc:361
std::string type_to_string(const T &t)
Definition: utilities.h:1111
std::string dealii_version_string()
Definition: utilities.cc:89
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1244
std::string trim(const std::string &input)
Definition: utilities.cc:487
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:809
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:714
std::string decompress(const std::string &compressed_input)
Definition: utilities.cc:407
const Epetra_Comm & comm_self()
Definition: utilities.cc:1182
Definition: point.h:110
std::string get_date()
Definition: utilities.cc:1104
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:438
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:1039
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:797
double string_to_double(const std::string &s)
Definition: utilities.cc:612
double get_cpu_load()
Definition: utilities.cc:1005
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:1166
T fixed_power(const T t)
Definition: utilities.h:1090
static ::ExceptionBase & ExcMessage(std::string arg1)
std::string compress(const std::string &input)
Definition: utilities.cc:384
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:851
#define Assert(cond, exc)
Definition: exceptions.h:1411
constexpr unsigned int pow(const unsigned int base, const int iexp)
Definition: utilities.h:487
unsigned long int VmSize
Definition: utilities.h:879
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:794
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:886
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:429
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1227
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:468
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:514
std::vector< std::array< std::uint64_t, dim > > inverse_Hilbert_space_filling_curve(const std::vector< Point< dim, Number >> &points, const int bits_per_dim=64)
Definition: utilities.cc:140
void destroy_communicator(Epetra_Comm &communicator)
Definition: utilities.cc:1225
Definition: cuda.h:31
std::string get_hostname()
Definition: utilities.cc:1073
unsigned long int VmHWM
Definition: utilities.h:884
const Epetra_Comm & comm_world()
Definition: utilities.cc:1150
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1371
int string_to_int(const std::string &s)
Definition: utilities.cc:564
std::vector< unsigned int > reverse_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:872
unsigned long int VmRSS
Definition: utilities.h:890
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1251
const std::string get_current_vectorization_level()
Definition: utilities.cc:1013
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1259
std::string get_time()
Definition: utilities.cc:1088
unsigned long int VmPeak
Definition: utilities.h:874
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:524
static ::ExceptionBase & ExcInternalError()