LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
synth-climate.h
1
8
9#ifndef LDNDC_DATASYNTH_CLIMATE_H_
10#define LDNDC_DATASYNTH_CLIMATE_H_
11
12#include "synthesizers/synth-base-streamdata.h"
13#include "climate/climatetypes.h"
14#include "time/cbm_date.h"
15
16#include "math/cbm_math.h"
17
18#define SYNTH_CLIMATE_REC_SIZE SYNTH_REC_SIZE_(climate)
19
20#define SYNTH_CLIMATE_INVALIDATE_BUFFER(__buf__) SYNTH_INVALIDATE_BUFFER_(climate,__buf__)
21
22#define SYNTH_CLIMATE_CHK_MATCHING(__item__) SYNTH_CHK_MATCHING_(climate,__item__)
23
24#define SYNTH_CLIMATE_RETURN_SUCCESS(__item__) SYNTH_RETURN_SUCCESS_(climate,__item__)
25
26#define SYNTH_CLIMATE_RECORD_ITEM_COMMON_DECL(__class__,__item_enum__) SYNTH_RECORD_ITEM_COMMON_DECL_(climate,__class__,__item_enum__)
27
28
29/* ??? */
30#define TSMIN (24.0)
31/* maximum overshoot pool */
32#define PRECIP_OVERSHOOT_MAX (70.0)
33/* stretching factor */
34#define PRECIP_STRETCHING_FACTOR (150.0)
35/* reduction rate for overshoot decrease calculation */
36#define PRECIP_OVERSHOOT_REDUCTION_RATE (0.3)
37/* probability of precipitation streching */
38#define PRECIP_STRETCHING_PROBABILITY (0.9)
39
40
41template < typename, unsigned int >
42class lvector_t;
43
44namespace ldndc{ namespace climate{ namespace synth
45{
46 typedef record::item_type record_item_t;
47 struct CBM_API scratch_t : public ldndc::synth::streamdata_scratch_base_t< streamdata_info_t >
48 {
49 /* shifted according to latitude */
50 unsigned int julian_day;
51
52 cbm::random::rng_uniform_t precip_rng;
53
54 record_item_t precip_generated;
55 record_item_t precip_overshoot;
56
57 record_item_t precip_d;
58 record_item_t precip_exp;
59 record_item_t precip_value_fact;
60
61 double fp_base(
62 double /* latitude */) const;
63
64 double precip_value_fact_fun(
65 double /* precipitation sum */,
66 unsigned int /* days in year */) const;
67
68 lerr_t initialize(
69 climate_info_t const * /* climate meta info */,
70 ltime_t const * /* input date */,
71 ltime_t const * /* output date */);
72
73 lerr_t configure(
74 climate_info_t const * /* climate meta info */,
75 ldate_t const * /* current date */,
76 unsigned int /* current target subday */);
77 };
78
79
80 struct CBM_API item_base_t : public ldndc::synth::streamdata_item_base_t< streamdata_info_t, scratch_t >
81 {
82 };
83
84
85 class CBM_API lsynth_climate_t : public ldndc::synth::streamdata_synth_base_t< streamdata_info_t >
86 {
87 public:
88 lsynth_climate_t();
89 lsynth_climate_t(
90 climate_info_t const * /* climate meta info */,
91 ltime_t const * /* input date */,
92 ltime_t const * /* output date */);
93
94
95 virtual ~lsynth_climate_t();
96
101 lerr_t configure(
102 ldate_t const * /* target date */,
103 unsigned int = ldndc::invalid_t< unsigned int >::value /* target subday */);
104
109 lerr_t synthesize_record(
110 record_item_t const * /* subday data buffer (input) */, record_item_t * /* subday data buffer (output) */,
111 record_item_t const * /* day data buffer (input) */, record_item_t * /* day data buffer (output) */,
112
113 ldate_t const * /* current date */,
114
115 lvector_t< unsigned int, 1 > * = NULL /* modification count */);
116
124 lerr_t check_record(
125 record_item_t const * /* subday data buffer (input) */,
126 record_item_t const * /* day data buffer (input) */) const;
127
128 inline
129 unsigned int subday()
130 const
131 {
132 return this->scratch_.subday;
133 }
134
135 inline
136 unsigned int time_resolution_inout()
137 const
138 {
139 return this->scratch_.t_res_inout;
140 }
141
142 private:
143 climate_info_t info_;
144 scratch_t scratch_;
145
146 /* default synthesizer execution order */
147 static record::record_item_e const SYNTH_ORDER[record::RECORD_SIZE];
148 /* (reordered) synthesizer execution order array for day timestep */
149 record::record_item_e synth_order_[record::RECORD_SIZE];
150 };
151 extern item_base_t const * climate_synthesizers[record::RECORD_SIZE];
152}}}
153
154
155#endif /* !LDNDC_DATASYNTH_CLIMATE_H_ */
156
Spatially explicit groundwater model.
Definition airchemistryput.h:15