ProblemInstat.hpp 2.34 KB
Newer Older
1
2
#pragma once

3
4
#include <string>

5
6
7
#include <dune/amdis/ProblemInstatBase.hpp>
#include <dune/amdis/ProblemStat.hpp>
#include <dune/amdis/common/Utility.hpp>
8
9
10
11
12

namespace AMDiS
{
  // forward declarations
  class AdaptInfo;
Praetorius, Simon's avatar
Praetorius, Simon committed
13

14
15
16
17
18
19
20
  /**
   * \ingroup Problem
   *
   * \brief
   * Standard implementation of ProblemTimeInterface for a time
   * dependent problems.
   */
21
  template <class GlobalBasis>
22
23
  class ProblemInstat
      : public ProblemInstatBase
24
25
  {
    using Self        = ProblemInstat;
26
    using ProblemType = ProblemStat<GlobalBasis>;
Praetorius, Simon's avatar
Praetorius, Simon committed
27

28
    using SystemVector = typename ProblemType::SystemVector;
Praetorius, Simon's avatar
Praetorius, Simon committed
29

30
31
  public:
    /// Constructs a ProblemInstat with prob as its stationary problem.
Praetorius, Simon's avatar
Praetorius, Simon committed
32
33
34
    ProblemInstat(std::string name, ProblemType& prob)
      : ProblemInstatBase(name, nullptr)
      , problemStat(prob)
35
36
    {}

Praetorius, Simon's avatar
Praetorius, Simon committed
37
38
39
    ProblemInstat(std::string name, ProblemType& prob, ProblemStatBase& initialProb)
      : ProblemInstatBase(name, &initialProb)
      , problemStat(prob)
40
41
42
    {}

    /// Initialisation of the problem.
43
    virtual void initialize(Flag initFlag = INIT_NOTHING);
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

    /// Used in \ref initialize().
    virtual void createUhOld();

    /// Implementation of \ref ProblemTimeInterface::initTimestep().
    virtual void initTimestep(AdaptInfo& adaptInfo) override;

    /// Implementation of \ref ProblemTimeInterface::closeTimestep().
    virtual void closeTimestep(AdaptInfo& adaptInfo) override;

    /// Returns \ref problemStat.
    ProblemType& getStatProblem()
    {
      return problemStat;
    }

    /// Returns \ref oldSolution.
    decltype(auto) getOldSolution()       { return *oldSolution; }
    decltype(auto) getOldSolution() const { return *oldSolution; }
Praetorius, Simon's avatar
Praetorius, Simon committed
63

64
    /// Returns the I'th component of \ref oldSolution.
65
66
67
68
69
    // template <std::size_t I = 0>
    // decltype(auto) getOldSolution(const index_t<I> _i = {})
    // {
    //   return (*oldSolution)[_i];
    // }
70
71

    /// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
72
    virtual void transferInitialSolution(AdaptInfo& adaptInfo) override;
73
74
75
76
77
78

  protected:
    /// Space problem solved in each timestep.
    ProblemType& problemStat;

    /// Solution of the last timestep.
79
    std::unique_ptr<SystemVector> oldSolution;
80
81
  };

Praetorius, Simon's avatar
Praetorius, Simon committed
82

83
#ifndef AMDIS_NO_EXTERN_PROBLEMINSTAT
84
  extern template class ProblemInstat<YaspGridBasis<2,1>>;
85
#endif
Praetorius, Simon's avatar
Praetorius, Simon committed
86

87
88
89
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"