From 55ab1ca827bc23ae92c73fb7dd0fbb92e35a5a05 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 11 Aug 2005 15:08:39 +0000 Subject: [PATCH] Add new header. git-svn-id: https://svn.dealii.org/trunk@11283 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/utilities.h | 119 ++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 deal.II/base/include/base/utilities.h diff --git a/deal.II/base/include/base/utilities.h b/deal.II/base/include/base/utilities.h new file mode 100644 index 0000000000..7e2c5e7de0 --- /dev/null +++ b/deal.II/base/include/base/utilities.h @@ -0,0 +1,119 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2005 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- +#ifndef __deal2__utilities_h +#define __deal2__utilities_h + +#include + +#include +#include + + + +/** + * A namespace for utility functions that are not particularly specific to + * finite element computing or numerical programs, but nevertheless are needed + * in various contexts when writing applications. + * + * @author Wolfgang Bangerth, 2005 + */ +namespace Utilities +{ + + /** + * Convert a number #i to a string, with + * as many digits as given to fill with + * leading zeros. + */ + std::string + int_to_string (const unsigned int i, + const unsigned int digits); + + /** + * Determine how many digits are needed to + * represent numbers at most as large as + * the given number. + */ + unsigned int + needed_digits (const unsigned int max_number); + + /** + * Given a string, convert it to an + * integer. Throw an assertion if that is + * not possible. + */ + int + string_to_int (const std::string &s); + + + /** + * Given a list of strings, convert it to a + * list of integers. Throw an assertion if + * that is not possible. + */ + std::vector + string_to_int (const std::vector &s); + + /** + * Given a string that contains text + * separated by commas, split it into its + * components; for each component, remove + * leading and trailing spaces. + */ + std::vector + split_comma_separated_list (const std::string &s); + + /** + * Generate a random number from a + * normalized Gaussian probability + * distribution centered around #a and + * with standard deviation #sigma. + */ + double + generate_normal_random_number (const double a, + const double sigma); + + + namespace System + { + + /** + * Return the CPU load as returned by + * "uptime". Note that the interpretation + * of this number depends on the actual + * number of processors in the + * machine. This is presently only + * implemented on Linux, using the + * /proc/loadavg pseudo-file, on other + * systems we simply return zero. + */ + double get_cpu_load (); + + + /** + * Return the name of the host this + * process runs on. + */ + std::string get_hostname (); + + + /** + * Return the present time as HH:MM:SS. + */ + std::string get_time (); + } +} + + +#endif + -- 2.39.5