Reference documentation for deal.II version Git 7baca85e57 2019-08-23 17:29:05 -0400
\(\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 n)
1034  {
1035  Assert(N >= 0, ExcNotImplemented());
1036  switch (N)
1037  {
1038  case 0:
1039  return ::internal::NumberType<T>::value(1);
1040  case 1:
1041  return n;
1042  case 2:
1043  return n * n;
1044  case 3:
1045  return n * n * n;
1046  case 4:
1047  return n * n * n * n;
1048  default:
1049  T result = n;
1050  for (int d = 1; d < N; ++d)
1051  result *= n;
1052  return result;
1053  }
1054  }
1055 
1056 
1057 
1058  template <class T>
1059  inline std::string
1060  type_to_string(const T &t)
1061  {
1062  return boost::core::demangle(typeid(t).name());
1063  }
1064 
1065 
1066 
1067  template <typename Iterator, typename T>
1068  inline Iterator
1069  lower_bound(Iterator first, Iterator last, const T &val)
1070  {
1071  return Utilities::lower_bound(first, last, val, std::less<T>());
1072  }
1073 
1074 
1075 
1076  template <typename Iterator, typename T, typename Comp>
1077  inline Iterator
1078  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1079  {
1080  // verify that the two iterators are properly ordered. since
1081  // we need operator- for the iterator type anyway, do the
1082  // test as follows, rather than via 'last >= first'
1083  Assert(last - first >= 0,
1084  ExcMessage(
1085  "The given iterators do not satisfy the proper ordering."));
1086 
1087  unsigned int len = static_cast<unsigned int>(last - first);
1088 
1089  if (len == 0)
1090  return first;
1091 
1092  while (true)
1093  {
1094  // if length equals 8 or less,
1095  // then do a rolled out
1096  // search. use a switch without
1097  // breaks for that and roll-out
1098  // the loop somehow
1099  if (len < 8)
1100  {
1101  switch (len)
1102  {
1103  case 7:
1104  if (!comp(*first, val))
1105  return first;
1106  ++first;
1107  DEAL_II_FALLTHROUGH;
1108  case 6:
1109  if (!comp(*first, val))
1110  return first;
1111  ++first;
1112  DEAL_II_FALLTHROUGH;
1113  case 5:
1114  if (!comp(*first, val))
1115  return first;
1116  ++first;
1117  DEAL_II_FALLTHROUGH;
1118  case 4:
1119  if (!comp(*first, val))
1120  return first;
1121  ++first;
1122  DEAL_II_FALLTHROUGH;
1123  case 3:
1124  if (!comp(*first, val))
1125  return first;
1126  ++first;
1127  DEAL_II_FALLTHROUGH;
1128  case 2:
1129  if (!comp(*first, val))
1130  return first;
1131  ++first;
1132  DEAL_II_FALLTHROUGH;
1133  case 1:
1134  if (!comp(*first, val))
1135  return first;
1136  return first + 1;
1137  default:
1138  // indices seem
1139  // to not be
1140  // sorted
1141  // correctly!? or
1142  // did len
1143  // become==0
1144  // somehow? that
1145  // shouldn't have
1146  // happened
1147  Assert(false, ExcInternalError());
1148  }
1149  }
1150 
1151 
1152 
1153  const unsigned int half = len >> 1;
1154  const Iterator middle = first + half;
1155 
1156  // if the value is larger than
1157  // that pointed to by the
1158  // middle pointer, then the
1159  // insertion point must be
1160  // right of it
1161  if (comp(*middle, val))
1162  {
1163  first = middle + 1;
1164  len -= half + 1;
1165  }
1166  else
1167  len = half;
1168  }
1169  }
1170 
1171 
1172  // --------------------- non-inline functions
1173 
1174  template <typename T>
1175  size_t
1176  pack(const T & object,
1177  std::vector<char> &dest_buffer,
1178  const bool allow_compression)
1179  {
1180  // the data is never compressed when we can't use zlib.
1181  (void)allow_compression;
1182 
1183  std::size_t size = 0;
1184 
1185  // see if the object is small and copyable via memcpy. if so, use
1186  // this fast path. otherwise, we have to go through the BOOST
1187  // serialization machinery
1188  //
1189  // we have to work around the fact that GCC 4.8.x claims to be C++
1190  // conforming, but is not actually as it does not implement
1191  // std::is_trivially_copyable.
1192 #if __GNUG__ && __GNUC__ < 5
1193  if (__has_trivial_copy(T) && sizeof(T) < 256)
1194 #else
1195 # ifdef DEAL_II_WITH_CXX17
1196  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1197 # else
1198  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1199 # endif
1200 #endif
1201  {
1202  const std::size_t previous_size = dest_buffer.size();
1203  dest_buffer.resize(previous_size + sizeof(T));
1204 
1205  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1206 
1207  size = sizeof(T);
1208  }
1209  else
1210  {
1211  // use buffer as the target of a compressing
1212  // stream into which we serialize the current object
1213  const std::size_t previous_size = dest_buffer.size();
1214 #ifdef DEAL_II_WITH_ZLIB
1215  if (allow_compression)
1216  {
1217  boost::iostreams::filtering_ostream out;
1218  out.push(
1219  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1220  boost::iostreams::gzip::default_compression)));
1221  out.push(boost::iostreams::back_inserter(dest_buffer));
1222 
1223  boost::archive::binary_oarchive archive(out);
1224  archive << object;
1225  out.flush();
1226  }
1227  else
1228 #endif
1229  {
1230  std::ostringstream out;
1231  boost::archive::binary_oarchive archive(out);
1232  archive << object;
1233 
1234  const std::string &s = out.str();
1235  dest_buffer.reserve(dest_buffer.size() + s.size());
1236  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1237  }
1238 
1239  size = dest_buffer.size() - previous_size;
1240  }
1241 
1242  return size;
1243  }
1244 
1245 
1246  template <typename T>
1247  std::vector<char>
1248  pack(const T &object, const bool allow_compression)
1249  {
1250  std::vector<char> buffer;
1251  pack<T>(object, buffer, allow_compression);
1252  return buffer;
1253  }
1254 
1255 
1256  template <typename T>
1257  T
1258  unpack(const std::vector<char>::const_iterator &cbegin,
1259  const std::vector<char>::const_iterator &cend,
1260  const bool allow_compression)
1261  {
1262  T object;
1263 
1264  // the data is never compressed when we can't use zlib.
1265  (void)allow_compression;
1266 
1267  // see if the object is small and copyable via memcpy. if so, use
1268  // this fast path. otherwise, we have to go through the BOOST
1269  // serialization machinery
1270  //
1271  // we have to work around the fact that GCC 4.8.x claims to be C++
1272  // conforming, but is not actually as it does not implement
1273  // std::is_trivially_copyable.
1274 #if __GNUG__ && __GNUC__ < 5
1275  if (__has_trivial_copy(T) && sizeof(T) < 256)
1276 #else
1277 # ifdef DEAL_II_WITH_CXX17
1278  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1279 # else
1280  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1281 # endif
1282 #endif
1283  {
1284  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1285  std::memcpy(&object, &*cbegin, sizeof(T));
1286  }
1287  else
1288  {
1289  std::string decompressed_buffer;
1290 
1291  // first decompress the buffer
1292 #ifdef DEAL_II_WITH_ZLIB
1293  if (allow_compression)
1294  {
1295  boost::iostreams::filtering_ostream decompressing_stream;
1296  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1297  decompressing_stream.push(
1298  boost::iostreams::back_inserter(decompressed_buffer));
1299  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1300  }
1301  else
1302 #endif
1303  {
1304  decompressed_buffer.assign(cbegin, cend);
1305  }
1306 
1307  // then restore the object from the buffer
1308  std::istringstream in(decompressed_buffer);
1309  boost::archive::binary_iarchive archive(in);
1310 
1311  archive >> object;
1312  }
1313 
1314  return object;
1315  }
1316 
1317 
1318  template <typename T>
1319  T
1320  unpack(const std::vector<char> &buffer, const bool allow_compression)
1321  {
1322  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1323  }
1324 
1325 
1326  template <typename T, int N>
1327  void
1328  unpack(const std::vector<char>::const_iterator &cbegin,
1329  const std::vector<char>::const_iterator &cend,
1330  T (&unpacked_object)[N],
1331  const bool allow_compression)
1332  {
1333  // see if the object is small and copyable via memcpy. if so, use
1334  // this fast path. otherwise, we have to go through the BOOST
1335  // serialization machinery
1336  //
1337  // we have to work around the fact that GCC 4.8.x claims to be C++
1338  // conforming, but is not actually as it does not implement
1339  // std::is_trivially_copyable.
1340  if (
1341 #if __GNUG__ && __GNUC__ < 5
1342  __has_trivial_copy(T)
1343 #else
1344  std::is_trivially_copyable<T>()
1345 #endif
1346  && sizeof(T) * N < 256)
1347  {
1348  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1349  ExcInternalError());
1350  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1351  }
1352  else
1353  {
1354  std::string decompressed_buffer;
1355 
1356  // first decompress the buffer
1357  (void)allow_compression;
1358 #ifdef DEAL_II_WITH_ZLIB
1359  if (allow_compression)
1360  {
1361  boost::iostreams::filtering_ostream decompressing_stream;
1362  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1363  decompressing_stream.push(
1364  boost::iostreams::back_inserter(decompressed_buffer));
1365  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1366  }
1367  else
1368 #endif
1369  {
1370  decompressed_buffer.assign(cbegin, cend);
1371  }
1372 
1373  // then restore the object from the buffer
1374  std::istringstream in(decompressed_buffer);
1375  boost::archive::binary_iarchive archive(in);
1376 
1377  archive >> unpacked_object;
1378  }
1379  }
1380 
1381 
1382  template <typename T, int N>
1383  void
1384  unpack(const std::vector<char> &buffer,
1385  T (&unpacked_object)[N],
1386  const bool allow_compression)
1387  {
1388  unpack<T, N>(buffer.cbegin(),
1389  buffer.cend(),
1390  unpacked_object,
1391  allow_compression);
1392  }
1393 
1394 } // namespace Utilities
1395 
1396 
1397 DEAL_II_NAMESPACE_CLOSE
1398 
1399 #ifndef DOXYGEN
1400 namespace boost
1401 {
1402  namespace serialization
1403  {
1404  // Provides boost and c++11 with a way to serialize tuples and pairs
1405  // automatically
1406  template <int N>
1407  struct Serialize
1408  {
1409  template <class Archive, typename... Args>
1410  static void
1411  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1412  {
1413  ar &std::get<N - 1>(t);
1414  Serialize<N - 1>::serialize(ar, t, version);
1415  }
1416  };
1417 
1418  template <>
1419  struct Serialize<0>
1420  {
1421  template <class Archive, typename... Args>
1422  static void
1423  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1424  {
1425  (void)ar;
1426  (void)t;
1427  (void)version;
1428  }
1429  };
1430 
1431  template <class Archive, typename... Args>
1432  void
1433  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1434  {
1435  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1436  }
1437  } // namespace serialization
1438 } // namespace boost
1439 #endif
1440 
1441 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1069
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:1060
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:1176
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:1320
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
static ::ExceptionBase & ExcNotImplemented()
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()