https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RestartableDataIO.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "RestartableDataIO.h"
11
12#include "MooseApp.h"
13
14// 3 - Restart system rewrite
15// 4 - Added advanced stateful restore
17
19 : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
20 libMesh::ParallelObject(app),
21 _data(&data)
22{
23}
24
25RestartableDataIO::RestartableDataIO(MooseApp & app, std::vector<RestartableDataMap> & data)
26 : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
27 libMesh::ParallelObject(app),
28 _data(&data)
29{
30}
31
34{
35 mooseAssert(dataSize() > tid, "Invalid thread");
36
37 if (std::holds_alternative<RestartableDataMap *>(_data))
38 return *std::get<RestartableDataMap *>(_data);
39 return (*std::get<std::vector<RestartableDataMap> *>(_data))[tid];
40}
41
42std::size_t
44{
45 return std::holds_alternative<RestartableDataMap *>(_data)
46 ? 1
47 : std::get<std::vector<RestartableDataMap> *>(_data)->size();
48}
49
50const std::string &
52{
53 static const std::string ext = ".rd";
54 return ext;
55}
56
57const std::string &
59{
60 static const std::string file = "data";
61 return file;
62}
63
64const std::string &
66{
67 static const std::string file = "header";
68 return file;
69}
70
71std::filesystem::path
72RestartableDataIO::restartableDataFolder(const std::filesystem::path & folder_base)
73{
74 auto folder = folder_base;
75 folder += getRestartableExt();
76 return folder;
77}
78
79std::filesystem::path
80RestartableDataIO::restartableDataFile(const std::filesystem::path & folder_base)
81{
82 return folder_base / restartableDataFile();
83}
84
85std::filesystem::path
86RestartableDataIO::restartableHeaderFile(const std::filesystem::path & folder_base)
87{
88 return folder_base / restartableHeaderFile();
89}
unsigned int THREAD_ID
Definition MooseTypes.h:237
Base class for MOOSE-based applications.
Definition MooseApp.h:110
Interface for objects interacting with the PerfGraph.
static const std::string & restartableDataFile()
const std::variant< RestartableDataMap *, std::vector< RestartableDataMap > * > _data
The data we wish to act on This is a variant so that we can act on threaded and non-threaded data.
static const std::string & restartableHeaderFile()
RestartableDataMap & currentData(const THREAD_ID tid)
RestartableDataIO(MooseApp &app, RestartableDataMap &data)
static const std::string & getRestartableExt()
static const unsigned int CURRENT_BACKUP_FILE_VERSION
The current version for the backup file.
static std::filesystem::path restartableDataFolder(const std::filesystem::path &folder_base)
std::size_t dataSize() const
Storage for restartable data that is ordered based on insertion order.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...