Reference documentation for deal.II version 9.1.0-pre
utilities.cc
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 #include <deal.II/base/config.h>
17 
18 // It's necessary to include winsock2.h before thread_local_storage.h,
19 // because Intel implementation of TBB includes winsock.h,
20 // and we'll get a conflict between winsock.h and winsock2.h otherwise.
21 #ifdef DEAL_II_MSVC
22 # include <winsock2.h>
23 #endif
24 
25 #include <deal.II/base/exceptions.h>
26 #include <deal.II/base/mpi.h>
27 #include <deal.II/base/thread_local_storage.h>
28 #include <deal.II/base/utilities.h>
29 
30 #include <boost/lexical_cast.hpp>
31 #include <boost/math/special_functions/erf.hpp>
32 #include <boost/random.hpp>
33 
34 #include <algorithm>
35 #include <cctype>
36 #include <cerrno>
37 #include <cmath>
38 #include <cstddef>
39 #include <cstdio>
40 #include <ctime>
41 #include <fstream>
42 #include <iomanip>
43 #include <iostream>
44 #include <limits>
45 #include <sstream>
46 
47 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
48 # include <unistd.h>
49 #endif
50 
51 #ifndef DEAL_II_MSVC
52 # include <cstdlib>
53 #endif
54 
55 
56 #ifdef DEAL_II_WITH_TRILINOS
57 # ifdef DEAL_II_WITH_MPI
58 # include <deal.II/lac/trilinos_parallel_block_vector.h>
59 # include <deal.II/lac/trilinos_vector.h>
60 # include <deal.II/lac/vector_memory.h>
61 
62 # include <Epetra_MpiComm.h>
63 # endif
64 # include <Epetra_SerialComm.h>
65 # include <Teuchos_RCP.hpp>
66 #endif
67 
68 
69 
70 DEAL_II_NAMESPACE_OPEN
71 
72 
73 namespace Utilities
74 {
76  unsigned int,
77  unsigned int,
78  << "When trying to convert " << arg1 << " to a string with "
79  << arg2 << " digits");
80  DeclException1(ExcInvalidNumber, unsigned int, << "Invalid number " << arg1);
82  std::string,
83  << "Can't convert the string " << arg1
84  << " to the desired type");
85 
86 
87  std::string
89  {
90  return DEAL_II_PACKAGE_NAME " version " DEAL_II_PACKAGE_VERSION;
91  }
92 
93 
94 
95  std::string
96  int_to_string(const unsigned int value, const unsigned int digits)
97  {
98  return to_string(value, digits);
99  }
100 
101 
102 
103  template <typename number>
104  std::string
105  to_string(const number value, const unsigned int digits)
106  {
107  std::string lc_string = boost::lexical_cast<std::string>(value);
108 
109  if (digits == numbers::invalid_unsigned_int)
110  return lc_string;
111  else if (lc_string.size() < digits)
112  {
113  // We have to add the padding zeroes in front of the number
114  const unsigned int padding_position = (lc_string[0] == '-') ? 1 : 0;
115 
116  const std::string padding(digits - lc_string.size(), '0');
117  lc_string.insert(padding_position, padding);
118  }
119  return lc_string;
120  }
121 
122 
123  std::string
124  replace_in_string(const std::string &input,
125  const std::string &from,
126  const std::string &to)
127  {
128  if (from.empty())
129  return input;
130 
131  std::string out = input;
132  std::string::size_type pos = out.find(from);
133 
134  while (pos != std::string::npos)
135  {
136  out.replace(pos, from.size(), to);
137  pos = out.find(from, pos + to.size());
138  }
139  return out;
140  }
141 
142  std::string
143  trim(const std::string &input)
144  {
145  std::string::size_type left = 0;
146  std::string::size_type right = input.size() > 0 ? input.size() - 1 : 0;
147 
148  for (; left < input.size(); ++left)
149  {
150  if (!std::isspace(input[left]))
151  {
152  break;
153  }
154  }
155 
156  for (; right >= left; --right)
157  {
158  if (!std::isspace(input[right]))
159  {
160  break;
161  }
162  }
163 
164  return std::string(input, left, right - left + 1);
165  }
166 
167 
168 
169  std::string
170  dim_string(const int dim, const int spacedim)
171  {
172  if (dim == spacedim)
173  return int_to_string(dim);
174  else
175  return int_to_string(dim) + "," + int_to_string(spacedim);
176  }
177 
178 
179  unsigned int
180  needed_digits(const unsigned int max_number)
181  {
182  if (max_number < 10)
183  return 1;
184  if (max_number < 100)
185  return 2;
186  if (max_number < 1000)
187  return 3;
188  if (max_number < 10000)
189  return 4;
190  if (max_number < 100000)
191  return 5;
192  if (max_number < 1000000)
193  return 6;
194  AssertThrow(false, ExcInvalidNumber(max_number));
195  return 0;
196  }
197 
198 
199 
200  int
201  string_to_int(const std::string &s_)
202  {
203  // trim whitespace on either side of the text if necessary
204  std::string s = s_;
205  while ((s.size() > 0) && (s[0] == ' '))
206  s.erase(s.begin());
207  while ((s.size() > 0) && (s[s.size() - 1] == ' '))
208  s.erase(s.end() - 1);
209 
210  // now convert and see whether we succeed. note that strtol only
211  // touches errno if an error occurred, so if we want to check
212  // whether an error happened, we need to make sure that errno==0
213  // before calling strtol since otherwise it may be that the
214  // conversion succeeds and that errno remains at the value it
215  // was before, whatever that was
216  char *p;
217  errno = 0;
218  const int i = std::strtol(s.c_str(), &p, 10);
219  AssertThrow(!((errno != 0) || (s.size() == 0) ||
220  ((s.size() > 0) && (*p != '\0'))),
221  ExcMessage("Can't convert <" + s + "> to an integer."));
222 
223  return i;
224  }
225 
226 
227 
228  std::vector<int>
229  string_to_int(const std::vector<std::string> &s)
230  {
231  std::vector<int> tmp(s.size());
232  for (unsigned int i = 0; i < s.size(); ++i)
233  tmp[i] = string_to_int(s[i]);
234  return tmp;
235  }
236 
237 
238 
239  double
240  string_to_double(const std::string &s_)
241  {
242  // trim whitespace on either side of the text if necessary
243  std::string s = s_;
244  while ((s.size() > 0) && (s[0] == ' '))
245  s.erase(s.begin());
246  while ((s.size() > 0) && (s[s.size() - 1] == ' '))
247  s.erase(s.end() - 1);
248 
249  // now convert and see whether we succeed. note that strtol only
250  // touches errno if an error occurred, so if we want to check
251  // whether an error happened, we need to make sure that errno==0
252  // before calling strtol since otherwise it may be that the
253  // conversion succeeds and that errno remains at the value it
254  // was before, whatever that was
255  char *p;
256  errno = 0;
257  const double d = std::strtod(s.c_str(), &p);
258  AssertThrow(!((errno != 0) || (s.size() == 0) ||
259  ((s.size() > 0) && (*p != '\0'))),
260  ExcMessage("Can't convert <" + s + "> to a double."));
261 
262  return d;
263  }
264 
265 
266 
267  std::vector<double>
268  string_to_double(const std::vector<std::string> &s)
269  {
270  std::vector<double> tmp(s.size());
271  for (unsigned int i = 0; i < s.size(); ++i)
272  tmp[i] = string_to_double(s[i]);
273  return tmp;
274  }
275 
276 
277 
278  std::vector<std::string>
279  split_string_list(const std::string &s, const std::string &delimiter)
280  {
281  // keep the currently remaining part of the input string in 'tmp' and
282  // keep chopping elements of the list off the front
283  std::string tmp = s;
284 
285  // as discussed in the documentation, eat whitespace from the end
286  // of the string
287  while (tmp.length() != 0 && tmp[tmp.length() - 1] == ' ')
288  tmp.erase(tmp.length() - 1, 1);
289 
290  // split the input list until it is empty. since in every iteration
291  // 'tmp' is what's left of the string after the next delimiter,
292  // and since we've stripped trailing space already, 'tmp' will
293  // be empty at one point if 's' ended in a delimiter, even if
294  // there was space after the last delimiter. this matches what's
295  // discussed in the documentation
296  std::vector<std::string> split_list;
297  while (tmp.length() != 0)
298  {
299  std::string name;
300  name = tmp;
301 
302  if (name.find(delimiter) != std::string::npos)
303  {
304  name.erase(name.find(delimiter), std::string::npos);
305  tmp.erase(0, tmp.find(delimiter) + delimiter.size());
306  }
307  else
308  tmp = "";
309 
310  // strip spaces from this element's front and end
311  while ((name.length() != 0) && (name[0] == ' '))
312  name.erase(0, 1);
313  while (name.length() != 0 && name[name.length() - 1] == ' ')
314  name.erase(name.length() - 1, 1);
315 
316  split_list.push_back(name);
317  }
318 
319  return split_list;
320  }
321 
322 
323  std::vector<std::string>
324  split_string_list(const std::string &s, const char delimiter)
325  {
326  std::string d = ",";
327  d[0] = delimiter;
328  return split_string_list(s, d);
329  }
330 
331 
332  std::vector<std::string>
333  break_text_into_lines(const std::string &original_text,
334  const unsigned int width,
335  const char delimiter)
336  {
337  std::string text = original_text;
338  std::vector<std::string> lines;
339 
340  // remove trailing spaces
341  while ((text.length() != 0) && (text[text.length() - 1] == delimiter))
342  text.erase(text.length() - 1, 1);
343 
344  // then split the text into lines
345  while (text.length() != 0)
346  {
347  // in each iteration, first remove
348  // leading spaces
349  while ((text.length() != 0) && (text[0] == delimiter))
350  text.erase(0, 1);
351 
352  std::size_t pos_newline = text.find_first_of('\n', 0);
353  if (pos_newline != std::string::npos && pos_newline <= width)
354  {
355  std::string line(text, 0, pos_newline);
356  while ((line.length() != 0) &&
357  (line[line.length() - 1] == delimiter))
358  line.erase(line.length() - 1, 1);
359  lines.push_back(line);
360  text.erase(0, pos_newline + 1);
361  continue;
362  }
363 
364  // if we can fit everything into one
365  // line, then do so. otherwise, we have
366  // to keep breaking
367  if (text.length() < width)
368  {
369  // remove trailing spaces
370  while ((text.length() != 0) &&
371  (text[text.length() - 1] == delimiter))
372  text.erase(text.length() - 1, 1);
373  lines.push_back(text);
374  text = "";
375  }
376  else
377  {
378  // starting at position width, find the
379  // location of the previous space, so
380  // that we can break around there
381  int location = std::min<int>(width, text.length() - 1);
382  for (; location > 0; --location)
383  if (text[location] == delimiter)
384  break;
385 
386  // if there are no spaces, then try if
387  // there are spaces coming up
388  if (location == 0)
389  for (location = std::min<int>(width, text.length() - 1);
390  location < static_cast<int>(text.length());
391  ++location)
392  if (text[location] == delimiter)
393  break;
394 
395  // now take the text up to the found
396  // location and put it into a single
397  // line, and remove it from 'text'
398  std::string line(text, 0, location);
399  while ((line.length() != 0) &&
400  (line[line.length() - 1] == delimiter))
401  line.erase(line.length() - 1, 1);
402  lines.push_back(line);
403  text.erase(0, location);
404  }
405  }
406 
407  return lines;
408  }
409 
410 
411 
412  bool
413  match_at_string_start(const std::string &name, const std::string &pattern)
414  {
415  if (pattern.size() > name.size())
416  return false;
417 
418  for (unsigned int i = 0; i < pattern.size(); ++i)
419  if (pattern[i] != name[i])
420  return false;
421 
422  return true;
423  }
424 
425 
426 
427  std::pair<int, unsigned int>
428  get_integer_at_position(const std::string &name, const unsigned int position)
429  {
430  Assert(position < name.size(), ExcInternalError());
431 
432  const std::string test_string(name.begin() + position, name.end());
433 
434  std::istringstream str(test_string);
435 
436  int i;
437  if (str >> i)
438  {
439  // compute the number of
440  // digits of i. assuming it
441  // is less than 8 is likely
442  // ok
443  if (i < 10)
444  return std::make_pair(i, 1U);
445  else if (i < 100)
446  return std::make_pair(i, 2U);
447  else if (i < 1000)
448  return std::make_pair(i, 3U);
449  else if (i < 10000)
450  return std::make_pair(i, 4U);
451  else if (i < 100000)
452  return std::make_pair(i, 5U);
453  else if (i < 1000000)
454  return std::make_pair(i, 6U);
455  else if (i < 10000000)
456  return std::make_pair(i, 7U);
457  else
458  {
459  Assert(false, ExcNotImplemented());
460  return std::make_pair(-1, numbers::invalid_unsigned_int);
461  }
462  }
463  else
464  return std::make_pair(-1, numbers::invalid_unsigned_int);
465  }
466 
467 
468 
469  double
470  generate_normal_random_number(const double a, const double sigma)
471  {
472  // if no noise: return now
473  if (sigma == 0)
474  return a;
475 
476  // we would want to use rand(), but that function is not reentrant
477  // in a thread context. one could use rand_r, but this does not
478  // produce reproducible results between threads either (though at
479  // least it is reentrant). these two approaches being
480  // non-workable, use a thread-local random number generator here
481  static Threads::ThreadLocalStorage<boost::mt19937> random_number_generator;
482  return boost::normal_distribution<>(a,
483  sigma)(random_number_generator.get());
484  }
485 
486 
487 
488  std::vector<unsigned int>
489  reverse_permutation(const std::vector<unsigned int> &permutation)
490  {
491  const unsigned int n = permutation.size();
492 
493  std::vector<unsigned int> out(n);
494  for (unsigned int i = 0; i < n; ++i)
495  out[i] = n - 1 - permutation[i];
496 
497  return out;
498  }
499 
500 
501 
502  std::vector<unsigned int>
503  invert_permutation(const std::vector<unsigned int> &permutation)
504  {
505  const unsigned int n = permutation.size();
506 
507  std::vector<unsigned int> out(n, numbers::invalid_unsigned_int);
508 
509  for (unsigned int i = 0; i < n; ++i)
510  {
511  Assert(permutation[i] < n, ExcIndexRange(permutation[i], 0, n));
512  out[permutation[i]] = i;
513  }
514 
515  // check that we have actually reached
516  // all indices
517  for (unsigned int i = 0; i < n; ++i)
519  ExcMessage("The given input permutation had duplicate entries!"));
520 
521  return out;
522  }
523 
524  std::vector<unsigned long long int>
525  reverse_permutation(const std::vector<unsigned long long int> &permutation)
526  {
527  const unsigned long long int n = permutation.size();
528 
529  std::vector<unsigned long long int> out(n);
530  for (unsigned long long int i = 0; i < n; ++i)
531  out[i] = n - 1 - permutation[i];
532 
533  return out;
534  }
535 
536 
537 
538  std::vector<unsigned long long int>
539  invert_permutation(const std::vector<unsigned long long int> &permutation)
540  {
541  const unsigned long long int n = permutation.size();
542 
543  std::vector<unsigned long long int> out(n, numbers::invalid_unsigned_int);
544 
545  for (unsigned long long int i = 0; i < n; ++i)
546  {
547  Assert(permutation[i] < n, ExcIndexRange(permutation[i], 0, n));
548  out[permutation[i]] = i;
549  }
550 
551  // check that we have actually reached
552  // all indices
553  for (unsigned long long int i = 0; i < n; ++i)
555  ExcMessage("The given input permutation had duplicate entries!"));
556 
557  return out;
558  }
559 
560 
561  template <typename Integer>
562  std::vector<Integer>
563  reverse_permutation(const std::vector<Integer> &permutation)
564  {
565  const unsigned int n = permutation.size();
566 
567  std::vector<Integer> out(n);
568  for (unsigned int i = 0; i < n; ++i)
569  out[i] = n - 1 - permutation[i];
570 
571  return out;
572  }
573 
574 
575 
576  template <typename Integer>
577  std::vector<Integer>
578  invert_permutation(const std::vector<Integer> &permutation)
579  {
580  const unsigned int n = permutation.size();
581 
582  std::vector<Integer> out(n, numbers::invalid_unsigned_int);
583 
584  for (unsigned int i = 0; i < n; ++i)
585  {
586  Assert(permutation[i] < n, ExcIndexRange(permutation[i], 0, n));
587  out[permutation[i]] = i;
588  }
589 
590  // check that we have actually reached
591  // all indices
592  for (unsigned int i = 0; i < n; ++i)
594  ExcMessage("The given input permutation had duplicate entries!"));
595 
596  return out;
597  }
598 
599 
600 
601  namespace System
602  {
603 #if defined(__linux__)
604 
605  double
606  get_cpu_load()
607  {
608  std::ifstream cpuinfo;
609  cpuinfo.open("/proc/loadavg");
610 
611  AssertThrow(cpuinfo, ExcIO());
612 
613  double load;
614  cpuinfo >> load;
615 
616  return load;
617  }
618 
619 #else
620 
621  double
623  {
624  return 0.;
625  }
626 
627 #endif
628 
629  const std::string
631  {
632  switch (DEAL_II_COMPILER_VECTORIZATION_LEVEL)
633  {
634  case 0:
635  return "disabled";
636  case 1:
637  return "SSE2";
638  case 2:
639  return "AVX";
640  case 3:
641  return "AVX512";
642  default:
643  AssertThrow(false,
645  "Invalid DEAL_II_COMPILER_VECTORIZATION_LEVEL."));
646  return "ERROR";
647  }
648  }
649 
650 
651  void
653  {
654  stats.VmPeak = stats.VmSize = stats.VmHWM = stats.VmRSS = 0;
655 
656  // parsing /proc/self/stat would be a
657  // lot easier, but it does not contain
658  // VmHWM, so we use /status instead.
659 #if defined(__linux__)
660  std::ifstream file("/proc/self/status");
661  std::string line;
662  std::string name;
663  while (!file.eof())
664  {
665  file >> name;
666  if (name == "VmPeak:")
667  file >> stats.VmPeak;
668  else if (name == "VmSize:")
669  file >> stats.VmSize;
670  else if (name == "VmHWM:")
671  file >> stats.VmHWM;
672  else if (name == "VmRSS:")
673  {
674  file >> stats.VmRSS;
675  break; // this is always the last entry
676  }
677 
678  getline(file, line);
679  }
680 #endif
681  }
682 
683 
684 
685  std::string
687  {
688 #if defined(DEAL_II_HAVE_UNISTD_H) && defined(DEAL_II_HAVE_GETHOSTNAME)
689  const unsigned int N = 1024;
690  char hostname[N];
691  gethostname(&(hostname[0]), N - 1);
692 #else
693  std::string hostname("unknown");
694 #endif
695  return hostname;
696  }
697 
698 
699 
700  std::string
702  {
703  std::time_t time1 = std::time(nullptr);
704  std::tm * time = std::localtime(&time1);
705 
706  std::ostringstream o;
707  o << time->tm_hour << ":" << (time->tm_min < 10 ? "0" : "")
708  << time->tm_min << ":" << (time->tm_sec < 10 ? "0" : "")
709  << time->tm_sec;
710 
711  return o.str();
712  }
713 
714 
715 
716  std::string
718  {
719  std::time_t time1 = std::time(nullptr);
720  std::tm * time = std::localtime(&time1);
721 
722  std::ostringstream o;
723  o << time->tm_year + 1900 << "/" << time->tm_mon + 1 << "/"
724  << time->tm_mday;
725 
726  return o.str();
727  }
728 
729 
730 
731  void
732  posix_memalign(void **memptr, size_t alignment, size_t size)
733  {
734 #ifndef DEAL_II_MSVC
735  const int ierr = ::posix_memalign(memptr, alignment, size);
736 
737  AssertThrow(ierr == 0, ExcOutOfMemory());
738  AssertThrow(*memptr != nullptr, ExcOutOfMemory());
739 #else
740  // Windows does not appear to have posix_memalign. just use the
741  // regular malloc in that case
742  *memptr = malloc(size);
743  (void)alignment;
744  AssertThrow(*memptr != 0, ExcOutOfMemory());
745 #endif
746  }
747 
748 
749 
750  bool
751  job_supports_mpi()
752  {
754  }
755  } // namespace System
756 
757 
758 #ifdef DEAL_II_WITH_TRILINOS
759 
760  namespace Trilinos
761  {
762  const Epetra_Comm &
764  {
765 # ifdef DEAL_II_WITH_MPI
766  static Teuchos::RCP<Epetra_MpiComm> communicator =
767  Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_WORLD), true);
768 # else
769  static Teuchos::RCP<Epetra_SerialComm> communicator =
770  Teuchos::rcp(new Epetra_SerialComm(), true);
771 # endif
772 
773  return *communicator;
774  }
775 
776 
777 
778  const Epetra_Comm &
780  {
781 # ifdef DEAL_II_WITH_MPI
782  static Teuchos::RCP<Epetra_MpiComm> communicator =
783  Teuchos::rcp(new Epetra_MpiComm(MPI_COMM_SELF), true);
784 # else
785  static Teuchos::RCP<Epetra_SerialComm> communicator =
786  Teuchos::rcp(new Epetra_SerialComm(), true);
787 # endif
788 
789  return *communicator;
790  }
791 
792 
793 
794  Epetra_Comm *
795  duplicate_communicator(const Epetra_Comm &communicator)
796  {
797 # ifdef DEAL_II_WITH_MPI
798 
799  // see if the communicator is in fact a
800  // parallel MPI communicator; if so,
801  // return a duplicate of it
802  const Epetra_MpiComm *mpi_comm =
803  dynamic_cast<const Epetra_MpiComm *>(&communicator);
804  if (mpi_comm != nullptr)
805  return new Epetra_MpiComm(
806  Utilities::MPI::duplicate_communicator(mpi_comm->GetMpiComm()));
807 # endif
808 
809  // if we don't support MPI, or if the
810  // communicator in question was in fact
811  // not an MPI communicator, return a
812  // copy of the same object again
813  Assert(dynamic_cast<const Epetra_SerialComm *>(&communicator) != nullptr,
814  ExcInternalError());
815  return new Epetra_SerialComm(
816  dynamic_cast<const Epetra_SerialComm &>(communicator));
817  }
818 
819 
820 
821  void
822  destroy_communicator(Epetra_Comm &communicator)
823  {
824  // save the communicator, reset the map, and delete the communicator if
825  // this whole thing was created as an MPI communicator
826 # ifdef DEAL_II_WITH_MPI
827  Epetra_MpiComm *mpi_comm = dynamic_cast<Epetra_MpiComm *>(&communicator);
828  if (mpi_comm != nullptr)
829  {
830  MPI_Comm comm = mpi_comm->GetMpiComm();
831  *mpi_comm = Epetra_MpiComm(MPI_COMM_SELF);
832  const int ierr = MPI_Comm_free(&comm);
833  AssertThrowMPI(ierr);
834  }
835 # endif
836  }
837 
838 
839 
840  unsigned int
841  get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
842  {
843  return mpi_communicator.NumProc();
844  }
845 
846 
847  unsigned int
848  get_this_mpi_process(const Epetra_Comm &mpi_communicator)
849  {
850  return (unsigned int)mpi_communicator.MyPID();
851  }
852 
853 
854 
855  Epetra_Map
856  duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
857  {
858  if (map.LinearMap() == true)
859  {
860  // each processor stores a
861  // contiguous range of
862  // elements in the
863  // following constructor
864  // call
865  return Epetra_Map(map.NumGlobalElements(),
866  map.NumMyElements(),
867  map.IndexBase(),
868  comm);
869  }
870  else
871  {
872  // the range is not
873  // contiguous
874  return Epetra_Map(map.NumGlobalElements(),
875  map.NumMyElements(),
876  map.MyGlobalElements(),
877  0,
878  comm);
879  }
880  }
881  } // namespace Trilinos
882 
883 #endif
884 
885  template std::string
886  to_string<int>(int, unsigned int);
887  template std::string
888  to_string<long int>(long int, unsigned int);
889  template std::string
890  to_string<long long int>(long long int, unsigned int);
891  template std::string
892  to_string<unsigned int>(unsigned int, unsigned int);
893  template std::string
894  to_string<unsigned long int>(unsigned long int, unsigned int);
895  template std::string
896  to_string<unsigned long long int>(unsigned long long int, unsigned int);
897  template std::string
898  to_string<float>(float, unsigned int);
899  template std::string
900  to_string<double>(double, unsigned int);
901  template std::string
902  to_string<long double>(long double, unsigned int);
903 
904 } // namespace Utilities
905 
906 DEAL_II_NAMESPACE_CLOSE
std::vector< std::string > split_string_list(const std::string &s, const std::string &delimiter=",")
Definition: utilities.cc:279
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:420
A class that provides a separate storage location on each thread that accesses the object...
static::ExceptionBase & ExcIO()
std::string dealii_version_string()
Definition: utilities.cc:88
unsigned int get_n_mpi_processes(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:841
std::string trim(const std::string &input)
Definition: utilities.cc:143
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
Definition: utilities.cc:428
#define AssertThrow(cond, exc)
Definition: exceptions.h:1329
static::ExceptionBase & ExcOutOfMemory()
const Epetra_Comm & comm_self()
Definition: utilities.cc:779
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
std::string get_date()
Definition: utilities.cc:717
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:105
void get_memory_stats(MemoryStats &stats)
Definition: utilities.cc:652
double string_to_double(const std::string &s)
Definition: utilities.cc:240
double get_cpu_load()
Definition: utilities.cc:622
static::ExceptionBase & ExcMessage(std::string arg1)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
double generate_normal_random_number(const double a, const double sigma)
Definition: utilities.cc:470
#define Assert(cond, exc)
Definition: exceptions.h:1227
unsigned long int VmSize
Definition: utilities.h:712
static::ExceptionBase & ExcCantConvertString(std::string arg1)
static::ExceptionBase & ExcInvalidNumber(unsigned int arg1)
bool match_at_string_start(const std::string &name, const std::string &pattern)
Definition: utilities.cc:413
void posix_memalign(void **memptr, size_t alignment, size_t size)
Definition: utilities.cc:732
std::vector< unsigned int > invert_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:503
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition: utilities.cc:96
std::string replace_in_string(const std::string &input, const std::string &from, const std::string &to)
Definition: utilities.cc:124
std::string dim_string(const int dim, const int spacedim)
Definition: utilities.cc:170
void destroy_communicator(Epetra_Comm &communicator)
Definition: utilities.cc:822
Definition: cuda.h:32
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter= ' ')
Definition: utilities.cc:333
std::string get_hostname()
Definition: utilities.cc:686
#define AssertThrowMPI(error_code)
Definition: exceptions.h:1443
MPI_Comm duplicate_communicator(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:91
unsigned long int VmHWM
Definition: utilities.h:717
const Epetra_Comm & comm_world()
Definition: utilities.cc:763
int string_to_int(const std::string &s)
Definition: utilities.cc:201
std::vector< unsigned int > reverse_permutation(const std::vector< unsigned int > &permutation)
Definition: utilities.cc:489
static::ExceptionBase & ExcNotImplemented()
unsigned long int VmRSS
Definition: utilities.h:723
unsigned int get_this_mpi_process(const Epetra_Comm &mpi_communicator)
Definition: utilities.cc:848
const std::string get_current_vectorization_level()
Definition: utilities.cc:630
Epetra_Map duplicate_map(const Epetra_BlockMap &map, const Epetra_Comm &comm)
Definition: utilities.cc:856
std::string get_time()
Definition: utilities.cc:701
bool job_supports_mpi()
Definition: mpi.cc:690
unsigned long int VmPeak
Definition: utilities.h:707
unsigned int needed_digits(const unsigned int max_number)
Definition: utilities.cc:180
static::ExceptionBase & ExcInternalError()
static::ExceptionBase & ExcInvalidNumber2StringConversersion(unsigned int arg1, unsigned int arg2)