31#define BOOST_BIND_GLOBAL_PLACEHOLDERS
32#include <boost/archive/iterators/base64_from_binary.hpp>
33#include <boost/archive/iterators/binary_from_base64.hpp>
34#include <boost/archive/iterators/transform_width.hpp>
35#include <boost/iostreams/copy.hpp>
36#include <boost/lexical_cast.hpp>
37#include <boost/random.hpp>
38#undef BOOST_BIND_GLOBAL_PLACEHOLDERS
55#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
64#ifdef DEAL_II_WITH_TRILINOS
65# ifdef DEAL_II_WITH_MPI
70# include <Epetra_MpiComm.h>
71# include <Teuchos_DefaultComm.hpp>
73# include <Epetra_SerialComm.h>
74# include <Teuchos_RCP.hpp>
85 <<
"When trying to convert " <<
arg1 <<
" to a string with "
90 <<
"Can't convert the string " <<
arg1
91 <<
" to the desired type");
108 std::vector<std::array<std::uint64_t, effective_dim>>
112 const std::array<LongDouble, dim> &
extents,
117 std::vector<std::array<Integer, effective_dim>>
int_points(points.size());
119 for (
unsigned int i = 0; i < points.size(); ++i)
122 unsigned int eff_d = 0;
123 for (
unsigned int d = 0; d < dim; ++d)
144 template <
int dim,
typename Number>
145 std::vector<std::array<std::uint64_t, dim>>
150 using Integer = std::uint64_t;
155 if (points.size() == 0)
156 return std::vector<std::array<std::uint64_t, dim>>();
160 for (
const auto &p : points)
161 for (
unsigned int d = 0; d < dim; ++d)
163 const double cid = p[d];
168 std::array<LongDouble, dim>
extents;
170 for (
unsigned int i = 0; i < dim; ++i)
181 std::min(std::numeric_limits<Integer>::digits,
182 std::numeric_limits<LongDouble>::digits));
185 const Integer
max_int = (
min_bits == std::numeric_limits<Integer>::digits ?
186 std::numeric_limits<Integer>::max() :
201 std::array<std::uint64_t, dim>
zero_ind;
202 for (
unsigned int d = 0; d < dim; ++d)
205 std::vector<std::array<std::uint64_t, dim>>
ind(points.size(),
zero_ind);
217 for (
unsigned int i = 0; i <
ind.
size(); ++i)
218 for (
unsigned int d = 0; d < 2; ++d)
233 for (
unsigned int i = 0; i <
ind.
size(); ++i)
245 for (
unsigned int i = 0; i < points.size(); ++i)
254 std::vector<std::array<std::uint64_t, dim>>
256 const std::vector<std::array<std::uint64_t, dim>> &points,
259 using Integer = std::uint64_t;
261 std::vector<std::array<Integer, dim>>
int_points(points);
287 ExcMessage(
"This integer type can not hold " +
295 auto &L =
res[index];
298 for (Integer
q =
M;
q > 1;
q >>= 1)
300 const Integer p =
q - 1;
301 for (
unsigned int i = 0; i < dim; ++i)
311 const Integer t = (X[0] ^ X[i]) & p;
319 for (
unsigned int i = 1; i < dim; ++i)
323 for (Integer
q =
M;
q > 1;
q >>= 1)
326 for (
unsigned int i = 0; i < dim; ++i)
341 for (
unsigned int i = 0; i < dim; ++i)
345 for (Integer
q =
M;
q > 0;
q >>= 1)
370 using Integer = std::uint64_t;
378 for (
unsigned int i = 0; i < dim; ++i)
381 const Integer v = (mask & index[dim - 1 - i]) << (
bits_per_dim * i);
392#ifdef DEAL_II_WITH_ZLIB
393 namespace bio = boost::iostreams;
395 std::stringstream compressed;
396 std::stringstream
origin(input);
401 bio::copy(out, compressed);
403 return compressed.str();
414#ifdef DEAL_II_WITH_ZLIB
415 namespace bio = boost::iostreams;
422 out.push(compressed);
436 using namespace boost::archive::iterators;
446 std::vector<unsigned char>
449 using namespace boost::archive::iterators;
478 template <
typename number>
480 to_string(
const number value,
const unsigned int digits)
490 std::string
lc_string = (std::is_integral<number>::value ?
491 std::to_string(value) :
492 boost::lexical_cast<std::string>(value));
511 const std::string &
from,
512 const std::string &
to)
517 std::string out = input;
518 std::string::size_type
pos = out.find(
from);
520 while (
pos != std::string::npos)
531 std::string::size_type left = 0;
532 std::string::size_type right = input.
size() > 0 ? input.size() - 1 : 0;
534 for (; left < input.size(); ++left)
536 if (std::isspace(input[left]) == 0)
542 for (; right >= left; --right)
544 if (std::isspace(input[right]) == 0)
550 return std::string(input, left, right - left + 1);
569 return static_cast<int>(
570 std::ceil(std::log10(std::fabs(
max_number + 0.1))));
577 template <
typename Number>
583 if (!(std::fabs(number) > std::numeric_limits<Number>::min()))
587 static_cast<int>(std::floor(std::log10(std::fabs(number))));
589 const int shift = -order +
static_cast<int>(
n_digits) - 1;
591 Assert(shift <=
static_cast<int>(std::floor(
592 std::log10(std::numeric_limits<Number>::max()))),
594 "Overflow. Use a smaller value for n_digits and/or make sure "
595 "that the absolute value of 'number' does not become too small."));
597 const Number factor =
std::pow(10.0,
static_cast<Number
>(shift));
599 const Number
number_cutoff = std::trunc(number * factor) / factor;
610 while ((s.size() > 0) && (s[0] ==
' '))
612 while ((s.size() > 0) && (s.back() ==
' '))
613 s.erase(s.end() - 1);
623 const int i = std::strtol(s.c_str(), &p, 10);
634 ((s.size() > 0) && (*p !=
'\0'))),
635 ExcMessage(
"Can't convert <" + s +
"> to an integer."));
645 std::vector<int> tmp(s.size());
646 for (
unsigned int i = 0; i < s.size(); ++i)
658 while ((s.size() > 0) && (s[0] ==
' '))
660 while ((s.size() > 0) && (s.back() ==
' '))
661 s.erase(s.end() - 1);
671 const double d = std::strtod(s.c_str(), &p);
682 ((s.size() > 0) && (*p !=
'\0'))),
683 ExcMessage(
"Can't convert <" + s +
"> to a double."));
693 std::vector<double> tmp(s.size());
694 for (
unsigned int i = 0; i < s.size(); ++i)
701 std::vector<std::string>
710 while (tmp.size() != 0 && tmp.back() ==
' ')
711 tmp.erase(tmp.size() - 1, 1);
720 while (tmp.size() != 0)
725 if (name.find(
delimiter) != std::string::npos)
727 name.erase(name.find(
delimiter), std::string::npos);
734 while ((name.size() != 0) && (name[0] ==
' '))
736 while (name.size() != 0 && name.back() ==
' ')
737 name.erase(name.size() - 1, 1);
746 std::vector<std::string>
755 std::vector<std::string>
757 const unsigned int width,
761 std::vector<std::string> lines;
779 while ((line.size() != 0) && (line.back() ==
delimiter))
780 line.erase(line.size() - 1, 1);
781 lines.push_back(line);
794 lines.push_back(
text);
820 while ((line.size() != 0) && (line.back() ==
delimiter))
821 line.erase(line.size() - 1, 1);
822 lines.push_back(line);
835 if (pattern.size() > name.size())
838 for (
unsigned int i = 0; i < pattern.size(); ++i)
839 if (pattern[i] != name[i])
847 std::pair<int, unsigned int>
852 const std::string
test_string(name.begin() + position, name.end());
864 return std::make_pair(i, 1U);
866 return std::make_pair(i, 2U);
868 return std::make_pair(i, 3U);
870 return std::make_pair(i, 4U);
872 return std::make_pair(i, 5U);
873 else if (i < 1000000)
874 return std::make_pair(i, 6U);
875 else if (i < 10000000)
876 return std::make_pair(i, 7U);
904 return boost::normal_distribution<>(a,
958 "Invalid DEAL_II_VECTORIZATION_WIDTH_IN_BITS."));
973 std::ifstream file(
"/proc/self/status");
979 if (name ==
"VmPeak:")
980 file >>
stats.VmPeak;
981 else if (name ==
"VmSize:")
982 file >>
stats.VmSize;
983 else if (name ==
"VmHWM:")
985 else if (name ==
"VmRSS:")
1001#if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
1002 const unsigned int N = 1024;
1016 std::time_t
time1 = std::time(
nullptr);
1017 std::tm * time = std::localtime(&
time1);
1019 std::ostringstream
o;
1020 o << time->tm_hour <<
":" << (time->tm_min < 10 ?
"0" :
"")
1021 << time->tm_min <<
":" << (time->tm_sec < 10 ?
"0" :
"")
1032 std::time_t
time1 = std::time(
nullptr);
1033 std::tm * time = std::localtime(&
time1);
1035 std::ostringstream
o;
1036 o << time->tm_year + 1900 <<
"/" << time->tm_mon + 1 <<
"/"
1071 template std::string
1073 template std::string
1075 template std::string
1077 template std::string
1079 template std::string
1081 template std::string
1083 template std::string
1085 template std::string
1087 template std::string
1095 template std::vector<std::array<std::uint64_t, 1>>
1099 template std::vector<std::array<std::uint64_t, 1>>
1101 const std::vector<std::array<std::uint64_t, 1>> &,
1103 template std::vector<std::array<std::uint64_t, 2>>
1107 template std::vector<std::array<std::uint64_t, 2>>
1109 const std::vector<std::array<std::uint64_t, 2>> &,
1111 template std::vector<std::array<std::uint64_t, 3>>
1115 template std::vector<std::array<std::uint64_t, 3>>
1117 const std::vector<std::array<std::uint64_t, 3>> &,
1120 template std::uint64_t
1122 template std::uint64_t
1124 template std::uint64_t
A class that provides a separate storage location on each thread that accesses the object.
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_PACKAGE_VERSION
#define DEAL_II_VECTORIZATION_WIDTH_IN_BITS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_PACKAGE_NAME
static ::ExceptionBase & ExcInvalidNumber2StringConversersion(unsigned int arg1, unsigned int arg2)
static ::ExceptionBase & ExcOutOfMemory(std::size_t arg1)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcInvalidNumber(unsigned int arg1)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcCantConvertString(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void get_memory_stats(MemoryStats &stats)
std::string get_hostname()
void posix_memalign(void **memptr, std::size_t alignment, std::size_t size)
const std::string get_current_vectorization_level()
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Number truncate_to_n_digits(const Number number, const unsigned int n_digits)
std::string dim_string(const int dim, const int spacedim)
std::uint64_t pack_integers(const std::array< std::uint64_t, dim > &index, const int bits_per_dim)
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
std::string encode_base64(const std::vector< unsigned char > &binary_input)
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
std::vector< unsigned char > decode_base64(const std::string &base64_input)
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
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)
std::string compress(const std::string &input)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
bool match_at_string_start(const std::string &name, const std::string &pattern)
std::string decompress(const std::string &compressed_input)
unsigned int needed_digits(const unsigned int max_number)
double string_to_double(const std::string &s)
std::string dealii_version_string()
std::string trim(const std::string &input)
double generate_normal_random_number(const double a, const double sigma)
int string_to_int(const std::string &s)
static const unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)