AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
ProblemInstat.hpp
1 #pragma once
2 
3 #include <string>
4 
5 #include <amdis/ProblemInstatBase.hpp>
6 #include <amdis/ProblemStat.hpp>
7 #include <amdis/common/TypeTraits.hpp>
8 
9 #include <dune/grid/yaspgrid.hh>
10 
11 namespace AMDiS
12 {
13  // forward declarations
14  class AdaptInfo;
15 
23  template <class Traits>
25  : public ProblemInstatBase
26  {
27  using Self = ProblemInstat;
29 
30  using SolutionVector = typename ProblemType::SolutionVector;
31 
32  public:
34  ProblemInstat(std::string const& name, ProblemType& prob)
35  : ProblemInstatBase(name)
36  , problemStat_(&prob)
37  {}
38 
40  ProblemInstat(std::string const& name, ProblemType& prob, ProblemStatBase& initialProb)
41  : ProblemInstatBase(name, initialProb)
42  , problemStat_(&prob)
43  {}
44 
46  void initialize(Flag initFlag = INIT_NOTHING);
47 
49  void initTimestep(AdaptInfo& adaptInfo) override;
50 
52  void closeTimestep(AdaptInfo& adaptInfo) override;
53 
56  ProblemType const& problemStat() const { return *problemStat_; }
57 
59  std::shared_ptr<SolutionVector const> oldSolutionVector() const
60  {
61  test_exit_dbg(bool(oldSolution_),
62  "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
63  return oldSolution_;
64  }
65 
67 
71  template <class Range = void, class... Indices>
72  auto oldSolution(Indices... ii) const
73  {
74  test_exit_dbg(bool(oldSolution_),
75  "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
76  return valueOf<Range>(*oldSolution_, ii...);
77  }
78 
80  void transferInitialSolution(AdaptInfo& adaptInfo) override;
81 
82  protected:
84  void createUhOld();
85 
86  protected:
89 
91  std::shared_ptr<SolutionVector> oldSolution_;
92  };
93 
94 
95  // Deduction guides
96  template <class Traits>
97  ProblemInstat(std::string const& name, ProblemStat<Traits>& prob)
99 
100  template <class Traits>
101  ProblemInstat(std::string const& name, ProblemStat<Traits>& prob, ProblemStatBase& initialProb)
103 
104 
105  // mark template as explicitly instantiated in cpp file
106  extern template class ProblemInstat<LagrangeBasis<Dune::YaspGrid<2>,1>>;
107  extern template class ProblemInstat<LagrangeBasis<Dune::YaspGrid<2>,1,1>>;
108 
109 } // end namespace AMDiS
110 
111 #include "ProblemInstat.inc.hpp"
ProblemInstat(std::string const &name, ProblemType &prob)
Constructs a ProblemInstat with prob as its stationary problem, stored as reference.
Definition: ProblemInstat.hpp:34
The Flag class encapsulates flags which represents simple information. Used e.g. while mesh traversal...
Definition: Flag.hpp:13
void createUhOld()
Used in initialize() to create the oldSolution_.
Definition: ProblemInstat.inc.hpp:39
void closeTimestep(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::closeTimestep().
Definition: ProblemInstat.inc.hpp:22
auto oldSolution(Indices... ii) const
Return a const view to a oldSolution component.
Definition: ProblemInstat.hpp:72
void initTimestep(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::initTimestep().
Definition: ProblemInstat.inc.hpp:51
The basic container that stores a base vector and a corresponding basis.
Definition: DOFVector.hpp:27
Definition: AdaptBase.hpp:6
ProblemType * problemStat_
Space problem solved in each timestep. (non-owning pointer)
Definition: ProblemInstat.hpp:88
void transferInitialSolution(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::transferInitialSolution().
Definition: ProblemInstat.inc.hpp:11
Definition: ProblemStat.hpp:52
virtual std::string const & name() const
Return the name of the instationary problem name_.
Definition: ProblemInstatBase.hpp:47
Standard implementation of ProblemTimeInterface for a time dependent problems.
Definition: ProblemInstat.hpp:24
ProblemInstat(std::string const &name, ProblemType &prob, ProblemStatBase &initialProb)
Constructor. Stores a reference to prob and initialProb.
Definition: ProblemInstat.hpp:40
void initialize(Flag initFlag=INIT_NOTHING)
Initialisation of the problem.
Definition: ProblemInstat.inc.hpp:30
Interface for time independent problems. Concrete problems must override all pure virtual methods...
Definition: ProblemStatBase.hpp:58
ProblemType & problemStat()
Returns problemStat.
Definition: ProblemInstat.hpp:55
Holds adapt parameters and infos about the problem.
Definition: AdaptInfo.hpp:25
std::shared_ptr< SolutionVector const > oldSolutionVector() const
Returns const-ref of oldSolution.
Definition: ProblemInstat.hpp:59
Base class for ProblemInstat.
Definition: ProblemInstatBase.hpp:19
std::shared_ptr< SolutionVector > oldSolution_
Solution of the last timestep.
Definition: ProblemInstat.hpp:91