Reference documentation for deal.II version Git 082d75bebd 2019-10-16 19:44:02 +0200
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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 
155  std::string
156  int_to_string(const unsigned int value,
157  const unsigned int digits = numbers::invalid_unsigned_int);
158 
169  template <typename number>
170  std::string
171  to_string(const number value,
172  const unsigned int digits = numbers::invalid_unsigned_int);
173 
178  unsigned int
179  needed_digits(const unsigned int max_number);
180 
185  int
186  string_to_int(const std::string &s);
187 
199  std::string
200  dim_string(const int dim, const int spacedim);
201 
206  std::vector<int>
207  string_to_int(const std::vector<std::string> &s);
208 
213  double
214  string_to_double(const std::string &s);
215 
216 
221  std::vector<double>
222  string_to_double(const std::vector<std::string> &s);
223 
224 
267  std::vector<std::string>
268  split_string_list(const std::string &s, const std::string &delimiter = ",");
269 
270 
275  std::vector<std::string>
276  split_string_list(const std::string &s, const char delimiter);
277 
278 
288  std::vector<std::string>
289  break_text_into_lines(const std::string &original_text,
290  const unsigned int width,
291  const char delimiter = ' ');
292 
297  bool
298  match_at_string_start(const std::string &name, const std::string &pattern);
299 
308  std::pair<int, unsigned int>
309  get_integer_at_position(const std::string &name, const unsigned int position);
310 
315  std::string
316  replace_in_string(const std::string &input,
317  const std::string &from,
318  const std::string &to);
319 
325  std::string
326  trim(const std::string &input);
327 
353  double
354  generate_normal_random_number(const double a, const double sigma);
355 
365  template <class T>
366  std::string
367  type_to_string(const T &t);
368 
377  template <int N, typename T>
378  T
379  fixed_power(const T t);
380 
405  template <int a, int N>
406  struct DEAL_II_DEPRECATED fixed_int_power
407  {
408  static const int value = a * fixed_int_power<a, N - 1>::value;
409  };
410 
418  template <int a>
419  struct DEAL_II_DEPRECATED fixed_int_power<a, 0>
420  {
421  static const int value = 1;
422  };
423 
429  constexpr unsigned int
430  pow(const unsigned int base, const int iexp)
431  {
432 #if defined(DEBUG) && defined(DEAL_II_WITH_CXX14) && \
433  defined(DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
434  // Up to __builtin_expect this is the same code as in the 'Assert' macro.
435  // The call to __builtin_expect turns out to be problematic.
436  if (!(iexp >= 0))
437  ::deal_II_exceptions::internals::issue_error_noreturn(
439  __FILE__,
440  __LINE__,
441  __PRETTY_FUNCTION__,
442  "iexp>=0",
443  "ExcMessage(\"The exponent must not be negative!\")",
444  ExcMessage("The exponent must not be negative!"));
445 #endif
446  // The "exponentiation by squaring" algorithm used below has to be
447  // compressed to one statement due to C++11's restrictions on constexpr
448  // functions. A more descriptive version would be:
449  //
450  // <code>
451  // if (iexp <= 0)
452  // return 1;
453  //
454  // // if the current exponent is not divisible by two,
455  // // we need to account for that.
456  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
457  //
458  // // a^b = (a*a)^(b/2) for b even
459  // // a^b = a*(a*a)^((b-1)/2 for b odd
460  // return prefactor * ::Utilities::pow(base*base, iexp/2);
461  // </code>
462 
463  return iexp <= 0 ? 1 :
464  (((iexp % 2 == 1) ? base : 1) *
465  ::Utilities::pow(base * base, iexp / 2));
466  }
467 
489  template <typename Iterator, typename T>
490  Iterator
491  lower_bound(Iterator first, Iterator last, const T &val);
492 
493 
499  template <typename Iterator, typename T, typename Comp>
500  Iterator
501  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
502 
508  std::vector<unsigned int>
509  reverse_permutation(const std::vector<unsigned int> &permutation);
510 
516  std::vector<unsigned int>
517  invert_permutation(const std::vector<unsigned int> &permutation);
518 
524  std::vector<unsigned long long int>
525  reverse_permutation(const std::vector<unsigned long long int> &permutation);
526 
532  std::vector<unsigned long long int>
533  invert_permutation(const std::vector<unsigned long long int> &permutation);
534 
552  template <typename T>
553  size_t
554  pack(const T & object,
555  std::vector<char> &dest_buffer,
556  const bool allow_compression = true);
557 
568  template <typename T>
569  std::vector<char>
570  pack(const T &object, const bool allow_compression = true);
571 
604  template <typename T>
605  T
606  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
607 
618  template <typename T>
619  T
620  unpack(const std::vector<char>::const_iterator &cbegin,
621  const std::vector<char>::const_iterator &cend,
622  const bool allow_compression = true);
623 
658  template <typename T, int N>
659  void
660  unpack(const std::vector<char> &buffer,
661  T (&unpacked_object)[N],
662  const bool allow_compression = true);
663 
674  template <typename T, int N>
675  void
676  unpack(const std::vector<char>::const_iterator &cbegin,
677  const std::vector<char>::const_iterator &cend,
678  T (&unpacked_object)[N],
679  const bool allow_compression = true);
680 
738  template <typename To, typename From>
739  std::unique_ptr<To>
740  dynamic_unique_cast(std::unique_ptr<From> &&p)
741  {
742  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
743  // and then release the pointer from the old
744  // owner
745  if (To *cast = dynamic_cast<To *>(p.get()))
746  {
747  std::unique_ptr<To> result(cast);
748  p.release();
749  return result;
750  }
751  else
752  throw std::bad_cast();
753  }
754 
760  namespace System
761  {
769  double
770  get_cpu_load();
771 
805  const std::string
807 
812  struct MemoryStats
813  {
817  unsigned long int VmPeak;
818 
822  unsigned long int VmSize;
823 
827  unsigned long int VmHWM;
828 
833  unsigned long int VmRSS;
834  };
835 
836 
841  void
843 
844 
848  std::string
849  get_hostname();
850 
851 
855  std::string
856  get_time();
857 
862  std::string
863  get_date();
864 
879  void
880  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
881  } // namespace System
882 
883 
884 #ifdef DEAL_II_WITH_TRILINOS
885 
890  namespace Trilinos
891  {
901  const Epetra_Comm &
902  comm_world();
903 
913  const Epetra_Comm &
914  comm_self();
915 
924  const Teuchos::RCP<const Teuchos::Comm<int>> &
926 
959  Epetra_Comm *
960  duplicate_communicator(const Epetra_Comm &communicator);
961 
984  void
985  destroy_communicator(Epetra_Comm &communicator);
986 
995  unsigned int
996  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
997 
1004  unsigned int
1005  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
1006 
1017  Epetra_Map
1018  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1019  } // namespace Trilinos
1020 
1021 #endif
1022 
1023 
1024 } // namespace Utilities
1025 
1026 
1027 // --------------------- inline functions
1028 
1029 namespace Utilities
1030 {
1031  template <int N, typename T>
1032  inline T
1033  fixed_power(const T x)
1034  {
1035  Assert(
1036  !std::is_integral<T>::value || (N >= 0),
1037  ExcMessage(
1038  "The non-type template parameter N must be a non-negative integer for integral type T"));
1039 
1040  if (N == 0)
1041  return T(1.);
1042  else if (N < 0)
1043  return T(1.) / fixed_power<-N>(x);
1044  else
1045  // Use exponentiation by squaring:
1046  return ((N % 2 == 1) ? x * fixed_power<N / 2>(x * x) :
1047  fixed_power<N / 2>(x * x));
1048  }
1049 
1050 
1051 
1052  template <class T>
1053  inline std::string
1054  type_to_string(const T &t)
1055  {
1056  return boost::core::demangle(typeid(t).name());
1057  }
1058 
1059 
1060 
1061  template <typename Iterator, typename T>
1062  inline Iterator
1063  lower_bound(Iterator first, Iterator last, const T &val)
1064  {
1065  return Utilities::lower_bound(first, last, val, std::less<T>());
1066  }
1067 
1068 
1069 
1070  template <typename Iterator, typename T, typename Comp>
1071  inline Iterator
1072  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1073  {
1074  // verify that the two iterators are properly ordered. since
1075  // we need operator- for the iterator type anyway, do the
1076  // test as follows, rather than via 'last >= first'
1077  Assert(last - first >= 0,
1078  ExcMessage(
1079  "The given iterators do not satisfy the proper ordering."));
1080 
1081  unsigned int len = static_cast<unsigned int>(last - first);
1082 
1083  if (len == 0)
1084  return first;
1085 
1086  while (true)
1087  {
1088  // if length equals 8 or less,
1089  // then do a rolled out
1090  // search. use a switch without
1091  // breaks for that and roll-out
1092  // the loop somehow
1093  if (len < 8)
1094  {
1095  switch (len)
1096  {
1097  case 7:
1098  if (!comp(*first, val))
1099  return first;
1100  ++first;
1101  DEAL_II_FALLTHROUGH;
1102  case 6:
1103  if (!comp(*first, val))
1104  return first;
1105  ++first;
1106  DEAL_II_FALLTHROUGH;
1107  case 5:
1108  if (!comp(*first, val))
1109  return first;
1110  ++first;
1111  DEAL_II_FALLTHROUGH;
1112  case 4:
1113  if (!comp(*first, val))
1114  return first;
1115  ++first;
1116  DEAL_II_FALLTHROUGH;
1117  case 3:
1118  if (!comp(*first, val))
1119  return first;
1120  ++first;
1121  DEAL_II_FALLTHROUGH;
1122  case 2:
1123  if (!comp(*first, val))
1124  return first;
1125  ++first;
1126  DEAL_II_FALLTHROUGH;
1127  case 1:
1128  if (!comp(*first, val))
1129  return first;
1130  return first + 1;
1131  default:
1132  // indices seem
1133  // to not be
1134  // sorted
1135  // correctly!? or
1136  // did len
1137  // become==0
1138  // somehow? that
1139  // shouldn't have
1140  // happened
1141  Assert(false, ExcInternalError());
1142  }
1143  }
1144 
1145 
1146 
1147  const unsigned int half = len >> 1;
1148  const Iterator middle = first + half;
1149 
1150  // if the value is larger than
1151  // that pointed to by the
1152  // middle pointer, then the
1153  // insertion point must be
1154  // right of it
1155  if (comp(*middle, val))
1156  {
1157  first = middle + 1;
1158  len -= half + 1;
1159  }
1160  else
1161  len = half;
1162  }
1163  }
1164 
1165 
1166  // --------------------- non-inline functions
1167 
1168  template <typename T>
1169  size_t
1170  pack(const T & object,
1171  std::vector<char> &dest_buffer,
1172  const bool allow_compression)
1173  {
1174  // the data is never compressed when we can't use zlib.
1175  (void)allow_compression;
1176 
1177  std::size_t size = 0;
1178 
1179  // see if the object is small and copyable via memcpy. if so, use
1180  // this fast path. otherwise, we have to go through the BOOST
1181  // serialization machinery
1182  //
1183  // we have to work around the fact that GCC 4.8.x claims to be C++
1184  // conforming, but is not actually as it does not implement
1185  // std::is_trivially_copyable.
1186 #if __GNUG__ && __GNUC__ < 5
1187  if (__has_trivial_copy(T) && sizeof(T) < 256)
1188 #else
1189 # ifdef DEAL_II_WITH_CXX17
1190  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1191 # else
1192  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1193 # endif
1194 #endif
1195  {
1196  const std::size_t previous_size = dest_buffer.size();
1197  dest_buffer.resize(previous_size + sizeof(T));
1198 
1199  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1200 
1201  size = sizeof(T);
1202  }
1203  else
1204  {
1205  // use buffer as the target of a compressing
1206  // stream into which we serialize the current object
1207  const std::size_t previous_size = dest_buffer.size();
1208 #ifdef DEAL_II_WITH_ZLIB
1209  if (allow_compression)
1210  {
1211  boost::iostreams::filtering_ostream out;
1212  out.push(
1213  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1214  boost::iostreams::gzip::default_compression)));
1215  out.push(boost::iostreams::back_inserter(dest_buffer));
1216 
1217  boost::archive::binary_oarchive archive(out);
1218  archive << object;
1219  out.flush();
1220  }
1221  else
1222 #endif
1223  {
1224  std::ostringstream out;
1225  boost::archive::binary_oarchive archive(out);
1226  archive << object;
1227 
1228  const std::string &s = out.str();
1229  dest_buffer.reserve(dest_buffer.size() + s.size());
1230  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1231  }
1232 
1233  size = dest_buffer.size() - previous_size;
1234  }
1235 
1236  return size;
1237  }
1238 
1239 
1240  template <typename T>
1241  std::vector<char>
1242  pack(const T &object, const bool allow_compression)
1243  {
1244  std::vector<char> buffer;
1245  pack<T>(object, buffer, allow_compression);
1246  return buffer;
1247  }
1248 
1249 
1250  template <typename T>
1251  T
1252  unpack(const std::vector<char>::const_iterator &cbegin,
1253  const std::vector<char>::const_iterator &cend,
1254  const bool allow_compression)
1255  {
1256  T object;
1257 
1258  // the data is never compressed when we can't use zlib.
1259  (void)allow_compression;
1260 
1261  // see if the object is small and copyable via memcpy. if so, use
1262  // this fast path. otherwise, we have to go through the BOOST
1263  // serialization machinery
1264  //
1265  // we have to work around the fact that GCC 4.8.x claims to be C++
1266  // conforming, but is not actually as it does not implement
1267  // std::is_trivially_copyable.
1268 #if __GNUG__ && __GNUC__ < 5
1269  if (__has_trivial_copy(T) && sizeof(T) < 256)
1270 #else
1271 # ifdef DEAL_II_WITH_CXX17
1272  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1273 # else
1274  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1275 # endif
1276 #endif
1277  {
1278  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1279  std::memcpy(&object, &*cbegin, sizeof(T));
1280  }
1281  else
1282  {
1283  std::string decompressed_buffer;
1284 
1285  // first decompress the buffer
1286 #ifdef DEAL_II_WITH_ZLIB
1287  if (allow_compression)
1288  {
1289  boost::iostreams::filtering_ostream decompressing_stream;
1290  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1291  decompressing_stream.push(
1292  boost::iostreams::back_inserter(decompressed_buffer));
1293  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1294  }
1295  else
1296 #endif
1297  {
1298  decompressed_buffer.assign(cbegin, cend);
1299  }
1300 
1301  // then restore the object from the buffer
1302  std::istringstream in(decompressed_buffer);
1303  boost::archive::binary_iarchive archive(in);
1304 
1305  archive >> object;
1306  }
1307 
1308  return object;
1309  }
1310 
1311 
1312  template <typename T>
1313  T
1314  unpack(const std::vector<char> &buffer, const bool allow_compression)
1315  {
1316  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1317  }
1318 
1319 
1320  template <typename T, int N>
1321  void
1322  unpack(const std::vector<char>::const_iterator &cbegin,
1323  const std::vector<char>::const_iterator &cend,
1324  T (&unpacked_object)[N],
1325  const bool allow_compression)
1326  {
1327  // see if the object is small and copyable via memcpy. if so, use
1328  // this fast path. otherwise, we have to go through the BOOST
1329  // serialization machinery
1330  //
1331  // we have to work around the fact that GCC 4.8.x claims to be C++
1332  // conforming, but is not actually as it does not implement
1333  // std::is_trivially_copyable.
1334  if (
1335 #if __GNUG__ && __GNUC__ < 5
1336  __has_trivial_copy(T)
1337 #else
1338  std::is_trivially_copyable<T>()
1339 #endif
1340  && sizeof(T) * N < 256)
1341  {
1342  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1343  ExcInternalError());
1344  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1345  }
1346  else
1347  {
1348  std::string decompressed_buffer;
1349 
1350  // first decompress the buffer
1351  (void)allow_compression;
1352 #ifdef DEAL_II_WITH_ZLIB
1353  if (allow_compression)
1354  {
1355  boost::iostreams::filtering_ostream decompressing_stream;
1356  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1357  decompressing_stream.push(
1358  boost::iostreams::back_inserter(decompressed_buffer));
1359  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1360  }
1361  else
1362 #endif
1363  {
1364  decompressed_buffer.assign(cbegin, cend);
1365  }
1366 
1367  // then restore the object from the buffer
1368  std::istringstream in(decompressed_buffer);
1369  boost::archive::binary_iarchive archive(in);
1370 
1371  archive >> unpacked_object;
1372  }
1373  }
1374 
1375 
1376  template <typename T, int N>
1377  void
1378  unpack(const std::vector<char> &buffer,
1379  T (&unpacked_object)[N],
1380  const bool allow_compression)
1381  {
1382  unpack<T, N>(buffer.cbegin(),
1383  buffer.cend(),
1384  unpacked_object,
1385  allow_compression);
1386  }
1387 
1388 } // namespace Utilities
1389 
1390 
1391 DEAL_II_NAMESPACE_CLOSE
1392 
1393 #ifndef DOXYGEN
1394 namespace boost
1395 {
1396  namespace serialization
1397  {
1398  // Provides boost and c++11 with a way to serialize tuples and pairs
1399  // automatically
1400  template <int N>
1401  struct Serialize
1402  {
1403  template <class Archive, typename... Args>
1404  static void
1405  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1406  {
1407  ar &std::get<N - 1>(t);
1408  Serialize<N - 1>::serialize(ar, t, version);
1409  }
1410  };
1411 
1412  template <>
1413  struct Serialize<0>
1414  {
1415  template <class Archive, typename... Args>
1416  static void
1417  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1418  {
1419  (void)ar;
1420  (void)t;
1421  (void)version;
1422  }
1423  };
1424 
1425  template <class Archive, typename... Args>
1426  void
1427  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1428  {
1429  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1430  }
1431  } // namespace serialization
1432 } // namespace boost
1433 #endif
1434 
1435 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1063
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:584
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:1043
static const unsigned int invalid_unsigned_int
Definition: types.h:187
std::uint64_t pack_integers(const std::array< std::uint64_t, dim > &index, const int bits_per_dim)
Definition: utilities.cc:360
std::string type_to_string(const T &t)
Definition: utilities.h:1054
std::string dealii_version_string()
Definition: utilities.cc:88
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1168
std::string trim(const std::string &input)
Definition: utilities.cc:430
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:733
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:638
const Epetra_Comm & comm_self()
Definition: utilities.cc:1106
Definition: point.h:110
std::string get_date()
Definition: utilities.cc:1028
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:392
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:963
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:740
double string_to_double(const std::string &s)
Definition: utilities.cc:536
double get_cpu_load()
Definition: utilities.cc:929
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:1090
T fixed_power(const T t)
Definition: utilities.h:1033
static ::ExceptionBase & ExcMessage(std::string arg1)
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:775
#define Assert(cond, exc)
Definition: exceptions.h:1407
constexpr unsigned int pow(const unsigned int base, const int iexp)
Definition: utilities.h:430
unsigned long int VmSize
Definition: utilities.h:822
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:718
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:810
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:383
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1170
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:411
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:457
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:139
void destroy_communicator(Epetra_Comm &communicator)
Definition: utilities.cc:1149
Definition: cuda.h:31
std::string get_hostname()
Definition: utilities.cc:997
unsigned long int VmHWM
Definition: utilities.h:827
const Epetra_Comm & comm_world()
Definition: utilities.cc:1074
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1314
int string_to_int(const std::string &s)
Definition: utilities.cc:488
std::vector< unsigned int > reverse_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:796
unsigned long int VmRSS
Definition: utilities.h:833
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1175
const std::string get_current_vectorization_level()
Definition: utilities.cc:937
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1183
std::string get_time()
Definition: utilities.cc:1012
unsigned long int VmPeak
Definition: utilities.h:817
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:467
static ::ExceptionBase & ExcInternalError()