StochasticField.h 1.67 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
11


class StochasticField {
private:
12
13
14
15
16
17
18
19
20
21
22
23
24
    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);
        }
        if (generatorName == "HybridFluxGenerator") {
            if (meshes.dim() == 1)
                return new HybridFluxGenerator1D(l, meshes);
            if (meshes.dim() == 2)
                return new HybridFluxGenerator2D(l, meshes);
        }
25
26
27
28
29
30
        if (generatorName == "DeterministicHybridFluxGenerator") {
            if (meshes.dim() == 1)
                return new DeterministicHybridFluxGenerator1D(l, meshes);
            if (meshes.dim() == 2)
                return new DeterministicHybridFluxGenerator2D(l, meshes);
        }
31
        Exit("Generator does not exist")
32
33
34
    }

public:
35
    string generatorName = "";
36
    map<int, SampleGenerator *> generators;
37
    Meshes &meshes;
38

39
40
41
    explicit StochasticField(Meshes &meshes, string generatorName) :
        meshes(meshes), generatorName(std::move(generatorName)) {
        for (int l = meshes.pLevel(); l <= meshes.Level(); l++)
42
43
44
45
46
47
48
49
50
51
52
53
54
            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);
    }
};

#endif //STOCHASTICFIELD_H