ProblemInstat.hpp 2.31 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
19
20
21
22
23
  /**
   * \ingroup Problem
   *
   * \brief
   * Standard implementation of ProblemTimeInterface for a time
   * dependent problems.
   */
  template <class Traits>
  class ProblemInstat : public ProblemInstatBase
  {
    using Self        = ProblemInstat;
    using ProblemType = ProblemStat<Traits>;
Praetorius, Simon's avatar
Praetorius, Simon committed
24

25
    using SystemVectorType = typename ProblemType::SystemVectorType;
Praetorius, Simon's avatar
Praetorius, Simon committed
26

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

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

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

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

61
62
    /// Returns the I'th component of \ref oldSolution.
    template <size_t I = 0>
Praetorius, Simon's avatar
Praetorius, Simon committed
63
    decltype(auto) getOldSolution(const index_<I> _i = {})
64
65
66
67
68
    {
        return (*oldSolution)[_i];
    }

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

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

    /// Solution of the last timestep.
Praetorius, Simon's avatar
Praetorius, Simon committed
76
    std::shared_ptr<SystemVectorType> oldSolution;
77
78
  };

Praetorius, Simon's avatar
Praetorius, Simon committed
79

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

84
85
86
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"