#pragma once #include #include #include #include namespace AMDiS { // forward declarations class AdaptInfo; /** * \ingroup Problem * * \brief * Standard implementation of ProblemTimeInterface for a time * dependent problems. */ template class ProblemInstat : public ProblemInstatBase { using Self = ProblemInstat; using ProblemType = ProblemStat; using SolutionVector = typename ProblemType::SolutionVector; public: /// Constructs a ProblemInstat with prob as its stationary problem, stored as reference. ProblemInstat(std::string const& name, ProblemType& prob) : ProblemInstatBase(name) , problemStat_(&prob) {} /// Constructor. Stores a reference to prob and initialProb. ProblemInstat(std::string const& name, ProblemType& prob, ProblemStatBase& initialProb) : ProblemInstatBase(name, initialProb) , problemStat_(&prob) {} /// Initialisation of the problem. void initialize(Flag initFlag = INIT_NOTHING); /// Implementation of \ref ProblemTimeInterface::initTimestep(). void initTimestep(AdaptInfo& adaptInfo) override; /// Implementation of \ref ProblemTimeInterface::closeTimestep(). void closeTimestep(AdaptInfo& adaptInfo) override; /// Returns \ref problemStat. ProblemType& problemStat() { return *problemStat_; } ProblemType const& problemStat() const { return *problemStat_; } /// Returns const-ref of \ref oldSolution. std::shared_ptr oldSolutionVector() const { test_exit_dbg(bool(oldSolution_), "OldSolution need to be created. Call initialize with INIT_UH_OLD."); return oldSolution_; } /// Return a const view to a oldSolution component /** * \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 auto oldSolution(Indices... ii) const { test_exit_dbg(bool(oldSolution_), "OldSolution need to be created. Call initialize with INIT_UH_OLD."); return valueOf(*oldSolution_, ii...); } /// Implementation of \ref ProblemTimeInterface::transferInitialSolution(). void transferInitialSolution(AdaptInfo& adaptInfo) override; protected: /// Used in \ref initialize() to create the \ref oldSolution_. void createUhOld(); protected: /// Space problem solved in each timestep. (non-owning pointer) ProblemType* problemStat_; /// Solution of the last timestep. std::shared_ptr oldSolution_; }; // Deduction guides template ProblemInstat(std::string const& name, ProblemStat& prob) -> ProblemInstat; template ProblemInstat(std::string const& name, ProblemStat& prob, ProblemStatBase& initialProb) -> ProblemInstat; // mark template as explicitly instantiated in cpp file extern template class ProblemInstat>; extern template class ProblemInstat>; } // end namespace AMDiS #include "ProblemInstat.inc.hpp"