LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
ldndc::event::event_trigger_t Struct Reference

Threshold conditions that gate a time-windowed event (time="t1 -> t2" XML attribute). More...

#include </var/lib/jenkins/workspace/landscapedndc-builds/crabmeat-src/scientific/event/events/eventbase.h>

Public Member Functions

 event_trigger_t ()
 Thresholds triggering windowed events: no condition given.
 
int forest_threshold_count () const
 Number of given forest thresholds (thin, harvest, regrow)
 
bool have_trigger () const
 True if any threshold condition is given.
 
lerr_t check (char const *) const
 Checks consistency of given thresholds, logs all problems.
 
void drop ()
 Removes all thresholds and marks them as dropped (invalid input)
 

Public Attributes

std::string species
 
double dvs_min
 
double dvs_max
 
double fraction_field_capacity
 
std::string water_management
 
double agb_cut
 
double basal_area_min
 
bool dropped
 

Detailed Description

Threshold conditions that gate a time-windowed event (time="t1 -> t2" XML attribute).

All given conditions must be satisfied simultaneously for the event to fire at a particular time step. If no conditions are set, no threshold test is performed (see per-event dispatch rules below).

Available XML attributes on the <trigger> child element:

  • species — species checked for DVS/AGB; if omitted, the sum over all present plants is used.
  • fraction_dvs_min [0–1] — minimum development stage (alias: fraction_gdd).
  • fraction_dvs_max [0–1] — maximum development stage.
  • fraction_field_capacity [-] — fires only when volumetric soil water in the top 20 cm is at most this fraction of field capacity.
  • watermanagement — "flooded" (surface water > 0.02 m) or "drained" (no surface water).
  • agb_cut [kgC ha⁻¹] — (cut only) fires when aboveground biomass ≥ value; same unit as cut::remains_absolute.
  • Forest thresholds — exactly one per <trigger>; refers to the cohort named by the enclosing event's name attribute:
    • basal_area_min [m² ha⁻¹] (thin only)
    • stand_volume_min [m³ ha⁻¹] (thin, harvest, regrow)
    • top_height_min [m] (thin, harvest, regrow)
    • dbh_min [m] (harvest only) — mean DBH

Invalid or inconsistent thresholds (e.g. more than one forest threshold, or a forest threshold on an unsupported event) are logged and dropped; event_trigger_t::dropped is set to true and the windowed event fires once at the window start.

Per-event dispatch semantics (see also Events):

  • harvest (crop): fires once when DVS ≥ 1, or at window end.
  • harvest (forest, with forest threshold): fires once when threshold met, or at window end.
  • fertilize / manure: fired once — at window start if no threshold, at first step the condition is met, or at window end if never met.
  • irrigate / cut (with threshold): fired every step (at most once per day) the condition is met.
  • irrigate / cut (no threshold): fired every step.
  • thin / regrow: fired once — same logic as fertilize.
Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas

Constructor & Destructor Documentation

◆ event_trigger_t()

ldndc::event::event_trigger_t::event_trigger_t ( )

Thresholds triggering windowed events: no condition given.

Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas
46 : species( ""),
47 dvs_min( invalid_dbl),
48 dvs_max( invalid_dbl),
49 fraction_field_capacity( invalid_dbl),
51 agb_cut( invalid_dbl),
52 basal_area_min( invalid_dbl),
53 stand_volume_min( invalid_dbl),
54 top_height_min( invalid_dbl),
55 dbh_min( invalid_dbl),
56 dropped( false)
57{
58}
double dvs_min
Definition eventbase.h:98
std::string water_management
Definition eventbase.h:104
double basal_area_min
Definition eventbase.h:112
double agb_cut
Definition eventbase.h:106
double fraction_field_capacity
Definition eventbase.h:102
bool dropped
Definition eventbase.h:120
std::string species
Definition eventbase.h:96
double dvs_max
Definition eventbase.h:100

References agb_cut, basal_area_min, dropped, dvs_max, dvs_min, fraction_field_capacity, species, and water_management.

Referenced by drop().

Here is the caller graph for this function:

Member Function Documentation

◆ check()

lerr_t ldndc::event::event_trigger_t::check ( char const * _event_name) const

Checks consistency of given thresholds, logs all problems.

checks consistency of given conditions (logs all problems)

Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas
105{
106 lerr_t rc = LDNDC_ERR_OK;
107 if ( cbm::is_valid( this->dvs_min)
108 && ( cbm::flt_less( this->dvs_min, 0.0) || cbm::flt_greater( this->dvs_min, 1.0)))
109 {
110 CBM_LogError( _event_name, " event attribute 'fraction_dvs_min' not in [0,1]",
111 " [fraction_dvs_min=",this->dvs_min,"]");
112 rc = LDNDC_ERR_FAIL;
113 }
114 if ( cbm::is_valid( this->dvs_max)
115 && ( cbm::flt_less( this->dvs_max, 0.0) || cbm::flt_greater( this->dvs_max, 1.0)))
116 {
117 CBM_LogError( _event_name, " event attribute 'fraction_dvs_max' not in [0,1]",
118 " [fraction_dvs_max=",this->dvs_max,"]");
119 rc = LDNDC_ERR_FAIL;
120 }
121 if ( cbm::is_valid( this->dvs_min) && cbm::is_valid( this->dvs_max)
122 && cbm::flt_greater( this->dvs_min, this->dvs_max))
123 {
124 CBM_LogError( _event_name, " event attribute 'fraction_dvs_min' greater 'fraction_dvs_max'");
125 rc = LDNDC_ERR_FAIL;
126 }
127 if ( cbm::is_valid( this->fraction_field_capacity)
128 && !cbm::flt_greater_zero( this->fraction_field_capacity))
129 {
130 CBM_LogError( _event_name, " event attribute 'fraction_field_capacity' not greater 0",
131 " [fraction_field_capacity=",this->fraction_field_capacity,"]");
132 rc = LDNDC_ERR_FAIL;
133 }
134 double const forest_thresholds[] =
135 { this->basal_area_min, this->stand_volume_min, this->top_height_min, this->dbh_min };
136 char const * forest_threshold_names[] =
137 { "basal_area_min", "stand_volume_min", "top_height_min", "dbh_min" };
138 for ( size_t k = 0; k < 4; ++k)
139 {
140 if ( cbm::is_valid( forest_thresholds[k]) && !cbm::flt_greater_zero( forest_thresholds[k]))
141 {
142 CBM_LogError( _event_name, " event attribute '", forest_threshold_names[k], "' not greater 0",
143 " [", forest_threshold_names[k], "=", forest_thresholds[k], "]");
144 rc = LDNDC_ERR_FAIL;
145 }
146 }
147 if ( this->forest_threshold_count() > 1)
148 {
149 CBM_LogError( _event_name, " event: only one of 'basal_area_min', 'stand_volume_min',"
150 " 'top_height_min', 'dbh_min' may be given");
151 rc = LDNDC_ERR_FAIL;
152 }
153 if ( cbm::is_valid( this->agb_cut)
154 && !cbm::flt_greater_zero( this->agb_cut))
155 {
156 CBM_LogError( _event_name, " event attribute 'agb_cut' not greater 0",
157 " [agb_cut=",this->agb_cut,"]");
158 rc = LDNDC_ERR_FAIL;
159 }
160 if ( !this->water_management.empty()
161 && !cbm::is_equal( this->water_management.c_str(), "flooded")
162 && !cbm::is_equal( this->water_management.c_str(), "drained"))
163 {
164 CBM_LogError( _event_name, " event attribute 'watermanagement' unknown",
165 " [watermanagement=",this->water_management,",supported=flooded,drained,none]");
166 rc = LDNDC_ERR_FAIL;
167 }
168 return rc;
169}
int forest_threshold_count() const
Number of given forest thresholds (thin, harvest, regrow)
Definition eventbase.cpp:86

References agb_cut, basal_area_min, dvs_max, dvs_min, forest_threshold_count(), fraction_field_capacity, and water_management.

Here is the call graph for this function:

◆ drop()

void ldndc::event::event_trigger_t::drop ( )

Removes all thresholds and marks them as dropped (invalid input)

removes all conditions and marks thresholds as dropped

Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas
180{
181 *this = event_trigger_t();
182 this->dropped = true;
183}
event_trigger_t()
Thresholds triggering windowed events: no condition given.
Definition eventbase.cpp:45

References dropped, and event_trigger_t().

Here is the call graph for this function:

◆ forest_threshold_count()

int ldndc::event::event_trigger_t::forest_threshold_count ( ) const

Number of given forest thresholds (thin, harvest, regrow)

number of valid forest threshold fields set (0 or 1)

Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas
88{
89 return ( cbm::is_valid( this->basal_area_min) ? 1 : 0)
90 + ( cbm::is_valid( this->stand_volume_min) ? 1 : 0)
91 + ( cbm::is_valid( this->top_height_min) ? 1 : 0)
92 + ( cbm::is_valid( this->dbh_min) ? 1 : 0);
93}

References basal_area_min.

Referenced by check(), and have_trigger().

Here is the caller graph for this function:

◆ have_trigger()

bool ldndc::event::event_trigger_t::have_trigger ( ) const

True if any threshold condition is given.

Note
2026-09-28 Event time windowing functionality finally ported into the trunk, Edwin Haas
70{
71 return cbm::is_valid( this->dvs_min) || cbm::is_valid( this->dvs_max)
72 || cbm::is_valid( this->fraction_field_capacity)
73 || !this->water_management.empty()
74 || cbm::is_valid( this->agb_cut)
75 || ( this->forest_threshold_count() > 0);
76}

References agb_cut, dvs_max, dvs_min, forest_threshold_count(), fraction_field_capacity, and water_management.

Here is the call graph for this function:

Member Data Documentation

◆ agb_cut

double ldndc::event::event_trigger_t::agb_cut

XML attr agb_cut (cut only) — fire when AGB ≥ value [kgC ha⁻¹]

Referenced by check(), event_trigger_t(), and have_trigger().

◆ basal_area_min

double ldndc::event::event_trigger_t::basal_area_min

forest thresholds (exactly one allowed per trigger): basal_area_min [m² ha⁻¹] (thin), stand_volume_min [m³ ha⁻¹] (thin/harvest/regrow), top_height_min [m] (thin/harvest/regrow), dbh_min [m] (harvest)

Referenced by check(), event_trigger_t(), and forest_threshold_count().

◆ dropped

bool ldndc::event::event_trigger_t::dropped

true if thresholds were given but are invalid/inconsistent and were dropped; the event fires once at the window start

Referenced by drop(), and event_trigger_t().

◆ dvs_max

double ldndc::event::event_trigger_t::dvs_max

XML attr fraction_dvs_max — maximum DVS [0–1]

Referenced by check(), event_trigger_t(), and have_trigger().

◆ dvs_min

double ldndc::event::event_trigger_t::dvs_min

XML attr fraction_dvs_min (alias fraction_gdd) — minimum DVS [0–1]

Referenced by check(), event_trigger_t(), and have_trigger().

◆ fraction_field_capacity

double ldndc::event::event_trigger_t::fraction_field_capacity

XML attr fraction_field_capacity — soil water (0–20 cm) ≤ fraction of FC [-]

Referenced by check(), event_trigger_t(), and have_trigger().

◆ species

std::string ldndc::event::event_trigger_t::species

XML attr species — species checked for DVS/AGB; empty = sum of all plants

Referenced by event_trigger_t().

◆ water_management

std::string ldndc::event::event_trigger_t::water_management

XML attr watermanagement — "flooded" (surface water > 0.02 m) or "drained"

Referenced by check(), event_trigger_t(), and have_trigger().