9#include <amdis/operations/Assigner.hpp>
13template <
class GB,
class T,
class Traits>
15backup(std::string
const& filename)
17 std::ofstream out(filename, std::ios::binary);
19 std::int64_t numElements = this->basis().gridView().size(0);
20 out.write((
char*)&numElements,
sizeof(std::int64_t));
22 auto localView = this->basis().localView();
23 std::vector<value_type> data;
24 for (
auto const& element : elements(this->basis().gridView()))
26 localView.bind(element);
27 this->gather(localView, data);
29 std::uint64_t len = data.size();
30 out.write((
char*)&len,
sizeof(std::uint64_t));
31 out.write((
char*)data.data(), len*
sizeof(
value_type));
38template <
class GB,
class T,
class Traits>
40restore(std::string
const& filename)
42 std::ifstream in(filename, std::ios::binary);
44 std::int64_t numElements = 0;
45 in.read((
char*)&numElements,
sizeof(std::int64_t));
46 assert(numElements == this->basis().gridView().size(0));
49 auto localView = this->basis().localView();
50 std::vector<value_type> data;
51 this->init(this->basis(),
true);
52 for (
auto const& element : elements(this->basis().gridView()))
54 std::uint64_t len = 0;
55 in.read((
char*)&len,
sizeof(std::uint64_t));
58 in.read((
char*)data.data(), len*
sizeof(
value_type));
60 localView.bind(element);
void restore(std::string const &filename)
Read backup data from file.
Definition: DOFVector.inc.hpp:40
void backup(std::string const &filename)
Write DOFVector to file.
Definition: DOFVector.inc.hpp:15
T value_type
The type of the elements of the DOFVector.
Definition: DOFVector.hpp:60
Definition: Assigner.hpp:8