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

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

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

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

26
    using SystemVector = typename ProblemType::SystemVector;
Praetorius, Simon's avatar
Praetorius, Simon committed
27

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

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

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

    /// 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
61

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

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

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

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

Praetorius, Simon's avatar
Praetorius, Simon committed
80

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

85
86
87
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"