LCOV - code coverage report
Current view: top level - src/restart - RestartableDataIO.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 863ef6 Lines: 31 32 96.9 %
Date: 2025-10-15 18:16:15 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       13662 : RestartableDataIO::RestartableDataIO(MooseApp & app, RestartableDataMap & data)
      19             :   : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
      20             :     libMesh::ParallelObject(app),
      21       40986 :     _data(&data)
      22             : {
      23       13662 : }
      24             : 
      25      115631 : RestartableDataIO::RestartableDataIO(MooseApp & app, std::vector<RestartableDataMap> & data)
      26             :   : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
      27             :     libMesh::ParallelObject(app),
      28      346893 :     _data(&data)
      29             : {
      30      115631 : }
      31             : 
      32             : RestartableDataMap &
      33      216601 : RestartableDataIO::currentData(const THREAD_ID tid)
      34             : {
      35             :   mooseAssert(dataSize() > tid, "Invalid thread");
      36             : 
      37      216601 :   if (std::holds_alternative<RestartableDataMap *>(_data))
      38       37584 :     return *std::get<RestartableDataMap *>(_data);
      39      179017 :   return (*std::get<std::vector<RestartableDataMap> *>(_data))[tid];
      40             : }
      41             : 
      42             : std::size_t
      43      331856 : RestartableDataIO::dataSize() const
      44             : {
      45      331856 :   return std::holds_alternative<RestartableDataMap *>(_data)
      46      331856 :              ? 1
      47      331856 :              : std::get<std::vector<RestartableDataMap> *>(_data)->size();
      48             : }
      49             : 
      50             : const std::string &
      51       31968 : RestartableDataIO::getRestartableExt()
      52             : {
      53       53092 :   static const std::string ext = ".rd";
      54       31968 :   return ext;
      55             : }
      56             : 
      57             : const std::string &
      58       49743 : RestartableDataIO::restartableDataFile()
      59             : {
      60       70867 :   static const std::string file = "data";
      61       49743 :   return file;
      62             : }
      63             : 
      64             : const std::string &
      65       28531 : RestartableDataIO::restartableHeaderFile()
      66             : {
      67       43441 :   static const std::string file = "header";
      68       28531 :   return file;
      69             : }
      70             : 
      71             : std::filesystem::path
      72       31968 : RestartableDataIO::restartableDataFolder(const std::filesystem::path & folder_base)
      73             : {
      74       31968 :   auto folder = folder_base;
      75       31968 :   folder += getRestartableExt();
      76       31968 :   return folder;
      77           0 : }
      78             : 
      79             : std::filesystem::path
      80       49743 : RestartableDataIO::restartableDataFile(const std::filesystem::path & folder_base)
      81             : {
      82       49743 :   return folder_base / restartableDataFile();
      83             : }
      84             : 
      85             : std::filesystem::path
      86       28531 : RestartableDataIO::restartableHeaderFile(const std::filesystem::path & folder_base)
      87             : {
      88       28531 :   return folder_base / restartableHeaderFile();
      89             : }

Generated by: LCOV version 1.14