LCOV - code coverage report
Current view: top level - src/restart - RestartableDataIO.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 7edd10 Lines: 31 32 96.9 %
Date: 2025-11-11 08:32:45 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14