7#include <dune/grid/common/backuprestore.hh>
8#include <dune/grid/common/capabilities.hh>
10#include <amdis/BackupRestore.hpp>
11#include <amdis/Initfile.hpp>
12#include <amdis/Output.hpp>
13#include <amdis/common/Filesystem.hpp>
14#include <amdis/io/FileWriterBase.hpp>
18 template <
class SystemVector>
24 using Grid =
typename GridView::Grid;
28 BackupWriter(std::string
const& name, std::shared_ptr<SystemVector> systemVector)
30 , systemVector_(std::move(systemVector))
38 std::string filename =
filesystem::path({this->dir(), this->filename()}).
string();
43 if (this->
doWrite(adaptInfo) || force) {
44 GridView
const& gridView = systemVector_->basis().gridView();
45 backupGrid(gridView, filename +
".grid",
46 bool_t<Dune::Capabilities::hasBackupRestoreFacilities<Grid>::v>{});
47 systemVector_->backup(filename +
".solution");
49 msg(
"Backup written to files '{}' and '{}'.", filename +
".grid", filename +
".solution");
56 template <
class G = Grid,
57 class =
decltype(Dune::BackupRestoreFacility<G>::backup(std::declval<G>(), std::string(
"")))>
58 void backupGrid(GridView
const& gv, std::string filename, std::true_type)
60 Dune::BackupRestoreFacility<Grid>::backup(gv.grid(), filename);
63 template <
bool B,
class G = Grid,
class GV = GridView,
65 void backupGrid(GridView
const& gv, std::string filename, bool_t<B>)
67 warning(
"Falling back to backup of gridview.");
72 std::shared_ptr<SystemVector> systemVector_;
75 bool animation_ =
false;
Holds adapt parameters and infos about the problem.
Definition: AdaptInfo.hpp:26
int timestepNumber() const
Returns timestepNumber_.
Definition: AdaptInfo.hpp:255
static void backup(GridView const &gv, std::string const &filename)
Write a hierarchic grid to disk.
Definition: BackupRestore.hpp:123
Definition: BackupWriter.hpp:21
void write(AdaptInfo &adaptInfo, bool force) override
Implements FileWriterBase::write.
Definition: BackupWriter.hpp:36
BackupWriter(std::string const &name, std::shared_ptr< SystemVector > systemVector)
Constructor.
Definition: BackupWriter.hpp:28
Base class for filewriters.
Definition: FileWriterBase.hpp:39
bool doWrite(AdaptInfo &adaptInfo) const
Return whether to write the current timestep or not.
Definition: FileWriterBase.cpp:24
typename PreBasis::GridView GridView
The grid view that the FE space is defined on.
Definition: GlobalBasis.hpp:57
static std::optional< T > get(std::string const &key)
Get parameter-values from parameter-tree.
Definition: Initfile.hpp:25
Definition: Filesystem.hpp:13
constexpr bool GlobalBasis
A Dune::Functions::GlobalBasis type.
Definition: Concepts.hpp:189