https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
RestartableDataIO Class Reference

Class for doing restart. More...

#include <RestartableDataIO.h>

Inheritance diagram for RestartableDataIO:
[legend]

Public Member Functions

 RestartableDataIO (MooseApp &app, RestartableDataMap &data)
 
 RestartableDataIO (MooseApp &app, std::vector< RestartableDataMap > &data)
 
PerfGraphperfGraph ()
 Get the PerfGraph.
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static const std::string & getRestartableExt ()
 
static const std::string & restartableDataFile ()
 
static const std::string & restartableHeaderFile ()
 
static std::filesystem::path restartableDataFolder (const std::filesystem::path &folder_base)
 
static std::filesystem::path restartableDataFile (const std::filesystem::path &folder_base)
 
static std::filesystem::path restartableHeaderFile (const std::filesystem::path &folder_base)
 
static InputParameters validParams ()
 

Protected Types

typedef int COMPARE_HASH_CODE_TYPE
 The type to used for comparing hash codes (sanity checking)
 

Protected Member Functions

RestartableDataMapcurrentData (const THREAD_ID tid)
 
std::size_t dataSize () const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 Call to register a named section for timing.
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

const std::variant< RestartableDataMap *, std::vector< RestartableDataMap > * > _data
 The data we wish to act on This is a variant so that we can act on threaded and non-threaded data.
 
MooseApp_pg_moose_app
 The MooseApp that owns the PerfGraph.
 
const std::string _prefix
 A prefix to use for all sections.
 
const Parallel::Communicator_communicator
 

Static Protected Attributes

static const unsigned int CURRENT_BACKUP_FILE_VERSION = 4
 The current version for the backup file.
 

Detailed Description

Class for doing restart.

It takes care of writing and reading the restart files.

Definition at line 27 of file RestartableDataIO.h.

Member Typedef Documentation

◆ COMPARE_HASH_CODE_TYPE

The type to used for comparing hash codes (sanity checking)

Definition at line 84 of file RestartableDataIO.h.

Constructor & Destructor Documentation

◆ RestartableDataIO() [1/2]

RestartableDataIO::RestartableDataIO ( MooseApp app,
RestartableDataMap data 
)

Definition at line 18 of file RestartableDataIO.C.

19 : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
21 _data(&data)
22{
23}
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:179
Interface for objects interacting with the PerfGraph.
const std::variant< RestartableDataMap *, std::vector< RestartableDataMap > * > _data
The data we wish to act on This is a variant so that we can act on threaded and non-threaded data.

◆ RestartableDataIO() [2/2]

RestartableDataIO::RestartableDataIO ( MooseApp app,
std::vector< RestartableDataMap > &  data 
)

Definition at line 25 of file RestartableDataIO.C.

26 : PerfGraphInterface(app.perfGraph(), "RestartableDataIO"),
28 _data(&data)
29{
30}

Member Function Documentation

◆ currentData()

RestartableDataMap & RestartableDataIO::currentData ( const THREAD_ID  tid)
protected
Returns
The restartable data for thread tid

This exists so that we can support threaded and non-threaded data in _data

Definition at line 33 of file RestartableDataIO.C.

34{
35 mooseAssert(dataSize() > tid, "Invalid thread");
36
37 if (std::holds_alternative<RestartableDataMap *>(_data))
38 return *std::get<RestartableDataMap *>(_data);
39 return (*std::get<std::vector<RestartableDataMap> *>(_data))[tid];
40}
std::size_t dataSize() const

Referenced by RestartableDataReader::restore(), RestartableDataReader::restoreData(), and RestartableDataWriter::write().

◆ dataSize()

std::size_t RestartableDataIO::dataSize ( ) const
protected
Returns
The size of _data

Definition at line 43 of file RestartableDataIO.C.

44{
45 return std::holds_alternative<RestartableDataMap *>(_data)
46 ? 1
47 : std::get<std::vector<RestartableDataMap> *>(_data)->size();
48}

Referenced by currentData(), RestartableDataReader::readHeader(), RestartableDataReader::restore(), and RestartableDataWriter::write().

◆ getRestartableExt()

const std::string & RestartableDataIO::getRestartableExt ( )
static
Returns
The common extension for restartable data folders

Definition at line 51 of file RestartableDataIO.C.

52{
53 static const std::string ext = ".rd";
54 return ext;
55}

Referenced by restartableDataFolder().

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 86 of file PerfGraphInterface.C.

87{
88 return _pg_moose_app.perfGraph();
89}
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.

Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), PerfGraphReporter::finalize(), and PerfGraphOutput::output().

◆ registerTimedSection() [1/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
Returns
The ID of the section - use when starting timing

Definition at line 61 of file PerfGraphInterface.C.

63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ registerTimedSection() [2/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level,
const std::string &  live_message,
const bool  print_dots = true 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
live_messageThe message to be printed to the screen during execution
print_dotsWhether or not progress dots should be printed for this section
Returns
The ID of the section - use when starting timing

Definition at line 72 of file PerfGraphInterface.C.

76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}

◆ restartableDataFile() [1/2]

const std::string & RestartableDataIO::restartableDataFile ( )
static
Returns
The filename for the restartable data

Definition at line 58 of file RestartableDataIO.C.

59{
60 static const std::string file = "data";
61 return file;
62}

Referenced by RestartableDataReader::isAvailable(), restartableDataFile(), RestartableDataReader::setInput(), and RestartableDataWriter::write().

◆ restartableDataFile() [2/2]

std::filesystem::path RestartableDataIO::restartableDataFile ( const std::filesystem::path &  folder_base)
static
Returns
The path to the restartable data file with base folder_base

Does not append .rd to the folder base

Definition at line 80 of file RestartableDataIO.C.

81{
82 return folder_base / restartableDataFile();
83}
static const std::string & restartableDataFile()

◆ restartableDataFolder()

std::filesystem::path RestartableDataIO::restartableDataFolder ( const std::filesystem::path &  folder_base)
static
Returns
The path to the restartable data folder with base folder_base

This just appends .rd

Definition at line 72 of file RestartableDataIO.C.

73{
74 auto folder = folder_base;
75 folder += getRestartableExt();
76 return folder;
77}
static const std::string & getRestartableExt()

Referenced by MooseApp::metaDataFolderBase(), and MooseApp::restartFolderBase().

◆ restartableHeaderFile() [1/2]

const std::string & RestartableDataIO::restartableHeaderFile ( )
static
Returns
The filename for the restartable header

Definition at line 65 of file RestartableDataIO.C.

66{
67 static const std::string file = "header";
68 return file;
69}

Referenced by restartableHeaderFile(), RestartableDataReader::setInput(), and RestartableDataWriter::write().

◆ restartableHeaderFile() [2/2]

std::filesystem::path RestartableDataIO::restartableHeaderFile ( const std::filesystem::path &  folder_base)
static
Returns
The path to the restartable header file with base folder_base

Does not append .rd to the folder base

Definition at line 86 of file RestartableDataIO.C.

87{
88 return folder_base / restartableHeaderFile();
89}
static const std::string & restartableHeaderFile()

◆ timedSectionName()

std::string PerfGraphInterface::timedSectionName ( const std::string &  section_name) const
protectedinherited
Returns
The name of the timed section with the name section_name.

Optionally adds a prefix if one is defined.

Definition at line 55 of file PerfGraphInterface.C.

56{
57 return _prefix.empty() ? "" : (_prefix + "::") + section_name;
58}
const std::string _prefix
A prefix to use for all sections.

Referenced by PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

17{
19 return params;
20}
InputParameters emptyInputParameters()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.

Referenced by Convergence::validParams().

Member Data Documentation

◆ _data

const std::variant<RestartableDataMap *, std::vector<RestartableDataMap> *> RestartableDataIO::_data
protected

The data we wish to act on This is a variant so that we can act on threaded and non-threaded data.

Definition at line 79 of file RestartableDataIO.h.

Referenced by currentData(), and dataSize().

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 135 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 138 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ CURRENT_BACKUP_FILE_VERSION

const unsigned int RestartableDataIO::CURRENT_BACKUP_FILE_VERSION = 4
staticprotected

The current version for the backup file.

Definition at line 82 of file RestartableDataIO.h.

Referenced by RestartableDataReader::readHeader().


The documentation for this class was generated from the following files: