StochasticField.h 1.38 KB
Newer Older
1
2
3
#ifndef STOCHASTICFIELD_H
#define STOCHASTICFIELD_H

4
5
#include <utility>

6
#include "CirculantEmbedding.h"
7
#include "HybridFluxGenerator.h"
8
9
10


class StochasticField {
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public:
    string generatorName = "";
    map<int, SampleGenerator *> generators;
    Meshes &meshes;

    explicit StochasticField(Meshes &meshes, string generatorName) :
        meshes(meshes), generatorName(std::move(generatorName)) {
        for (int l = meshes.pLevel(); l <= meshes.Level(); l++)
            generators[l] = getGenerator(l);
    }

    void GetFineSample(int l, Vector &fineField) {
        generators[l]->GetFineSample(fineField);
    }

    void GetCoarseSample(int l, const Vector &fineField, Vector &coarseField) {
        generators[l]->GetCoarseSample(fineField, coarseField);
    }

30
private:
31
32
33
34
35
36
37
    SampleGenerator *getGenerator(int l) {
        if (generatorName == "CirculantEmbedding") {
            if (meshes.dim() == 1)
                return new CirculantEmbedding1D(l, meshes);
            if (meshes.dim() == 2)
                return new CirculantEmbedding2D(l, meshes);
        }
38

39
40
41
42
43
44
45
        if (generatorName == "HybridFluxGenerator") {
            if (meshes.dim() == 1)
                return new HybridFluxGenerator1D(l, meshes);
            if (meshes.dim() == 2)
                return new HybridFluxGenerator2D(l, meshes);
        }
        Exit("Generator does not exist")
46
47
48
49
    }
};

#endif //STOCHASTICFIELD_H