← Documentation
ADS-IDAC Engine 5.0.0
Client.h
Go to the documentation of this file.
1
20
21#ifndef CLIENT_H
22#define CLIENT_H
23
24#include <mpi.h>
25#include "ParallelUtilities.h"
26#include "ParallelGlobal.h"
27#include "../Solver/ThermalHydraulicSolver.h"
28#include "../Solver/AdsidacCallback.h"
29#include <filesystem>
30#include <memory>
31#include <unordered_map>
32
33namespace fs = std::filesystem;
34
35using PU = ParallelUtilities;
36
42class Client {
43public:
48 explicit Client(int rank);
49
56 int Work();
57
71 void parallel_restartforanewsequence_(int branch_index);
72
76 void execute_relap();
77
82
83 int parent_seq_id_ = -1;
84 double branch_time_ = 0.0;
86
87 MPI_Status status_client{};
88
91 std::shared_ptr<RestartNodeInfo> rinfo;
92 std::shared_ptr<BranchRecord> branch_record;
93 std::string file_path;
95 };
96
106 void hold_branch_data(int cid, std::shared_ptr<RestartNodeInfo> rinfo,
107 BranchRecord& br, const std::string& path, int refs);
108
117 void restore_relap_state(const std::string& file_path, bool clear_buf);
118
124 void complete_sequence(int seq_id);
125
126private:
127 int rank;
129 std::unique_ptr<ThermalHydraulicSolver> solver_;
131 std::shared_ptr<RestartNodeInfo> restart_info_;
132 std::shared_ptr<BranchRecord> branch_center_;
134 std::unordered_map<int, HeldBranchData> held_data_;
135
142 std::vector<char> base_cache_;
143 bool ensure_base_cache();
144 void restore_buffer(std::vector<char> raw);
145 void self_merge_outputs();
151};
152
153#endif //CLIENT_H
ParallelUtilities PU
Definition: Client.h:35
Shared declarations for MPI parallel execution: message tags, utilities, Fortran callbacks.
Static MPI utility functions — colored logging, Boost object serialization over MPI.
ADS-IDAC engine's implementation of SolverCallback.
MPI worker client that executes simulation sequences.
Definition: Client.h:42
void execute_relap()
Run one sequence on this client's solver: sets the thermo cache mode from the configuration,...
Definition: Client.cpp:675
void hold_branch_data(int cid, std::shared_ptr< RestartNodeInfo > rinfo, BranchRecord &br, const std::string &path, int refs)
Store branch data for deferred peer transfer or a later self-run.
Definition: Client.cpp:684
AdsidacCallback callback_
Per-rank callback instance.
Definition: Client.h:130
int rank
MPI rank of this client.
Definition: Client.h:127
int Work()
Main client work loop: receive tasks, execute, report back.
Definition: Client.cpp:249
void restore_buffer(std::vector< char > raw)
Splice the base on if raw lacks it (MPI_Abort if impossible), then solver_->restore()
Definition: Client.cpp:130
void self_merge_outputs()
Definition: Client.cpp:540
Client(int rank)
Create the solver, initialize the engine modules and redirect the scheduler's output directories to <...
Definition: Client.cpp:202
MPI_Status status_client
Status of the message being handled by Work()
Definition: Client.h:87
int parent_seq_id_
Parent sequence ID for current run (received from server)
Definition: Client.h:83
double branch_time_
Sim time when parent branched to create this sequence.
Definition: Client.h:84
bool ensure_base_cache()
Load <project>/restart_base.bin if not already resident; false if unavailable.
Definition: Client.cpp:120
int branches_this_seq_
Count of branching events during current sequence.
Definition: Client.h:85
int getNextLocalBranchID()
Increment and return the rank-local branch-point counter. The value names restart transfer files and ...
Definition: Client.h:81
std::unordered_map< int, HeldBranchData > held_data_
Rank-local branch-point id -> data held for deferred peer sends and self-runs.
Definition: Client.h:134
void parallel_restartforanewsequence_(int branch_index)
Install the received branch tree as the global one and prepare the restart of one branch alternative.
Definition: Client.cpp:602
void restore_relap_state(const std::string &file_path, bool clear_buf)
Restore the solver state from restart_info_'s buffer or a restart file.
Definition: Client.cpp:155
std::shared_ptr< RestartNodeInfo > restart_info_
Snapshot of the task being started (immutable after creation)
Definition: Client.h:131
std::unique_ptr< ThermalHydraulicSolver > solver_
Per-rank solver instance.
Definition: Client.h:129
void complete_sequence(int seq_id)
Post-sequence completion: write the sequence's ES, KPS, analysis and PE node files,...
Definition: Client.cpp:184
int local_branch_counter_
Per-client branch-point counter (see getNextLocalBranchID)
Definition: Client.h:128
std::shared_ptr< BranchRecord > branch_center_
Branch record of the task being started (consumed by parallel_restartforanewsequence_)
Definition: Client.h:132
std::vector< char > base_cache_
[header][complete restart base], cached once per rank.
Definition: Client.h:142
KeyParameterHistory KPS
Unused; sequences record into g_sim.KPS.
Definition: Client.h:133
Data held locally for deferred peer-to-peer transfer.
Definition: Client.h:90
std::string file_path
Restart transfer file (read only when rinfo carries no buffer)
Definition: Client.h:93
int ref_count
Number of queued tasks still referencing this data.
Definition: Client.h:94
std::shared_ptr< RestartNodeInfo > rinfo
Shared with g_sim.restart_info (no extra buffer copy)
Definition: Client.h:91
std::shared_ptr< BranchRecord > branch_record
Deep copy (owns its own BranchCluster objects)
Definition: Client.h:92