Commit 2d1a440f authored by Praetorius, Simon's avatar Praetorius, Simon

random functor added

parent ab2c1462
......@@ -9,8 +9,29 @@
#include <boost/fusion/include/boost_array.hpp>
#include "MetaTools.h"
#include "Helpers.h"
namespace tools {
struct Random : AbstractFunction<double,WorldVector<double> >
{
Random(double mean_, double amplitude_) : mean(mean_), amplitude(amplitude_)
{
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
mpi::startRand();
#else
std::srand(Helpers::getRandomSeed());
#endif
}
double operator()(const WorldVector<double> &x) const
{
return mean + amplitude * (std::rand() / static_cast<double>(RAND_MAX) - 0.5);
}
private:
double mean;
double amplitude;
};
/// Quadrature Rules
///____________________________________________________________________________________
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment