ProblemInstat.hpp 2.99 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

    /// 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.
61
62
    std::unique_ptr<SystemVector> getOldSolutionVector() const
    {
63
64
      test_exit_dbg(oldSolution,
        "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
65
66
67
68
69
70
71
72
73
74
      return *oldSolution;
    }

    /// Return a mutable view to a oldSolution component
    template <class TreePath = RootTreePath>
    auto getOldSolution(TreePath const& path = {})
    {
      auto&& tp = makeTreePath(path);
      return makeDOFVectorView(*oldSolution, tp);
    }
Praetorius, Simon's avatar
Praetorius, Simon committed
75

76
77
78
79
80
81
82
    /// Return a const view to a oldSolution component
    template <class TreePath = RootTreePath>
    auto getOldSolution(TreePath const& path = {}) const
    {
      auto&& tp = makeTreePath(path);
      return makeDOFVectorView(*oldSolution, tp);
    }
83
84

    /// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
85
    virtual void transferInitialSolution(AdaptInfo& adaptInfo) override;
86
87
88
89
90
91

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

    /// Solution of the last timestep.
92
    std::unique_ptr<SystemVector> oldSolution;
93
94
  };

95
96
97
98
99
100
101
102
103
104

#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>
105
  ProblemInstat<Traits> makeProblemInstat(std::string name, ProblemStat<Traits>& prob)
106
107
108
109
  {
    return {std::move(name), prob};
  }

110
111
112
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"