← Documentation
ADS-IDAC Engine 5.0.0
AdsidacCallback.cpp
Go to the documentation of this file.
1
4
5#include "AdsidacCallback.h"
6#include "../Global/RestartTrim.h"
7#include <cstdlib>
8#include <filesystem>
9#include "../Global/fmodule.h"
10#include "../ParallelExec/ParallelGlobal.h"
11#ifdef ENABLE_MPI
12#include "../ParallelExec/ParallelExecution.h"
13#endif
14
15#include <iostream>
16#include <fstream>
17#include <memory>
18#include <string>
19#include <vector>
20#include "../Global/SimulationContext.h"
21#include "../Global/SharedConfig.h"
22#include "../Global/CheckedIO.h"
23
24using namespace std;
25
26// Fortran membuf accessor. Not called in this file: onBranchingPoint obtains
27// the restart buffer through solver.checkpoint().
28extern "C" { void ads_membuf_get_(char** ptr, int* sz); }
29
30extern void outputErrMessageToFile(string);
31
32// ---- SolverCallback implementations ----
33
35 BranchEndState *es_pt;
36 string str;
37 bool terminate_current_sequence = false;
38
39 if (r5pars_.csnostop == 11) {
40 es_pt = new BranchEndState();
42 str = "Plant model simulation failure";
43 es_pt->setConsequenceDescription(str);
45 g_sim.expected_abort = true;
46 return;
47 } else if (r5pars_.csnostop != 0 && r5pars_.csnostop != 3) {
48 es_pt = new BranchEndState();
50 str = "Sequence terminated by RELAP5";
51 es_pt->setConsequenceDescription(str);
53 g_sim.expected_abort = true;
54 return;
55 }
56 if (g_sim.fresh_restart) {
57 g_sim.fresh_restart = false;
60 }
77 }
81 }
83
86
87 terminate_current_sequence =
89 if (!terminate_current_sequence) {
91 if (r5pars_.cnbranch > 1) {
92 str = std::to_string(r5pars_.cnbranch);
93 str += " branches are generated";
94 g_sim.Aux_info.addRecord(str, -999);
95 cout << " " << r5pars_.timesno << " " << str << endl;
96 std::shared_ptr<RestartNodeInfo> restart_info_pt_1 = make_shared<RestartNodeInfo>();
97 // Propagate the run's branch-ID epoch so peers receiving this
98 // snapshot seed their windows in the same epoch.
99 restart_info_pt_1->id_epoch_base = g_sim.id_epoch_base;
100 restart_info_pt_1->setCorrespondingBranchClusterID(g_sim.Branch_center.getIDOfRecentGeneratedBranchCluster());
101 restart_info_pt_1->saveRestartNodeInfo();
102 int enq_cid = restart_info_pt_1->getCorrespondingBranchClusterID();
103 g_sim.restart_info.push_back(restart_info_pt_1);
106 }
107 if (r5pars_.cnbranch > 0) {
109 r5pars_.cgennode = true;
110 }
111 } else {
113 }
115}
116
118 // Empty: the engine has no timestep-level crew actions
119}
120
125}
126
130 // Register the loaded procedure book as the process-local master.
131 // Snapshots serialize state only; deserialization re-seeds structure and
132 // definitions from this object (identical on every rank: same input
133 // files, guarded by the config fingerprint).
153}
154
156#ifdef ENABLE_MPI
158 {
159 if (PG::rank > 0 && g_client)
160 {
161 int local_id = g_client->getNextLocalBranchID();
162 std::shared_ptr<RestartNodeInfo> rinfo = g_sim.restart_info.back();
163 int cid = rinfo->getCorrespondingBranchClusterID();
164
165 std::string branch_name = "restart_" + std::to_string(local_id)
166 + "_cid" + std::to_string(cid) + ".r";
167 bool use_mem = should_use_memory_restart();
168 std::string local_branch_path = use_mem
169 ? (g_sim.config.shm_prefix + "rank" + std::to_string(PG::rank) + "_" + branch_name)
170 : ("../rank_" + std::to_string(PG::rank) + "/" + branch_name);
171
172 auto ckpt_buf = solver.checkpoint();
173
174 // Restart trimming (opt-in, see trim_enabled below): ship one
175 // restart record, not the whole accumulated buffer.
176 //
177 // A captured buffer holds one dump per branch point for the entire
178 // sequence. In MPI each branch is transferred separately and each
179 // transfer carries all of it, while the receiver restores from
180 // exactly one record: the one whose ncount goes into card 103,
181 // which Client::parallel_restartforanewsequence_ reads from this
182 // same cluster. So all N branches of this branch point want the
183 // same single record.
184 //
185 // Placed here, before the memory/file fork, so it shrinks the held
186 // buffer, the .r file AND the wire transfer together.
187 // The whole block is MPI-only, so serial (which shares one buffer
188 // across all children and needs every dump) is excluded by
189 // construction.
190 //
191 // Falls back to the full buffer if the record is not found: extra
192 // bandwidth is survivable, a wrong restart is not.
194 // Enabled only when the environment variable ADS_RESTART_TRIM is
195 // "1" (read once per process); off by default.
196 static const bool trim_enabled = [] {
197 const char* v = std::getenv("ADS_RESTART_TRIM");
198 return v && *v == '1';
199 }();
200 if (bc && !ckpt_buf.empty() && trim_enabled) {
201 const auto want = static_cast<int32_t>(bc->getNCountForRestartRELAP5());
202
203 // Publish the run-wide base once, so receivers can splice it
204 // back on and the wire carries only [header][target]. The base
205 // is byte-identical across lineages, which is what makes this
206 // legal. It is written before the transfer that needs it, so
207 // on a coherent shared filesystem a peer on another node sees
208 // it. An existing restart_base.bin is left in place.
209 static bool base_published = false;
210 if (!base_published) {
211 const std::string base_path =
212 g_sim.SScheduler.getProjectDirectory() + "/restart_base.bin";
213 std::error_code ec;
214 if (!std::filesystem::exists(base_path, ec)) {
215 auto hb = adsidac::extract_header_and_base(ckpt_buf);
216 if (!hb.empty()) {
217 // temp + rename: several ranks may reach this at once
218 const std::string tmp = base_path + ".r"
219 + std::to_string(PG::rank) + ".tmp";
220 write_file_or_die(tmp, hb.data(), hb.size());
221 std::filesystem::rename(tmp, base_path, ec);
222 if (ec) std::filesystem::remove(tmp, ec);
223 }
224 }
225 base_published = true;
226 }
227
228 auto one = adsidac::extract_record_no_base(ckpt_buf, want);
229 if (!one.empty()) {
230 if (const char* t = std::getenv("ADS_MEMBUF_TRACE"); t && *t == '1') {
231 std::cout << "[TRIM] cid=" << cid << " ncount=" << want
232 << " " << ckpt_buf.size() / 1048576.0 << " MB -> "
233 << one.size() / 1048576.0 << " MB ("
234 << (double)ckpt_buf.size() / one.size() << "x)" << std::endl;
235 }
236 ckpt_buf = std::move(one);
237 } else {
238 PU::print_message(PG::rank, "[TRIM] cid=" + std::to_string(cid)
239 + " ncount=" + std::to_string(want)
240 + " not found in buffer — sending it whole", PG::log);
241 }
242 }
243
244 if (use_mem) {
245 if (!ckpt_buf.empty() && !g_sim.restart_info.empty()) {
247 rinfo->relap_restart_buf = lz4_compress(ckpt_buf.data(), static_cast<int>(ckpt_buf.size()));
248 } else {
249 rinfo->relap_restart_buf = std::move(ckpt_buf);
250 }
251 }
252 } else {
253 if (!ckpt_buf.empty()) {
255 auto comp = lz4_compress(ckpt_buf.data(), static_cast<int>(ckpt_buf.size()));
256 write_file_or_die(local_branch_path, comp.data(), comp.size());
257 } else {
258 write_file_or_die(local_branch_path, ckpt_buf.data(), ckpt_buf.size());
259 }
260 }
261 }
262
263 int num_branches = static_cast<int>(bc->all_branch.size());
264
265 PU::print_message(PG::rank, "[PEER] CID=" + std::to_string(cid)
266 + " branches=" + std::to_string(num_branches)
267 + " RSS=" + std::to_string(get_rss_mb()) + "MB"
268 + " buf=" + std::to_string(rinfo->relap_restart_buf.size()/1024/1024) + "MB", PG::log);
269
270 MPI_Send(&local_id, 1, MPI_INT, 0, PG::server_branch_meta, MPI_COMM_WORLD);
271 MPI_Send(&num_branches, 1, MPI_INT, 0, PG::server_branch_meta, MPI_COMM_WORLD);
272
273 int num_direct;
274 MPI_Recv(&num_direct, 1, MPI_INT, 0, PG::client_peer_assign,
275 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
276
277 // Serialize the snapshot once and send the same bytes to every
278 // direct target: rinfo embeds the restart buffer and BranchRecord
279 // grows with the tree, so per-target serialization is costly.
280 std::string rinfo_bytes, branch_bytes;
281 if (num_direct > 0) {
282 rinfo_bytes = PU::serialize_object(*rinfo);
283 branch_bytes = PU::serialize_object(g_sim.Branch_center);
284 }
285
286 for (int i = 0; i < num_direct; i++) {
287 int target_rank, branch_index, seq_id, parent_seq_id;
288 MPI_Recv(&target_rank, 1, MPI_INT, 0, PG::client_peer_assign,
289 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
290 MPI_Recv(&branch_index, 1, MPI_INT, 0, PG::client_peer_assign,
291 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
292 MPI_Recv(&seq_id, 1, MPI_INT, 0, PG::client_peer_assign,
293 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
294 MPI_Recv(&parent_seq_id, 1, MPI_INT, 0, PG::client_peer_assign,
295 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
296
297 PU::print_message(PG::rank, "[PEER] Direct send -> C["
298 + std::to_string(target_rank) + "] bi="
299 + std::to_string(branch_index) + " seq=" + std::to_string(seq_id), PG::log);
300
301 PU::send_bytes(rinfo_bytes, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
302 PU::send_bytes(branch_bytes, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
303 int path_len = static_cast<int>(local_branch_path.size());
304 MPI_Send(&path_len, 1, MPI_INT, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
305 MPI_Send(local_branch_path.c_str(), path_len, MPI_CHAR,
306 target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
307 MPI_Send(&seq_id, 1, MPI_INT, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
308 MPI_Send(&branch_index, 1, MPI_INT, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
309 MPI_Send(&parent_seq_id, 1, MPI_INT, target_rank, PG::client_peer_restart, MPI_COMM_WORLD);
310 }
311
312 int num_queued;
313 MPI_Recv(&num_queued, 1, MPI_INT, 0, PG::client_peer_assign,
314 MPI_COMM_WORLD, MPI_STATUS_IGNORE);
315
316 if (num_queued > 0) {
317 g_client->hold_branch_data(local_id, rinfo, g_sim.Branch_center, local_branch_path, num_queued);
318 } else {
319 // Every branch was sent directly to a peer, so nothing holds
320 // this snapshot, but the shared_ptr still in
321 // g_sim.restart_info would keep the restart buffer alive until
322 // the next task clears the vector. Release the buffer now.
323 rinfo->relap_restart_buf.clear();
324 rinfo->relap_restart_buf.shrink_to_fit();
325 }
326
328
329 PU::print_message(PG::rank, "[PEER] Branch done: "
330 + std::to_string(num_direct) + " direct, "
331 + std::to_string(num_queued) + " queued (held locally)", PG::log);
332 }
333 }
334#endif
335}
336
337// ---- Restart management ----
338
340 bool found_restart_point = false;
341 long n_count;
342 string content = "100 restart transnt\n101 run\n103 ";
343
344 size_t chosen_idx = static_cast<size_t>(-1);
345 const size_t total = g_sim.Branch_center.branch_cluster.size();
346 for (size_t idx = 0; idx < total; ++idx) {
348 if (bc->getCurrentBranchNum() < (static_cast<int>(bc->all_branch.size()) - 1)) {
349 chosen_idx = idx;
350 break;
351 }
352 }
353
354 if (chosen_idx != static_cast<size_t>(-1)) {
355 BranchCluster *chosen = g_sim.Branch_center.branch_cluster[chosen_idx].get();
356 int cid = chosen->getIDOfThisBranchCluster();
357 n_count = chosen->getNCountForRestartRELAP5();
358 auto seq_it = g_sim.cid_to_source_sequence.find(cid);
359 if (seq_it != g_sim.cid_to_source_sequence.end()) {
360 auto buf_it = g_sim.restart_buffers.find(seq_it->second);
361 if (buf_it != g_sim.restart_buffers.end() && !buf_it->second.empty()) {
362 solver.restore(buf_it->second);
363 } else {
364 std::string backup = restart_path("restart_seq_" + std::to_string(seq_it->second) + ".r");
365 std::ifstream ifs(backup, std::ios::binary | std::ios::ate);
366 if (!ifs || ifs.tellg() <= 0) {
367 std::cerr << "ERROR: cannot read restart file: " << backup << std::endl;
368 } else {
369 auto file_sz = static_cast<size_t>(ifs.tellg());
370 ifs.seekg(0);
371 std::vector<char> buf(file_sz);
372 ifs.read(buf.data(), static_cast<std::streamsize>(file_sz));
373 solver.restore(buf);
374 }
375 }
376 }
377
378 found_restart_point = true;
379 g_sim.fresh_restart = true;
380 } else {
381 solver.setTerminateAll(true);
382 for (auto &bc : g_sim.Branch_center.branch_cluster) {
383 bc->savePENodeToFile();
384 }
386
387 for (auto& [c, s] : g_sim.cid_to_source_sequence) {
388 std::string bkp = restart_path("restart_seq_" + std::to_string(s) + ".r");
389 if (fs::exists(bkp)) fs::remove(bkp);
390 }
392
393 cout << "All sequences have been simulated" << endl;
394 }
395
396 if (found_restart_point) {
397 content += to_string(n_count);
398 content += "\n.";
399 ofstream fout("indeck.i", ios::out);
400 fout << content;
401 fout.close();
402 } else if (!solver.isTerminateAll()) {
403 ofstream fout("err messages.txt", ios::app);
404 cout << "restartForANewSequence: could not find the restart point."
405 << endl;
406 fout << r5pars_.timesno
407 << " restartForANewSequence: could not find the restart point.\n";
408 fout.close();
409 }
410
413}
414
416 bool found_restart_branch = false;
417 bool found_restart_info = false;
418 int restart_branch_cluster_ID = -1, restart_branch_num = -1, new_branch_ID;
419 int id_of_mother_branch_cluster, id_of_mother_branch;
420 // Assigned from g_sim.restart_info when found; only dereferenced inside
421 // if (found_restart_info). Left null here because constructing a
422 // RestartNodeInfo builds two crew BBNs.
423 std::shared_ptr<RestartNodeInfo> restart_info_pt;
424 BranchProbability *restart_branch_pt = nullptr;
425 BranchCluster *mother_bc_pt;
426 BranchProbability *mother_branch;
427
428 for (size_t idx = 0; idx < g_sim.Branch_center.branch_cluster.size(); ++idx) {
430 int cid = bc->getIDOfThisBranchCluster();
431 int curr = bc->getCurrentBranchNum();
432 if (curr < (static_cast<int>(bc->all_branch.size()) - 1)) {
433 found_restart_branch = true;
434 restart_branch_cluster_ID = cid;
435 restart_branch_num = curr + 1;
437 g_sim.seq_restart_branch_num = restart_branch_num;
438 bc->setCurrentBranchNum(restart_branch_num);
441 restart_branch_pt = bc->all_branch.at(restart_branch_num).get();
442 restart_branch_pt->setIDOfThisBranch(new_branch_ID);
446 restart_branch_pt->getUnconditionalBranchProbability());
447
448 id_of_mother_branch_cluster = bc->getIDOfMotherCluster();
449 id_of_mother_branch = bc->getIDOfTheMotherBranch();
450 mother_bc_pt = g_sim.Branch_center.findBrnachCluster(id_of_mother_branch_cluster);
451 if (mother_bc_pt) {
452 mother_branch = mother_bc_pt->findBranch(id_of_mother_branch);
453 if (mother_branch) {
454 mother_branch->child_IDs.push_back(new_branch_ID);
455 }
456 }
457 break;
458 }
459 }
460
461 if (found_restart_branch) {
462 bool cid_consumed = false;
463 for (auto ri = g_sim.restart_info.begin(); ri != g_sim.restart_info.end(); ++ri) {
464 if (*ri && (*ri)->getCorrespondingBranchClusterID() == restart_branch_cluster_ID) {
465 found_restart_info = true;
466 restart_info_pt = *ri;
467
468 BranchCluster *bc = g_sim.Branch_center.findBrnachCluster(restart_branch_cluster_ID);
469 cid_consumed = (bc && restart_branch_num >= static_cast<int>(bc->all_branch.size()) - 1);
470
471 if (cid_consumed) {
472 *ri = nullptr;
473 g_sim.restart_info.erase(ri);
474 }
475 break;
476 }
477 }
478
479 if (found_restart_info) {
493 g_sim.Decision_Maker.m_RM.reset();
494 g_sim.Action_Taker.m_RM.reset();
495
496 if (g_sim.Plant.setConnectionToRELAP5() == -1) {
497 // Card-number remapping failed mid-run: continuing would read
498 // stale _obj indices. Flag the sequence (AdsSimErr end state)
499 // instead of simulating from a broken bridge.
500 r5pars_.sim_err = true;
501 g_sim.Branch_center.setTempESMessage("setConnectionToRELAP5 failed at restart.");
503 }
504 g_sim.Indicator.copyControlPanelForRestart(restart_info_pt->r_Indicator);
506 restart_info_pt->r_All_procedure);
508 restart_info_pt->r_Aux_info);
509 g_sim.KPS.copyKeyParameterHistory(restart_info_pt->r_KPS);
511 restart_info_pt->r_Command_handler);
513 restart_info_pt->r_Decision_Maker);
515 restart_info_pt->r_Action_Taker);
516 g_sim.IE.copyInitiatingEventController(restart_info_pt->r_IE);
518 restart_info_pt->r_System_reliability);
520 restart_info_pt->r_All_polynomial);
521
522 // Give the selected branch its content. The snapshot is taken
523 // BEFORE the mainline (branch 0) is injected, so the restored
524 // command center holds only the commands pending at the branch
525 // point; the alternative this child stands for is loaded here.
526 // Environment variable ADS_RESTART_INJECT (read once per process):
527 // "0" skips the injection; unset or any other value injects
528 // (the default).
529 static const bool inject_on_restart = [] {
530 const char* v = std::getenv("ADS_RESTART_INJECT");
531 return !(v && *v == '0');
532 }();
533 if (inject_on_restart) {
534 restart_branch_pt->sendBranchInfoToCommandCenter(new_branch_ID);
535 }
536
537 if (cid_consumed) {
538 auto cs_it = g_sim.cid_to_source_sequence.find(restart_branch_cluster_ID);
539 if (cs_it != g_sim.cid_to_source_sequence.end()) {
540 int consumed_seq = cs_it->second;
541 g_sim.cid_to_source_sequence.erase(cs_it);
542 bool still_needed = false;
543 for (auto& [c, s] : g_sim.cid_to_source_sequence) {
544 if (s == consumed_seq) { still_needed = true; break; }
545 }
546 if (!still_needed) {
547 std::string bkp = restart_path("restart_seq_" + std::to_string(consumed_seq) + ".r");
548 if (fs::exists(bkp)) {
549 fs::remove(bkp);
550 }
551 g_sim.restart_buffers.erase(consumed_seq);
552 }
553 }
554 }
555 } else {
556 ofstream fout("err messages.txt", ios::app);
557 cout << r5pars_.timesno
558 << "\tADSV2::initiationForRestart: found restart branch but not restart info node."
559 << endl;
560 fout << r5pars_.timesno
561 << "\tADSV2::initiationForRestart: found restart branch but not restart info node.\n";
562 fout.close();
563 }
564 } else {
565 ofstream fout("err messages.txt", ios::app);
566 cout << r5pars_.timesno
567 << "\tADSV2::initiationForRestart: count not find restart branch."
568 << endl;
569 fout << r5pars_.timesno
570 << "\tADSV2::initiationForRestart: count not find restart branch.\n";
571 fout.close();
572 solver.setTerminateAll(true);
573 }
574}
void outputErrMessageToFile(string)
Definition: ADSIDAC.cpp:624
void ads_membuf_get_(char **ptr, int *sz)
Engine-side implementation of SolverCallback.
void write_file_or_die(const std::string &path, const char *data, size_t size)
Write an entire buffer to a binary file (truncating it); fatal on any failure.
Definition: CheckedIO.h:42
Client * g_client
std::vector< char > lz4_compress(const char *data, int size)
LZ4-compress a buffer with a 4-byte original-size header.
bool should_use_memory_restart()
Decide whether to use memory mode for this restart operation. memory_limit_mb == 0 → unlimited (alway...
std::string restart_path(const std::string &name)
Get restart file path (shm or local).
long get_rss_mb()
Get current process RSS in MB (Linux + macOS, returns 0 elsewhere).
SimulationContext g_sim
Global simulation context: the single instance, defined in SimulationContext.cpp.
void onBranchingPoint(ThermalHydraulicSolver &solver) override
Hand the branches of the newest branch point to the MPI scheduler.
void onScenarioStart(ThermalHydraulicSolver &solver) override
Update plant parameter values, initialize the control panel and refresh the support-system display st...
void onFirstInit(ThermalHydraulicSolver &solver) override
Read the input files of every engine module and initialize them.
void initiationForRestart(ThermalHydraulicSolver &solver)
Restore the C++ simulation state for the branch about to run.
void onTimestepAction(ThermalHydraulicSolver &solver) override
No-op: the engine has no timestep-level actions.
void onEvaluationPoint(ThermalHydraulicSolver &solver) override
One engine cycle at an evaluation point.
void restartForNewSequence(ThermalHydraulicSolver &solver)
Serial path: find the next unexplored branch and prepare its restart.
void addRecord(std::string, int)
void copyAnalysisInfoContainerForRestart(AnalysisInfoContainer &)
int getNCountForRestartRELAP5()
int getIDOfMotherCluster()
BranchProbability * findBranch(int)
Finds the alternative with the given branch ID, searching from the last alternative.
int getIDOfThisBranchCluster()
int getCurrentBranchNum()
void setCurrentBranchNum(int)
Sets the index (within all_branch) of the most recently started alternative. Alternatives with a larg...
int getIDOfTheMotherBranch()
std::vector< std::unique_ptr< BranchProbability > > all_branch
The alternatives of this branching point; index 0 is the one the generating sequence continues on.
The end state (ES node) that terminates one sequence of the DET.
void setTypeOfConsequence(Consequence)
void setConsequenceDescription(std::string)
One alternative of a BranchCluster, i.e. one PE node of the DET.
double getUnconditionalBranchProbability()
std::vector< int > child_IDs
void sendBranchInfoToCommandCenter(int)
Hands the content of this alternative to the command center (g_sim.Command_handler)....
void setTempTypeOfConsequence(Consequence)
Stores the consequence of the end state the running sequence will get.
void addAnEndState(BranchEndState *)
Closes the running sequence with an end state and takes ownership of it.
void clearBranchRecordForRestart()
Clears the pending forks only (same as clearBranches()).
void clearBranches()
Drops every pending fork and system alarm and resets the pending branch types and counts....
int getIDOfRecentGeneratedES()
int checkAndAddBranchCluster()
Expands the pending forks into a new BranchCluster.
int getIDOfRecentGeneratedBranchCluster()
void setIDOfMotherBranch(int)
void setIDOfRecentGeneratedBranch(int)
int getIDOfRecentGeneratedBranch()
void setRecentUnconditionalBranchProbability(double)
BranchCluster * findBrnachCluster(int)
Finds a cluster by ID, searching from the most recent cluster.
std::vector< std::unique_ptr< BranchCluster > > branch_cluster
All branching points generated so far, in creation order.
Definition: BranchRecord.h:284
void sendCurrentBranchCommandToCommandCenter()
Sends the content of the running sequence's alternative of the most recent cluster to the command cen...
void setTempESMessage(std::string)
Stores the description of the end state the running sequence will get if it is terminated (set by mod...
void setIDOfMotherCluster(int)
void copyCalculationAidFromRestartInfoForRestart(const CalculationAid &)
void clearCalculationAidForRestart()
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
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
void copyCommandControlCenterFromRestartInfo(CommandControlCenter &)
void clearCommunicationPlaceAllPointers()
void clearCommunicationPlaceForRestart()
void setCurrentTime()
void copyControlPanelForRestart(ControlPanel &)
void clearForRestart()
void readInfoFromFile()
void oneThroughProcess()
void initiationForSimulation()
void checkAndActiveComponentFailure()
Registers the hardware forks that are due at the current evaluation point.
void copyHWReliabilityModule(HWReliabilityModule &)
Appends deep copies of the units of another module and copies its state of activation....
void clearForRestart()
Removes all units and resets the state of activation.
void readInfoFromFile()
Loads SystemReliability.txt from the hardware reliability directory (Scheduler::getHardwareReliabilit...
void copyInitiatingEventController(InitiatingEventController &)
void copyKeyParameterHistory(KeyParameterHistory &)
void oneThroughProcessForBlockI()
Definition: OperatorAT.cpp:587
void clearOperatorATForRestart()
void oneThroughProcessForBlockD()
Definition: OperatorAT.cpp:23
void scanControlPanel()
Definition: OperatorAT.cpp:547
void copyOperatorATFromRestartInfo(OperatorAT &)
void copyOperatorDMFromRestartInfo(OperatorDM &)
void oneThroughProcessForBlockD()
Definition: OperatorDM.cpp:29
void clearOperatorDMForRestart()
void scanControlPanel()
Definition: OperatorDM.cpp:760
void oneThroughProcessForBlockI()
Definition: OperatorDM.cpp:800
void updateEvidenceForAllPSFs()
Definition: Operator.cpp:1517
std::unique_ptr< ReasonMachine > m_RM
Definition: Operator.h:55
KB knowledge_base
Definition: Operator.h:127
void checkCompletenessOfSystemDecomposition(int)
Definition: Operator.cpp:1087
EventSymptomMatrix diagnosis_matrix
Definition: Operator.h:129
bool getPauseMentalProcedure()
Definition: Operator.cpp:586
bool getPauseActivity()
Definition: Operator.cpp:580
void initiationForSimulation()
Definition: Operator.cpp:79
void copyProceduresFromRestartInfoForRestart(Procedures &)
Definition: Procedures.cpp:212
void initiationForSimulation()
Definition: Procedures.cpp:42
void clearProceduresForRestart()
Definition: Procedures.cpp:188
bool checkForTerminatingCurrentSequence()
Decides whether the running sequence ends at this evaluation point.
Definition: Scheduler.cpp:694
std::string getProjectDirectory()
Definition: Scheduler.cpp:595
void executeActionsToInteractWithSystem()
void updateParametersValues()
int setConnectionToRELAP5()
Abstract interface for thermal-hydraulic solvers.
virtual bool isTerminateAll() const =0
True if all simulation should terminate.
virtual void restore(const std::vector< char > &data)=0
Restore the solver's state from a buffer returned by checkpoint().
virtual void setTerminateAll(bool v)=0
Set the terminate-all flag.
virtual std::vector< char > checkpoint()=0
Extract the solver's restart checkpoint as an opaque byte buffer.
struct @0 r5pars_
bool log
Enable/disable rank-specific logging.
@ server_branch_meta
Client A -> Server: branch metadata only (rank-local branch id + num_branches)
@ client_peer_assign
Server -> Client A: peer assignment list for direct sends.
@ client_peer_restart
Client A -> Client B: direct peer-to-peer restart data.
int rank
MPI rank of this process.
void set_shared_procedures(const Procedures *master)
void set_shared_kb(int operator_type, const KB *master)
void set_shared_control_panel(const ControlPanel *master)
void set_shared_diagnosis_matrix(int operator_type, const EventSymptomMatrix *master)
std::vector< char > extract_record_no_base(const std::vector< char > &buf, std::int32_t want)
[header][target], the wire payload with the base omitted.
Definition: RestartTrim.h:132
std::vector< char > extract_header_and_base(const std::vector< char > &buf)
[header][complete base], the run-wide constant that is cached per rank and published as <project>/res...
Definition: RestartTrim.h:113
constexpr int ODM
Definition: SimConstants.h:145
constexpr int OAT
Definition: SimConstants.h:144
std::string shm_prefix
Path prefix for memory-restart files: "/dev/shm/adsidac_<pid>_" when /dev/shm exists,...
Definition: SimConfig.h:26
int is_mpi_environment
1 if OMPI_COMM_WORLD_SIZE or PMI_SIZE is set in the environment, 0 for serial
Definition: SimConfig.h:33
bool compress_queue
–compress-queue (default off): LZ4-compress RELAP restart buffers held and sent between MPI ranks
Definition: SimConfig.h:22
int seq_restart_branch_num
Branch index within that cluster.
SupportSystemReliabilityModule Support_system_reliability
Support system reliability.
Scheduler SScheduler
Simulation scheduling, parses CLI options.
Procedures All_procedure
Emergency operating procedures.
OperatorAT Action_Taker
Crew action execution model.
KeyParameterHistory KPS
Time-series parameter recording.
int seq_restart_cid
CID of restart-origin cluster.
std::vector< std::pair< double, int > > current_seq_events
(branching_time, num_branches) pairs
ControlPanel Indicator
Control room panel state.
HWReliabilityModule System_reliability
Hardware fault trees.
OperatorDM Decision_Maker
Crew decision-making model.
SystemModule Plant
Maps RELAP5 card numbers to C++ objects.
std::map< int, std::vector< char > > restart_buffers
seq_id -> RELAP5 restart buffer
CommandControlCenter Command_handler
Command/control dispatch.
InitiatingEventController IE
Initiating event definition.
int id_epoch_base
Branch-ID epoch for resumed MPI runs; 0 = fresh run.
bool fresh_restart
One-shot flag for restart init.
bool branches_generated_this_sequence
True if branches generated this seq.
std::map< int, int > cid_to_source_sequence
Maps cluster ID to source sequence.
CommunicationPlace Communication_place
Inter-module communication.
AnalysisInfoContainer Aux_info
Analysis records.
BranchRecord Branch_center
Dynamic event tree state.
std::deque< std::shared_ptr< RestartNodeInfo > > restart_info
Restart checkpoints for FIFO.
bool expected_abort
Sequence ended abnormally.
CalculationAid All_polynomial
Polynomial calculations.