AdaptBase.hpp 2.13 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
18
19
20
  /// Interface for adaption loops.
  class AdaptBase
  {
  public:
    /// Constructor
    AdaptBase(std::string sname,
              ProblemIterationInterface* problemIteration,
              AdaptInfo& adapt,
21
22
              ProblemTimeInterface* problemTime = nullptr,
              AdaptInfo* initialAdaptInfo = nullptr)
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
      : name(sname)
      , problemIteration(problemIteration)
      , adaptInfo(adapt)
      , problemTime(problemTime)
      , initialAdaptInfo(initialAdaptInfo)
    {}

    /// Destructor
    virtual ~AdaptBase() {}

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

    /// Returns \ref name
    std::string getName() const
    {
      return name;
    }

45
    /// Returns \ref problemIteration
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    ProblemIterationInterface* getProblemIteration() const
    {
      return problemIteration;
    }

    ///
    void setProblemIteration(ProblemIterationInterface* pii)
    {
      problemIteration = pii;
    }

    /// Returns \ref adaptInfo
    AdaptInfo& getAdaptInfo() const
    {
      return adaptInfo;
    }

63
    /// Returns \ref problemTime
64
65
66
67
68
69
70
71
72
73
74
    ProblemTimeInterface* getProblemTime() const
    {
      return problemTime;
    }

    ///
    void setProblemTime(ProblemTimeInterface* pti)
    {
      problemTime = pti;
    }

75
    /// Returns \ref initialAdaptInfo
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    AdaptInfo& getInitialAdaptInfo() const
    {
      return *initialAdaptInfo;
    }

  protected:
    /// Name of the adaption loop
    std::string name;

    /// Problem iteration interface
    ProblemIterationInterface* problemIteration;

    /// Main adapt info
    AdaptInfo& adaptInfo;

    /// problem time interface
    ProblemTimeInterface* problemTime;

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

    /// Info level
    static int info;
  };

} // end namespace AMDiS