Reference documentation for deal.II version Git 8f0f58a98a 2021-10-21 17:29:01 -0600
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
utilities.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2021 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 
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 
44 
45 #include <boost/archive/binary_iarchive.hpp>
46 #include <boost/archive/binary_oarchive.hpp>
47 #include <boost/core/demangle.hpp>
48 #include <boost/iostreams/device/array.hpp>
49 #include <boost/iostreams/device/back_inserter.hpp>
50 #include <boost/iostreams/filtering_streambuf.hpp>
51 #include <boost/serialization/array.hpp>
52 #include <boost/serialization/complex.hpp>
53 #include <boost/serialization/vector.hpp>
54 
55 #ifdef DEAL_II_WITH_ZLIB
56 # include <boost/iostreams/filter/gzip.hpp>
57 #endif
58 
60 
62 
63 // forward declare Point
64 #ifndef DOXYGEN
65 template <int dim, typename Number>
66 class Point;
67 #endif
68 
76 namespace Utilities
77 {
84  std::string
86 
103  template <int dim, typename Number>
104  std::vector<std::array<std::uint64_t, dim>>
106  const std::vector<Point<dim, Number>> &points,
107  const int bits_per_dim = 64);
108 
112  template <int dim>
113  std::vector<std::array<std::uint64_t, dim>>
115  const std::vector<std::array<std::uint64_t, dim>> &points,
116  const int bits_per_dim = 64);
117 
133  template <int dim>
134  std::uint64_t
135  pack_integers(const std::array<std::uint64_t, dim> &index,
136  const int bits_per_dim);
137 
150  std::string
151  compress(const std::string &input);
152 
166  std::string
167  decompress(const std::string &compressed_input);
168 
182  std::string
183  encode_base64(const std::vector<unsigned char> &binary_input);
184 
193  std::vector<unsigned char>
194  decode_base64(const std::string &base64_input);
195 
217  std::string
218  int_to_string(const unsigned int value,
219  const unsigned int digits = numbers::invalid_unsigned_int);
220 
232  template <typename number>
233  std::string
234  to_string(const number value,
235  const unsigned int digits = numbers::invalid_unsigned_int);
236 
241  unsigned int
242  needed_digits(const unsigned int max_number);
243 
252  template <typename Number>
253  Number
254  truncate_to_n_digits(const Number number, const unsigned int n_digits);
255 
260  int
261  string_to_int(const std::string &s);
262 
274  std::string
275  dim_string(const int dim, const int spacedim);
276 
281  std::vector<int>
282  string_to_int(const std::vector<std::string> &s);
283 
288  double
289  string_to_double(const std::string &s);
290 
291 
296  std::vector<double>
297  string_to_double(const std::vector<std::string> &s);
298 
299 
342  std::vector<std::string>
343  split_string_list(const std::string &s, const std::string &delimiter = ",");
344 
345 
350  std::vector<std::string>
351  split_string_list(const std::string &s, const char delimiter);
352 
353 
363  std::vector<std::string>
364  break_text_into_lines(const std::string &original_text,
365  const unsigned int width,
366  const char delimiter = ' ');
367 
372  bool
373  match_at_string_start(const std::string &name, const std::string &pattern);
374 
383  std::pair<int, unsigned int>
384  get_integer_at_position(const std::string &name, const unsigned int position);
385 
390  std::string
391  replace_in_string(const std::string &input,
392  const std::string &from,
393  const std::string &to);
394 
400  std::string
401  trim(const std::string &input);
402 
428  double
429  generate_normal_random_number(const double a, const double sigma);
430 
438  template <class T>
439  std::string
440  type_to_string(const T &t);
441 
450  template <int N, typename T>
451  T
452  fixed_power(const T t);
453 
459  template <typename T>
460  constexpr T
461  pow(const T base, const int iexp)
462  {
463 #if defined(DEBUG) && !defined(DEAL_II_CXX14_CONSTEXPR_BUG)
464  // Up to __builtin_expect this is the same code as in the 'Assert' macro.
465  // The call to __builtin_expect turns out to be problematic.
466  if (!(iexp >= 0))
469  abort_or_throw_on_exception,
470  __FILE__,
471  __LINE__,
472  __PRETTY_FUNCTION__,
473  "iexp>=0",
474  "ExcMessage(\"The exponent must not be negative!\")",
475  ExcMessage("The exponent must not be negative!"));
476 #endif
477  // The "exponentiation by squaring" algorithm used below has to be
478  // compressed to one statement due to C++11's restrictions on constexpr
479  // functions. A more descriptive version would be:
480  //
481  // <code>
482  // if (iexp <= 0)
483  // return 1;
484  //
485  // // avoid overflow of one additional recursion with pow(base * base, 0)
486  // if (iexp == 1)
487  // return base;
488  //
489  // // if the current exponent is not divisible by two,
490  // // we need to account for that.
491  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
492  //
493  // // a^b = (a*a)^(b/2) for b even
494  // // a^b = a*(a*a)^((b-1)/2 for b odd
495  // return prefactor * ::Utilities::pow(base*base, iexp/2);
496  // </code>
497 
498  static_assert(std::is_integral<T>::value, "Only integral types supported");
499 
500  return iexp <= 0 ?
501  1 :
502  (iexp == 1 ? base :
503  (((iexp % 2 == 1) ? base : 1) *
504  ::Utilities::pow(base * base, iexp / 2)));
505  }
506 
528  template <typename Iterator, typename T>
529  Iterator
530  lower_bound(Iterator first, Iterator last, const T &val);
531 
532 
538  template <typename Iterator, typename T, typename Comp>
539  Iterator
540  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
541 
547  template <typename Integer>
548  std::vector<Integer>
549  reverse_permutation(const std::vector<Integer> &permutation);
550 
556  template <typename Integer>
557  std::vector<Integer>
558  invert_permutation(const std::vector<Integer> &permutation);
559 
575  template <typename T>
576  size_t
577  pack(const T & object,
578  std::vector<char> &dest_buffer,
579  const bool allow_compression = true);
580 
589  template <typename T>
590  std::vector<char>
591  pack(const T &object, const bool allow_compression = true);
592 
623  template <typename T>
624  T
625  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
626 
635  template <typename T>
636  T
637  unpack(const std::vector<char>::const_iterator &cbegin,
638  const std::vector<char>::const_iterator &cend,
639  const bool allow_compression = true);
640 
673  template <typename T, int N>
674  void
675  unpack(const std::vector<char> &buffer,
676  T (&unpacked_object)[N],
677  const bool allow_compression = true);
678 
687  template <typename T, int N>
688  void
689  unpack(const std::vector<char>::const_iterator &cbegin,
690  const std::vector<char>::const_iterator &cend,
691  T (&unpacked_object)[N],
692  const bool allow_compression = true);
693 
697  bool
698  get_bit(const unsigned char number, const unsigned int n);
699 
700 
704  void
705  set_bit(unsigned char &number, const unsigned int n, const bool x);
706 
707 
765  template <typename To, typename From>
766  std::unique_ptr<To>
767  dynamic_unique_cast(std::unique_ptr<From> &&p);
768 
772  template <typename T>
773  T &
775 
779  template <typename T>
780  T &
781  get_underlying_value(std::shared_ptr<T> &p);
782 
786  template <typename T>
787  T &
788  get_underlying_value(const std::shared_ptr<T> &p);
789 
793  template <typename T>
794  T &
795  get_underlying_value(std::unique_ptr<T> &p);
796 
800  template <typename T>
801  T &
802  get_underlying_value(const std::unique_ptr<T> &p);
803 
809  namespace System
810  {
818  double
819  get_cpu_load();
820 
854  const std::string
856 
861  struct MemoryStats
862  {
866  unsigned long int VmPeak;
867 
871  unsigned long int VmSize;
872 
876  unsigned long int VmHWM;
877 
882  unsigned long int VmRSS;
883  };
884 
885 
890  void
892 
893 
897  std::string
898  get_hostname();
899 
900 
904  std::string
905  get_time();
906 
911  std::string
912  get_date();
913 
928  void
929  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
930  } // namespace System
931 
932 
933 #ifdef DEAL_II_WITH_TRILINOS
934 
939  namespace Trilinos
940  {
950  const Epetra_Comm &
951  comm_world();
952 
962  const Epetra_Comm &
963  comm_self();
964 
973  const Teuchos::RCP<const Teuchos::Comm<int>> &
975 
1008  Epetra_Comm *
1009  duplicate_communicator(const Epetra_Comm &communicator);
1010 
1033  void
1034  destroy_communicator(Epetra_Comm &communicator);
1035 
1044  unsigned int
1045  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
1046 
1053  unsigned int
1054  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
1055 
1066  Epetra_Map
1067  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1068  } // namespace Trilinos
1069 
1070 #endif
1071 
1072 
1073 } // namespace Utilities
1074 
1075 
1076 // --------------------- inline functions
1077 
1078 namespace Utilities
1079 {
1080  template <int N, typename T>
1081  inline T
1082  fixed_power(const T x)
1083  {
1084  Assert(
1085  !std::is_integral<T>::value || (N >= 0),
1086  ExcMessage(
1087  "The non-type template parameter N must be a non-negative integer for integral type T"));
1088 
1089  if (N == 0)
1090  return T(1.);
1091  else if (N < 0)
1092  return T(1.) / fixed_power<-N>(x);
1093  else
1094  // Use exponentiation by squaring:
1095  return ((N % 2 == 1) ? x * fixed_power<N / 2>(x * x) :
1096  fixed_power<N / 2>(x * x));
1097  }
1098 
1099 
1100 
1101  template <class T>
1102  inline std::string
1103  type_to_string(const T &t)
1104  {
1105  return boost::core::demangle(typeid(t).name());
1106  }
1107 
1108 
1109 
1110  template <typename Iterator, typename T>
1111  inline Iterator
1112  lower_bound(Iterator first, Iterator last, const T &val)
1113  {
1114  return Utilities::lower_bound(first, last, val, std::less<T>());
1115  }
1116 
1117 
1118 
1119  template <typename Iterator, typename T, typename Comp>
1120  inline Iterator
1121  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1122  {
1123  // verify that the two iterators are properly ordered. since
1124  // we need operator- for the iterator type anyway, do the
1125  // test as follows, rather than via 'last >= first'
1126  Assert(last - first >= 0,
1127  ExcMessage(
1128  "The given iterators do not satisfy the proper ordering."));
1129 
1130  unsigned int len = static_cast<unsigned int>(last - first);
1131 
1132  if (len == 0)
1133  return first;
1134 
1135  while (true)
1136  {
1137  // if length equals 8 or less,
1138  // then do a rolled out
1139  // search. use a switch without
1140  // breaks for that and roll-out
1141  // the loop somehow
1142  if (len < 8)
1143  {
1144  switch (len)
1145  {
1146  case 7:
1147  if (!comp(*first, val))
1148  return first;
1149  ++first;
1151  case 6:
1152  if (!comp(*first, val))
1153  return first;
1154  ++first;
1156  case 5:
1157  if (!comp(*first, val))
1158  return first;
1159  ++first;
1161  case 4:
1162  if (!comp(*first, val))
1163  return first;
1164  ++first;
1166  case 3:
1167  if (!comp(*first, val))
1168  return first;
1169  ++first;
1171  case 2:
1172  if (!comp(*first, val))
1173  return first;
1174  ++first;
1176  case 1:
1177  if (!comp(*first, val))
1178  return first;
1179  return first + 1;
1180  default:
1181  // indices seem
1182  // to not be
1183  // sorted
1184  // correctly!? or
1185  // did len
1186  // become==0
1187  // somehow? that
1188  // shouldn't have
1189  // happened
1190  Assert(false, ExcInternalError());
1191  }
1192  }
1193 
1194 
1195 
1196  const unsigned int half = len >> 1;
1197  const Iterator middle = first + half;
1198 
1199  // if the value is larger than
1200  // that pointed to by the
1201  // middle pointer, then the
1202  // insertion point must be
1203  // right of it
1204  if (comp(*middle, val))
1205  {
1206  first = middle + 1;
1207  len -= half + 1;
1208  }
1209  else
1210  len = half;
1211  }
1212  }
1213 
1214 
1215  // --------------------- non-inline functions
1216 
1217  template <typename T>
1218  size_t
1219  pack(const T & object,
1220  std::vector<char> &dest_buffer,
1221  const bool allow_compression)
1222  {
1223  std::size_t size = 0;
1224 
1225  // see if the object is small and copyable via memcpy. if so, use
1226  // this fast path. otherwise, we have to go through the BOOST
1227  // serialization machinery
1228 #ifdef DEAL_II_HAVE_CXX17
1229  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1230 #else
1231  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1232 #endif
1233  {
1234  (void)allow_compression;
1235  const std::size_t previous_size = dest_buffer.size();
1236  dest_buffer.resize(previous_size + sizeof(T));
1237 
1238  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1239 
1240  size = sizeof(T);
1241  }
1242  else
1243  {
1244  // use buffer as the target of a compressing
1245  // stream into which we serialize the current object
1246  const std::size_t previous_size = dest_buffer.size();
1247  {
1248  boost::iostreams::filtering_ostreambuf fosb;
1249 #ifdef DEAL_II_WITH_ZLIB
1250  if (allow_compression)
1251  fosb.push(boost::iostreams::gzip_compressor());
1252 #else
1253  (void)allow_compression;
1254 #endif
1255  fosb.push(boost::iostreams::back_inserter(dest_buffer));
1256 
1257  boost::archive::binary_oarchive boa(fosb);
1258  boa << object;
1259  // the stream object has to be destroyed before the return statement
1260  // to ensure that all data has been written in the buffer
1261  }
1262  size = dest_buffer.size() - previous_size;
1263  }
1264 
1265  return size;
1266  }
1267 
1268 
1269  template <typename T>
1270  std::vector<char>
1271  pack(const T &object, const bool allow_compression)
1272  {
1273  std::vector<char> buffer;
1274  pack<T>(object, buffer, allow_compression);
1275  return buffer;
1276  }
1277 
1278 
1279  template <typename T>
1280  T
1281  unpack(const std::vector<char>::const_iterator &cbegin,
1282  const std::vector<char>::const_iterator &cend,
1283  const bool allow_compression)
1284  {
1285  T object;
1286 
1287  // see if the object is small and copyable via memcpy. if so, use
1288  // this fast path. otherwise, we have to go through the BOOST
1289  // serialization machinery
1290 #ifdef DEAL_II_HAVE_CXX17
1291  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1292 #else
1293  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1294 #endif
1295  {
1296  (void)allow_compression;
1297  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1298  std::memcpy(&object, &*cbegin, sizeof(T));
1299  }
1300  else
1301  {
1302  // decompress the buffer section into the object
1303  boost::iostreams::filtering_istreambuf fisb;
1304 #ifdef DEAL_II_WITH_ZLIB
1305  if (allow_compression)
1306  fisb.push(boost::iostreams::gzip_decompressor());
1307 #else
1308  (void)allow_compression;
1309 #endif
1310  fisb.push(boost::iostreams::array_source(&*cbegin, &*cend));
1311 
1312  boost::archive::binary_iarchive bia(fisb);
1313  bia >> object;
1314  }
1315 
1316  return object;
1317  }
1318 
1319 
1320  template <typename T>
1321  T
1322  unpack(const std::vector<char> &buffer, const bool allow_compression)
1323  {
1324  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1325  }
1326 
1327 
1328  template <typename T, int N>
1329  void
1330  unpack(const std::vector<char>::const_iterator &cbegin,
1331  const std::vector<char>::const_iterator &cend,
1332  T (&unpacked_object)[N],
1333  const bool allow_compression)
1334  {
1335  // see if the object is small and copyable via memcpy. if so, use
1336  // this fast path. otherwise, we have to go through the BOOST
1337  // serialization machinery
1338 #ifdef DEAL_II_HAVE_CXX17
1339  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) * N < 256)
1340 #else
1341  if (std::is_trivially_copyable<T>() && sizeof(T) * N < 256)
1342 #endif
1343  {
1344  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1345  ExcInternalError());
1346  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1347  }
1348  else
1349  {
1350  // decompress the buffer section into the object
1351  boost::iostreams::filtering_istreambuf fisb;
1352 #ifdef DEAL_II_WITH_ZLIB
1353  if (allow_compression)
1354  fisb.push(boost::iostreams::gzip_decompressor());
1355 #else
1356  (void)allow_compression;
1357 #endif
1358  fisb.push(boost::iostreams::array_source(&*cbegin, &*cend));
1359 
1360  boost::archive::binary_iarchive bia(fisb);
1361  bia >> unpacked_object;
1362  }
1363  }
1364 
1365 
1366  template <typename T, int N>
1367  void
1368  unpack(const std::vector<char> &buffer,
1369  T (&unpacked_object)[N],
1370  const bool allow_compression)
1371  {
1372  unpack<T, N>(buffer.cbegin(),
1373  buffer.cend(),
1374  unpacked_object,
1375  allow_compression);
1376  }
1377 
1378 
1379 
1380  inline bool
1381  get_bit(const unsigned char number, const unsigned int n)
1382  {
1383  AssertIndexRange(n, 8);
1384 
1385  // source:
1386  // https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit
1387  // "Checking a bit"
1388  return (number >> n) & 1U;
1389  }
1390 
1391 
1392 
1393  inline void
1394  set_bit(unsigned char &number, const unsigned int n, const bool x)
1395  {
1396  AssertIndexRange(n, 8);
1397 
1398  // source:
1399  // https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit
1400  // "Changing the nth bit to x"
1401  number ^= (-static_cast<unsigned char>(x) ^ number) & (1U << n);
1402  }
1403 
1404 
1405 
1406  template <typename To, typename From>
1407  inline std::unique_ptr<To>
1408  dynamic_unique_cast(std::unique_ptr<From> &&p)
1409  {
1410  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
1411  // and then release the pointer from the old
1412  // owner
1413  if (To *cast = dynamic_cast<To *>(p.get()))
1414  {
1415  std::unique_ptr<To> result(cast);
1416  p.release();
1417  return result;
1418  }
1419  else
1420  throw std::bad_cast();
1421  }
1422 
1423 
1424 
1425  template <typename T>
1426  inline T &
1428  {
1429  return p;
1430  }
1431 
1432 
1433 
1434  template <typename T>
1435  inline T &
1436  get_underlying_value(std::shared_ptr<T> &p)
1437  {
1438  return *p;
1439  }
1440 
1441 
1442 
1443  template <typename T>
1444  inline T &
1445  get_underlying_value(const std::shared_ptr<T> &p)
1446  {
1447  return *p;
1448  }
1449 
1450 
1451 
1452  template <typename T>
1453  inline T &
1454  get_underlying_value(std::unique_ptr<T> &p)
1455  {
1456  return *p;
1457  }
1458 
1459 
1460 
1461  template <typename T>
1462  inline T &
1463  get_underlying_value(const std::unique_ptr<T> &p)
1464  {
1465  return *p;
1466  }
1467 
1468 
1469 
1470  template <typename Integer>
1471  std::vector<Integer>
1472  reverse_permutation(const std::vector<Integer> &permutation)
1473  {
1474  const std::size_t n = permutation.size();
1475 
1476  std::vector<Integer> out(n);
1477  for (std::size_t i = 0; i < n; ++i)
1478  out[i] = n - 1 - permutation[i];
1479 
1480  return out;
1481  }
1482 
1483 
1484 
1485  template <typename Integer>
1486  std::vector<Integer>
1487  invert_permutation(const std::vector<Integer> &permutation)
1488  {
1489  const std::size_t n = permutation.size();
1490 
1491  std::vector<Integer> out(n, numbers::invalid_unsigned_int);
1492 
1493  for (std::size_t i = 0; i < n; ++i)
1494  {
1495  AssertIndexRange(permutation[i], n);
1496  out[permutation[i]] = i;
1497  }
1498 
1499  // check that we have actually reached
1500  // all indices
1501  for (std::size_t i = 0; i < n; ++i)
1503  ExcMessage("The given input permutation had duplicate entries!"));
1504 
1505  return out;
1506  }
1507 } // namespace Utilities
1508 
1509 
1511 
1512 #ifndef DOXYGEN
1513 namespace boost
1514 {
1515  namespace serialization
1516  {
1517  // Provides boost and c++11 with a way to serialize tuples and pairs
1518  // automatically.
1519  template <int N>
1520  struct Serialize
1521  {
1522  template <class Archive, typename... Args>
1523  static void
1524  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1525  {
1526  ar &std::get<N - 1>(t);
1527  Serialize<N - 1>::serialize(ar, t, version);
1528  }
1529  };
1530 
1531  template <>
1532  struct Serialize<0>
1533  {
1534  template <class Archive, typename... Args>
1535  static void
1536  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1537  {
1538  (void)ar;
1539  (void)t;
1540  (void)version;
1541  }
1542  };
1543 
1544  template <class Archive, typename... Args>
1545  void
1546  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1547  {
1548  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1549  }
1550  } // namespace serialization
1551 } // namespace boost
1552 #endif
1553 
1554 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1112
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:704
std::string encode_base64(const std::vector< unsigned char > &binary_input)
Definition: utilities.cc:436
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:1050
static const unsigned int invalid_unsigned_int
Definition: types.h:196
Number truncate_to_n_digits(const Number number, const unsigned int n_digits)
Definition: utilities.cc:581
std::uint64_t pack_integers(const std::array< std::uint64_t, dim > &index, const int bits_per_dim)
Definition: utilities.cc:369
std::string type_to_string(const T &t)
Definition: utilities.h:1103
std::vector< unsigned char > decode_base64(const std::string &base64_input)
Definition: utilities.cc:449
std::string dealii_version_string()
Definition: utilities.cc:97
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1175
std::string trim(const std::string &input)
Definition: utilities.cc:531
T & get_underlying_value(T &p)
Definition: utilities.h:1427
#define AssertIndexRange(index, range)
Definition: exceptions.h:1720
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:853
std::vector< Integer > reverse_permutation(const std::vector< Integer > &permutation)
Definition: utilities.h:1472
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:758
static const char U
std::string decompress(const std::string &compressed_input)
Definition: utilities.cc:414
const Epetra_Comm & comm_self()
Definition: utilities.cc:1113
Definition: point.h:110
std::string get_date()
Definition: utilities.cc:1035
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:482
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:970
constexpr T pow(const T base, const int iexp)
Definition: utilities.h:461
double string_to_double(const std::string &s)
Definition: utilities.cc:656
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:414
double get_cpu_load()
Definition: utilities.cc:936
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:1097
T fixed_power(const T t)
Definition: utilities.h:1082
static ::ExceptionBase & ExcMessage(std::string arg1)
std::string compress(const std::string &input)
Definition: utilities.cc:392
Epetra_Comm * duplicate_communicator(const Epetra_Comm &communicator)
Definition: utilities.cc:1129
static const char T
void set_bit(unsigned char &number, const unsigned int n, const bool x)
Definition: utilities.h:1394
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:895
#define Assert(cond, exc)
Definition: exceptions.h:1461
unsigned long int VmSize
Definition: utilities.h:871
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:838
std::vector< Integer > invert_permutation(const std::vector< Integer > &permutation)
Definition: utilities.h:1487
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:473
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1219
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:512
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:558
Point< 2 > first
Definition: grid_out.cc:4586
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:148
void destroy_communicator(Epetra_Comm &communicator)
Definition: utilities.cc:1156
void issue_error_noreturn(ExceptionHandling handling, const char *file, int line, const char *function, const char *cond, const char *exc_name, ExceptionType e)
Definition: exceptions.h:1346
std::string get_hostname()
Definition: utilities.cc:1004
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:1408
unsigned long int VmHWM
Definition: utilities.h:876
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:452
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
const Epetra_Comm & comm_world()
Definition: utilities.cc:1081
static const char N
const MPI_Comm & comm
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1322
int string_to_int(const std::string &s)
Definition: utilities.cc:608
unsigned long int VmRSS
Definition: utilities.h:882
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1182
const std::string get_current_vectorization_level()
Definition: utilities.cc:944
#define DEAL_II_FALLTHROUGH
Definition: config.h:172
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1190
std::string get_time()
Definition: utilities.cc:1019
unsigned long int VmPeak
Definition: utilities.h:866
bool get_bit(const unsigned char number, const unsigned int n)
Definition: utilities.h:1381
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:568
static ::ExceptionBase & ExcInternalError()