ProblemInstatBase.hpp 2.14 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
20
  class ProblemInstatBase
      : public ProblemTimeInterface
21
22
23
  {
  public:
    /// Constructor.
24
25
26
27
28
    ProblemInstatBase(std::string const& name)
      : name_(name)
    {}

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

    /// Destructor.
36
    virtual ~ProblemInstatBase() = default;
37
38
39
40

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

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

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

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

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

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

  protected:
72
    /// Name of the instationary problem.
73
    std::string name_;
74

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

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

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

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

} // end namespace AMDiS