ProblemInstatBase.hpp 2.19 KB
Newer Older
1
2
#pragma once

3
4
#include <string>

5
6
7
8
9
10
#include "ProblemTimeInterface.hpp"

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

13
14
15
16
17
18
  /**
   * \ingroup Problem
   *
   * \brief
   * Base class for \ref ProblemInstat.
   */
Praetorius, Simon's avatar
Praetorius, Simon committed
19
  class ProblemInstatBase
20
      : public virtual ProblemTimeInterface
21
22
23
  {
  public:
    /// Constructor.
24
    ProblemInstatBase(std::string const& name)
25
26
      : ProblemTimeInterface()
      , name_(name)
27
28
29
    {}

    /// Constructor. Stores a pointer to the provided initialProblem.
30
    ProblemInstatBase(std::string const& name,
31
                      ProblemStatBase& initialProblem)
32
33
      : ProblemTimeInterface()
      , name_(name)
34
      , initialProblem_(&initialProblem)
35
36
37
    {}

    /// Destructor.
38
    ~ProblemInstatBase() override = default;
39
40

    /// Implementation of \ref ProblemTimeInterface::setTime().
41
    void setTime(AdaptInfo& adaptInfo) override;
42

43
    /// Implementation of \ref ProblemTimeInterface::solveInitialProblem().
44
    void solveInitialProblem(AdaptInfo& adaptInfo) override;
45

46
47
    /// Return the name of the instationary problem \ref name_
    virtual std::string const& name() const
48
    {
49
      return name_;
50
51
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
52
    /// Return reference to current simulation time \ref time_ set in \ref setTime
53
    /// from `AdaptInfo::time()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
54
    double const& time() const
55
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
56
      return time_;
57
58
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
59
    /// Return reference to current simulation timestep \ref tau_ set in \ref setTime
60
    /// from `AdaptInfo::timestep()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
61
    double const& tau() const&
62
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
63
      return tau_;
64
65
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
66
    /// Return reference to current simulation 1.0/timestep \ref invTau_ set in
67
    /// \ref setTime from `1.0 / AdaptInfo::timestep()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
68
    double const& invTau() const
69
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
70
      return invTau_;
71
72
73
    }

  protected:
74
    /// Name of the instationary problem.
75
    std::string name_;
76

77
78
    /// An initialization problem solved in \ref solveInitialProblem(). non-owning pointer.
    ProblemStatBase* initialProblem_ = nullptr;
79

80
    /// The current time, set from adaptInfo.time()
81
    double time_ = 0.0;
82

83
    /// Timestep, set from adaptInfo.timestep()
84
    double tau_ = 1.0;
85

86
    /// 1 / timestep, calculated after timestep is set
87
    double invTau_ = 1.0;
88
89
90
  };

} // end namespace AMDiS