LCOV - code coverage report
Current view: top level - include/outputs - Checkpoint.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 3 3 100.0 %
Date: 2026-05-29 20:35:17 Functions: 2 2 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             : #pragma once
      11             : 
      12             : // MOOSE includes
      13             : #include "FileOutput.h"
      14             : #include "AutoCheckpointAction.h"
      15             : 
      16             : #include <deque>
      17             : #include <filesystem>
      18             : 
      19             : class MaterialPropertyStorage;
      20             : 
      21             : /**
      22             :  * A structure for storing the various output files associated with checkpoint output
      23             :  */
      24             : struct CheckpointFileNames
      25             : {
      26             :   /// Filename for CheckpointIO file (the mesh)
      27             :   std::string checkpoint;
      28             : 
      29             :   /// Filenames for restartable data
      30             :   std::vector<std::filesystem::path> restart;
      31             : 
      32       14285 :   bool operator==(const CheckpointFileNames & rhs) const
      33             :   {
      34             :     // Compare the relevant members for equality
      35       14285 :     return (this->checkpoint == rhs.checkpoint) && (this->restart == rhs.restart);
      36             :   }
      37             : };
      38             : 
      39             : /**
      40             :  * Writes out three things:
      41             :  *
      42             :  * 1. A restart file with a `.rd` extendsion that contains a single Backup that has been serialized
      43             :  * 2. Mesh file(s) in the form of a libMesh Checkpoint file(s)
      44             :  * 3. Mesh meta-data file... this will be underneath the directory that the Checkpoint mesh creates
      45             :  *
      46             :  * These files are written to a directory called output_prefix + _ + "_cp"
      47             :  */
      48             : class Checkpoint : public FileOutput
      49             : {
      50             : 
      51             :   friend class AutoCheckpointAction;
      52             : 
      53             : public:
      54             :   static InputParameters validParams();
      55             : 
      56             :   /**
      57             :    * Class constructor
      58             :    * @param parameters
      59             :    */
      60             :   Checkpoint(const InputParameters & parameters);
      61             : 
      62             :   /**
      63             :    * Returns the base filename for the checkpoint files
      64             :    */
      65             :   virtual std::string filename() override;
      66             : 
      67             :   /**
      68             :    * Retrieve the checkpoint output directory
      69             :    * @return String containing the checkpoint output directory
      70             :    */
      71             :   std::string directory() const;
      72             : 
      73             :   /**
      74             :    * Gathers and records information used later for console output
      75             :    * @return A stringstream containing the following entries:
      76             :    * Wall Time Interval : interval length in seconds, if any, otherwise "Disabled"
      77             :    * User Checkpoint    : name of user-define checkpoint, if any, otherwise "Disabled"
      78             :    * # Checkpoints Kept : value if the 'num_files' parameter
      79             :    * Execute On         : value of the 'execute_on' parameter
      80             :    */
      81             :   std::stringstream checkpointInfo() const;
      82             : 
      83        2016 :   bool supportsMaterialPropertyOutput() const override { return true; }
      84             : 
      85             : protected:
      86             :   /**
      87             :    * Outputs a checkpoint file.
      88             :    * Each call to this function creates various files associated with
      89             :    */
      90             :   virtual void output() override;
      91             : 
      92             :   /// Determines if the checkpoint should write out to a file.
      93             :   virtual bool shouldOutput() override;
      94             : 
      95             : private:
      96             :   void updateCheckpointFiles(CheckpointFileNames file_struct);
      97             : 
      98             :   /// Determines if the requested values of execute_on are valid for checkpoints
      99             :   void validateExecuteOn() const;
     100             : 
     101             :   /// Max no. of output files to store
     102             :   unsigned int _num_files;
     103             : 
     104             :   /// Directory suffix
     105             :   const std::string _suffix;
     106             : 
     107             :   /// Vector of checkpoint filename structures
     108             :   std::deque<CheckpointFileNames> _file_names;
     109             : };

Generated by: LCOV version 1.14