AdaptBase.hpp 2.16 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
#pragma once

// std c++ headers
#include <string>

namespace AMDiS
{
  // forward declarations
  class AdaptInfo;
  class ProblemIterationInterface;
  class ProblemTimeInterface;
12

13
14
15
16
17
  /// Interface for adaption loops.
  class AdaptBase
  {
  public:
    /// Constructor
18
    AdaptBase(std::string const& name,
19
              ProblemIterationInterface* problemIteration,
20
              AdaptInfo& adaptInfo,
21
22
              ProblemTimeInterface* problemTime = nullptr,
              AdaptInfo* initialAdaptInfo = nullptr)
23
      : name_(name)
24
25
26
27
      , problemIteration_(problemIteration)
      , adaptInfo_(adaptInfo)
      , problemTime_(problemTime)
      , initialAdaptInfo_(initialAdaptInfo)
28
29
30
    {}

    /// Destructor
31
    virtual ~AdaptBase() = default;
32
33
34
35
36
37
38
39

    /** \brief
     * Pure virtual method. Must be overloaded by sub classes to perform
     * a concrete adaption loop.
     */
    virtual int adapt() = 0;

    /// Returns \ref name
Praetorius, Simon's avatar
Praetorius, Simon committed
40
    std::string const& name() const
41
    {
42
      return name_;
43
44
    }

45
    /// Returns \ref problemIteration
Praetorius, Simon's avatar
Praetorius, Simon committed
46
    ProblemIterationInterface* problemIteration() const
47
    {
48
      return problemIteration_;
49
50
51
    }

    ///
52
    void setProblemIteration(ProblemIterationInterface* problemIteration)
53
    {
54
      problemIteration_ = problemIteration;
55
56
57
    }

    /// Returns \ref adaptInfo
Praetorius, Simon's avatar
Praetorius, Simon committed
58
    AdaptInfo& adaptInfo() const
59
    {
60
      return adaptInfo_;
61
62
    }

63
    /// Returns \ref problemTime
Praetorius, Simon's avatar
Praetorius, Simon committed
64
    ProblemTimeInterface* problemTime() const
65
    {
66
      return problemTime_;
67
68
69
    }

    ///
70
    void setProblemTime(ProblemTimeInterface* problemTime)
71
    {
72
      problemTime_ = problemTime;
73
74
    }

75
    /// Returns \ref initialAdaptInfo
Praetorius, Simon's avatar
Praetorius, Simon committed
76
    AdaptInfo& initialAdaptInfo() const
77
    {
78
      return *initialAdaptInfo_;
79
80
81
82
    }

  protected:
    /// Name of the adaption loop
83
    std::string name_;
84
85

    /// Problem iteration interface
86
    ProblemIterationInterface* problemIteration_;
87
88

    /// Main adapt info
89
    AdaptInfo& adaptInfo_;
90
91

    /// problem time interface
92
    ProblemTimeInterface* problemTime_;
93
94
95

    /** \brief
     * Adapt info for initial adapt. Will be given to
96
     * problemTime->solveInitialProblem().
97
     */
98
    AdaptInfo* initialAdaptInfo_;
99
100
101
  };

} // end namespace AMDiS