//---------------------------------------------------------------------------
-// $Id$
+// $Id$
// Version: $Name$
//
// Copyright (C) 2005, 2006, 2008, 2009 by the deal.II authors
<< "Can't convert the string " << arg1
<< " to the desired type");
-
+
std::string
int_to_string (const unsigned int i,
const unsigned int digits)
// not pad the resulting string at all
if (digits == numbers::invalid_unsigned_int)
return int_to_string (i, needed_digits(i));
-
-
+
+
AssertThrow ( ! ((digits==1 && i>=10) ||
(digits==2 && i>=100) ||
(digits==3 && i>=1000) ||
(digits==5 && i>=100000)||
(i>=1000000)),
ExcInvalidNumber2StringConversersion(i, digits));
-
+
std::string s;
- switch (digits)
+ switch (digits)
{
case 6:
s += '0' + i/100000;
}
-
+
int
string_to_int (const std::string &s)
{
#else
static const int max_int = INT_MAX;
#endif
-
+
int i = max_int;
ss >> i;
// check for errors
AssertThrow (i != max_int, ExcCantConvertString (s));
-
+
return i;
}
-
+
std::vector<int>
}
else
tmp = "";
-
+
while ((name.length() != 0) &&
(name[0] == ' '))
name.erase (0,1);
// remove trailing spaces
while ((text.length() != 0) && (text[text.length()-1] == delimiter))
text.erase(text.length()-1,1);
-
+
// then split the text into lines
while (text.length() != 0)
{
for (; location>0; --location)
if (text[location] == delimiter)
break;
-
+
// if there are no spaces, then try if
// there are spaces coming up
if (location == 0)
++location)
if (text[location] == delimiter)
break;
-
+
// now take the text up to the found
// location and put it into a single
// line, and remove it from 'text'
text.erase (0, location);
}
}
-
+
return lines;
}
-
+
bool
return true;
}
-
+
std::pair<int, unsigned int>
get_integer_at_position (const std::string &name,
const unsigned int position)
{
Assert (position < name.size(), ExcInternalError());
-
+
const std::string test_string (name.begin()+position,
name.end());
-
+
std::istringstream str(test_string);
int i;
return std::make_pair (-1, numbers::invalid_unsigned_int);
}
-
+
double
generate_normal_random_number (const double a,
if (sigma == 0)
return a;
-#ifdef HAVE_RAND_R
+#ifdef HAVE_RAND_R
static unsigned int seed = 0xabcd1234;
const double y = 1.0*rand_r(&seed)/RAND_MAX;
#else
reverse_permutation (const std::vector<unsigned int> &permutation)
{
const unsigned int n = permutation.size();
-
+
std::vector<unsigned int> out (n);
for (unsigned int i=0; i<n; ++i)
out[i] = n - 1 - permutation[i];
invert_permutation (const std::vector<unsigned int> &permutation)
{
const unsigned int n = permutation.size();
-
+
std::vector<unsigned int> out (n, numbers::invalid_unsigned_int);
-
+
for (unsigned int i=0; i<n; ++i)
{
Assert (permutation[i] < n, ExcIndexRange (permutation[i], 0, n));
for (unsigned int i=0; i<n; ++i)
Assert (out[i] != numbers::invalid_unsigned_int,
ExcMessage ("The given input permutation had duplicate entries!"));
-
+
return out;
}
-
+
{
std::ifstream cpuinfo;
cpuinfo.open("/proc/loadavg");
-
+
AssertThrow(cpuinfo, ExcIO());
double load;
}
#else
-
+
double get_cpu_load ()
{
return 0.;
}
-
+
#endif
std::string get_time ()
{
std::time_t time1= std::time (0);
- std::tm *time = std::localtime(&time1);
+ std::tm *time = std::localtime(&time1);
std::ostringstream o;
o << time->tm_hour << ":"
return o.str();
}
-
+
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
bool job_supports_mpi ()
return (MPI_has_been_started > 0);
}
-
+
// Unfortunately, we have to work
// around an oddity in the way PETSc
// and some gcc versions interact. If
{
int n_jobs=1;
(void) MPI_Comm_size (mpi_communicator, &n_jobs);
-
+
return n_jobs;
}
-
+
unsigned int get_this_mpi_process (const MPI_Comm &mpi_communicator)
{
int rank=0;
(void) MPI_Comm_rank (mpi_communicator, &rank);
-
+
return rank;
}
MPI_Comm_dup (mpi_communicator, &new_communicator);
return new_communicator;
}
-
-
+
+
#else
-
+
bool job_supports_mpi ()
{
return false;
}
-
+
unsigned int get_this_mpi_process (const MPI_Comm &)
{
return 0;
}
-
+
MPI_Comm duplicate_communicator (const MPI_Comm &mpi_communicator)
{
return mpi_communicator;
static bool constructor_has_already_run = false;
Assert (constructor_has_already_run == false,
ExcMessage ("You can only create a single object of this class "
- "in a program sinc it initialize the MPI system."));
-
+ "in a program since it initializes the MPI system."));
+
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
int MPI_has_been_started = 0;
MPI_Initialized(&MPI_has_been_started);
#else
return false;
#endif
- }
+ }
}
-
+
#ifdef DEAL_II_USE_TRILINOS
-
+
namespace Trilinos
{
const Epetra_Comm&
static Teuchos::RCP<Epetra_SerialComm>
communicator = Teuchos::rcp (new Epetra_SerialComm (), true);
#endif
-
+
return *communicator;
}
static Teuchos::RCP<Epetra_SerialComm>
communicator = Teuchos::rcp (new Epetra_SerialComm (), true);
#endif
-
+
return *communicator;
}
void destroy_communicator (Epetra_Comm &communicator)
{
Assert (&communicator != 0, ExcInternalError());
-
+
// save the communicator, reset
// the map, and delete the
// communicator if this whole
#endif
}
-
+
unsigned int get_n_mpi_processes (const Epetra_Comm &mpi_communicator)
{
return mpi_communicator.NumProc();
}
-
+
unsigned int get_this_mpi_process (const Epetra_Comm &mpi_communicator)
{
}
-
+
Epetra_Map
duplicate_map (const Epetra_BlockMap &map,
const Epetra_Comm &comm)
comm);
}
}
-
+
#endif
}