Reference documentation for deal.II version Git 953c9590e9 2020-10-28 17:25:14 -0400
\(\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 - 2020 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/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 
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  __FILE__,
470  __LINE__,
471  __PRETTY_FUNCTION__,
472  "iexp>=0",
473  "ExcMessage(\"The exponent must not be negative!\")",
474  ExcMessage("The exponent must not be negative!"));
475 #endif
476  // The "exponentiation by squaring" algorithm used below has to be
477  // compressed to one statement due to C++11's restrictions on constexpr
478  // functions. A more descriptive version would be:
479  //
480  // <code>
481  // if (iexp <= 0)
482  // return 1;
483  //
484  // // avoid overflow of one additional recursion with pow(base * base, 0)
485  // if (iexp == 1)
486  // return base;
487  //
488  // // if the current exponent is not divisible by two,
489  // // we need to account for that.
490  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
491  //
492  // // a^b = (a*a)^(b/2) for b even
493  // // a^b = a*(a*a)^((b-1)/2 for b odd
494  // return prefactor * ::Utilities::pow(base*base, iexp/2);
495  // </code>
496 
497  static_assert(std::is_integral<T>::value, "Only integral types supported");
498 
499  return iexp <= 0 ?
500  1 :
501  (iexp == 1 ? base :
502  (((iexp % 2 == 1) ? base : 1) *
503  ::Utilities::pow(base * base, iexp / 2)));
504  }
505 
527  template <typename Iterator, typename T>
528  Iterator
529  lower_bound(Iterator first, Iterator last, const T &val);
530 
531 
537  template <typename Iterator, typename T, typename Comp>
538  Iterator
539  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
540 
546  template <typename Integer>
547  std::vector<Integer>
548  reverse_permutation(const std::vector<Integer> &permutation);
549 
555  template <typename Integer>
556  std::vector<Integer>
557  invert_permutation(const std::vector<Integer> &permutation);
558 
574  template <typename T>
575  size_t
576  pack(const T & object,
577  std::vector<char> &dest_buffer,
578  const bool allow_compression = true);
579 
588  template <typename T>
589  std::vector<char>
590  pack(const T &object, const bool allow_compression = true);
591 
622  template <typename T>
623  T
624  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
625 
634  template <typename T>
635  T
636  unpack(const std::vector<char>::const_iterator &cbegin,
637  const std::vector<char>::const_iterator &cend,
638  const bool allow_compression = true);
639 
672  template <typename T, int N>
673  void
674  unpack(const std::vector<char> &buffer,
675  T (&unpacked_object)[N],
676  const bool allow_compression = true);
677 
686  template <typename T, int N>
687  void
688  unpack(const std::vector<char>::const_iterator &cbegin,
689  const std::vector<char>::const_iterator &cend,
690  T (&unpacked_object)[N],
691  const bool allow_compression = true);
692 
750  template <typename To, typename From>
751  std::unique_ptr<To>
752  dynamic_unique_cast(std::unique_ptr<From> &&p)
753  {
754  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
755  // and then release the pointer from the old
756  // owner
757  if (To *cast = dynamic_cast<To *>(p.get()))
758  {
759  std::unique_ptr<To> result(cast);
760  p.release();
761  return result;
762  }
763  else
764  throw std::bad_cast();
765  }
766 
772  namespace System
773  {
781  double
782  get_cpu_load();
783 
817  const std::string
819 
824  struct MemoryStats
825  {
829  unsigned long int VmPeak;
830 
834  unsigned long int VmSize;
835 
839  unsigned long int VmHWM;
840 
845  unsigned long int VmRSS;
846  };
847 
848 
853  void
855 
856 
860  std::string
861  get_hostname();
862 
863 
867  std::string
868  get_time();
869 
874  std::string
875  get_date();
876 
891  void
892  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
893  } // namespace System
894 
895 
896 #ifdef DEAL_II_WITH_TRILINOS
897 
902  namespace Trilinos
903  {
913  const Epetra_Comm &
914  comm_world();
915 
925  const Epetra_Comm &
926  comm_self();
927 
936  const Teuchos::RCP<const Teuchos::Comm<int>> &
938 
971  Epetra_Comm *
972  duplicate_communicator(const Epetra_Comm &communicator);
973 
996  void
997  destroy_communicator(Epetra_Comm &communicator);
998 
1007  unsigned int
1008  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
1009 
1016  unsigned int
1017  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
1018 
1029  Epetra_Map
1030  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1031  } // namespace Trilinos
1032 
1033 #endif
1034 
1035 
1036 } // namespace Utilities
1037 
1038 
1039 // --------------------- inline functions
1040 
1041 namespace Utilities
1042 {
1043  template <int N, typename T>
1044  inline T
1045  fixed_power(const T x)
1046  {
1047  Assert(
1048  !std::is_integral<T>::value || (N >= 0),
1049  ExcMessage(
1050  "The non-type template parameter N must be a non-negative integer for integral type T"));
1051 
1052  if (N == 0)
1053  return T(1.);
1054  else if (N < 0)
1055  return T(1.) / fixed_power<-N>(x);
1056  else
1057  // Use exponentiation by squaring:
1058  return ((N % 2 == 1) ? x * fixed_power<N / 2>(x * x) :
1059  fixed_power<N / 2>(x * x));
1060  }
1061 
1062 
1063 
1064  template <class T>
1065  inline std::string
1066  type_to_string(const T &t)
1067  {
1068  return boost::core::demangle(typeid(t).name());
1069  }
1070 
1071 
1072 
1073  template <typename Iterator, typename T>
1074  inline Iterator
1075  lower_bound(Iterator first, Iterator last, const T &val)
1076  {
1077  return Utilities::lower_bound(first, last, val, std::less<T>());
1078  }
1079 
1080 
1081 
1082  template <typename Iterator, typename T, typename Comp>
1083  inline Iterator
1084  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1085  {
1086  // verify that the two iterators are properly ordered. since
1087  // we need operator- for the iterator type anyway, do the
1088  // test as follows, rather than via 'last >= first'
1089  Assert(last - first >= 0,
1090  ExcMessage(
1091  "The given iterators do not satisfy the proper ordering."));
1092 
1093  unsigned int len = static_cast<unsigned int>(last - first);
1094 
1095  if (len == 0)
1096  return first;
1097 
1098  while (true)
1099  {
1100  // if length equals 8 or less,
1101  // then do a rolled out
1102  // search. use a switch without
1103  // breaks for that and roll-out
1104  // the loop somehow
1105  if (len < 8)
1106  {
1107  switch (len)
1108  {
1109  case 7:
1110  if (!comp(*first, val))
1111  return first;
1112  ++first;
1114  case 6:
1115  if (!comp(*first, val))
1116  return first;
1117  ++first;
1119  case 5:
1120  if (!comp(*first, val))
1121  return first;
1122  ++first;
1124  case 4:
1125  if (!comp(*first, val))
1126  return first;
1127  ++first;
1129  case 3:
1130  if (!comp(*first, val))
1131  return first;
1132  ++first;
1134  case 2:
1135  if (!comp(*first, val))
1136  return first;
1137  ++first;
1139  case 1:
1140  if (!comp(*first, val))
1141  return first;
1142  return first + 1;
1143  default:
1144  // indices seem
1145  // to not be
1146  // sorted
1147  // correctly!? or
1148  // did len
1149  // become==0
1150  // somehow? that
1151  // shouldn't have
1152  // happened
1153  Assert(false, ExcInternalError());
1154  }
1155  }
1156 
1157 
1158 
1159  const unsigned int half = len >> 1;
1160  const Iterator middle = first + half;
1161 
1162  // if the value is larger than
1163  // that pointed to by the
1164  // middle pointer, then the
1165  // insertion point must be
1166  // right of it
1167  if (comp(*middle, val))
1168  {
1169  first = middle + 1;
1170  len -= half + 1;
1171  }
1172  else
1173  len = half;
1174  }
1175  }
1176 
1177 
1178  // --------------------- non-inline functions
1179 
1180  template <typename T>
1181  size_t
1182  pack(const T & object,
1183  std::vector<char> &dest_buffer,
1184  const bool allow_compression)
1185  {
1186  // the data is never compressed when we can't use zlib.
1187  (void)allow_compression;
1188 
1189  std::size_t size = 0;
1190 
1191  // see if the object is small and copyable via memcpy. if so, use
1192  // this fast path. otherwise, we have to go through the BOOST
1193  // serialization machinery
1194  //
1195  // we have to work around the fact that GCC 4.8.x claims to be C++
1196  // conforming, but is not actually as it does not implement
1197  // std::is_trivially_copyable.
1198 #if __GNUG__ && __GNUC__ < 5
1199  if (__has_trivial_copy(T) && sizeof(T) < 256)
1200 #else
1201 # ifdef DEAL_II_HAVE_CXX17
1202  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1203 # else
1204  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1205 # endif
1206 #endif
1207  {
1208  const std::size_t previous_size = dest_buffer.size();
1209  dest_buffer.resize(previous_size + sizeof(T));
1210 
1211  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1212 
1213  size = sizeof(T);
1214  }
1215  else
1216  {
1217  // use buffer as the target of a compressing
1218  // stream into which we serialize the current object
1219  const std::size_t previous_size = dest_buffer.size();
1220 #ifdef DEAL_II_WITH_ZLIB
1221  if (allow_compression)
1222  {
1223  boost::iostreams::filtering_ostream out;
1224  out.push(
1225  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1226  boost::iostreams::gzip::default_compression)));
1227  out.push(boost::iostreams::back_inserter(dest_buffer));
1228 
1229  boost::archive::binary_oarchive archive(out);
1230  archive << object;
1231  out.flush();
1232  }
1233  else
1234 #endif
1235  {
1236  std::ostringstream out;
1237  boost::archive::binary_oarchive archive(out);
1238  archive << object;
1239 
1240  const std::string s = out.str();
1241  dest_buffer.reserve(dest_buffer.size() + s.size());
1242  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1243  }
1244 
1245  size = dest_buffer.size() - previous_size;
1246  }
1247 
1248  return size;
1249  }
1250 
1251 
1252  template <typename T>
1253  std::vector<char>
1254  pack(const T &object, const bool allow_compression)
1255  {
1256  std::vector<char> buffer;
1257  pack<T>(object, buffer, allow_compression);
1258  return buffer;
1259  }
1260 
1261 
1262  template <typename T>
1263  T
1264  unpack(const std::vector<char>::const_iterator &cbegin,
1265  const std::vector<char>::const_iterator &cend,
1266  const bool allow_compression)
1267  {
1268  T object;
1269 
1270  // the data is never compressed when we can't use zlib.
1271  (void)allow_compression;
1272 
1273  // see if the object is small and copyable via memcpy. if so, use
1274  // this fast path. otherwise, we have to go through the BOOST
1275  // serialization machinery
1276  //
1277  // we have to work around the fact that GCC 4.8.x claims to be C++
1278  // conforming, but is not actually as it does not implement
1279  // std::is_trivially_copyable.
1280 #if __GNUG__ && __GNUC__ < 5
1281  if (__has_trivial_copy(T) && sizeof(T) < 256)
1282 #else
1283 # ifdef DEAL_II_HAVE_CXX17
1284  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1285 # else
1286  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1287 # endif
1288 #endif
1289  {
1290  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1291  std::memcpy(&object, &*cbegin, sizeof(T));
1292  }
1293  else
1294  {
1295  std::string decompressed_buffer;
1296 
1297  // first decompress the buffer
1298 #ifdef DEAL_II_WITH_ZLIB
1299  if (allow_compression)
1300  {
1301  boost::iostreams::filtering_ostream decompressing_stream;
1302  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1303  decompressing_stream.push(
1304  boost::iostreams::back_inserter(decompressed_buffer));
1305  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1306  }
1307  else
1308 #endif
1309  {
1310  decompressed_buffer.assign(cbegin, cend);
1311  }
1312 
1313  // then restore the object from the buffer
1314  std::istringstream in(decompressed_buffer);
1315  boost::archive::binary_iarchive archive(in);
1316 
1317  archive >> object;
1318  }
1319 
1320  return object;
1321  }
1322 
1323 
1324  template <typename T>
1325  T
1326  unpack(const std::vector<char> &buffer, const bool allow_compression)
1327  {
1328  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1329  }
1330 
1331 
1332  template <typename T, int N>
1333  void
1334  unpack(const std::vector<char>::const_iterator &cbegin,
1335  const std::vector<char>::const_iterator &cend,
1336  T (&unpacked_object)[N],
1337  const bool allow_compression)
1338  {
1339  // see if the object is small and copyable via memcpy. if so, use
1340  // this fast path. otherwise, we have to go through the BOOST
1341  // serialization machinery
1342  //
1343  // we have to work around the fact that GCC 4.8.x claims to be C++
1344  // conforming, but is not actually as it does not implement
1345  // std::is_trivially_copyable.
1346  if (
1347 #if __GNUG__ && __GNUC__ < 5
1348  __has_trivial_copy(T)
1349 #else
1350  std::is_trivially_copyable<T>()
1351 #endif
1352  && sizeof(T) * N < 256)
1353  {
1354  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1355  ExcInternalError());
1356  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1357  }
1358  else
1359  {
1360  std::string decompressed_buffer;
1361 
1362  // first decompress the buffer
1363  (void)allow_compression;
1364 #ifdef DEAL_II_WITH_ZLIB
1365  if (allow_compression)
1366  {
1367  boost::iostreams::filtering_ostream decompressing_stream;
1368  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1369  decompressing_stream.push(
1370  boost::iostreams::back_inserter(decompressed_buffer));
1371  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1372  }
1373  else
1374 #endif
1375  {
1376  decompressed_buffer.assign(cbegin, cend);
1377  }
1378 
1379  // then restore the object from the buffer
1380  std::istringstream in(decompressed_buffer);
1381  boost::archive::binary_iarchive archive(in);
1382 
1383  archive >> unpacked_object;
1384  }
1385  }
1386 
1387 
1388  template <typename T, int N>
1389  void
1390  unpack(const std::vector<char> &buffer,
1391  T (&unpacked_object)[N],
1392  const bool allow_compression)
1393  {
1394  unpack<T, N>(buffer.cbegin(),
1395  buffer.cend(),
1396  unpacked_object,
1397  allow_compression);
1398  }
1399 
1400 
1401 
1402  template <typename Integer>
1403  std::vector<Integer>
1404  reverse_permutation(const std::vector<Integer> &permutation)
1405  {
1406  const std::size_t n = permutation.size();
1407 
1408  std::vector<Integer> out(n);
1409  for (std::size_t i = 0; i < n; ++i)
1410  out[i] = n - 1 - permutation[i];
1411 
1412  return out;
1413  }
1414 
1415 
1416 
1417  template <typename Integer>
1418  std::vector<Integer>
1419  invert_permutation(const std::vector<Integer> &permutation)
1420  {
1421  const std::size_t n = permutation.size();
1422 
1423  std::vector<Integer> out(n, numbers::invalid_unsigned_int);
1424 
1425  for (std::size_t i = 0; i < n; ++i)
1426  {
1427  AssertIndexRange(permutation[i], n);
1428  out[permutation[i]] = i;
1429  }
1430 
1431  // check that we have actually reached
1432  // all indices
1433  for (std::size_t i = 0; i < n; ++i)
1435  ExcMessage("The given input permutation had duplicate entries!"));
1436 
1437  return out;
1438  }
1439 } // namespace Utilities
1440 
1441 
1443 
1444 #ifndef DOXYGEN
1445 namespace boost
1446 {
1447  namespace serialization
1448  {
1449  // Provides boost and c++11 with a way to serialize tuples and pairs
1450  // automatically
1451  template <int N>
1452  struct Serialize
1453  {
1454  template <class Archive, typename... Args>
1455  static void
1456  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1457  {
1458  ar &std::get<N - 1>(t);
1459  Serialize<N - 1>::serialize(ar, t, version);
1460  }
1461  };
1462 
1463  template <>
1464  struct Serialize<0>
1465  {
1466  template <class Archive, typename... Args>
1467  static void
1468  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1469  {
1470  (void)ar;
1471  (void)t;
1472  (void)version;
1473  }
1474  };
1475 
1476  template <class Archive, typename... Args>
1477  void
1478  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1479  {
1480  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1481  }
1482  } // namespace serialization
1483 } // namespace boost
1484 #endif
1485 
1486 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1075
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:705
std::string encode_base64(const std::vector< unsigned char > &binary_input)
Definition: utilities.cc:437
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:1051
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:582
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:1066
std::vector< unsigned char > decode_base64(const std::string &base64_input)
Definition: utilities.cc:450
std::string dealii_version_string()
Definition: utilities.cc:97
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1176
std::string trim(const std::string &input)
Definition: utilities.cc:532
#define AssertIndexRange(index, range)
Definition: exceptions.h:1648
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:854
std::vector< Integer > reverse_permutation(const std::vector< Integer > &permutation)
Definition: utilities.h:1404
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:759
std::string decompress(const std::string &compressed_input)
Definition: utilities.cc:415
const Epetra_Comm & comm_self()
Definition: utilities.cc:1114
Definition: point.h:110
std::string get_date()
Definition: utilities.cc:1036
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:483
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:971
constexpr T pow(const T base, const int iexp)
Definition: utilities.h:461
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:752
double string_to_double(const std::string &s)
Definition: utilities.cc:657
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:382
double get_cpu_load()
Definition: utilities.cc:937
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:1098
T fixed_power(const T t)
Definition: utilities.h:1045
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:1130
static const char T
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:896
#define Assert(cond, exc)
Definition: exceptions.h:1423
unsigned long int VmSize
Definition: utilities.h:834
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:369
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:839
std::vector< Integer > invert_permutation(const std::vector< Integer > &permutation)
Definition: utilities.h:1419
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:474
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1182
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:513
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:559
Point< 2 > first
Definition: grid_out.cc:4334
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:1157
Definition: cuda.h:32
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:1310
*braid_SplitCommworld & comm
std::string get_hostname()
Definition: utilities.cc:1005
unsigned long int VmHWM
Definition: utilities.h:839
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:419
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:368
const Epetra_Comm & comm_world()
Definition: utilities.cc:1082
static const char N
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1326
int string_to_int(const std::string &s)
Definition: utilities.cc:609
unsigned long int VmRSS
Definition: utilities.h:845
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1183
const std::string get_current_vectorization_level()
Definition: utilities.cc:945
#define DEAL_II_FALLTHROUGH
Definition: config.h:153
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1191
std::string get_time()
Definition: utilities.cc:1020
unsigned long int VmPeak
Definition: utilities.h:829
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:569
static ::ExceptionBase & ExcInternalError()