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

3
4
#include <string>

5
6
7
#include <amdis/ProblemInstatBase.hpp>
#include <amdis/ProblemStat.hpp>
#include <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 Traits>
22
23
  class ProblemInstat
      : public ProblemInstatBase
24
25
  {
    using Self        = ProblemInstat;
26
    using ProblemType = ProblemStat<Traits>;
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
  };

82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
  // Deduction rule
  template <class Traits>
  ProblemInstat(std::string name, ProblemStat<Traits>& prob)
    -> ProblemInstat<Traits>;
#endif

  // Generator for ProblemInstat with given ProblemStat
  template <class Traits>
  ProblemInstat<Traits>
  makeProblemInstat(std::string name, ProblemStat<Traits>& prob)
  {
    return {std::move(name), prob};
  }

99
100
101
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"