HybridFluxGenerator.h 2.39 KB
Newer Older
1
2
3
4
5
6
#ifndef HYBRIDFLUXGENERATOR_H
#define HYBRIDFLUXGENERATOR_H

#include "SampleGenerator.h"
#include "CirculantEmbedding.h"
#include "assemble/HybridEllipticAssemble.h"
niklas.baumgarten's avatar
niklas.baumgarten committed
7
#include "problem/StochasticEllipticProblem.hpp"
8
9
10


class HybridFluxGenerator : public SampleGenerator {
niklas.baumgarten's avatar
niklas.baumgarten committed
11
private:
12
13
14
    MatrixGraphs cellMatrixGraphs;
    MatrixGraphs faceMatrixGraphs;

15
16
17
18
    unique_ptr<Vector> finePerm;
    unique_ptr<Vector> coarsePerm;
    unique_ptr<Vector> flux;
    unique_ptr<Vector> u;
19
20

    void initialize(bool fineField);
niklas.baumgarten's avatar
niklas.baumgarten committed
21

22
protected:
23
24
25
26
27
28
29
30
    shared_ptr<IDiscretizationT<>> disc;
    shared_ptr<StochasticEllipticProblem> problem;
    unique_ptr<HybridEllipticAssemble> assemble;
    unique_ptr<CirculantEmbedding> permeabilityGenerator;
    unique_ptr<Preconditioner> pc;

    Solver solver;
    Newton newton;
31

niklas.baumgarten's avatar
niklas.baumgarten committed
32
33
34
35
    void generateFineSample(Vector &fineField) override;

    void generateCoarseSample(const Vector &fineField, Vector &coarseField) override;

36
public:
37
38
39
40
41
42
43
44
45
    explicit HybridFluxGenerator(int l, Meshes &meshes) :
        SampleGenerator(l, meshes),
        cellMatrixGraphs(MatrixGraphs(meshes, dof("cell", 3))),
        faceMatrixGraphs(MatrixGraphs(meshes, dof("face", 1))),
        pc(unique_ptr<Preconditioner>(GetPC("SuperLU"))),
        solver(Solver(pc.get(), "GMRES")),
        newton(Newton(solver)) {

        finePerm = make_unique<Vector>(cellMatrixGraphs[l - meshes.pLevel()]);
46
        if (l != meshes.pLevel())
47
            coarsePerm = make_unique<Vector>(cellMatrixGraphs[l - meshes.pLevel() - 1]);
48
    }
49
50
};

51
52
53
54
class HybridFluxGenerator1D : public HybridFluxGenerator {
public:
    explicit HybridFluxGenerator1D(int l, Meshes &meshes) :
        HybridFluxGenerator(l, meshes) {
55
56
57
58
59

        disc = make_shared<DiscretizationT<>>(meshes, "RT0_P0");
        problem = make_shared<StochasticLaplace1D>();
        assemble = make_unique<HybridEllipticAssemble>(disc, problem);
        permeabilityGenerator = make_unique<CirculantEmbedding1D>(l, meshes);
60
61
    }
};
62

63
class HybridFluxGenerator2D : public HybridFluxGenerator {
64
65
public:
    explicit HybridFluxGenerator2D(int l, Meshes &meshes)
66
        : HybridFluxGenerator(l, meshes) {
67

68
69
70
71
        disc = make_shared<DiscretizationT<>>(meshes, "RT0_P0");
        problem = make_shared<StochasticLaplace2D>();
        assemble = make_unique<HybridEllipticAssemble>(disc, problem);
        permeabilityGenerator = make_unique<CirculantEmbedding2D>(l, meshes);
72
    }
73
74
75
};

#endif //HYBRIDFLUXGENERATOR_H