-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomField.h
78 lines (57 loc) · 1.97 KB
/
RandomField.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* RandomField.h
*
* Created on: Dec 16, 2014
* Author: viktor
*/
#ifndef RANDOMFIELD_H_
#define RANDOMFIELD_H_
#include <deal.II/base/function.h> // function base class
#include "RandomGenerator.h" // random generator
using namespace dealii;
namespace MonteCarlo
{
/*---------------------------------------------------------------------------*/
/* Class interface */
/*---------------------------------------------------------------------------*/
template< int dim >
class RandomField : public Function<dim>
{
public:
RandomField() {};
virtual ~RandomField() {};
void generate(); // generate instance, i.e. generate random vector
void set_random_vector(std::vector<double> &set_vector);
static int get_stoch_dim();
protected:
std::vector<double> random_vector;
static distributions type_of_distribution;
static int stoch_dim;
virtual double phi( double x, int n ) const = 0; // n-th eigenfunction value of the K-L series
virtual double ksi( int n ) const = 0; // n-th eigenvalue of the K-L series
};
template<int dim> distributions RandomField<dim>::type_of_distribution;
template<int dim> int RandomField<dim>::stoch_dim;
/*---------------------------------------------------------------------------*/
/* Class implementation */
/*---------------------------------------------------------------------------*/
template< int dim >
void RandomField<dim>::generate()
{
RandomGenerator generate1( type_of_distribution, stoch_dim );
double *vector = generate1.vector();
random_vector.assign( vector, vector + stoch_dim );
delete vector;
}
template< int dim >
void RandomField<dim>::set_random_vector(std::vector<double> &set_vector)
{
random_vector = set_vector;
}
template< int dim >
int RandomField<dim>::get_stoch_dim()
{
return stoch_dim;
}
}//MonteCarlo
#endif /* RANDOMFIELD_H_ */