2.0.0b10
catchment modelling framework
Loading...
Searching...
No Matches
node_list Class Reference

A collection of nodes for fast access of the waterbalance. More...

Detailed Description

A collection of nodes for fast access of the waterbalance.

In setups with many storages and rather fast computations, the speed of data access for output generation can take a high portion of the total run time. To accelerate data access, one can use the node_list object

Todo
Add a get_volume / set_volume function pair, to complement get_potential / set_potential

Public Member Functions

 node_list ()
 Creates an empty node_lust

 
 node_list (const cmf::water::node_list &forcopy)
 Copy the node_list.
 
void append (flux_node::ptr node)
 Adds a flux node to the list.
 
cmf::math::num_array conc (cmf::math::Time t, const cmf::water::solute &_Solute) const
 Returns an array holding the concentration of all the flux nodes for the given solute.
 
flux_node::ptr get (ptrdiff_t index) const
 Returns a node in the node_list.
 
cmf::geometry::point_vector get_fluxes3d (cmf::math::Time t) const
 Returns the current flow vector for each node.
 
cmf::geometry::point_vector get_fluxes3d_to (const cmf::water::node_list &targets, cmf::math::Time t) const
 Returns the flux vectors to the nodes of a given target node_list.
 
cmf::math::num_array get_fluxes_to (const cmf::water::node_list &targets, cmf::math::Time t) const
 A fast method to perform flux queries as a batch.
 
cmf::geometry::point_vector get_positions () const
 Returns the positions of the nodes.
 
cmf::math::num_array get_potentials (cmf::math::Time t=cmf::math::never)
 Returns the potential of the nodes.
 
node_list getslice (ptrdiff_t begin, ptrdiff_t end, ptrdiff_t step=1) const
 Returns a slice of the node_list.
 
real global_water_balance (cmf::math::Time t) const
 Returns the sum of the water balances of the nodes.
 
 operator cmf::math::state_list ()
 Implements StateVariableOwner.
 
cmf::water::node_list operator+ (const cmf::water::node_list &right) const
 Returns the union of two node_lists.
 
node_listoperator+= (const cmf::water::node_list &right)
 Extends the node_list with another.
 
bool remove (flux_node::ptr node)
 Removes a flux node from the list, returns true if successful.
 
ptrdiff_t set_potentials (const cmf::math::num_array &potentials)
 Sets the potentials of the node_list.
 
size_t size () const
 The number of nodes.
 
cmf::math::num_array water_balance (cmf::math::Time t) const
 Returns the water balance of each vector as a vector.
 

Member Function Documentation

◆ get_fluxes_to()

cmf::math::num_array get_fluxes_to ( const cmf::water::node_list & targets,
cmf::math::Time t ) const

A fast method to perform flux queries as a batch.

The node lists left and right should have the same length.

Returns
The vector containing the flux from left to right at the same position
Parameters
targetsA node_list containing the source nodes
tThe time for the fluxes

Replaces slow Python code like:

fluxes=[left_node[i].flux_to(right_node[i],t) for i in range(len(left_nodes))]

◆ global_water_balance()

real global_water_balance ( cmf::math::Time t) const

Returns the sum of the water balances of the nodes.

\[\sigma_{global} = \sum_{i=0}^N{\sum_{j=0}^{C_i}{q_{ij}(t)}} \]

Replaces slow Python code like:

sum=0
for n in nodes:
sum+=n.water_balance(t)

◆ set_potentials()

ptrdiff_t set_potentials ( const cmf::math::num_array & potentials)

Sets the potentials of the node_list.

If nodes do not have changeable potentials, they are skipped silently

Returns
The number of nodes with changed potential

◆ water_balance()

cmf::math::num_array water_balance ( cmf::math::Time t) const

Returns the water balance of each vector as a vector.

\[ \sigma_i = \sum_{j=0}^{C_i}{q_{ij}(t)} \]

Replaces slow Python code like:

balances=[n.water_balance(t) for n in nodes]