MonteCarloTransport.h 1.38 KB
Newer Older
1
2
3
4
5
#ifndef MLMC_MONTECARLOTRANSPORT_HPP
#define MLMC_MONTECARLOTRANSPORT_HPP

#include "MonteCarlo.h"
#include "assemble/DGTransportAssemble.h"
niklas.baumgarten's avatar
niklas.baumgarten committed
6
#include "TimeIntegrator.h"
7
8
9
10
11
12
13
14
15
16

class MonteCarloTransport : public MonteCarlo {
public:
    DGTransportAssemble *assemble;
    Transfer *transfer;

    MonteCarloTransport(int l, int dM, bool baseLevel, Meshes *meshes,
                        StochasticFields *stochFields, MatrixGraphs *graphs,
                        DGTransportAssemble *assemble) :

niklas.baumgarten's avatar
niklas.baumgarten committed
17
18
            MonteCarlo(l, dM, baseLevel, meshes, stochFields, graphs),
            assemble(assemble) {
19
20
21
22
23

        transfer = new MatrixTransfer(*assemble);
        transfer->Construct((*graphs)[l - plevel], (*graphs)[l - plevel - 1]);
    }

24
    ~MonteCarloTransport() {
25
26
27
28
        transfer->Destruct();
        delete transfer;
    }

29
    void upscale(const Vector &uc, Vector &uc_up) override {
niklas.baumgarten's avatar
niklas.baumgarten committed
30
        uc_up = (*transfer) * uc;
31
32
    }

33
    void updateUSum(const Vector &uc_up, const Vector &uf) {
niklas.baumgarten's avatar
niklas.baumgarten committed
34
35
36
        u_sum += uf;
        u_sum_diff += uf;
        u_sum_diff -= uc_up;
37
38
    }

39
    void updateUAvg() {
niklas.baumgarten's avatar
niklas.baumgarten committed
40
41
42
        Scalar M_inverted = 1.0 / M;
        u_avg = M_inverted * u_sum;
        u_avg_diff = M_inverted * u_sum_diff;
43
44
45
46
    }

    void method() override;

47
    void solveTransport(double &Q, double &cost, Vector &u);
48

niklas.baumgarten's avatar
niklas.baumgarten committed
49
50
    void solveElliptic(double &Q, double &cost, Vector &u);

51
52
53
54
};


#endif //MLMC_MONTECARLOTRANSPORT_HPP