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

Generated by: LCOV version 1.14