Reference documentation for deal.II version 9.1.1
\(\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 template <int dim, typename Number>
65 class Point;
66 
75 namespace Utilities
76 {
83  std::string
85 
102  template <int dim, typename Number>
103  std::vector<std::array<std::uint64_t, dim>>
105  const std::vector<Point<dim, Number>> &points,
106  const int bits_per_dim = 64);
107 
111  template <int dim>
112  std::vector<std::array<std::uint64_t, dim>>
114  const std::vector<std::array<std::uint64_t, dim>> &points,
115  const int bits_per_dim = 64);
116 
132  template <int dim>
133  std::uint64_t
134  pack_integers(const std::array<std::uint64_t, dim> &index,
135  const int bits_per_dim);
136 
153  std::string
154  int_to_string(const unsigned int value,
155  const unsigned int digits = numbers::invalid_unsigned_int);
156 
167  template <typename number>
168  std::string
169  to_string(const number value,
170  const unsigned int digits = numbers::invalid_unsigned_int);
171 
176  unsigned int
177  needed_digits(const unsigned int max_number);
178 
183  int
184  string_to_int(const std::string &s);
185 
197  std::string
198  dim_string(const int dim, const int spacedim);
199 
204  std::vector<int>
205  string_to_int(const std::vector<std::string> &s);
206 
211  double
212  string_to_double(const std::string &s);
213 
214 
219  std::vector<double>
220  string_to_double(const std::vector<std::string> &s);
221 
222 
265  std::vector<std::string>
266  split_string_list(const std::string &s, const std::string &delimiter = ",");
267 
268 
273  std::vector<std::string>
274  split_string_list(const std::string &s, const char delimiter);
275 
276 
286  std::vector<std::string>
287  break_text_into_lines(const std::string &original_text,
288  const unsigned int width,
289  const char delimiter = ' ');
290 
295  bool
296  match_at_string_start(const std::string &name, const std::string &pattern);
297 
306  std::pair<int, unsigned int>
307  get_integer_at_position(const std::string &name, const unsigned int position);
308 
313  std::string
314  replace_in_string(const std::string &input,
315  const std::string &from,
316  const std::string &to);
317 
323  std::string
324  trim(const std::string &input);
325 
351  double
352  generate_normal_random_number(const double a, const double sigma);
353 
363  template <class T>
364  std::string
365  type_to_string(const T &t);
366 
375  template <int N, typename T>
376  T
377  fixed_power(const T t);
378 
403  template <int a, int N>
404  struct DEAL_II_DEPRECATED fixed_int_power
405  {
406  static const int value = a * fixed_int_power<a, N - 1>::value;
407  };
408 
416  template <int a>
417  struct DEAL_II_DEPRECATED fixed_int_power<a, 0>
418  {
419  static const int value = 1;
420  };
421 
427  constexpr unsigned int
428  pow(const unsigned int base, const int iexp)
429  {
430 #if defined(DEBUG) && defined(DEAL_II_WITH_CXX14) && \
431  defined(DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
432  // Up to __builtin_expect this is the same code as in the 'Assert' macro.
433  // The call to __builtin_expect turns out to be problematic.
434  if (!(iexp >= 0))
435  ::deal_II_exceptions::internals::issue_error_noreturn(
437  __FILE__,
438  __LINE__,
439  __PRETTY_FUNCTION__,
440  "iexp>=0",
441  "ExcMessage(\"The exponent must not be negative!\")",
442  ExcMessage("The exponent must not be negative!"));
443 #endif
444  // The "exponentiation by squaring" algorithm used below has to be
445  // compressed to one statement due to C++11's restrictions on constexpr
446  // functions. A more descriptive version would be:
447  //
448  // <code>
449  // if (iexp <= 0)
450  // return 1;
451  //
452  // // if the current exponent is not divisible by two,
453  // // we need to account for that.
454  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
455  //
456  // // a^b = (a*a)^(b/2) for b evenb
457  // // a^b = a*(a*a)^((b-1)/2 for b odd
458  // return prefactor * ::Utilities::pow(base*base, iexp/2);
459  // </code>
460 
461  return iexp <= 0 ? 1 :
462  (((iexp % 2 == 1) ? base : 1) *
463  ::Utilities::pow(base * base, iexp / 2));
464  }
465 
487  template <typename Iterator, typename T>
488  Iterator
489  lower_bound(Iterator first, Iterator last, const T &val);
490 
491 
497  template <typename Iterator, typename T, typename Comp>
498  Iterator
499  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
500 
506  std::vector<unsigned int>
507  reverse_permutation(const std::vector<unsigned int> &permutation);
508 
514  std::vector<unsigned int>
515  invert_permutation(const std::vector<unsigned int> &permutation);
516 
522  std::vector<unsigned long long int>
523  reverse_permutation(const std::vector<unsigned long long int> &permutation);
524 
530  std::vector<unsigned long long int>
531  invert_permutation(const std::vector<unsigned long long int> &permutation);
532 
550  template <typename T>
551  size_t
552  pack(const T & object,
553  std::vector<char> &dest_buffer,
554  const bool allow_compression = true);
555 
566  template <typename T>
567  std::vector<char>
568  pack(const T &object, const bool allow_compression = true);
569 
602  template <typename T>
603  T
604  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
605 
616  template <typename T>
617  T
618  unpack(const std::vector<char>::const_iterator &cbegin,
619  const std::vector<char>::const_iterator &cend,
620  const bool allow_compression = true);
621 
656  template <typename T, int N>
657  void
658  unpack(const std::vector<char> &buffer,
659  T (&unpacked_object)[N],
660  const bool allow_compression = true);
661 
672  template <typename T, int N>
673  void
674  unpack(const std::vector<char>::const_iterator &cbegin,
675  const std::vector<char>::const_iterator &cend,
676  T (&unpacked_object)[N],
677  const bool allow_compression = true);
678 
736  template <typename To, typename From>
737  std::unique_ptr<To>
738  dynamic_unique_cast(std::unique_ptr<From> &&p)
739  {
740  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
741  // and then release the pointer from the old
742  // owner
743  if (To *cast = dynamic_cast<To *>(p.get()))
744  {
745  std::unique_ptr<To> result(cast);
746  p.release();
747  return result;
748  }
749  else
750  throw std::bad_cast();
751  }
752 
758  namespace System
759  {
767  double
768  get_cpu_load();
769 
803  const std::string
805 
810  struct MemoryStats
811  {
815  unsigned long int VmPeak;
816 
820  unsigned long int VmSize;
821 
825  unsigned long int VmHWM;
826 
831  unsigned long int VmRSS;
832  };
833 
834 
839  void
841 
842 
846  std::string
847  get_hostname();
848 
849 
853  std::string
854  get_time();
855 
860  std::string
861  get_date();
862 
877  void
878  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
879  } // namespace System
880 
881 
882 #ifdef DEAL_II_WITH_TRILINOS
883 
888  namespace Trilinos
889  {
899  const Epetra_Comm &
900  comm_world();
901 
911  const Epetra_Comm &
912  comm_self();
913 
922  const Teuchos::RCP<const Teuchos::Comm<int>> &
924 
957  Epetra_Comm *
958  duplicate_communicator(const Epetra_Comm &communicator);
959 
982  void
983  destroy_communicator(Epetra_Comm &communicator);
984 
993  unsigned int
994  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
995 
1002  unsigned int
1003  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
1004 
1015  Epetra_Map
1016  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1017  } // namespace Trilinos
1018 
1019 #endif
1020 
1021 
1022 } // namespace Utilities
1023 
1024 
1025 // --------------------- inline functions
1026 
1027 namespace Utilities
1028 {
1029  template <int N, typename T>
1030  inline T
1031  fixed_power(const T n)
1032  {
1033  Assert(N >= 0, ExcNotImplemented());
1034  switch (N)
1035  {
1036  case 0:
1037  return ::internal::NumberType<T>::value(1);
1038  case 1:
1039  return n;
1040  case 2:
1041  return n * n;
1042  case 3:
1043  return n * n * n;
1044  case 4:
1045  return n * n * n * n;
1046  default:
1047  T result = n;
1048  for (int d = 1; d < N; ++d)
1049  result *= n;
1050  return result;
1051  }
1052  }
1053 
1054 
1055 
1056  template <class T>
1057  inline std::string
1058  type_to_string(const T &t)
1059  {
1060  return boost::core::demangle(typeid(t).name());
1061  }
1062 
1063 
1064 
1065  template <typename Iterator, typename T>
1066  inline Iterator
1067  lower_bound(Iterator first, Iterator last, const T &val)
1068  {
1069  return Utilities::lower_bound(first, last, val, std::less<T>());
1070  }
1071 
1072 
1073 
1074  template <typename Iterator, typename T, typename Comp>
1075  inline Iterator
1076  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1077  {
1078  // verify that the two iterators are properly ordered. since
1079  // we need operator- for the iterator type anyway, do the
1080  // test as follows, rather than via 'last >= first'
1081  Assert(last - first >= 0,
1082  ExcMessage(
1083  "The given iterators do not satisfy the proper ordering."));
1084 
1085  unsigned int len = static_cast<unsigned int>(last - first);
1086 
1087  if (len == 0)
1088  return first;
1089 
1090  while (true)
1091  {
1092  // if length equals 8 or less,
1093  // then do a rolled out
1094  // search. use a switch without
1095  // breaks for that and roll-out
1096  // the loop somehow
1097  if (len < 8)
1098  {
1099  switch (len)
1100  {
1101  case 7:
1102  if (!comp(*first, val))
1103  return first;
1104  ++first;
1105  DEAL_II_FALLTHROUGH;
1106  case 6:
1107  if (!comp(*first, val))
1108  return first;
1109  ++first;
1110  DEAL_II_FALLTHROUGH;
1111  case 5:
1112  if (!comp(*first, val))
1113  return first;
1114  ++first;
1115  DEAL_II_FALLTHROUGH;
1116  case 4:
1117  if (!comp(*first, val))
1118  return first;
1119  ++first;
1120  DEAL_II_FALLTHROUGH;
1121  case 3:
1122  if (!comp(*first, val))
1123  return first;
1124  ++first;
1125  DEAL_II_FALLTHROUGH;
1126  case 2:
1127  if (!comp(*first, val))
1128  return first;
1129  ++first;
1130  DEAL_II_FALLTHROUGH;
1131  case 1:
1132  if (!comp(*first, val))
1133  return first;
1134  return first + 1;
1135  default:
1136  // indices seem
1137  // to not be
1138  // sorted
1139  // correctly!? or
1140  // did len
1141  // become==0
1142  // somehow? that
1143  // shouldn't have
1144  // happened
1145  Assert(false, ExcInternalError());
1146  }
1147  }
1148 
1149 
1150 
1151  const unsigned int half = len >> 1;
1152  const Iterator middle = first + half;
1153 
1154  // if the value is larger than
1155  // that pointed to by the
1156  // middle pointer, then the
1157  // insertion point must be
1158  // right of it
1159  if (comp(*middle, val))
1160  {
1161  first = middle + 1;
1162  len -= half + 1;
1163  }
1164  else
1165  len = half;
1166  }
1167  }
1168 
1169 
1170  // --------------------- non-inline functions
1171 
1172  template <typename T>
1173  size_t
1174  pack(const T & object,
1175  std::vector<char> &dest_buffer,
1176  const bool allow_compression)
1177  {
1178  // the data is never compressed when we can't use zlib.
1179  (void)allow_compression;
1180 
1181  std::size_t size = 0;
1182 
1183  // see if the object is small and copyable via memcpy. if so, use
1184  // this fast path. otherwise, we have to go through the BOOST
1185  // serialization machinery
1186  //
1187  // we have to work around the fact that GCC 4.8.x claims to be C++
1188  // conforming, but is not actually as it does not implement
1189  // std::is_trivially_copyable.
1190 #if __GNUG__ && __GNUC__ < 5
1191  if (__has_trivial_copy(T) && sizeof(T) < 256)
1192 #else
1193 # ifdef DEAL_II_WITH_CXX17
1194  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1195 # else
1196  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1197 # endif
1198 #endif
1199  {
1200  const std::size_t previous_size = dest_buffer.size();
1201  dest_buffer.resize(previous_size + sizeof(T));
1202 
1203  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1204 
1205  size = sizeof(T);
1206  }
1207  else
1208  {
1209  // use buffer as the target of a compressing
1210  // stream into which we serialize the current object
1211  const std::size_t previous_size = dest_buffer.size();
1212 #ifdef DEAL_II_WITH_ZLIB
1213  if (allow_compression)
1214  {
1215  boost::iostreams::filtering_ostream out;
1216  out.push(
1217  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1218  boost::iostreams::gzip::best_compression)));
1219  out.push(boost::iostreams::back_inserter(dest_buffer));
1220 
1221  boost::archive::binary_oarchive archive(out);
1222  archive << object;
1223  out.flush();
1224  }
1225  else
1226 #endif
1227  {
1228  std::ostringstream out;
1229  boost::archive::binary_oarchive archive(out);
1230  archive << object;
1231 
1232  const std::string &s = out.str();
1233  dest_buffer.reserve(dest_buffer.size() + s.size());
1234  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1235  }
1236 
1237  size = dest_buffer.size() - previous_size;
1238  }
1239 
1240  return size;
1241  }
1242 
1243 
1244  template <typename T>
1245  std::vector<char>
1246  pack(const T &object, const bool allow_compression)
1247  {
1248  std::vector<char> buffer;
1249  pack<T>(object, buffer, allow_compression);
1250  return buffer;
1251  }
1252 
1253 
1254  template <typename T>
1255  T
1256  unpack(const std::vector<char>::const_iterator &cbegin,
1257  const std::vector<char>::const_iterator &cend,
1258  const bool allow_compression)
1259  {
1260  T object;
1261 
1262  // the data is never compressed when we can't use zlib.
1263  (void)allow_compression;
1264 
1265  // see if the object is small and copyable via memcpy. if so, use
1266  // this fast path. otherwise, we have to go through the BOOST
1267  // serialization machinery
1268  //
1269  // we have to work around the fact that GCC 4.8.x claims to be C++
1270  // conforming, but is not actually as it does not implement
1271  // std::is_trivially_copyable.
1272 #if __GNUG__ && __GNUC__ < 5
1273  if (__has_trivial_copy(T) && sizeof(T) < 256)
1274 #else
1275 # ifdef DEAL_II_WITH_CXX17
1276  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1277 # else
1278  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1279 # endif
1280 #endif
1281  {
1282  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1283  std::memcpy(&object, &*cbegin, sizeof(T));
1284  }
1285  else
1286  {
1287  std::string decompressed_buffer;
1288 
1289  // first decompress the buffer
1290 #ifdef DEAL_II_WITH_ZLIB
1291  if (allow_compression)
1292  {
1293  boost::iostreams::filtering_ostream decompressing_stream;
1294  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1295  decompressing_stream.push(
1296  boost::iostreams::back_inserter(decompressed_buffer));
1297  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1298  }
1299  else
1300 #endif
1301  {
1302  decompressed_buffer.assign(cbegin, cend);
1303  }
1304 
1305  // then restore the object from the buffer
1306  std::istringstream in(decompressed_buffer);
1307  boost::archive::binary_iarchive archive(in);
1308 
1309  archive >> object;
1310  }
1311 
1312  return object;
1313  }
1314 
1315 
1316  template <typename T>
1317  T
1318  unpack(const std::vector<char> &buffer, const bool allow_compression)
1319  {
1320  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1321  }
1322 
1323 
1324  template <typename T, int N>
1325  void
1326  unpack(const std::vector<char>::const_iterator &cbegin,
1327  const std::vector<char>::const_iterator &cend,
1328  T (&unpacked_object)[N],
1329  const bool allow_compression)
1330  {
1331  // see if the object is small and copyable via memcpy. if so, use
1332  // this fast path. otherwise, we have to go through the BOOST
1333  // serialization machinery
1334  //
1335  // we have to work around the fact that GCC 4.8.x claims to be C++
1336  // conforming, but is not actually as it does not implement
1337  // std::is_trivially_copyable.
1338  if (
1339 #if __GNUG__ && __GNUC__ < 5
1340  __has_trivial_copy(T)
1341 #else
1342  std::is_trivially_copyable<T>()
1343 #endif
1344  && sizeof(T) * N < 256)
1345  {
1346  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1347  ExcInternalError());
1348  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1349  }
1350  else
1351  {
1352  std::string decompressed_buffer;
1353 
1354  // first decompress the buffer
1355  (void)allow_compression;
1356 #ifdef DEAL_II_WITH_ZLIB
1357  if (allow_compression)
1358  {
1359  boost::iostreams::filtering_ostream decompressing_stream;
1360  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1361  decompressing_stream.push(
1362  boost::iostreams::back_inserter(decompressed_buffer));
1363  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1364  }
1365  else
1366 #endif
1367  {
1368  decompressed_buffer.assign(cbegin, cend);
1369  }
1370 
1371  // then restore the object from the buffer
1372  std::istringstream in(decompressed_buffer);
1373  boost::archive::binary_iarchive archive(in);
1374 
1375  archive >> unpacked_object;
1376  }
1377  }
1378 
1379 
1380  template <typename T, int N>
1381  void
1382  unpack(const std::vector<char> &buffer,
1383  T (&unpacked_object)[N],
1384  const bool allow_compression)
1385  {
1386  unpack<T, N>(buffer.cbegin(),
1387  buffer.cend(),
1388  unpacked_object,
1389  allow_compression);
1390  }
1391 
1392 } // namespace Utilities
1393 
1394 
1395 DEAL_II_NAMESPACE_CLOSE
1396 
1397 #ifndef DOXYGEN
1398 namespace boost
1399 {
1400  namespace serialization
1401  {
1402  // Provides boost and c++11 with a way to serialize tuples and pairs
1403  // automatically
1404  template <int N>
1405  struct Serialize
1406  {
1407  template <class Archive, typename... Args>
1408  static void
1409  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1410  {
1411  ar &std::get<N - 1>(t);
1412  Serialize<N - 1>::serialize(ar, t, version);
1413  }
1414  };
1415 
1416  template <>
1417  struct Serialize<0>
1418  {
1419  template <class Archive, typename... Args>
1420  static void
1421  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1422  {
1423  (void)ar;
1424  (void)t;
1425  (void)version;
1426  }
1427  };
1428 
1429  template <class Archive, typename... Args>
1430  void
1431  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1432  {
1433  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1434  }
1435  } // namespace serialization
1436 } // namespace boost
1437 #endif
1438 
1439 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1067
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:566
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:1023
static const unsigned int invalid_unsigned_int
Definition: types.h:173
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:1058
std::string dealii_version_string()
Definition: utilities.cc:88
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1148
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:715
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:620
const Epetra_Comm & comm_self()
Definition: utilities.cc:1086
Definition: point.h:110
std::string get_date()
Definition: utilities.cc:1008
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:943
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:738
double string_to_double(const std::string &s)
Definition: utilities.cc:527
double get_cpu_load()
Definition: utilities.cc:909
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:1070
T fixed_power(const T t)
Definition: utilities.h:1031
static ::ExceptionBase & ExcMessage(std::string arg1)
Epetra_Comm * duplicate_communicator(const Epetra_Comm &communicator)
Definition: utilities.cc:1102
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:757
#define Assert(cond, exc)
Definition: exceptions.h:1407
constexpr unsigned int pow(const unsigned int base, const int iexp)
Definition: utilities.h:428
unsigned long int VmSize
Definition: utilities.h:820
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:700
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:790
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:1174
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:1129
Definition: cuda.h:31
std::string get_hostname()
Definition: utilities.cc:977
unsigned long int VmHWM
Definition: utilities.h:825
const Epetra_Comm & comm_world()
Definition: utilities.cc:1054
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1318
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:776
static ::ExceptionBase & ExcNotImplemented()
unsigned long int VmRSS
Definition: utilities.h:831
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1155
const std::string get_current_vectorization_level()
Definition: utilities.cc:917
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1163
std::string get_time()
Definition: utilities.cc:992
unsigned long int VmPeak
Definition: utilities.h:815
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:467
static ::ExceptionBase & ExcInternalError()