StochasticCollocation.hpp 1.39 KB
Newer Older
niklas.baumgarten's avatar
niklas.baumgarten committed
1
2
3
#ifndef STOCHASTICCOLLOCATION_HPP
#define STOCHASTICCOLLOCATION_HPP

niklas.baumgarten's avatar
niklas.baumgarten committed
4
#include "Estimator.hpp"
5
6


niklas.baumgarten's avatar
niklas.baumgarten committed
7
class StochasticCollocation : public Estimator {
8
private:
9
  SampleID fineId;
10

11
12
13
14
15
  SampleID coarseId;

  MeshesCreator meshesCreator;

  PDESolverCreator pdeSolverCreator;
16
public:
17
18
19
20
  StochasticCollocation(MeshesCreator meshesCreator = MeshesCreator(),
                        PDESolverCreator pdeCreator = PDESolverCreator()) :
    Estimator(0.0, 0, 0),
    meshesCreator(meshesCreator), pdeSolverCreator(pdeCreator) {}
21

22
23
24
25
26
  std::string Name() const override {
    return "StochasticCollocation";
  }

  void Method() override {
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    std::unique_ptr<Meshes> meshes = meshesCreator.
      WithMeshName(pdeSolverCreator.GetMeshName()).
      WithCommSplit(aggregate.commSplit).
      WithPLevel(level - 1).
      WithLevel(level).
      CreateUnique();

    std::unique_ptr<PDESolver> pdeSolver = pdeSolverCreator.
      CreateUnique(*meshes);

    SampleSolution fineSolution(pdeSolver->GetDisc(), fineId);
    SampleSolution coarseSolution(pdeSolver->GetDisc(), coarseId);

    while (aggregate.ctr.dMcomm != 0) {

      pdeSolver->DrawSample(fineId);
      pdeSolver->Run(fineSolution);

      aggregate.Update(fineSolution, coarseSolution);
//    errors.Estimate(aggregate);
//
//    if (errors.stochastic > epsilon && epsilon != 0.0)
//      mout << "TODO" << endl;
//      aggregate.
    }
52
53
  }
};
niklas.baumgarten's avatar
niklas.baumgarten committed
54
55

#endif //STOCHASTICCOLLOCATION_HPP