HybridFluxGenerator.hpp 4.17 KB
Newer Older
1
2
#ifndef HYBRIDFLUXGENERATOR_HPP
#define HYBRIDFLUXGENERATOR_HPP
3

4
5
#include "SampleGenerator.hpp"
#include "CirculantEmbedding.hpp"
niklas.baumgarten's avatar
niklas.baumgarten committed
6
#include <memory>
7

niklas.baumgarten's avatar
niklas.baumgarten committed
8
#include "pdesolver/PDESolver.hpp"
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
//class HybridFluxGenerator : public SampleGenerator<Scalar> {
//private:
//    PDESolver *pdeSolver;
//
//public:
//    HybridFluxGenerator(Meshes &meshes) : SampleGenerator(meshes) {
//        std::string problemName = "StochasticLaplace2D";
//        pdeSolver = PDESolverCreator(meshes).
//            WithModel("HybridElliptic").
//            WithProblem(problemName).Create();
//    }
//};

//class MultilevelHybridFluxGenerator : public SampleGenerator {
//private:
//    MatrixGraphs cellMGraphs;
//    MatrixGraphs faceMGraphs;
//
//    Vector *faceFlux = nullptr;
//    Vector *faceValues = nullptr;
//    Vector *cellFlux = nullptr;
//
//protected:
//    IStochasticEllipticProblem *problem;
//    HybridEllipticAssemble *assemble;
//    RTLagrangeDiscretization *disc;
//    Preconditioner *pc;
//    Solver *solver;
//    Newton *newton;
//    Meshes &meshes;
//
//    void drawSample(const SampleID &id) override {
//        if (!id.coarse) {
//            generateFineSample(id);
niklas.baumgarten's avatar
niklas.baumgarten committed
45
46
47
//            if (plotting)
//                plotter->PlotVector("flux", *cellFlux, 3,
//                                    id.level.fine, "CellData");
48
49
//        } else {
//            generateCoarseSample(id);
niklas.baumgarten's avatar
niklas.baumgarten committed
50
51
52
//            if (plotting)
//                plotter->PlotVector("flux", *cellFlux, 3,
//                                    id.level.coarse, "CellData");
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//        }
//    }
//
//public:
//    explicit MultilevelHybridFluxGenerator(Meshes &meshes) :
//        SampleGenerator(meshes),
//        meshes(meshes),
//        cellMGraphs(MatrixGraphs(meshes, dof(new CellDoF(3)))),
//        faceMGraphs(MatrixGraphs(meshes, dof(new FaceDoF(1)))),
//        disc(new RTLagrangeDiscretization(meshes, 0, 0)),
//        pc(GetPC("SuperLU")),
//        solver(new Solver(pc, "GMRES")),
//        newton(new Newton(*solver)) {
//        if (meshes.dim() == 1) {
//            problem = new StochasticLaplace1D(meshes);
//            assemble = new HybridEllipticAssemble(disc, problem);
//        }
//        if (meshes.dim() == 2) {
//            problem = new StochasticLaplace2D(meshes);
//            assemble = new HybridEllipticAssemble(disc, problem);
//        }
//    }
//
//    virtual ~MultilevelHybridFluxGenerator() {
//        delete problem;
//        delete assemble;
//        delete disc;
//        delete solver;
//        delete newton;
//    }
//
//    string Name() const override { return "Hybrid Flux Generator"; }
//
//    void generateFineSample(SampleID id) {
//        cellFlux = new Vector(cellMGraphs[id.level.mGfine]);
//        faceValues = new Vector(faceMGraphs[id.level.mGfine]);
//        faceFlux = new Vector(faceMGraphs[id.level.mGfine]);
//
//        assemble->DrawSample(id);
//        newton->operator()(*assemble, *faceValues);
//        assemble->SetNormalFlux(*faceValues, *faceFlux);
//        assemble->SetFlux(*faceValues, *cellFlux);
//    }
//
//    void generateCoarseSample(SampleID id) {
//        cellFlux = new Vector(cellMGraphs[id.level.mGcoarse]);
//        faceValues = new Vector(faceMGraphs[id.level.mGcoarse]);
//        faceFlux = new Vector(faceMGraphs[id.level.mGcoarse]);
//
//        assemble->DrawSample(id);
//        newton->operator()(*assemble, *faceValues);
//        assemble->SetNormalFlux(*faceValues, *faceFlux);
//        assemble->SetFlux(*faceValues, *cellFlux);
//    };
//
//    VectorField EvalVectorFieldSample(const cell &c) override {
//        RTLagrangeElement elem(*disc, *faceFlux, c);
//        VectorField F = zero;
//        double area = 0;
//        for (int q = 0; q < elem.nQ(); ++q) {
//            double w = elem.QWeight(q);
//            area += w;
//            F += w * elem.VelocityField(q, *faceFlux);
//        }
//        F *= (1 / area);
//        return F;
//    }
//
//    Scalar EvalSample(int face, const cell &c) override {
//        RTLagrangeElement elem(*disc, *faceFlux, c);
//        RTFaceElementT<> faceElem(*disc, *faceFlux, c, face);
//        return (*faceFlux)(elem[face], 0) * elem.Sign(face) / faceElem.Area();
//    }
//};
niklas.baumgarten's avatar
niklas.baumgarten committed
127

128
#endif //HYBRIDFLUXGENERATOR_HPP