Internals

Data Structures

This section gives an overview of the data structure used in Asynch and mostly intended for the project maintainers.

struct AsynchSolver

This is the main structure that holds the state of the server and associated data structures for a simulation.

Public Members

MPI_Comm comm

COMM on which the solver works.

int np

Number of procs in the comm.

int my_rank

This processes rank in the comm (varies by proc)

bool verbose

Set to true is asynch.

AsynchModel *model

The object model.

ErrorData errors_tol

Object for global error data.

GlobalVars *globals

Global information.

Link *sys

Array of links in the network [dim].

unsigned int N

Number of links in sys.

unsigned int num_methods

Number of methods in rk_methods.

RKMethod *rk_methods

List of RK methods available.

TransData *my_data

Data for communication between procs.

short int *getting

List of data links to get information about.

int *assignments

Link with sys location i is assigned to proc assignments[i].

Link **my_sys

Array of pointer to links in the network assigned to this proc [dim].

unsigned int my_N

Number of links in sys assigned to this proc.

unsigned int save_size

Number of links in save_list.

unsigned int *save_list

List of link ids to print data.

unsigned int my_save_size

Number of links assigned to this proc in save_list.

List of Links to print data.

unsigned int peaksave_size

Number of links in peaksave_list.

unsigned int *peaksave_list

List of link ids to print peakflow data.

unsigned int my_peaksave_size

Number of links assigned to this proc in peaksave_list.

List of Links to print peakflow data.

Lookup *id_to_loc

Lookup table to convert from ids to sys locations.

Workspace workspace

Temporary workspace.

char rkdfilename[ASYNCH_MAX_PATH_LENGTH]

Filename for .rkd file.

FILE *outputfile

File handle for outputing temporary data.

FILE *peakfile

File handle for the peakflow data.

ConnData db_connections[ASYNCH_MAX_DB_CONNECTIONS]

Database connection information.

Forcing forcings[ASYNCH_MAX_DB_CONNECTIONS - ASYNCH_DB_LOC_FORCING_START]

Forcing information.

struct GlobalVars

Structure to contain all data that is global to the river system.

Public Members

unsigned short model_uid

Index for the model used.

double maxtime

Integrate up to this time (duration) [minutes].

double t_0

Initial time to start integration.

double t

Current time of integration.

time_t begin_time

Unix begin time.

time_t end_time

Unix end time.

unsigned short method

RK method to use (if it is the same for all links)

unsigned int max_localorder

Max local order of implemented numerical methods.

unsigned short max_rk_stages

The largest number of internal stages of any RK method used !!!! Is this needed? !!!!

unsigned short max_parents

The largest number of parents any link has.

int iter_limit

If a link has >= iter_limit of steps stored, no new computations occur.

int max_transfer_steps

Maximum number of steps to communicate at once between processes.

unsigned int discont_size

Size of discont, discont_send, discont_order_send at each link.

unsigned short int uses_dam

1 if this type can use dams, 0 else

double *global_params

List of global parameters.

unsigned int num_global_params

Number of global parameters.

unsigned int num_params

Number of params at each link without a dam /unsigned int iparams_size; //!< Number of iparams at each link.

unsigned int dam_params_size

Number of params at each link with a dam.

unsigned int num_disk_params

Number of parameters to read from disk.

unsigned int area_idx

Index of upstream area (A_i) in params.

unsigned int areah_idx

Index of hillslope area (A_h) in params.

unsigned short int init_flag

0 if reading .ini file, 1 if reading .uini file, 2 if reading .rec file

unsigned short int rvr_flag

0 if reading .rvr file, 1 if using database

unsigned short int prm_flag

0 if reading .prm file, 1 if using database

double print_time

Each link will write state every print_time minutes. -1 uses a formula.

unsigned short int print_par_flag

0 to use specified name for output files, 1 to add parameters

unsigned short int dam_flag

0 if not using .dam file, 1 if using

unsigned short int hydrosave_flag

0 if not saving hydrographs, 1 if saving

unsigned short int peaksave_flag

0 if not saving peak flows, 1 if saving

char *peakfilename

Filename for .pea file.

unsigned int max_dim

Maximum num of degree of freedom in the system (assim uses variable dimensions)

unsigned int outletlink

For database: holds the link id of the outlet. Use 0 if reading entire database.

unsigned int string_size

Size of filename buffers.

unsigned int query_size

Size of database query buffers.

unsigned short int convertarea_flag

1 if hillslope and upstream areas are converted from km^2 to m^2, 0 if not

double discont_tol

The error tolerance to use for locating discontinuities.

unsigned int min_error_tolerances

The minimum number of error tolerances needed at every link. Used for uniform error tolerances.

double dump_time

Each link states will dump every dump_time minutes.

unsigned int init_timestamp

The timestamp of the initial state (only used to get initial condition from the DB)

unsigned int num_states_for_printing

Number of states used for printing.

unsigned int *print_indices

List of indices in solution vectors where data is written to output [num_states_for_printing].

unsigned int num_outputs

Number of outputs.

struct ConnData

Structure to hold information about an PostgreSQL database.

Public Members

PGconn *conn

Connection to a database.

char connectinfo[ASYNCH_MAX_CONNSTRING_LENGTH]

Connection information for a database.

char query[ASYNCH_MAX_QUERY_LENGTH]

Buffer space for making queries.

unsigned int time_offset

Added to the integration time to get the actual unix time.

struct ErrorData

Holds the error estimation information for a link.

See Hairer, E. and Norsett, S.P. and Wanner, G., Solving Ordinary Differential Equations I, Nonstiff Problems.

Public Members

double facmax

Parameter for error estimation.

double facmin

Parameter for error estimation.

double fac

Parameter for error estimation.

double *abstol

Absolute tolerance [num_dof].

double *reltol

Relative tolerance [num_dof].

double *abstol_dense

Absolute tolerance for dense output [num_dof].

double *reltol_dense

Relative tolerance for dense output [num_dof].

struct Forcing

This structure holds all the data for a forcing in the river system.

Public Members

unsigned int raindb_start_time

This is the unix time corresponding to the local intergrator time 0.

unsigned int good_timestamp

A timestamp in the db where a forcing actually exists.

unsigned int next_timestamp

Holds the next timestep to use for pulling data.

unsigned int lastused_first_file

The value of first_file when the GetPasses routine was last called. 0 if never set.

unsigned int lastused_last_file

The value of last_file when the GetPasses routine was last called. 0 if never set.

unsigned int number_timesteps

The number of times which feature a forcing at some link.