StochasticField.h 1.35 KB
Newer Older
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
#ifndef STOCHASTICFIELD_H
#define STOCHASTICFIELD_H

#include "CirculantEmbedding.h"
#include "HybridFluxCalculator.h"


class StochasticField {
private:
    virtual SampleGenerator *getGenerator(int l) {
        if (dim == 1)
            return new CirculantEmbedding1D(l);
        if (dim == 2)
            return new CirculantEmbedding2D(l);
    }

public:
    map<int, SampleGenerator *> generators;
    int pLevel = 0, maxLevel = 0, dim = 0;

    explicit StochasticField(Meshes *meshes) {
        pLevel = meshes->pLevel();
        maxLevel = meshes->Level();
        dim = meshes->dim();
        for (int l = pLevel; l <= maxLevel; 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);
    }
};

class StochasticVectorField : public StochasticField {
private:
    SampleGenerator *getGenerator(int l) {
        if (dim == 1)
            return nullptr;
//            return new HybridPollutionFluxCalculator1D(l);
        if (dim == 2)
            return new HybridPollutionFluxCalculator2D(l);
    }

public:
    explicit StochasticVectorField(Meshes *meshes) : StochasticField(meshes) {}
};

#endif //STOCHASTICFIELD_H