NGen
Loading...
Searching...
No Matches
hy_features::HY_Features Class Reference

Collection interface to HY_Features objects and their associated model formulations. More...

#include <HY_Features.hpp>

+ Collaboration diagram for hy_features::HY_Features:

Public Member Functions

 HY_Features ()
 Construct a new, default HY_Features object.
 
 HY_Features (geojson::GeoJSON fabric, std::shared_ptr< Formulation_Manager > formulations)
 Construct a new HY_Features object from a GeoJSON feature collection and a set of formulations.
 
 HY_Features (geojson::GeoJSON catchments, std::string *link_key, std::shared_ptr< Formulation_Manager > formulations)
 Construct a new HY_Features object from a Network and a set of formulations.
 
std::shared_ptr< HY_CatchmentRealizationcatchment_at (std::string id)
 Get the HY_CatchmentRealization pointer identified by id.
 
 HY_Features (network::Network network, std::shared_ptr< Formulation_Manager > formulations, geojson::GeoJSON fabric)
 Construct a new HY_Features object from a Network and a set of formulations.
 
std::shared_ptr< HY_HydroNexusnexus_at (const std::string &id)
 Get the HY_HydroNexus pointer identifed by id.
 
auto catchments ()
 An iterator of only the catchment feature ids.
 
auto catchments (long lyr)
 An iterator of only the catchment feature ids from only the specified layer.
 
const auto & layers ()
 Return a set of layers that contain a catchment.
 
auto nexuses ()
 An iterator of only the nexus feature ids.
 
std::vector< std::shared_ptr< HY_HydroNexus > > destination_nexuses (const std::string &id)
 Get a vector of destination (downstream) nexus pointers.
 
void validate_dendritic ()
 Validates that the feature topology is dendritic.
 
virtual ~HY_Features ()
 Destroy the hy features object.
 

Private Types

using Formulation_Manager = realization::Formulation_Manager
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< HY_Catchment > > _catchments
 Internal mapping of catchment id -> HY_Catchment pointer.
 
std::unordered_map< std::string, std::shared_ptr< HY_HydroNexus > > _nexuses
 Internal mapping of nexus id -> HY_HydroNexus pointer.
 
network::Network network
 network::Network graph of identities.
 
std::shared_ptr< Formulation_Managerformulations
 Pointer to the formulation manager used to associate catchment formulations with HY_Catchment objects.
 
std::set< long > hf_layers
 The set of layers that contain at least one catchment.
 

Detailed Description

Collection interface to HY_Features objects and their associated model formulations.

A HY_Features collection provides organized access to HY_Features objects. It is backed by a topologically connected network::Network index and provides quick id based iteration of various feature types, as well as helper functions for accessing pointers to the constructed features.

Simple usage example to execute model formulations for each catchment for a single time:

geojson::GeoJSON catchment_collection = geojson::read("catchment_data.geojson", std::vector<std::string>());
std::shared_ptr<realization::Formulation_Manager> manager = std::make_shared<realization::Formulation_Manager>("realization_config.json");
manager->read(catchment_collection, utils::getStdOut());
hy_features::HY_Features features = hy_features::HY_Features(catchment_collection, manager);
int time_index = 0;
for(const auto& id : features.catchments()) {
auto r = features.catchment_at(id);
auto r_c = dynamic_pointer_cast<realization::Catchment_Formulation>(r);
double response = r_c->get_response(time_index, 3600.0);
std::string output = std::to_string(time_index)+", examlpe_time_stamp,"+
r_c->get_output_line_for_timestep(time_index)+"\n";
r_c->write_output(output);
}
Collection interface to HY_Features objects and their associated model formulations.
Definition HY_Features.hpp:41
std::shared_ptr< HY_CatchmentRealization > catchment_at(std::string id)
Get the HY_CatchmentRealization pointer identified by id.
Definition HY_Features.hpp:82
auto catchments()
An iterator of only the catchment feature ids.
Definition HY_Features.hpp:120
std::shared_ptr< FeatureCollection > GeoJSON
Easy short-hand for a smart pointer to a FeatureCollection.
Definition FeatureBuilder.hpp:21
static GeoJSON read(const std::string &file_path, const std::vector< std::string > &ids={})
Definition FeatureBuilder.hpp:444
static StreamHandler getStdOut()
Definition StreamHandler.hpp:103

Member Typedef Documentation

◆ Formulation_Manager

Constructor & Destructor Documentation

◆ HY_Features() [1/4]

hy_features::HY_Features::HY_Features ( )
inline

Construct a new, default HY_Features object.

◆ HY_Features() [2/4]

HY_Features::HY_Features ( geojson::GeoJSON fabric,
std::shared_ptr< Formulation_Manager > formulations )

Construct a new HY_Features object from a GeoJSON feature collection and a set of formulations.

Constructs the network::Network index and then

Parameters
fabric
formulations

◆ HY_Features() [3/4]

HY_Features::HY_Features ( geojson::GeoJSON catchments,
std::string * link_key,
std::shared_ptr< Formulation_Manager > formulations )

Construct a new HY_Features object from a Network and a set of formulations.

Constructs the HY_Catchment objects for each catchment connecting them with the provided link_key attaches the formulation associated with the catchment found in the Formulation_Manager. Also constucts each nexus as a HY_PointHydroNexus.

Parameters
catchments
link_key
formulations

◆ HY_Features() [4/4]

HY_Features::HY_Features ( network::Network network,
std::shared_ptr< Formulation_Manager > formulations,
geojson::GeoJSON fabric )

Construct a new HY_Features object from a Network and a set of formulations.

Constructs the HY_Catchment objects for each catchment feature in the network, and attaches tha formaulation associated with the catchment found in the Formulation_Manager. Also constucts each nexus as a HY_PointHydroNexus.

Parameters
network
formulations

References _catchments, _nexuses, formulations, hf_layers, hy_features::identifiers::isCatchment(), hy_features::identifiers::isNexus(), and hy_features::identifiers::seperator.

◆ ~HY_Features()

virtual hy_features::HY_Features::~HY_Features ( )
inlinevirtual

Destroy the hy features object.

Member Function Documentation

◆ catchment_at()

std::shared_ptr< HY_CatchmentRealization > hy_features::HY_Features::catchment_at ( std::string id)
inline

Get the HY_CatchmentRealization pointer identified by id.

If no realization exists for id, a nullptr is returned.

Parameters
id
Returns
std::shared_ptr<HY_CatchmentRealization>

References _catchments.

Referenced by ngen::Layer::update_models().

◆ catchments() [1/2]

auto hy_features::HY_Features::catchments ( )
inline

An iterator of only the catchment feature ids.

Returns
auto

References hy_features::identifiers::catchment.

Referenced by validate_dendritic().

◆ catchments() [2/2]

auto hy_features::HY_Features::catchments ( long lyr)
inline

An iterator of only the catchment feature ids from only the specified layer.

Returns
auto

References hy_features::identifiers::catchment.

◆ destination_nexuses()

std::vector< std::shared_ptr< HY_HydroNexus > > hy_features::HY_Features::destination_nexuses ( const std::string & id)
inline

Get a vector of destination (downstream) nexus pointers.

If id is not a known catchment identifier, then an empty vector is returned.

Parameters
id
Returns
std::vector<std::shared_ptr<HY_HydroNexus>>

References _catchments, and _nexuses.

Referenced by ngen::Layer::update_models().

◆ layers()

const auto & hy_features::HY_Features::layers ( )
inline

Return a set of layers that contain a catchment.

References hf_layers.

◆ nexus_at()

std::shared_ptr< HY_HydroNexus > hy_features::HY_Features::nexus_at ( const std::string & id)
inline

Get the HY_HydroNexus pointer identifed by id.

If no nexus exists for id, a nullptr is returned.

Parameters
id
Returns
std::shared_ptr<HY_HydroNexus>

References _nexuses.

Referenced by ngen::SurfaceLayer::update_models().

◆ nexuses()

auto hy_features::HY_Features::nexuses ( )
inline

An iterator of only the nexus feature ids.

Returns
auto

References hy_features::identifiers::nexus.

Referenced by ngen::SurfaceLayer::update_models().

◆ validate_dendritic()

void hy_features::HY_Features::validate_dendritic ( )
inline

Validates that the feature topology is dendritic.

References catchments().

Member Data Documentation

◆ _catchments

std::unordered_map<std::string, std::shared_ptr<HY_Catchment> > hy_features::HY_Features::_catchments
private

Internal mapping of catchment id -> HY_Catchment pointer.

Referenced by HY_Features(), catchment_at(), and destination_nexuses().

◆ _nexuses

std::unordered_map<std::string, std::shared_ptr<HY_HydroNexus> > hy_features::HY_Features::_nexuses
private

Internal mapping of nexus id -> HY_HydroNexus pointer.

Referenced by HY_Features(), destination_nexuses(), and nexus_at().

◆ formulations

std::shared_ptr<Formulation_Manager> hy_features::HY_Features::formulations
private

Pointer to the formulation manager used to associate catchment formulations with HY_Catchment objects.

Referenced by HY_Features().

◆ hf_layers

std::set<long> hy_features::HY_Features::hf_layers
private

The set of layers that contain at least one catchment.

Referenced by HY_Features(), and layers().

◆ network

network::Network hy_features::HY_Features::network
private

network::Network graph of identities.


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