Tsunami Project Lab
Loading...
Searching...
No Matches
tsunami_lab::io::Stations Class Reference

#include <Stations.h>

Public Member Functions

 Stations (std::string i_xmlPath, t_real i_dxy, t_idx i_nx, t_idx i_ny, t_idx i_stride)
 
void sample (t_real i_simTime, t_real const *i_h, t_real const *i_hu, t_real const *i_hv, t_real const *i_bm)
 
t_idx size () const
 
std::string const & name (t_idx i) const
 
t_idx cellIx (t_idx i) const
 
t_idx cellIy (t_idx i) const
 
t_real frequency () const
 

Constructor & Destructor Documentation

◆ Stations()

tsunami_lab::io::Stations::Stations ( std::string i_xmlPath,
t_real i_dxy,
t_idx i_nx,
t_idx i_ny,
t_idx i_stride )

Parses the given XML config, pins each station to its containing cell, and opens one CSV per station in the current working directory (filename = <name>.csv). On any malformed config (missing root, missing frequency, station out of bounds, duplicate name, unwritable file) throws std::runtime_error with a message pointing at the offending element.

Parameters
i_xmlPathpath to the XML config (read from CWD).
i_dxyuniform cell width/height (m).
i_nxnumber of interior cells in x-direction.
i_nynumber of interior cells in y-direction.
i_striderow stride of the data arrays passed to sample().

Member Function Documentation

◆ cellIx()

t_idx tsunami_lab::io::Stations::cellIx ( t_idx i) const
inline

Containing cell index of the i-th station (mainly for tests).

◆ cellIy()

t_idx tsunami_lab::io::Stations::cellIy ( t_idx i) const
inline

◆ frequency()

t_real tsunami_lab::io::Stations::frequency ( ) const
inline

Shared output frequency in seconds.

◆ name()

std::string const & tsunami_lab::io::Stations::name ( t_idx i) const
inline

Read-only view on the i-th station's name (mainly for tests).

◆ sample()

void tsunami_lab::io::Stations::sample ( t_real i_simTime,
t_real const * i_h,
t_real const * i_hu,
t_real const * i_hv,
t_real const * i_bm )

Writes a row to every station file if the simulation has reached the next scheduled sample time. Safe to call every time step.

If the simulation advanced past several sample times in a single step (very small frequency), one row is emitted per missed target; each row records the actual simulation time of the call, so the recorded times are slightly after the scheduled targets.

For 1d wave-propagation patches i_hv may be nullptr; the column is then written as 0.

Parameters
i_simTimecurrent simulation time.
i_hwater heights (interior origin, length stride*ny).
i_hux-momenta (same layout).
i_hvy-momenta (same layout) or nullptr in 1d.
i_bmbathymetry or nullptr.

◆ size()

t_idx tsunami_lab::io::Stations::size ( ) const
inline

Number of stations parsed from the config (mainly for tests).


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