← Documentation
ADS-IDAC Engine 5.0.0
RelapSolver Class Reference

Concrete ThermalHydraulicSolver that wraps RELAP5/MOD3.3. More...

#include <RelapSolver.h>

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

Public Member Functions

void runSequence (SolverCallback &cb) override
 Run one RELAP5 sequence: registers cb and this solver as the active pair, calls relap5_() (blocking), then clears the registration. More...
 
double currentTime () const override
 r5pars_.timesno [s] More...
 
int stopFlag () const override
 r5pars_.csnostop More...
 
bool isTerminateAll () const override
 r5pars_.terminateall More...
 
void setTerminateAll (bool v) override
 Sets r5pars_.terminateall. More...
 
void setBranchCount (int n) override
 Sets r5pars_.cnbranch. More...
 
void setGenNode (bool v) override
 Sets r5pars_.cgennode. More...
 
void setNewRestart (bool v) override
 Sets r5pars_.cnewrst. More...
 
void setInputDeck (const std::string &path) override
 Copy path into r5pars_.carg2 (truncated to the array size minus one) and set r5pars_.carg2len to path.size(). More...
 
std::vector< char > checkpoint () override
 Copy the Fortran in-memory restart buffer. More...
 
void restore (const std::vector< char > &data) override
 Load data into the Fortran in-memory restart buffer. More...
 
void setThermoCacheMode (int mode) override
 Forwards to ads_set_cache_mode_() More...
 
void setMembufMode (int mode) override
 Forwards to ads_set_membuf_mode_() More...
 
- Public Member Functions inherited from ThermalHydraulicSolver
virtual ~ThermalHydraulicSolver ()=default
 
virtual void runSequence (SolverCallback &cb)=0
 Run one complete simulation sequence. Blocks until the sequence completes. The solver calls back into cb at evaluation points during execution. More...
 
virtual double currentTime () const =0
 Current simulation time [s]. More...
 
virtual int stopFlag () const =0
 RELAP5 stop flag. 0=running, 3=normal end, 11=crash. More...
 
virtual bool isTerminateAll () const =0
 True if all simulation should terminate. More...
 
virtual void setTerminateAll (bool v)=0
 Set the terminate-all flag. More...
 
virtual void setBranchCount (int n)=0
 Set the number of branches generated at the current branching point. More...
 
virtual void setGenNode (bool v)=0
 Signal the solver to generate a restart checkpoint at this point. More...
 
virtual void setNewRestart (bool v)=0
 Set whether this is a fresh start (true) or a restart (false). More...
 
virtual void setInputDeck (const std::string &path)=0
 Set the input deck file path for the next sequence. More...
 
virtual std::vector< char > checkpoint ()=0
 Extract the solver's restart checkpoint as an opaque byte buffer. More...
 
virtual void restore (const std::vector< char > &data)=0
 Restore the solver's state from a buffer returned by checkpoint(). More...
 
virtual void setThermoCacheMode (int mode)=0
 Set thermodynamic table caching mode (RelapSolver; no-op for RestApiSolver). 2 forces a reload of the steam tables at every sequence; any other value (0 is the default) reuses the cached tables when the table set is unchanged. More...
 
virtual void setMembufMode (int mode)=0
 Set in-memory restart buffer mode (RelapSolver; no-op for RestApiSolver). 1=enabled, 0=disabled. The engine always passes 1. More...
 

Private Attributes

std::vector< char > base_cache_
 

Detailed Description

Concrete ThermalHydraulicSolver that wraps RELAP5/MOD3.3.

Internally reads/writes the r5pars_ shared C/Fortran struct and calls relap5_() for sequence execution. Fortran callbacks (interfc_, secini_, etc.) are routed to the active SolverCallback via static pointers set during runSequence().

Definition at line 22 of file RelapSolver.h.

Member Function Documentation

◆ checkpoint()

std::vector< char > RelapSolver::checkpoint ( )
overridevirtual

Copy the Fortran in-memory restart buffer.

Environment variables, each read once per process: ADS_MEMBUF_TRIM=1 returns only [file header + plot-id block][last restart dump] (default: the whole accumulated buffer); ADS_MEMBUF_TRACE=1 prints a "[MEMBUF]" line on stdout describing the captured buffer.

Returns
The buffer, or an empty vector when the Fortran buffer is empty.

Implements ThermalHydraulicSolver.

Definition at line 69 of file RelapSolver.cpp.

References ads_membuf_get_(), ads_membuf_get_trimmed_(), and ads_membuf_stats_().

Here is the call graph for this function:

◆ currentTime()

double RelapSolver::currentTime ( ) const
overridevirtual

r5pars_.timesno [s]

Implements ThermalHydraulicSolver.

Definition at line 47 of file RelapSolver.cpp.

References r5pars_.

◆ isTerminateAll()

bool RelapSolver::isTerminateAll ( ) const
overridevirtual

r5pars_.terminateall

Implements ThermalHydraulicSolver.

Definition at line 49 of file RelapSolver.cpp.

References r5pars_.

◆ restore()

void RelapSolver::restore ( const std::vector< char > &  data)
overridevirtual

Load data into the Fortran in-memory restart buffer.

A buffer without a complete restart record gets the cached [header][base] prefix spliced on first; the prefix comes from an earlier self-contained buffer or from <project>/restart_base.bin. Calls std::abort() if no base is available or the splice fails. An empty data is ignored.

Implements ThermalHydraulicSolver.

Definition at line 103 of file RelapSolver.cpp.

References ads_membuf_set_(), base_cache_, adsidac::extract_header_and_base(), g_sim, Scheduler::getProjectDirectory(), adsidac::has_complete_restart(), read_file_verified(), adsidac::splice_base(), and SimulationContext::SScheduler.

Here is the call graph for this function:

◆ runSequence()

void RelapSolver::runSequence ( SolverCallback &  cb)
overridevirtual

Run one RELAP5 sequence: registers cb and this solver as the active pair, calls relap5_() (blocking), then clears the registration.

Implements ThermalHydraulicSolver.

Definition at line 37 of file RelapSolver.cpp.

References relap5_(), s_active_callback, and s_active_solver.

Here is the call graph for this function:

◆ setBranchCount()

void RelapSolver::setBranchCount ( int  n)
overridevirtual

Sets r5pars_.cnbranch.

Implements ThermalHydraulicSolver.

Definition at line 54 of file RelapSolver.cpp.

References r5pars_.

◆ setGenNode()

void RelapSolver::setGenNode ( bool  v)
overridevirtual

Sets r5pars_.cgennode.

Implements ThermalHydraulicSolver.

Definition at line 55 of file RelapSolver.cpp.

References r5pars_.

◆ setInputDeck()

void RelapSolver::setInputDeck ( const std::string &  path)
overridevirtual

Copy path into r5pars_.carg2 (truncated to the array size minus one) and set r5pars_.carg2len to path.size().

Implements ThermalHydraulicSolver.

Definition at line 61 of file RelapSolver.cpp.

References r5pars_.

◆ setMembufMode()

void RelapSolver::setMembufMode ( int  mode)
overridevirtual

Forwards to ads_set_membuf_mode_()

Implements ThermalHydraulicSolver.

Definition at line 148 of file RelapSolver.cpp.

References ads_set_membuf_mode_().

Here is the call graph for this function:

◆ setNewRestart()

void RelapSolver::setNewRestart ( bool  v)
overridevirtual

Sets r5pars_.cnewrst.

Implements ThermalHydraulicSolver.

Definition at line 59 of file RelapSolver.cpp.

References r5pars_.

◆ setTerminateAll()

void RelapSolver::setTerminateAll ( bool  v)
overridevirtual

Sets r5pars_.terminateall.

Implements ThermalHydraulicSolver.

Definition at line 50 of file RelapSolver.cpp.

References r5pars_.

◆ setThermoCacheMode()

void RelapSolver::setThermoCacheMode ( int  mode)
overridevirtual

Forwards to ads_set_cache_mode_()

Implements ThermalHydraulicSolver.

Definition at line 147 of file RelapSolver.cpp.

References ads_set_cache_mode_().

Here is the call graph for this function:

◆ stopFlag()

int RelapSolver::stopFlag ( ) const
overridevirtual

r5pars_.csnostop

Implements ThermalHydraulicSolver.

Definition at line 48 of file RelapSolver.cpp.

References r5pars_.

Member Data Documentation

◆ base_cache_

std::vector<char> RelapSolver::base_cache_
private

[header][complete restart base], a run-wide constant, cached so base-less MPI transfers can be completed before restore.

Definition at line 66 of file RelapSolver.h.

Referenced by restore().


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