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.3 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
67
68
69
    /**
     * \tparam Range  The range type return by evaluating the view in coordinates. If not specified,
     *                it is automatically selected using \ref RangeType_t template.
     **/
    template <class Range = void, class... Indices>
70
    auto oldSolution(Indices... ii) const
71
    {
72
73
      test_exit_dbg(bool(oldSolution_),
        "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
74
      return valueOf<Range>(*oldSolution_, ii...);
75
    }
76
77

    /// Implementation of \ref ProblemTimeInterface::transferInitialSolution().
78
    void transferInitialSolution(AdaptInfo& adaptInfo) override;
79
80

  protected:
81
82
83
84
85
86
    /// Used in \ref initialize() to create the \ref oldSolution_.
    void createUhOld();

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

    /// Solution of the last timestep.
Praetorius, Simon's avatar
Praetorius, Simon committed
89
    std::shared_ptr<SolutionVector> oldSolution_;
90
91
  };

92

93
  // Deduction guides
94
  template <class Traits>
95
  ProblemInstat(std::string const& name, ProblemStat<Traits>& prob)
96
    -> ProblemInstat<Traits>;
97
98
99
100

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

102

103
104
105
106
  // mark template as explicitly instantiated in cpp file
  extern template class ProblemInstat<YaspGridBasis<2,1>>;
  extern template class ProblemInstat<YaspGridBasis<2,2>>;

107
108
109
} // end namespace AMDiS

#include "ProblemInstat.inc.hpp"