Line data Source code
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 16 : const unsigned int RestartableDataIO::CURRENT_BACKUP_FILE_VERSION = 4; 17 : 18 13093 : RestartableDataIO::RestartableDataIO(MooseApp & app, RestartableDataMap & data) 19 : : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"), 20 : libMesh::ParallelObject(app), 21 13093 : _data(&data) 22 : { 23 13093 : } 24 : 25 112824 : RestartableDataIO::RestartableDataIO(MooseApp & app, std::vector<RestartableDataMap> & data) 26 : : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"), 27 : libMesh::ParallelObject(app), 28 112824 : _data(&data) 29 : { 30 112824 : } 31 : 32 : RestartableDataMap & 33 212665 : RestartableDataIO::currentData(const THREAD_ID tid) 34 : { 35 : mooseAssert(dataSize() > tid, "Invalid thread"); 36 : 37 212665 : if (std::holds_alternative<RestartableDataMap *>(_data)) 38 36032 : return *std::get<RestartableDataMap *>(_data); 39 176633 : return (*std::get<std::vector<RestartableDataMap> *>(_data))[tid]; 40 : } 41 : 42 : std::size_t 43 325216 : RestartableDataIO::dataSize() const 44 : { 45 325216 : return std::holds_alternative<RestartableDataMap *>(_data) 46 325216 : ? 1 47 325216 : : std::get<std::vector<RestartableDataMap> *>(_data)->size(); 48 : } 49 : 50 : const std::string & 51 30662 : RestartableDataIO::getRestartableExt() 52 : { 53 30662 : static const std::string ext = ".rd"; 54 30662 : return ext; 55 : } 56 : 57 : const std::string & 58 47613 : RestartableDataIO::restartableDataFile() 59 : { 60 47613 : static const std::string file = "data"; 61 47613 : return file; 62 : } 63 : 64 : const std::string & 65 27323 : RestartableDataIO::restartableHeaderFile() 66 : { 67 27323 : static const std::string file = "header"; 68 27323 : return file; 69 : } 70 : 71 : std::filesystem::path 72 30662 : RestartableDataIO::restartableDataFolder(const std::filesystem::path & folder_base) 73 : { 74 30662 : auto folder = folder_base; 75 30662 : folder += getRestartableExt(); 76 30662 : return folder; 77 0 : } 78 : 79 : std::filesystem::path 80 47613 : RestartableDataIO::restartableDataFile(const std::filesystem::path & folder_base) 81 : { 82 47613 : return folder_base / restartableDataFile(); 83 : } 84 : 85 : std::filesystem::path 86 27323 : RestartableDataIO::restartableHeaderFile(const std::filesystem::path & folder_base) 87 : { 88 27323 : return folder_base / restartableHeaderFile(); 89 : }