StochasticProblem.C 1.35 KB
Newer Older
1
2
#include "StochasticProblem.h"

niklas.baumgarten's avatar
niklas.baumgarten committed
3
class StochasticLaplace1D : public StochasticProblem {
4
public:
niklas.baumgarten's avatar
niklas.baumgarten committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
    explicit StochasticLaplace1D(StochasticFields &stochFields) :
            StochasticProblem(stochFields) {}

    Scalar Solution(const Point &x) const override { return -x[0]; }

    VectorField Flux(int, const Point &x) const override {
        return VectorField(-1.0, 0.0);
    }

    string Name() const override { return string("Stochastic Laplace 1D"); }
};

class StochasticLaplace2D : public StochasticProblem {
public:
    explicit StochasticLaplace2D(StochasticFields &stochFields) :
20
21
22
23
24
25
26
27
28
29
30
31
32
            StochasticProblem(stochFields) {}

    Scalar Solution(const Point &x) const override { return -x[1]; }

    VectorField Flux(int, const Point &x) const override {
        return VectorField(0.0, -1.0);
    }

    string Name() const override { return string("Stochastic Laplace 2D"); }
};

StochasticProblem *getStochasticProblem(StochasticFields &stochFields,
                                        string StochProblem) {
niklas.baumgarten's avatar
niklas.baumgarten committed
33
34
35
36
37
    if (StochProblem.empty()) ReadConfig(Settings, "Problem", StochProblem);
    if (StochProblem == "StochasticLaplace1D")
        return new StochasticLaplace1D(stochFields);
    if (StochProblem == "StochasticLaplace2D")
        return new StochasticLaplace2D(stochFields);
38
39
40
    else Exit("This StochProblem is not implemented")
    return nullptr;
}