← Documentation
ADS-IDAC Engine 5.0.0
AdsidacCallback Class Reference

ADS-IDAC engine's implementation of SolverCallback. More...

#include <AdsidacCallback.h>

Inheritance diagram for AdsidacCallback:
[legend]
Collaboration diagram for AdsidacCallback:
[legend]

Public Member Functions

void onEvaluationPoint (ThermalHydraulicSolver &solver) override
 One engine cycle at an evaluation point. More...
 
void onScenarioStart (ThermalHydraulicSolver &solver) override
 Update plant parameter values, initialize the control panel and refresh the support-system display states. solver is unused. More...
 
void onFirstInit (ThermalHydraulicSolver &solver) override
 Read the input files of every engine module and initialize them. More...
 
void onTimestepAction (ThermalHydraulicSolver &solver) override
 No-op: the engine has no timestep-level actions. More...
 
void onBranchingPoint (ThermalHydraulicSolver &solver) override
 Hand the branches of the newest branch point to the MPI scheduler. More...
 
void restartForNewSequence (ThermalHydraulicSolver &solver)
 Serial path: find the next unexplored branch and prepare its restart. More...
 
void initiationForRestart (ThermalHydraulicSolver &solver)
 Restore the C++ simulation state for the branch about to run. More...
 
- Public Member Functions inherited from SolverCallback
virtual ~SolverCallback ()=default
 
virtual void onEvaluationPoint (ThermalHydraulicSolver &solver)=0
 Called at each evaluation point (~0.5s simulation time intervals). RelapSolver routes the Fortran interfc_() callback here; RestApiSolver calls it after every 0.5 s advance. The engine performs crew scanning, diagnosis, branching decisions here. More...
 
virtual void onScenarioStart (ThermalHydraulicSolver &solver)=0
 Called once at the start of each scenario/sequence. RelapSolver routes the Fortran secini_() callback here; RestApiSolver calls it at the start of every runSequence(). The engine updates parameter values and initializes the control panel. More...
 
virtual void onFirstInit (ThermalHydraulicSolver &solver)=0
 Called once for the entire simulation during first initialization. RelapSolver routes the Fortran actonce_() callback here; RestApiSolver calls it on the first runSequence() of the solver object, before onScenarioStart(). The engine reads configuration files and initializes all modules. More...
 
virtual void onTimestepAction (ThermalHydraulicSolver &solver)=0
 Called at each timestep for action execution. RelapSolver routes the Fortran actte_() callback here; RestApiSolver never calls it. More...
 
virtual void onBranchingPoint (ThermalHydraulicSolver &solver)=0
 Called when a branching point is reached during simulation. RelapSolver routes the Fortran initiate_branching_() callback here; RestApiSolver calls it after taking a checkpoint, when the engine has set the gen-node flag and more than one branch. In MPI mode, handles peer-to-peer restart data exchange. More...
 

Detailed Description

ADS-IDAC engine's implementation of SolverCallback.

Implements the callback interface that the solver calls during sequence execution. Also provides restart management methods called from the main loop and from within onEvaluationPoint.

Definition at line 23 of file AdsidacCallback.h.

Member Function Documentation

◆ initiationForRestart()

void AdsidacCallback::initiationForRestart ( ThermalHydraulicSolver &  solver)

Restore the C++ simulation state for the branch about to run.

Selects the first cluster with an unexplored branch, advances its current branch number, mints the branch ID (getIDOfRecentGeneratedBranch() + 1) and links it to the mother branch. It then takes the matching snapshot from g_sim.restart_info (erased when this is the cluster's last branch), clears every module, remaps the RELAP5 connection (a failure flags the sequence AdsSimErr), copies the snapshot into the live modules and loads the selected branch's content into the command center (skipped only when the environment variable ADS_RESTART_INJECT is "0"). When no other CID references the source sequence, its restart buffer and backup file are released. If no branch or no snapshot is found, a line is appended to "err messages.txt"; with no branch, solver.setTerminateAll(true) is set. Called from onEvaluationPoint when g_sim.fresh_restart is true.

Definition at line 415 of file AdsidacCallback.cpp.

References SimulationContext::Action_Taker, AdsSimErr, BranchCluster::all_branch, SimulationContext::All_polynomial, SimulationContext::All_procedure, SimulationContext::Aux_info, SimulationContext::Branch_center, BranchRecord::branch_cluster, BranchProbability::child_IDs, SimulationContext::cid_to_source_sequence, AnalysisInfoContainer::clearAnalysisInfoContainerForRestart(), BranchRecord::clearBranchRecordForRestart(), CalculationAid::clearCalculationAidForRestart(), CommandControlCenter::clearCommandControlCenteForRestart(), CommunicationPlace::clearCommunicationPlaceForRestart(), ControlPanel::clearForRestart(), HWReliabilityModule::clearForRestart(), SupportSystemReliabilityModule::clearForRestart(), InitiatingEventController::clearInitiatingEventController(), KeyParameterHistory::clearKeyParameterHistory(), OperatorAT::clearOperatorATForRestart(), OperatorDM::clearOperatorDMForRestart(), Procedures::clearProceduresForRestart(), SimulationContext::Command_handler, SimulationContext::Communication_place, AnalysisInfoContainer::copyAnalysisInfoContainerForRestart(), CalculationAid::copyCalculationAidFromRestartInfoForRestart(), CommandControlCenter::copyCommandControlCenterFromRestartInfo(), ControlPanel::copyControlPanelForRestart(), HWReliabilityModule::copyHWReliabilityModule(), InitiatingEventController::copyInitiatingEventController(), KeyParameterHistory::copyKeyParameterHistory(), OperatorAT::copyOperatorATFromRestartInfo(), OperatorDM::copyOperatorDMFromRestartInfo(), Procedures::copyProceduresFromRestartInfoForRestart(), SimulationContext::Decision_Maker, BranchCluster::findBranch(), BranchRecord::findBrnachCluster(), g_sim, BranchCluster::getCurrentBranchNum(), BranchCluster::getIDOfMotherCluster(), BranchRecord::getIDOfRecentGeneratedBranch(), BranchCluster::getIDOfTheMotherBranch(), BranchCluster::getIDOfThisBranchCluster(), BranchProbability::getUnconditionalBranchProbability(), SimulationContext::IE, SimulationContext::Indicator, SimulationContext::KPS, Operator::m_RM, SimulationContext::Plant, r5pars_, SimulationContext::restart_buffers, SimulationContext::restart_info, restart_path(), BranchProbability::sendBranchInfoToCommandCenter(), SimulationContext::seq_restart_branch_num, SimulationContext::seq_restart_cid, SystemModule::setConnectionToRELAP5(), BranchCluster::setCurrentBranchNum(), BranchRecord::setIDOfMotherBranch(), BranchRecord::setIDOfMotherCluster(), BranchRecord::setIDOfRecentGeneratedBranch(), BranchProbability::setIDOfThisBranch(), BranchRecord::setRecentUnconditionalBranchProbability(), BranchRecord::setTempESMessage(), BranchRecord::setTempTypeOfConsequence(), ThermalHydraulicSolver::setTerminateAll(), SimulationContext::Support_system_reliability, and SimulationContext::System_reliability.

Referenced by initiationforrestart_(), and onEvaluationPoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onBranchingPoint()

void AdsidacCallback::onBranchingPoint ( ThermalHydraulicSolver &  solver)
overridevirtual

Hand the branches of the newest branch point to the MPI scheduler.

Does nothing in serial runs, on rank 0, or in a build without ENABLE_MPI. On a client rank it captures solver.checkpoint(), optionally trims it to one restart record (environment variable ADS_RESTART_TRIM=1, default off), keeps it in the snapshot's relap_restart_buf (memory mode) or writes it to a restart_<lid>_cid<N>.r file (file mode), LZ4-compressed when –compress-queue is set, and reports (local id, branch count) to the server with server_branch_meta. It then sends the snapshot and the BranchRecord to each peer the server assigns, and holds them in the Client (hold_branch_data) if the server queued any branch. Blocks on the server's client_peer_assign replies.

Implements SolverCallback.

Definition at line 155 of file AdsidacCallback.cpp.

References BranchCluster::all_branch, SimulationContext::Branch_center, Client::branches_this_seq_, ThermalHydraulicSolver::checkpoint(), PG::client_peer_assign, PG::client_peer_restart, SimConfig::compress_queue, SimulationContext::config, adsidac::extract_header_and_base(), adsidac::extract_record_no_base(), BranchRecord::findBrnachCluster(), g_client, g_sim, get_rss_mb(), BranchCluster::getNCountForRestartRELAP5(), Client::getNextLocalBranchID(), Scheduler::getProjectDirectory(), Client::hold_branch_data(), SimConfig::is_mpi_environment, PG::log, lz4_compress(), PG::rank, SimulationContext::restart_info, PG::server_branch_meta, SimConfig::shm_prefix, should_use_memory_restart(), SimulationContext::SScheduler, and write_file_or_die().

Here is the call graph for this function:

◆ onEvaluationPoint()

void AdsidacCallback::onEvaluationPoint ( ThermalHydraulicSolver &  solver)
overridevirtual

One engine cycle at an evaluation point.

If r5pars_.csnostop is 11, or is nonzero and not 3, adds a THFail end state, sets g_sim.expected_abort and returns. On the first evaluation point after a restart (g_sim.fresh_restart) it first calls initiationForRestart(). It then runs the crew and plant modules once, samples the key parameter history, and checks sequence termination (Scheduler::checkForTerminatingCurrentSequence). If the sequence continues it sets r5pars_.cnbranch from BranchRecord::checkAndAddBranchCluster(); with more than one branch it appends a RestartNodeInfo snapshot to g_sim.restart_info, and with at least one branch it sends the current branch command to the command center and sets r5pars_.cgennode.

Implements SolverCallback.

Definition at line 34 of file AdsidacCallback.cpp.

References SimulationContext::Action_Taker, BranchRecord::addAnEndState(), KeyParameterHistory::addDataSet(), AnalysisInfoContainer::addRecord(), SimulationContext::Aux_info, SimulationContext::Branch_center, SimulationContext::branches_generated_this_sequence, HWReliabilityModule::checkAndActiveComponentFailure(), SupportSystemReliabilityModule::checkAndActiveSupportSystemFailure(), BranchRecord::checkAndAddBranchCluster(), InitiatingEventController::checkAndExecuteInitiatingEvent(), Scheduler::checkForTerminatingCurrentSequence(), SimulationContext::cid_to_source_sequence, BranchRecord::clearBranches(), CommunicationPlace::clearCommunicationPlaceAllPointers(), SimulationContext::Command_handler, SimulationContext::Communication_place, SimulationContext::current_seq_events, SimulationContext::Decision_Maker, SystemModule::executeActionsToInteractWithSystem(), SimulationContext::expected_abort, SimulationContext::fresh_restart, g_sim, BranchRecord::getIDOfRecentGeneratedBranchCluster(), BranchRecord::getIDOfRecentGeneratedES(), Operator::getPauseActivity(), Operator::getPauseMentalProcedure(), SimulationContext::id_epoch_base, SimulationContext::IE, SimulationContext::Indicator, initiationForRestart(), SimulationContext::KPS, ControlPanel::oneThroughProcess(), OperatorAT::oneThroughProcessForBlockD(), OperatorDM::oneThroughProcessForBlockD(), OperatorAT::oneThroughProcessForBlockI(), OperatorDM::oneThroughProcessForBlockI(), SimulationContext::Plant, r5pars_, SimulationContext::restart_info, OperatorAT::scanControlPanel(), OperatorDM::scanControlPanel(), BranchRecord::sendCurrentBranchCommandToCommandCenter(), CommandControlCenter::sendInfoToCommunicationPlace(), BranchEndState::setConsequenceDescription(), ControlPanel::setCurrentTime(), BranchEndState::setTypeOfConsequence(), SimulationContext::SScheduler, SimulationContext::Support_system_reliability, SimulationContext::System_reliability, THFail, Operator::updateEvidenceForAllPSFs(), SystemModule::updateParametersValues(), and SupportSystemReliabilityModule::updateSupportSystemDisplayStates().

Here is the call graph for this function:

◆ onFirstInit()

void AdsidacCallback::onFirstInit ( ThermalHydraulicSolver &  solver)
overridevirtual

Read the input files of every engine module and initialize them.

Order: control panel, procedures (then registered as the process-local shared masters), polynomials, crew (ODM, OAT), hardware reliability, support-system reliability, control panel initialization, initiating event, system-decomposition completeness check, first panel scan, first key-parameter sample. solver is unused.

Implements SolverCallback.

Definition at line 127 of file AdsidacCallback.cpp.

References SimulationContext::Action_Taker, KeyParameterHistory::addDataSet(), SimulationContext::All_polynomial, SimulationContext::All_procedure, Operator::checkCompletenessOfSystemDecomposition(), SimulationContext::Decision_Maker, Operator::diagnosis_matrix, g_sim, SimulationContext::IE, SimulationContext::Indicator, ControlPanel::initiationForSimulation(), Operator::initiationForSimulation(), Procedures::initiationForSimulation(), InitiatingEventController::InitiationForSimulation(), Operator::knowledge_base, SimulationContext::KPS, sim::Operator::OAT, sim::Operator::ODM, CalculationAid::readInfoFromFile(), ControlPanel::readInfoFromFile(), HWReliabilityModule::readInfoFromFile(), SupportSystemReliabilityModule::readInfoFromFile(), OperatorAT::scanControlPanel(), OperatorDM::scanControlPanel(), adsidac::set_shared_control_panel(), adsidac::set_shared_diagnosis_matrix(), adsidac::set_shared_kb(), adsidac::set_shared_procedures(), SimulationContext::Support_system_reliability, SimulationContext::System_reliability, and SupportSystemReliabilityModule::updateSupportSystemDisplayStates().

Here is the call graph for this function:

◆ onScenarioStart()

void AdsidacCallback::onScenarioStart ( ThermalHydraulicSolver &  solver)
overridevirtual

Update plant parameter values, initialize the control panel and refresh the support-system display states. solver is unused.

Implements SolverCallback.

Definition at line 121 of file AdsidacCallback.cpp.

References g_sim, SimulationContext::Indicator, ControlPanel::initiationForSimulation(), SimulationContext::Plant, SimulationContext::Support_system_reliability, SystemModule::updateParametersValues(), and SupportSystemReliabilityModule::updateSupportSystemDisplayStates().

Here is the call graph for this function:

◆ onTimestepAction()

void AdsidacCallback::onTimestepAction ( ThermalHydraulicSolver &  solver)
overridevirtual

No-op: the engine has no timestep-level actions.

Implements SolverCallback.

Definition at line 117 of file AdsidacCallback.cpp.

◆ restartForNewSequence()

void AdsidacCallback::restartForNewSequence ( ThermalHydraulicSolver &  solver)

Serial path: find the next unexplored branch and prepare its restart.

Scans g_sim.Branch_center.branch_cluster front to back for the first cluster with an unexplored branch. If found, restores solver from the source sequence's entry in g_sim.restart_buffers, or from its restart_seq_<seq>.r backup file, writes indeck.i (card 103 = the cluster's restart count) and sets g_sim.fresh_restart. If none remains, calls solver.setTerminateAll(true), saves every PE node, clears the clusters and removes the backup files. Always clears the key parameter history and the analysis records. A missing backup file is reported on stderr and the sequence proceeds without a restore. Called from the serial main loop after each sequence completes.

Definition at line 339 of file AdsidacCallback.cpp.

References BranchCluster::all_branch, SimulationContext::Aux_info, SimulationContext::Branch_center, BranchRecord::branch_cluster, SimulationContext::cid_to_source_sequence, AnalysisInfoContainer::clearAnalysisInfoContainerForRestart(), KeyParameterHistory::clearKeyParameterHistory(), SimulationContext::fresh_restart, g_sim, BranchCluster::getCurrentBranchNum(), BranchCluster::getIDOfThisBranchCluster(), BranchCluster::getNCountForRestartRELAP5(), ThermalHydraulicSolver::isTerminateAll(), SimulationContext::KPS, r5pars_, SimulationContext::restart_buffers, restart_path(), ThermalHydraulicSolver::restore(), and ThermalHydraulicSolver::setTerminateAll().

Referenced by main(), and restartforanewsequence_().

Here is the call graph for this function:
Here is the caller graph for this function:

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