ORB5X 1.0.0
Performance-portable global electromagnetic gyrokinetic PIC code
orb5x::ControlAll Class Reference

Coordinate the complete lifetime of an ORB5X simulation. More...

#include "control_all.hpp"

Static Public Member Functions

static void broadcast_file_related_variables (int &datn)
 Broadcast file-generation state from world rank zero.
 
static void check_MPI_types ()
 Verify that ORB5X scalar types match their MPI datatypes.
 
static void close_hdf5_files ()
 Flush diagnostics and close all main, parallel, test, and PSZS files.
 
static void control (int argc=0, char *argv[]=nullptr)
 Run ORB5X from command-line parsing through final shutdown.
 
static void copy_hdf5_to_main_directory (int datn)
 Copy result and restart artifacts to the launch directory.
 
static void create_data_directory ()
 Create restart-generation directories record_path/0 and /1.
 
static void create_group_if_not_exists (H5::H5File *file, const std::string &group_path, const std::string &description="")
 Recursively ensure an HDF5 group path exists.
 
static void create_hdf5_file ()
 Create a new main result file and its top-level metadata groups.
 
static void create_hdf5_testpart_file ()
 Create the root-owned test-particle result file when requested.
 
static void create_parallel_hdf5_file ()
 Collectively create and initialize the parallel result file.
 
static void date (const std::string &str)
 Print a labeled local wall-clock date on world rank zero.
 
static H5::H5File * get_hdf5_file_handle ()
 Access the main serial result-file handle.
 
static void increment_run_counter ()
 Increment /parameters/run_number and update diagnostic state.
 
static void initialize_all_modules (int datn)
 Initialize numerical modules in their required dependency order.
 
static void initialize_run_counter ()
 Set the run counter to one and persist it in the result file.
 
static void open_hdf5_file ()
 Open the existing main orb5_res.h5 result file read/write.
 
static void open_hdf5_testpart_file ()
 Open the root-owned test-particle result file when requested.
 
static void open_parallel_hdf5_file ()
 Collectively open the spatial-domain parallel result file.
 
static void parse_program_arguments (int argc, char *argv[], bool &nl_input_path, std::string &input_path)
 Interpret the input-file and dry-run command-line options.
 
static void prepare_density ()
 Construct density profiles needed before particle initialization.
 
static void print_run_label ()
 Print the ORB5X run banner on world rank zero.
 
static void restart_end_time ()
 Enforce the configured normalized-physics-time limit after restart.
 
static void run_file_check (int &datn)
 Validate restart-control files and read the active generation.
 
static void store_commit_hash ()
 Store available build revision, diff, and environment provenance.
 
static void store_input_file ()
 Archive the exact input text as /run_info/input/run_NN.
 
static void store_species_info ()
 Store configured species names under /parameters/species_names.
 
static void summarize_run ()
 Print the validated geometry, species, timestep, and grid summary.
 
static void write_checkpoint ()
 Write a complete alternating-generation restart checkpoint.
 

Detailed Description

Coordinate the complete lifetime of an ORB5X simulation.

ControlAll is the application-level orchestrator. It reads and validates input, establishes the MPI topology, creates or reopens result files, initializes physics modules in dependency order, advances the timestep loop, writes alternating restart generations, and performs ordered shutdown. Numerical kernels remain in their owning modules; this class connects them and owns the ordering and rank/communicator rules of the run.

The class is static because one process participates in exactly one active ORB5X run. Shared module state and HDF5 handles live in globals.hpp.

Member Function Documentation

◆ broadcast_file_related_variables()

static void orb5x::ControlAll::broadcast_file_related_variables ( int &  datn)
static

Broadcast file-generation state from world rank zero.

Parameters
[in,out]datnRoot restart generation on entry; synchronized value on all ranks on return.

◆ check_MPI_types()

static void orb5x::ControlAll::check_MPI_types ( )
static

Verify that ORB5X scalar types match their MPI datatypes.

A mismatch between Real/Complex and MPI_DOUBLE/ MPI_DOUBLE_COMPLEX terminates the run through the abnormal epilogue.

◆ close_hdf5_files()

static void orb5x::ControlAll::close_hdf5_files ( )
static

Flush diagnostics and close all main, parallel, test, and PSZS files.

◆ control()

static void orb5x::ControlAll::control ( int  argc = 0,
char *  argv[] = nullptr 
)
static

Run ORB5X from command-line parsing through final shutdown.

Parameters
[in]argcNumber of command-line arguments.
[in]argvArgument vector; may contain an input path and dry-run option.

◆ copy_hdf5_to_main_directory()

static void orb5x::ControlAll::copy_hdf5_to_main_directory ( int  datn)
static

Copy result and restart artifacts to the launch directory.

Parameters
[in]datnRestart generation (0 or 1) to copy.
Note
File-system work is performed by world rank zero.

◆ create_data_directory()

static void orb5x::ControlAll::create_data_directory ( )
static

Create restart-generation directories record_path/0 and /1.

◆ create_group_if_not_exists()

static void orb5x::ControlAll::create_group_if_not_exists ( H5::H5File *  file,
const std::string &  group_path,
const std::string &  description = "" 
)
static

Recursively ensure an HDF5 group path exists.

Parameters
[in,out]fileOpen file in which to create groups; null is a no-op.
[in]group_pathAbsolute or relative slash-separated group path.
[in]descriptionOptional title attribute for the requested group.
Note
Work is restricted to world rank zero; existing groups are preserved.

◆ create_hdf5_file()

static void orb5x::ControlAll::create_hdf5_file ( )
static

Create a new main result file and its top-level metadata groups.

◆ create_hdf5_testpart_file()

static void orb5x::ControlAll::create_hdf5_testpart_file ( )
static

Create the root-owned test-particle result file when requested.

◆ create_parallel_hdf5_file()

static void orb5x::ControlAll::create_parallel_hdf5_file ( )
static

Collectively create and initialize the parallel result file.

Note
Uses comm_sd; serial HDF5 builds issue a warning and do no I/O.

◆ date()

static void orb5x::ControlAll::date ( const std::string &  str)
static

Print a labeled local wall-clock date on world rank zero.

Parameters
[in]strLabel placed before the timestamp.

◆ get_hdf5_file_handle()

static H5::H5File * orb5x::ControlAll::get_hdf5_file_handle ( )
static

Access the main serial result-file handle.

Returns
Root-owned HDF5 handle, or nullptr on non-root ranks or when closed.

◆ increment_run_counter()

static void orb5x::ControlAll::increment_run_counter ( )
static

Increment /parameters/run_number and update diagnostic state.

◆ initialize_all_modules()

static void orb5x::ControlAll::initialize_all_modules ( int  datn)
static

Initialize numerical modules in their required dependency order.

Parameters
[in]datnActive restart generation, either 0 or 1.

This includes equilibrium and mesh construction, fields, particles, diagnostics, optional electron-fluid and source models, and either restart restoration or fresh distribution loading.

◆ initialize_run_counter()

static void orb5x::ControlAll::initialize_run_counter ( )
static

Set the run counter to one and persist it in the result file.

◆ open_hdf5_file()

static void orb5x::ControlAll::open_hdf5_file ( )
static

Open the existing main orb5_res.h5 result file read/write.

Note
Only world rank zero owns the resulting global handle.

◆ open_hdf5_testpart_file()

static void orb5x::ControlAll::open_hdf5_testpart_file ( )
static

Open the root-owned test-particle result file when requested.

◆ open_parallel_hdf5_file()

static void orb5x::ControlAll::open_parallel_hdf5_file ( )
static

Collectively open the spatial-domain parallel result file.

Note
Uses comm_sd and requires a parallel HDF5 build.

◆ parse_program_arguments()

static void orb5x::ControlAll::parse_program_arguments ( int  argc,
char *  argv[],
bool &  nl_input_path,
std::string &  input_path 
)
static

Interpret the input-file and dry-run command-line options.

Parameters
[in]argcNumber of command-line arguments.
[in]argvArgument vector to scan.
[out]nl_input_pathTrue when an explicit input path was supplied.
[out]input_pathLast valid input-file path found in argv.

--dry-run enables validation without time integration. --dry-run:ntasks=N additionally emulates a world size of N while validating decomposition parameters.

◆ prepare_density()

static void orb5x::ControlAll::prepare_density ( )
static

Construct density profiles needed before particle initialization.

Profiles are prepared for species using the adiabatic-density model and for kinetic species participating in the CDTN formulation. Stored values follow ORB5X normalized units.

◆ print_run_label()

static void orb5x::ControlAll::print_run_label ( )
static

Print the ORB5X run banner on world rank zero.

◆ restart_end_time()

static void orb5x::ControlAll::restart_end_time ( )
static

Enforce the configured normalized-physics-time limit after restart.

The remaining number of steps is derived from the current simulation time and normalized timestep dt; a run already at its limit exits normally.

◆ run_file_check()

static void orb5x::ControlAll::run_file_check ( int &  datn)
static

Validate restart-control files and read the active generation.

Parameters
[out]datnRestart generation read from datn, defaulting to zero.

Missing mystop, myres, and datn control files are created by the world root before their values are used.

◆ store_commit_hash()

static void orb5x::ControlAll::store_commit_hash ( )
static

Store available build revision, diff, and environment provenance.

Missing optional build metadata is accepted and leaves the corresponding datasets absent.

◆ store_input_file()

static void orb5x::ControlAll::store_input_file ( )
static

Archive the exact input text as /run_info/input/run_NN.

◆ store_species_info()

static void orb5x::ControlAll::store_species_info ( )
static

Store configured species names under /parameters/species_names.

Note
The dataset is written by world rank zero for the first run only.

◆ summarize_run()

static void orb5x::ControlAll::summarize_run ( )
static

Print the validated geometry, species, timestep, and grid summary.

◆ write_checkpoint()

static void orb5x::ControlAll::write_checkpoint ( )
static

Write a complete alternating-generation restart checkpoint.

A checkpoint is triggered by the configured wall-time interval or the myres control file. The routine switches generation 0/1, serializes particle and field state (plus enabled optional modules), copies completed artifacts, and reopens files needed to continue the run.


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