MonteCarloTransport.hpp 1.91 KB
Newer Older
1
2
3
#ifndef MLMC_MONTECARLOTRANSPORT_HPP
#define MLMC_MONTECARLOTRANSPORT_HPP

niklas.baumgarten's avatar
niklas.baumgarten committed
4
#include "MonteCarlo.hpp"
5
#include "assemble/DGTransportAssemble.h"
6
#include "timestepping/TimeIntegrator.h"
niklas.baumgarten's avatar
niklas.baumgarten committed
7
#include "matrixgraph/CellMatrixGraph.hpp"
8

9

10
class MonteCarloTransport : public MonteCarlo {
niklas.baumgarten's avatar
niklas.baumgarten committed
11
protected:
niklas.baumgarten's avatar
niklas.baumgarten committed
12
    void Initialize() override;
niklas.baumgarten's avatar
niklas.baumgarten committed
13
14

    void method() override;
niklas.baumgarten's avatar
niklas.baumgarten committed
15

16
17
18
19
20
    void solvePDE(int l,
                  int m,
                  bool fineLevel,
                  double &valueQ,
                  double &cost,
niklas.baumgarten's avatar
niklas.baumgarten committed
21
22
23
24
25
                  Vector &solution) override;

private:
    double startTime = 0.0;
    double endTime = 0.0;
26
27

    TimeSeries getTimeSeries(bool fineLevel);
28

29
30
public:
    DGTransportAssemble *assemble;
31

32
33
34
    unique_ptr<Preconditioner> pc;
    unique_ptr<Solver> solver;

niklas.baumgarten's avatar
niklas.baumgarten committed
35
    MatrixGraphs cellMatrixGraphs;
36
    MatrixGraphs faceMatrixGraphs;
37
38
    CellMatrixGraphs solMatrixGraphs;

niklas.baumgarten's avatar
niklas.baumgarten committed
39
40
    Vector fineInput;
    Vector coarseInput;
41
42
43
    Vector fineSolution;
    Vector coarseSolution;

44
45
    MonteCarloTransport(int l, int dM, bool baseLevel,
                        Meshes *meshes, StochasticField *stochFields,
46
                        DGTransportAssemble *assemble) :
niklas.baumgarten's avatar
niklas.baumgarten committed
47
        MonteCarlo(l, dM, baseLevel, meshes, stochFields),
48
        assemble(assemble),
niklas.baumgarten's avatar
niklas.baumgarten committed
49
        cellMatrixGraphs(MatrixGraphs(*meshes, dof("cell", 3))),
50
        faceMatrixGraphs(MatrixGraphs(*meshes, dof("face", 3))),
51
        solMatrixGraphs(*meshes, *assemble->disc),
niklas.baumgarten's avatar
niklas.baumgarten committed
52
53
        fineInput(Vector(faceMatrixGraphs[l - pLevel])),
        coarseInput(Vector(faceMatrixGraphs[l - pLevel - 1])),
54
        fineSolution(Vector(solMatrixGraphs[l - pLevel])),
55
56
57
        coarseSolution(Vector(solMatrixGraphs[l - pLevel - 1])),
        pc(unique_ptr<Preconditioner>(GetPC("PointBlockGaussSeidel"))),
        solver(make_unique<Solver>(pc.get(), "GMRES")) {
58

59
60
        config.get("startTime", startTime);
        config.get("endTime", endTime);
niklas.baumgarten's avatar
niklas.baumgarten committed
61

niklas.baumgarten's avatar
niklas.baumgarten committed
62
        Initialize();
63
64
65
66
    }
};

#endif //MLMC_MONTECARLOTRANSPORT_HPP