Class module_base

Inheritance Relationships

Derived Types

Class Documentation

class module_base

Base class for individual modules.

A module must inherent from this class. This provides the interface for all module.

Subclassed by Burridge_iswr, Cullen_monthly_llra_ta, Dist_tlapse, Dodson_NSA_ta, FSM, Gray_inf, Harder_precip_phase, Iqbal_iswr, Kunkel_monthlyTd_rh, Lehning_snowpack, Liston_monthly_llra_ta, Liston_wind, Longwave_from_obs, MS_wind, Marsh_shading_iswr, PBSM3D, PenmanMonteith_evaporation, Richard_albedo, Sicart_ilwr, Simple_Canopy, Thornton_p, Walcek_cloud, WindNinja, Winstral_parameters, const_llra_ta, crop_rotation, deform_mesh, fast_shadow, fetchr, iswr, iswr_from_nwp, iswr_from_obs, kunkel_rh, lw_no_lapse, module_template, mpi, p_from_obs, p_lapse, p_no_lapse, point_mode, rh_from_obs, rh_no_lapse, scale_wind_vert, slope_iswr, snobal, snow_slide, solar, sub_grid, t_no_lapse, threshold_p_phase, uniform_wind

Public Types

enum class parallel

A module must declare itself as either parallel data, where the module only operates upon a single mesh element, or parallel domain, where the module operates upon the domain in its entirety. The default is data parallel

Values:

enumerator data

Sets that this module is element parallel. That is, this module can compute the solution at this element without needing to communicate with surrounding elements. There is no guarantee on element ordering

enumerator domain

Sets that this module is domain parallel. That is, this module requires surrounding elements to compute its answer and that it is dependent upon the order of traversal of elements.

Public Functions

inline module_base()

Default constructor

inline module_base(std::string name = "", parallel type = parallel::data, config_file input_cfg = pt::basic_ptree<std::string, std::string>())

Consturctor that initializes everything

inline virtual ~module_base()

Default destructor

inline virtual void checkpoint(mesh &domain, netcdf &chkpt)

Checkpoint (save state) the current module. By default this errors out if the modules does not support checkpointing.

Parameters:
  • domain

  • data

inline virtual void load_checkpoint(mesh &domain, netcdf &chkpt)
inline virtual void run(mesh_elem &face)

Needs to be implemented by each data parallel module. This will be called and executed for each timestep

Parameters:
  • face – The terrain element (triangle) to be worked upon for an element parallel domain

  • global_param – A pointer to the shared global paramter space with domain-wide paramters

inline virtual void run(mesh &domain)
inline virtual void init(mesh &domain)
inline parallel parallel_type()
inline boost::shared_ptr<std::vector<variable_info>> provides()

List of the variables that this module provides.

inline boost::shared_ptr<std::vector<std::string>> provides_vector()

List of the vetors that this module provides.

inline boost::shared_ptr<std::vector<std::string>> provides_parameter()

List of the parameters that this module provides.

inline void provides_vector(const std::string &name)

  • default behaviour is to make it of type NEIGHBOR Set a vector variable that this module provides. ** Currently not used to resolve dependencies ** This is a list of variables that are stored as x,y,z vectors, such as wind velocities Vector_3 so magnitude needs to be stored in a normal _provides variable

Parameters:

name

inline void provides(const std::string &name)

Set a variable that this module provides

  • default behaviour is to make it of type NEIGHBOR

inline void provides(const std::string &name, SpatialType st)

Set a variable that this module provides

inline void provides(const std::string &name, SpatialType st, double distance)

Set a variable that this module provides

inline void provides_parameter(const std::string &variable)

Set a parameter that this module provides

inline boost::shared_ptr<std::vector<variable_info>> depends()

List of the variables from other modules that this module depends upon

inline void conflicts(const std::string &variable)

Modules we conflict with and absolutely cannot run alongside. Use sparingly.

inline boost::shared_ptr<std::vector<std::string>> conflicts()
inline boost::shared_ptr<std::vector<std::string>> optionals()

List of the optional depends variables from other modules that this module depends upon

inline void depends(const std::string &name)

Set a variable, from another module, that this module depends upon

inline void depends(const std::string &name, SpatialType st)
inline void depends(const std::string &name, SpatialType st, double distance)
inline boost::shared_ptr<std::vector<std::string>> depends_from_met()

List of the variables from the met files that this module depends upon

inline void depends_from_met(const std::string &variable)

Set a variable, from a met file, that this module depends upon

inline void optional(const std::string &variable)

Set an optional (not required) variable, from another module, that this module depends upon.

inline bool has_optional(const std::string &variable)

Checks if an optional variable was found

inline std::vector<std::string> get_variable_names_from_collection(std::vector<variable_info> collection)
inline void set_all_nan_on_skip(mesh_elem &face)

If you want to skip evaluating this current face, call this to set all provides outputs to nan E.g., called if the is_water, is_glacier, etc is true

inline void set_optional_found(const std::string &variable)

Set that an optional variable was found

inline bool is_nan(const double &variable)
inline bool is_water(mesh_elem &face)
inline bool is_glacier(mesh_elem &face)

Public Members

std::string ID

ID of the module

pt::ptree cfg

Configuration file. If module does not need one, then this will contain nothing

int IDnum

Upon instantiation the module is assigned a value based upon its initialization order. Primarily used to dependency resolution. No real usage otherwise.

boost::shared_ptr<global> global_param

Global parameter store

Protected Attributes

parallel _parallel_type
boost::shared_ptr<std::vector<variable_info>> _provides
boost::shared_ptr<std::vector<std::string>> _provides_parameters
boost::shared_ptr<std::vector<variable_info>> _depends
boost::shared_ptr<std::vector<std::string>> _depends_from_met
boost::shared_ptr<std::vector<std::string>> _optional
boost::shared_ptr<std::vector<std::string>> _conflicts
boost::shared_ptr<std::vector<std::string>> _vectors
std::map<std::string, bool> _optional_found