Reference documentation for deal.II version Git 96dee1a3e7 2019-03-21 22:06:48 +0100
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
utilities.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2005 - 2018 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 #include <boost/archive/binary_iarchive.hpp>
44 #include <boost/archive/binary_oarchive.hpp>
45 #include <boost/core/demangle.hpp>
46 #include <boost/serialization/array.hpp>
47 #include <boost/serialization/complex.hpp>
48 #include <boost/serialization/vector.hpp>
49 
50 #ifdef DEAL_II_WITH_ZLIB
51 # include <boost/iostreams/device/back_inserter.hpp>
52 # include <boost/iostreams/filter/gzip.hpp>
53 # include <boost/iostreams/filtering_stream.hpp>
54 # include <boost/iostreams/stream.hpp>
55 #endif
56 
57 DEAL_II_NAMESPACE_OPEN
58 
59 // forward declare Point
60 template <int dim, typename Number>
61 class Point;
62 
71 namespace Utilities
72 {
79  std::string
81 
95  template <int dim, typename Number>
96  std::vector<std::array<std::uint64_t, dim>>
98  const std::vector<Point<dim, Number>> &points,
99  const int bits_per_dim = 64);
100 
104  template <int dim>
105  std::vector<std::array<std::uint64_t, dim>>
107  const std::vector<std::array<std::uint64_t, dim>> &points,
108  const int bits_per_dim = 64);
109 
125  template <int dim>
126  std::uint64_t
127  pack_integers(const std::array<std::uint64_t, dim> &index,
128  const int bits_per_dim);
129 
146  std::string
147  int_to_string(const unsigned int value,
148  const unsigned int digits = numbers::invalid_unsigned_int);
149 
160  template <typename number>
161  std::string
162  to_string(const number value,
163  const unsigned int digits = numbers::invalid_unsigned_int);
164 
169  unsigned int
170  needed_digits(const unsigned int max_number);
171 
176  int
177  string_to_int(const std::string &s);
178 
190  std::string
191  dim_string(const int dim, const int spacedim);
192 
197  std::vector<int>
198  string_to_int(const std::vector<std::string> &s);
199 
204  double
205  string_to_double(const std::string &s);
206 
207 
212  std::vector<double>
213  string_to_double(const std::vector<std::string> &s);
214 
215 
258  std::vector<std::string>
259  split_string_list(const std::string &s, const std::string &delimiter = ",");
260 
261 
266  std::vector<std::string>
267  split_string_list(const std::string &s, const char delimiter);
268 
269 
279  std::vector<std::string>
280  break_text_into_lines(const std::string &original_text,
281  const unsigned int width,
282  const char delimiter = ' ');
283 
288  bool
289  match_at_string_start(const std::string &name, const std::string &pattern);
290 
299  std::pair<int, unsigned int>
300  get_integer_at_position(const std::string &name, const unsigned int position);
301 
306  std::string
307  replace_in_string(const std::string &input,
308  const std::string &from,
309  const std::string &to);
310 
316  std::string
317  trim(const std::string &input);
318 
344  double
345  generate_normal_random_number(const double a, const double sigma);
346 
356  template <class T>
357  std::string
358  type_to_string(const T &t);
359 
368  template <int N, typename T>
369  T
370  fixed_power(const T t);
371 
396  template <int a, int N>
397  struct DEAL_II_DEPRECATED fixed_int_power
398  {
399  static const int value = a * fixed_int_power<a, N - 1>::value;
400  };
401 
409  template <int a>
410  struct DEAL_II_DEPRECATED fixed_int_power<a, 0>
411  {
412  static const int value = 1;
413  };
414 
420  constexpr unsigned int
421  pow(const unsigned int base, const int iexp)
422  {
423 #if defined(DEBUG) && defined(DEAL_II_WITH_CXX14) && \
424  defined(DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR)
425  // Up to __builtin_expect this is the same code as in the 'Assert' macro.
426  // The call to __builtin_expect turns out to be problematic.
427  if (!(iexp >= 0))
428  ::deal_II_exceptions::internals::issue_error_noreturn(
430  __FILE__,
431  __LINE__,
432  __PRETTY_FUNCTION__,
433  "iexp>=0",
434  "ExcMessage(\"The exponent must not be negative!\")",
435  ExcMessage("The exponent must not be negative!"));
436 #endif
437  // The "exponentiation by squaring" algorithm used below has to be
438  // compressed to one statement due to C++11's restrictions on constexpr
439  // functions. A more descriptive version would be:
440  //
441  // <code>
442  // if (iexp <= 0)
443  // return 1;
444  //
445  // // if the current exponent is not divisible by two,
446  // // we need to account for that.
447  // const unsigned int prefactor = (iexp % 2 == 1) ? base : 1;
448  //
449  // // a^b = (a*a)^(b/2) for b evenb
450  // // a^b = a*(a*a)^((b-1)/2 for b odd
451  // return prefactor * ::Utilities::pow(base*base, iexp/2);
452  // </code>
453 
454  return iexp <= 0 ? 1 :
455  (((iexp % 2 == 1) ? base : 1) *
456  ::Utilities::pow(base * base, iexp / 2));
457  }
458 
480  template <typename Iterator, typename T>
481  Iterator
482  lower_bound(Iterator first, Iterator last, const T &val);
483 
484 
490  template <typename Iterator, typename T, typename Comp>
491  Iterator
492  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp);
493 
499  std::vector<unsigned int>
500  reverse_permutation(const std::vector<unsigned int> &permutation);
501 
507  std::vector<unsigned int>
508  invert_permutation(const std::vector<unsigned int> &permutation);
509 
515  std::vector<unsigned long long int>
516  reverse_permutation(const std::vector<unsigned long long int> &permutation);
517 
523  std::vector<unsigned long long int>
524  invert_permutation(const std::vector<unsigned long long int> &permutation);
525 
543  template <typename T>
544  size_t
545  pack(const T & object,
546  std::vector<char> &dest_buffer,
547  const bool allow_compression = true);
548 
559  template <typename T>
560  std::vector<char>
561  pack(const T &object, const bool allow_compression = true);
562 
595  template <typename T>
596  T
597  unpack(const std::vector<char> &buffer, const bool allow_compression = true);
598 
609  template <typename T>
610  T
611  unpack(const std::vector<char>::const_iterator &cbegin,
612  const std::vector<char>::const_iterator &cend,
613  const bool allow_compression = true);
614 
649  template <typename T, int N>
650  void
651  unpack(const std::vector<char> &buffer,
652  T (&unpacked_object)[N],
653  const bool allow_compression = true);
654 
665  template <typename T, int N>
666  void
667  unpack(const std::vector<char>::const_iterator &cbegin,
668  const std::vector<char>::const_iterator &cend,
669  T (&unpacked_object)[N],
670  const bool allow_compression = true);
671 
729  template <typename To, typename From>
730  std::unique_ptr<To>
731  dynamic_unique_cast(std::unique_ptr<From> &&p)
732  {
733  // Let's see if we can cast from 'From' to 'To'. If so, do the cast,
734  // and then release the pointer from the old
735  // owner
736  if (To *cast = dynamic_cast<To *>(p.get()))
737  {
738  std::unique_ptr<To> result(cast);
739  p.release();
740  return result;
741  }
742  else
743  throw std::bad_cast();
744  }
745 
751  namespace System
752  {
760  double
761  get_cpu_load();
762 
796  const std::string
798 
803  struct MemoryStats
804  {
808  unsigned long int VmPeak;
809 
813  unsigned long int VmSize;
814 
818  unsigned long int VmHWM;
819 
824  unsigned long int VmRSS;
825  };
826 
827 
832  void
834 
835 
839  std::string
840  get_hostname();
841 
842 
846  std::string
847  get_time();
848 
853  std::string
854  get_date();
855 
870  void
871  posix_memalign(void **memptr, std::size_t alignment, std::size_t size);
872  } // namespace System
873 
874 
875 #ifdef DEAL_II_WITH_TRILINOS
876 
881  namespace Trilinos
882  {
892  const Epetra_Comm &
893  comm_world();
894 
904  const Epetra_Comm &
905  comm_self();
906 
915  const Teuchos::RCP<const Teuchos::Comm<int>> &
917 
950  Epetra_Comm *
951  duplicate_communicator(const Epetra_Comm &communicator);
952 
975  void
976  destroy_communicator(Epetra_Comm &communicator);
977 
986  unsigned int
987  get_n_mpi_processes(const Epetra_Comm &mpi_communicator);
988 
995  unsigned int
996  get_this_mpi_process(const Epetra_Comm &mpi_communicator);
997 
1008  Epetra_Map
1009  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm);
1010  } // namespace Trilinos
1011 
1012 #endif
1013 
1014 
1015 } // namespace Utilities
1016 
1017 
1018 // --------------------- inline functions
1019 
1020 namespace Utilities
1021 {
1022  template <int N, typename T>
1023  inline T
1024  fixed_power(const T n)
1025  {
1026  Assert(N >= 0, ExcNotImplemented());
1027  switch (N)
1028  {
1029  case 0:
1030  return ::internal::NumberType<T>::value(1);
1031  case 1:
1032  return n;
1033  case 2:
1034  return n * n;
1035  case 3:
1036  return n * n * n;
1037  case 4:
1038  return n * n * n * n;
1039  default:
1040  T result = n;
1041  for (int d = 1; d < N; ++d)
1042  result *= n;
1043  return result;
1044  }
1045  }
1046 
1047 
1048 
1049  template <class T>
1050  inline std::string
1051  type_to_string(const T &t)
1052  {
1053  return boost::core::demangle(typeid(t).name());
1054  }
1055 
1056 
1057 
1058  template <typename Iterator, typename T>
1059  inline Iterator
1060  lower_bound(Iterator first, Iterator last, const T &val)
1061  {
1062  return Utilities::lower_bound(first, last, val, std::less<T>());
1063  }
1064 
1065 
1066 
1067  template <typename Iterator, typename T, typename Comp>
1068  inline Iterator
1069  lower_bound(Iterator first, Iterator last, const T &val, const Comp comp)
1070  {
1071  // verify that the two iterators are properly ordered. since
1072  // we need operator- for the iterator type anyway, do the
1073  // test as follows, rather than via 'last >= first'
1074  Assert(last - first >= 0,
1075  ExcMessage(
1076  "The given iterators do not satisfy the proper ordering."));
1077 
1078  unsigned int len = static_cast<unsigned int>(last - first);
1079 
1080  if (len == 0)
1081  return first;
1082 
1083  while (true)
1084  {
1085  // if length equals 8 or less,
1086  // then do a rolled out
1087  // search. use a switch without
1088  // breaks for that and roll-out
1089  // the loop somehow
1090  if (len < 8)
1091  {
1092  switch (len)
1093  {
1094  case 7:
1095  if (!comp(*first, val))
1096  return first;
1097  ++first;
1098  DEAL_II_FALLTHROUGH;
1099  case 6:
1100  if (!comp(*first, val))
1101  return first;
1102  ++first;
1103  DEAL_II_FALLTHROUGH;
1104  case 5:
1105  if (!comp(*first, val))
1106  return first;
1107  ++first;
1108  DEAL_II_FALLTHROUGH;
1109  case 4:
1110  if (!comp(*first, val))
1111  return first;
1112  ++first;
1113  DEAL_II_FALLTHROUGH;
1114  case 3:
1115  if (!comp(*first, val))
1116  return first;
1117  ++first;
1118  DEAL_II_FALLTHROUGH;
1119  case 2:
1120  if (!comp(*first, val))
1121  return first;
1122  ++first;
1123  DEAL_II_FALLTHROUGH;
1124  case 1:
1125  if (!comp(*first, val))
1126  return first;
1127  return first + 1;
1128  default:
1129  // indices seem
1130  // to not be
1131  // sorted
1132  // correctly!? or
1133  // did len
1134  // become==0
1135  // somehow? that
1136  // shouldn't have
1137  // happened
1138  Assert(false, ExcInternalError());
1139  }
1140  }
1141 
1142 
1143 
1144  const unsigned int half = len >> 1;
1145  const Iterator middle = first + half;
1146 
1147  // if the value is larger than
1148  // that pointed to by the
1149  // middle pointer, then the
1150  // insertion point must be
1151  // right of it
1152  if (comp(*middle, val))
1153  {
1154  first = middle + 1;
1155  len -= half + 1;
1156  }
1157  else
1158  len = half;
1159  }
1160  }
1161 
1162 
1163  // --------------------- non-inline functions
1164 
1165  template <typename T>
1166  size_t
1167  pack(const T & object,
1168  std::vector<char> &dest_buffer,
1169  const bool allow_compression)
1170  {
1171  // the data is never compressed when we can't use zlib.
1172  (void)allow_compression;
1173 
1174  std::size_t size = 0;
1175 
1176  // see if the object is small and copyable via memcpy. if so, use
1177  // this fast path. otherwise, we have to go through the BOOST
1178  // serialization machinery
1179  //
1180  // we have to work around the fact that GCC 4.8.x claims to be C++
1181  // conforming, but is not actually as it does not implement
1182  // std::is_trivially_copyable.
1183 #if __GNUG__ && __GNUC__ < 5
1184  if (__has_trivial_copy(T) && sizeof(T) < 256)
1185 #else
1186 # ifdef DEAL_II_WITH_CXX17
1187  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1188 # else
1189  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1190 # endif
1191 #endif
1192  {
1193  const std::size_t previous_size = dest_buffer.size();
1194  dest_buffer.resize(previous_size + sizeof(T));
1195 
1196  std::memcpy(dest_buffer.data() + previous_size, &object, sizeof(T));
1197 
1198  size = sizeof(T);
1199  }
1200  else
1201  {
1202  // use buffer as the target of a compressing
1203  // stream into which we serialize the current object
1204  const std::size_t previous_size = dest_buffer.size();
1205 #ifdef DEAL_II_WITH_ZLIB
1206  if (allow_compression)
1207  {
1208  boost::iostreams::filtering_ostream out;
1209  out.push(
1210  boost::iostreams::gzip_compressor(boost::iostreams::gzip_params(
1211  boost::iostreams::gzip::best_compression)));
1212  out.push(boost::iostreams::back_inserter(dest_buffer));
1213 
1214  boost::archive::binary_oarchive archive(out);
1215  archive << object;
1216  out.flush();
1217  }
1218  else
1219 #endif
1220  {
1221  std::ostringstream out;
1222  boost::archive::binary_oarchive archive(out);
1223  archive << object;
1224 
1225  const std::string &s = out.str();
1226  dest_buffer.reserve(dest_buffer.size() + s.size());
1227  std::move(s.begin(), s.end(), std::back_inserter(dest_buffer));
1228  }
1229 
1230  size = dest_buffer.size() - previous_size;
1231  }
1232 
1233  return size;
1234  }
1235 
1236 
1237  template <typename T>
1238  std::vector<char>
1239  pack(const T &object, const bool allow_compression)
1240  {
1241  std::vector<char> buffer;
1242  pack<T>(object, buffer, allow_compression);
1243  return buffer;
1244  }
1245 
1246 
1247  template <typename T>
1248  T
1249  unpack(const std::vector<char>::const_iterator &cbegin,
1250  const std::vector<char>::const_iterator &cend,
1251  const bool allow_compression)
1252  {
1253  T object;
1254 
1255  // the data is never compressed when we can't use zlib.
1256  (void)allow_compression;
1257 
1258  // see if the object is small and copyable via memcpy. if so, use
1259  // this fast path. otherwise, we have to go through the BOOST
1260  // serialization machinery
1261  //
1262  // we have to work around the fact that GCC 4.8.x claims to be C++
1263  // conforming, but is not actually as it does not implement
1264  // std::is_trivially_copyable.
1265 #if __GNUG__ && __GNUC__ < 5
1266  if (__has_trivial_copy(T) && sizeof(T) < 256)
1267 #else
1268 # ifdef DEAL_II_WITH_CXX17
1269  if constexpr (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1270 # else
1271  if (std::is_trivially_copyable<T>() && sizeof(T) < 256)
1272 # endif
1273 #endif
1274  {
1275  Assert(std::distance(cbegin, cend) == sizeof(T), ExcInternalError());
1276  std::memcpy(&object, &*cbegin, sizeof(T));
1277  }
1278  else
1279  {
1280  std::string decompressed_buffer;
1281 
1282  // first decompress the buffer
1283 #ifdef DEAL_II_WITH_ZLIB
1284  if (allow_compression)
1285  {
1286  boost::iostreams::filtering_ostream decompressing_stream;
1287  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1288  decompressing_stream.push(
1289  boost::iostreams::back_inserter(decompressed_buffer));
1290  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1291  }
1292  else
1293 #endif
1294  {
1295  decompressed_buffer.assign(cbegin, cend);
1296  }
1297 
1298  // then restore the object from the buffer
1299  std::istringstream in(decompressed_buffer);
1300  boost::archive::binary_iarchive archive(in);
1301 
1302  archive >> object;
1303  }
1304 
1305  return object;
1306  }
1307 
1308 
1309  template <typename T>
1310  T
1311  unpack(const std::vector<char> &buffer, const bool allow_compression)
1312  {
1313  return unpack<T>(buffer.cbegin(), buffer.cend(), allow_compression);
1314  }
1315 
1316 
1317  template <typename T, int N>
1318  void
1319  unpack(const std::vector<char>::const_iterator &cbegin,
1320  const std::vector<char>::const_iterator &cend,
1321  T (&unpacked_object)[N],
1322  const bool allow_compression)
1323  {
1324  // see if the object is small and copyable via memcpy. if so, use
1325  // this fast path. otherwise, we have to go through the BOOST
1326  // serialization machinery
1327  //
1328  // we have to work around the fact that GCC 4.8.x claims to be C++
1329  // conforming, but is not actually as it does not implement
1330  // std::is_trivially_copyable.
1331  if (
1332 #if __GNUG__ && __GNUC__ < 5
1333  __has_trivial_copy(T)
1334 #else
1335  std::is_trivially_copyable<T>()
1336 #endif
1337  && sizeof(T) * N < 256)
1338  {
1339  Assert(std::distance(cbegin, cend) == sizeof(T) * N,
1340  ExcInternalError());
1341  std::memcpy(unpacked_object, &*cbegin, sizeof(T) * N);
1342  }
1343  else
1344  {
1345  std::string decompressed_buffer;
1346 
1347  // first decompress the buffer
1348  (void)allow_compression;
1349 #ifdef DEAL_II_WITH_ZLIB
1350  if (allow_compression)
1351  {
1352  boost::iostreams::filtering_ostream decompressing_stream;
1353  decompressing_stream.push(boost::iostreams::gzip_decompressor());
1354  decompressing_stream.push(
1355  boost::iostreams::back_inserter(decompressed_buffer));
1356  decompressing_stream.write(&*cbegin, std::distance(cbegin, cend));
1357  }
1358  else
1359 #endif
1360  {
1361  decompressed_buffer.assign(cbegin, cend);
1362  }
1363 
1364  // then restore the object from the buffer
1365  std::istringstream in(decompressed_buffer);
1366  boost::archive::binary_iarchive archive(in);
1367 
1368  archive >> unpacked_object;
1369  }
1370  }
1371 
1372 
1373  template <typename T, int N>
1374  void
1375  unpack(const std::vector<char> &buffer,
1376  T (&unpacked_object)[N],
1377  const bool allow_compression)
1378  {
1379  unpack<T, N>(buffer.cbegin(),
1380  buffer.cend(),
1381  unpacked_object,
1382  allow_compression);
1383  }
1384 
1385 } // namespace Utilities
1386 
1387 
1388 DEAL_II_NAMESPACE_CLOSE
1389 
1390 #ifndef DOXYGEN
1391 namespace boost
1392 {
1393  namespace serialization
1394  {
1395  // Provides boost and c++11 with a way to serialize tuples and pairs
1396  // automatically
1397  template <int N>
1398  struct Serialize
1399  {
1400  template <class Archive, typename... Args>
1401  static void
1402  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1403  {
1404  ar &std::get<N - 1>(t);
1405  Serialize<N - 1>::serialize(ar, t, version);
1406  }
1407  };
1408 
1409  template <>
1410  struct Serialize<0>
1411  {
1412  template <class Archive, typename... Args>
1413  static void
1414  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1415  {
1416  (void)ar;
1417  (void)t;
1418  (void)version;
1419  }
1420  };
1421 
1422  template <class Archive, typename... Args>
1423  void
1424  serialize(Archive &ar, std::tuple<Args...> &t, const unsigned int version)
1425  {
1426  Serialize<sizeof...(Args)>::serialize(ar, t, version);
1427  }
1428  } // namespace serialization
1429 } // namespace boost
1430 #endif
1431 
1432 #endif
Iterator lower_bound(Iterator first, Iterator last, const T &val)
Definition: utilities.h:1060
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:480
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
Definition: utilities.cc:937
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:274
std::string type_to_string(const T &t)
Definition: utilities.h:1051
std::string dealii_version_string()
Definition: utilities.cc:87
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1062
std::string trim(const std::string &input)
Definition: utilities.cc:344
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:629
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
Definition: utilities.cc:534
const Epetra_Comm & comm_self()
Definition: utilities.cc:1000
Definition: point.h:108
std::string get_date()
Definition: utilities.cc:922
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:306
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:857
std::unique_ptr< To > dynamic_unique_cast(std::unique_ptr< From > &&p)
Definition: utilities.h:731
double string_to_double(const std::string &s)
Definition: utilities.cc:441
double get_cpu_load()
Definition: utilities.cc:823
const Teuchos::RCP< const Teuchos::Comm< int > > & tpetra_comm_self()
Definition: utilities.cc:984
T fixed_power(const T t)
Definition: utilities.h:1024
static ::ExceptionBase & ExcMessage(std::string arg1)
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:671
#define Assert(cond, exc)
Definition: exceptions.h:1407
constexpr unsigned int pow(const unsigned int base, const int iexp)
Definition: utilities.h:421
unsigned long int VmSize
Definition: utilities.h:813
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:614
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:704
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:297
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1167
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:325
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:371
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:96
void destroy_communicator(Epetra_Comm &communicator)
Definition: utilities.cc:1043
Definition: cuda.h:31
std::string get_hostname()
Definition: utilities.cc:891
unsigned long int VmHWM
Definition: utilities.h:818
const Epetra_Comm & comm_world()
Definition: utilities.cc:968
T unpack(const std::vector< char > &buffer, const bool allow_compression=true)
Definition: utilities.h:1311
int string_to_int(const std::string &s)
Definition: utilities.cc:402
std::vector< unsigned int > reverse_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:690
static ::ExceptionBase & ExcNotImplemented()
unsigned long int VmRSS
Definition: utilities.h:824
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:1069
const std::string get_current_vectorization_level()
Definition: utilities.cc:831
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:1077
std::string get_time()
Definition: utilities.cc:906
unsigned long int VmPeak
Definition: utilities.h:808
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:381
static ::ExceptionBase & ExcInternalError()