ProblemInstatBase.hpp 2.8 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 name,
24
                      ProblemStatBase* initialProb)
25
26
      : name_(std::move(name))
      , initialProblem_(initialProb ? initialProb : this)
27
28
29
    {}

    /// Destructor.
30
    virtual ~ProblemInstatBase() = default;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

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

    void solve(AdaptInfo&) { /* by default, do nothing */ }

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

    /// Implementation of \ref ProblemStatBase::estimate().
    virtual void estimate(AdaptInfo&) override { /* by default, do nothing */ }

46
47
    /// Implementation of \ref ProblemStatBase::buildAfterAdapt().
    virtual void buildAfterAdapt(AdaptInfo&, Flag, bool, bool) override { /* by default, 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
    }

    /// Implementation of \ref ProblemTimeInterface::closeTimestep().
    virtual void closeTimestep(AdaptInfo&) override { /* by default, do nothing */ }

    /// Implementation of \ref ProblemStatBase::getName().
65
    virtual std::string getName() const override
66
    {
67
      return name_;
68
69
70
71
72
    }

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

73
74
    /// Return pointer to current simulation time \ref cTime set in \ref setTime
    /// from `adaptInfo->getTime()`.
75
76
    double* getTime()
    {
77
      return &time_;
78
79
    }

80
81
    /// Return pointer to current simulation timestep \ref tau set in \ref setTime
    /// from `adaptInfo->getTimestep()`.
82
83
    double* getTau()
    {
84
      return &tau_;
85
86
    }

87
88
    /// Return pointer to current simulation 1.0/timestep \ref invTau set in
    /// \ref setTime from `1.0 / adaptInfo->getTimestep()`.
89
90
    double* getInvTau()
    {
91
      return &invTau_;
92
93
94
95
    }

  protected:
    /// Name of the problem.
96
    std::string name_;
97

98
    ProblemStatBase* initialProblem_;
99
100

    /// Time
101
    double time_ = 0.0;
102
103

    /// Timestep
104
    double tau_ = 1.0;
105
106

    /// 1 / timestep
107
    double invTau_ = 1.0;
108
109
110
  };

} // end namespace AMDiS