NGen
Loading...
Searching...
No Matches
HY_CatchmentRealization Class Reference

A hydrology-specific perspective of a catchment. More...

#include <HY_CatchmentRealization.hpp>

+ Inheritance diagram for HY_CatchmentRealization:
+ Collaboration diagram for HY_CatchmentRealization:

Classes

class  Response
 The response value distilled by this perspective, in every way the perspective can express it. More...
 

Public Types

enum class  Quantity {
  depth ,
  volume ,
  volumetric_flow
}
 A quantity a perspective can express its value as, each in one canonical unit. More...
 

Public Member Functions

 HY_CatchmentRealization ()
 
 HY_CatchmentRealization (std::string catchment_id, std::shared_ptr< realization::Formulation > formulation)
 
virtual ~HY_CatchmentRealization ()
 
const std::shared_ptr< realization::Formulation > & get_formulation () const
 The model producing this feature's values, or nullptr where the feature is not modeled.
 
const std::string & get_catchment_id () const
 The id this feature shares with the catchment it realizes.
 
std::shared_ptr< HY_Catchment > realize (std::vector< std::string > inflows, std::vector< std::string > outflows, long layer=0)
 Build the catchment this feature is a perspective of, and bind the two together.
 
std::shared_ptr< HY_Catchment > get_realized_catchment () const
 The catchment this feature realizes, whose inflow and outflow nexuses it shares.
 
virtual std::optional< double > area_sqkm () const
 The areal extent of this feature, in square kilometers, where the perspective has one.
 
virtual Response get_response (time_step_t t_index, time_step_t t_delta)
 Execute the attached model for the given time step, where it is of the specified size, and return the perspective's response.
 

Static Public Attributes

static constexpr std::size_t quantity_count = 3
 How many Quantity there are.
 

Protected Attributes

std::string catchment_id
 
std::shared_ptr< realization::Formulation > formulation
 
unsigned long id_number
 

Private Attributes

std::weak_ptr< HY_Catchment > realized_catchment
 

Detailed Description

A hydrology-specific perspective of a catchment.

A catchment is realized as the face it covers (HY_CatchmentArea), as the edge bounding that face (HY_CatchmentDivide), or as the edge running through it (HY_FlowPath). Each subtype carries the topology of its own perspective, and so answers what a value associated with the feature is distributed over.

A realization is constructed with the identity of the catchment it realizes. realize then builds that catchment and binds the two, after which the realization can reach the nexuses flowing into and out of it.

A realization may have a formulation attached, which is what produces the values associated with the feature. A catchment can be realized several ways and not every realization is modeled, so the attachment is optional.

Member Enumeration Documentation

◆ Quantity

A quantity a perspective can express its value as, each in one canonical unit.

Unit conversion should be handled at a higher level, outside of the perspective itself.

Enumerator
depth 

Meters.

volume 

Cubic meters, over the step.

volumetric_flow 

Cubic meters per second.

Constructor & Destructor Documentation

◆ HY_CatchmentRealization() [1/2]

HY_CatchmentRealization::HY_CatchmentRealization ( )
default

◆ HY_CatchmentRealization() [2/2]

HY_CatchmentRealization::HY_CatchmentRealization ( std::string catchment_id,
std::shared_ptr< realization::Formulation > formulation )

◆ ~HY_CatchmentRealization()

HY_CatchmentRealization::~HY_CatchmentRealization ( )
virtualdefault

Member Function Documentation

◆ area_sqkm()

virtual std::optional< double > HY_CatchmentRealization::area_sqkm ( ) const
inlinevirtual

The areal extent of this feature, in square kilometers, where the perspective has one.

A face has an area, and so does the edge bounding that face; the edge running through it has a length instead. Empty therefore says the perspective has no extent to give, never that the hydrofabric withheld one: a catchment whose hydrofabric carries no extent is refused when the realization is built, so it does not reach here.

Reimplemented in HY_CatchmentArea.

◆ get_catchment_id()

const std::string & HY_CatchmentRealization::get_catchment_id ( ) const
inline

The id this feature shares with the catchment it realizes.

References catchment_id.

Referenced by HY_CatchmentArea::get_response(), and get_response().

◆ get_formulation()

const std::shared_ptr< realization::Formulation > & HY_CatchmentRealization::get_formulation ( ) const
inline

The model producing this feature's values, or nullptr where the feature is not modeled.

References formulation.

◆ get_realized_catchment()

std::shared_ptr< HY_Catchment > HY_CatchmentRealization::get_realized_catchment ( ) const

The catchment this feature realizes, whose inflow and outflow nexuses it shares.

Null until realize has been called.

References realized_catchment.

◆ get_response()

HY_CatchmentRealization::Response HY_CatchmentRealization::get_response ( time_step_t t_index,
time_step_t t_delta )
virtual

Execute the attached model for the given time step, where it is of the specified size, and return the perspective's response.

A model's value is assumed to be depth by default.

Parameters
t_indexThe index of the time step for which to run model calculations.
t_deltaThe duration, in seconds, of the time step for which to run model calculations.
Returns
This perspective's response for the step, as each Quantity it expresses.
Exceptions
std::runtime_errorIf this feature has no formulation attached.

Reimplemented in HY_CatchmentArea.

References formulation, get_catchment_id(), and realization::Formulation::get_response().

Referenced by HY_CatchmentArea::get_response().

◆ realize()

std::shared_ptr< HY_Catchment > HY_CatchmentRealization::realize ( std::vector< std::string > inflows,
std::vector< std::string > outflows,
long layer = 0 )

Build the catchment this feature is a perspective of, and bind the two together.

The catchment is given this realization's identity, so the pair cannot disagree about what it names. Each then holds the other: the catchment owns its realization, and the realization reaches back to the catchment for its nexuses.

One realization is one perspective of one catchment. Calling this again returns the catchment already built and does not apply the arguments; realizing a catchment from another perspective means another realization, which builds its own.

Parameters
inflowsIds of the nexuses contributing to the catchment.
outflowsIds of the nexuses the catchment contributes to.
layerThe hydrofabric layer the catchment belongs to.
Returns
The catchment, newly built or the one this realization already built.
Exceptions
std::bad_weak_ptrIf this realization is not already held by a shared_ptr.

References catchment_id, and realized_catchment.

Referenced by HY_CatchmentRealization_Test::SetUp().

Member Data Documentation

◆ catchment_id

std::string HY_CatchmentRealization::catchment_id
protected

Referenced by get_catchment_id(), and realize().

◆ formulation

std::shared_ptr<realization::Formulation> HY_CatchmentRealization::formulation
protected

Referenced by get_formulation(), and get_response().

◆ id_number

unsigned long HY_CatchmentRealization::id_number
protected

◆ quantity_count

std::size_t HY_CatchmentRealization::quantity_count = 3
staticconstexpr

How many Quantity there are.

◆ realized_catchment

std::weak_ptr<HY_Catchment> HY_CatchmentRealization::realized_catchment
private

Referenced by get_realized_catchment(), and realize().


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