AMDiS 2.10
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
11namespace 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)
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 std::shared_ptr<SolutionVector> oldSolutionVector()
68 {
69 test_exit_dbg(bool(oldSolution_),
70 "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
71 return oldSolution_;
72 }
73
75
79 template <class Range = void, class... Indices>
80 auto oldSolution(Indices... ii) const
81 {
82 test_exit_dbg(bool(oldSolution_),
83 "OldSolution need to be created. Call initialize with INIT_UH_OLD.");
84 return valueOf<Range>(*oldSolution_, ii...);
85 }
86
88 void transferInitialSolution(AdaptInfo& adaptInfo) override;
89
90 protected:
92 void createUhOld();
93
94 protected:
97
99 std::shared_ptr<SolutionVector> oldSolution_;
100 };
101
102
103 // Deduction guides
104 template <class Traits>
105 ProblemInstat(std::string const& name, ProblemStat<Traits>& prob)
107
108 template <class Traits>
109 ProblemInstat(std::string const& name, ProblemStat<Traits>& prob, ProblemStatBase& initialProb)
111
112
113 // mark template as explicitly instantiated in cpp file
114 extern template class ProblemInstat<LagrangeBasis<Dune::YaspGrid<2>,1>>;
115 extern template class ProblemInstat<LagrangeBasis<Dune::YaspGrid<2>,1,1>>;
116
117} // end namespace AMDiS
118
119#include "ProblemInstat.inc.hpp"
Holds adapt parameters and infos about the problem.
Definition: AdaptInfo.hpp:26
The basic container that stores a base vector and a corresponding basis.
Definition: DOFVector.hpp:43
The Flag class encapsulates flags which represents simple information. Used e.g. while mesh traversal...
Definition: Flag.hpp:14
Base class for ProblemInstat.
Definition: ProblemInstatBase.hpp:21
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:26
void closeTimestep(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::closeTimestep().
Definition: ProblemInstat.inc.hpp:22
ProblemInstat(std::string const &name, ProblemType &prob)
Constructs a ProblemInstat with prob as its stationary problem, stored as reference.
Definition: ProblemInstat.hpp:34
std::shared_ptr< SolutionVector > oldSolutionVector()
Returns ref of oldSolution.
Definition: ProblemInstat.hpp:67
void createUhOld()
Used in initialize() to create the oldSolution_.
Definition: ProblemInstat.inc.hpp:39
std::shared_ptr< SolutionVector > oldSolution_
Solution of the last timestep.
Definition: ProblemInstat.hpp:99
ProblemType & problemStat()
Returns problemStat.
Definition: ProblemInstat.hpp:55
auto oldSolution(Indices... ii) const
Return a const view to a oldSolution component.
Definition: ProblemInstat.hpp:80
void initTimestep(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::initTimestep().
Definition: ProblemInstat.inc.hpp:51
void initialize(Flag initFlag=INIT_NOTHING)
Initialisation of the problem.
Definition: ProblemInstat.inc.hpp:30
ProblemType * problemStat_
Space problem solved in each timestep. (non-owning pointer)
Definition: ProblemInstat.hpp:96
std::shared_ptr< SolutionVector const > oldSolutionVector() const
Returns const-ref of oldSolution.
Definition: ProblemInstat.hpp:59
void transferInitialSolution(AdaptInfo &adaptInfo) override
Implementation of ProblemTimeInterface::transferInitialSolution().
Definition: ProblemInstat.inc.hpp:11
ProblemInstat(std::string const &name, ProblemType &prob, ProblemStatBase &initialProb)
Constructor. Stores a reference to prob and initialProb.
Definition: ProblemInstat.hpp:40
Interface for time independent problems. Concrete problems must override all pure virtual methods....
Definition: ProblemStatBase.hpp:59
Definition: ProblemStat.hpp:55