Am Montag, 13. Mai 2022, finden Wartungsarbeiten am Gitlab-Server (Update auf neue Version statt). Der Dienst wird daher am Montag für einige Zeit nicht verfügbar sein.
On Monday, May 13th 2022, the Gitlab server will be updated. The service will therefore not be accessible for some time on Monday.

ProblemInstat.hpp 3.07 KB
Newer Older
1
2
#pragma once

3
4
#include <string>

5
6
#include <amdis/ProblemInstatBase.hpp>
#include <amdis/ProblemStat.hpp>
7
#include <amdis/common/TypeTraits.hpp>
8
9
10
11
12

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

14
15
16
17
18
19
20
  /**
   * \ingroup Problem
   *
   * \brief
   * Standard implementation of ProblemTimeInterface for a time
   * dependent problems.
   */
21
  template <class Traits>
22
23
  class ProblemInstat
      : public ProblemInstatBase
24
25
  {
    using Self        = ProblemInstat;
26
    using ProblemType = ProblemStat<Traits>;
Praetorius, Simon's avatar
Praetorius, Simon committed
27

Praetorius, Simon's avatar
Praetorius, Simon committed
28
    using SolutionVector = typename ProblemType::SolutionVector;
Praetorius, Simon's avatar
Praetorius, Simon committed
29

30
  public:
31
    /// Constructs a ProblemInstat with prob as its stationary problem, stored as reference.
32
    ProblemInstat(std::string const& name, ProblemType& prob)
33
34
      : ProblemInstatBase(name)
      , problemStat_(&prob)
35
36
    {}

37
    /// Constructor. Stores a reference to prob and initialProb.
38
    ProblemInstat(std::string const& name, ProblemType& prob, ProblemStatBase& initialProb)
39
40
      : ProblemInstatBase(name, initialProb)
      , problemStat_(&prob)
41
42
43
    {}

    /// Initialisation of the problem.
44
    void initialize(Flag initFlag = INIT_NOTHING);
45
46

    /// Implementation of \ref ProblemTimeInterface::initTimestep().
47
    void initTimestep(AdaptInfo& adaptInfo) override;
48
49

    /// Implementation of \ref ProblemTimeInterface::closeTimestep().
50
    void closeTimestep(AdaptInfo& adaptInfo) override;
51
52

    /// Returns \ref problemStat.
53
54
    ProblemType&       problemStat()       { return *problemStat_; }
    ProblemType const& problemStat() const { return *problemStat_; }
55

56
    /// Returns const-ref of \ref oldSolution.
Praetorius, Simon's avatar
Praetorius, Simon committed
57
    std::shared_ptr<SolutionVector const> oldSolutionVector() const
58
    {
59
      test_exit_dbg(bool(oldSolution_),
60
        "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
61
      return oldSolution_;
62
63
64
    }

    /// Return a const view to a oldSolution component
65
66
    template <class... Indices>
    auto oldSolution(Indices... ii) const
67
    {
68
69
      test_exit_dbg(bool(oldSolution_),
        "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
70
      return valueOf(*oldSolution_, ii...);
71
    }
72
73

    /// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
74
    void transferInitialSolution(AdaptInfo& adaptInfo) override;
75
76

  protected:
77
78
79
80
81
82
    /// Used in \ref initialize() to create the \ref oldSolution_.
    void createUhOld();

  protected:
    /// Space problem solved in each timestep. (non-owning pointer)
    ProblemType* problemStat_;
83
84

    /// Solution of the last timestep.
Praetorius, Simon's avatar
Praetorius, Simon committed
85
    std::shared_ptr<SolutionVector> oldSolution_;
86
87
  };

88

89
  // Deduction guides
90
  template <class Traits>
91
  ProblemInstat(std::string const& name, ProblemStat<Traits>& prob)
92
    -> ProblemInstat<Traits>;
93
94
95
96

  template <class Traits>
  ProblemInstat(std::string const& name, ProblemStat<Traits>& prob, ProblemStatBase& initialProb)
    -> ProblemInstat<Traits>;
97

98

99
100
101
102
  // mark template as explicitly instantiated in cpp file
  extern template class ProblemInstat<YaspGridBasis<2,1>>;
  extern template class ProblemInstat<YaspGridBasis<2,2>>;

103
104
105
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"