|
IBAMR
IBAMR version 0.19.
|
Class RestartCleaner provides functionality to manage restart directories. More...
#include <ibtk/RestartCleaner.h>
Public Member Functions | |
| RestartCleaner (const std::string &object_name, SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > input_db) | |
| Constructor using SAMRAI Database configuration. More... | |
| ~RestartCleaner ()=default | |
| Destructor. More... | |
| void | cleanup () |
| Scan and cleanup old restart directories. More... | |
| std::vector< int > | getAvailableRestartRestoreNumbers () const |
| Get available restart restore numbers. More... | |
Private Types | |
| enum | CleanupStrategy { CleanupStrategy::KEEP_RECENT_N } |
| Internal strategy enumeration. More... | |
Private Member Functions | |
| RestartCleaner ()=delete | |
| RestartCleaner (const RestartCleaner &from)=delete | |
| RestartCleaner & | operator= (const RestartCleaner &that)=delete |
| CleanupStrategy | parseStrategy (const std::string &strategy_str) const |
| Parse strategy string to enum. More... | |
| void | executeStrategy () const |
| Execute cleanup based on current strategy. More... | |
| std::optional< int > | parseRestartRestoreNumber (const std::string &dirname) const |
| Parse restart restore number from directory name. More... | |
| std::vector< std::filesystem::path > | getAllRestartDirs (const std::string &restart_dir) const |
| Get all restart directories from the base path. More... | |
| void | keepRecentN () const |
| KEEP_RECENT_N strategy implementation. More... | |
Private Attributes | |
| std::string | d_object_name |
| std::string | d_restart_base_path |
| CleanupStrategy | d_strategy |
| int | d_keep_restart_count |
| bool | d_enable_logging |
| bool | d_dry_run |
Static Private Attributes | |
| static const std::regex | s_restart_dir_pattern |
This class provides methods to automatically clean up old restart directories while keeping the most recent ones. It is designed to work with IBAMR's standard restart directory naming convention and integrates with the SAMRAI Database configuration system.
The main functionalities include:
Supported cleanup strategies:
Sample usage:
|
strongprivate |
|
explicit |
This is the constructor for RestartCleaner and integrates with IBAMR's standard configuration system.
The input database is searched for the following keys:
| object_name | Name for this object (used in error messages and logging) |
| input_db | Database containing configuration parameters |
|
default |
|
privatedelete |
|
privatedelete |
| void IBTK::RestartCleaner::cleanup | ( | ) |
This method performs the complete cleanup process:
In parallel environments, file operations are performed only on the master processor (rank 0) to ensure consistency.
| std::vector<int> IBTK::RestartCleaner::getAvailableRestartRestoreNumbers | ( | ) | const |
Scans the restart directory and returns restart restore numbers for all currently existing restore directories, sorted in ascending order.
|
privatedelete |
|
private |
|
private |
|
private |
Extracts the restart restore number from directory names following the pattern "restore.NNNNNN..." where the restart restore number is zero-padded to at least 6 digits.
| dirname | Directory name to parse |
|
private |
Scans the restart base directory and returns all subdirectories that match the restart naming pattern.
| restart_dir | Base directory to scan |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticprivate |
1.8.17