ProblemInstatBase.hpp 3.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
#pragma once

#include "ProblemStatBase.hpp"
#include "ProblemTimeInterface.hpp"

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

11
12
13
14
15
16
  /**
   * \ingroup Problem
   *
   * \brief
   * Base class for \ref ProblemInstat.
   */
Praetorius, Simon's avatar
Praetorius, Simon committed
17
18
19
  class ProblemInstatBase
      : public ProblemTimeInterface
      , public ProblemStatBase   // NOTE: Why is this derived from ProblemStatBase
20
21
22
  {
  public:
    /// Constructor.
23
    ProblemInstatBase(std::string const& name,
24
                      ProblemStatBase* initialProb)
25
      : name_(name)
26
      , initialProblem_(initialProb ? initialProb : this)
27
28
29
    {}

    /// Destructor.
30
    virtual ~ProblemInstatBase() = default;
31
32
33
34

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

Praetorius, Simon's avatar
Praetorius, Simon committed
35
    void solve(AdaptInfo&) { /* do nothing */ }
36
37
38
39
40
41
42
43

    /// Implementation of \ref ProblemStatBase::solve().
    virtual void solve(AdaptInfo& adaptInfo, bool, bool) override
    {
      solve(adaptInfo);
    }

    /// Implementation of \ref ProblemStatBase::estimate().
Praetorius, Simon's avatar
Praetorius, Simon committed
44
    virtual void estimate(AdaptInfo&) override { /* do nothing */ }
45

46
    /// Implementation of \ref ProblemStatBase::buildAfterAdapt().
Praetorius, Simon's avatar
Praetorius, Simon committed
47
    virtual void buildAfterAdapt(AdaptInfo&, Flag, bool, bool) override { /* do nothing */ }
48
49
50
51

    /// Implementation of \ref ProblemStatBase::markElements().
    virtual Flag markElements(AdaptInfo&) override
    {
52
      return 0;
53
54
55
    }

    /// Implementation of \ref ProblemStatBase::refineMesh().
56
    virtual Flag adaptGrid(AdaptInfo&) override
57
    {
58
      return 0;
59
60
    }

61
62
63
64
65
66
67
68
69
70
71
72
    /// Implementation of \ref ProblemStatBase::globalCoarsen().
    virtual Flag globalCoarsen(int n) override
    {
      return 0;
    }

    /// Implementation of \ref ProblemStatBase::globalRefine().
    virtual Flag globalRefine(int n) override
    {
      return 0;
    }

73
    /// Implementation of \ref ProblemTimeInterface::closeTimestep().
Praetorius, Simon's avatar
Praetorius, Simon committed
74
    virtual void closeTimestep(AdaptInfo&) override { /* do nothing */ }
75

Praetorius, Simon's avatar
Praetorius, Simon committed
76
77
    /// Implementation of \ref ProblemStatBase::name().
    virtual std::string const& name() const override
78
    {
79
      return name_;
80
81
82
83
84
    }

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

Praetorius, Simon's avatar
Praetorius, Simon committed
85
    /// Return reference to current simulation time \ref time_ set in \ref setTime
86
    /// from `adaptInfo->getTime()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
87
    double const& time() const
88
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
89
      return time_;
90
91
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
92
    /// Return reference to current simulation timestep \ref tau_ set in \ref setTime
93
    /// from `adaptInfo->getTimestep()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
94
    double const& tau() const&
95
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
96
      return tau_;
97
98
    }

Praetorius, Simon's avatar
Praetorius, Simon committed
99
    /// Return reference to current simulation 1.0/timestep \ref invTau_ set in
100
    /// \ref setTime from `1.0 / adaptInfo->getTimestep()`.
Praetorius, Simon's avatar
Praetorius, Simon committed
101
    double const& invTau() const
102
    {
Praetorius, Simon's avatar
Praetorius, Simon committed
103
      return invTau_;
104
105
106
107
    }

  protected:
    /// Name of the problem.
108
    std::string name_;
109

110
    ProblemStatBase* initialProblem_;
111
112

    /// Time
113
    double time_ = 0.0;
114
115

    /// Timestep
116
    double tau_ = 1.0;
117
118

    /// 1 / timestep
119
    double invTau_ = 1.0;
120
121
122
  };

} // end namespace AMDiS