LandscapeDNDC 1.37.0
mbe_state.h
1
10#ifndef MoBiLE_STATE_H_
11#define MoBiLE_STATE_H_
12
13#include "ld_legacy.h"
14#include "state/mbe_substates.h"
15
16namespace ldndc {
17
18class MoBiLE_Substate;
19class LDNDC_API MoBiLE_State : public cbm::object_t
20{
21 MOBILE_OBJECT(MoBiLE_State)
22 public:
23 MoBiLE_State();
24 ~MoBiLE_State();
25
26 lerr_t initialize( cbm::io_kcomm_t *);
27
28 public:
29 double get_fh2o( ldndc::MoBiLE_Plant const * /* plant species */,
30 double /* water pressure at wilting point */,
31 double = 1.0 /* area fraction */,
32 bool = false /* use van genuchten */,
33 bool = true /* root weighted */,
34 bool = false /*root mass or length distribution */) const;
35
36 double get_fh2o_sl( substate_watercycle_t const * /* watercycle state */,
37 size_t /* soil layer */,
38 double const & /* water content at wilting point */,
39 double = 1.0 /* area fraction */) const;
40
41 public:
42 MoBiLE_PlantVegetation vegetation;
43
44 public:
49 template < class _S >
50 _S * get_substate()
51 { return static_cast< _S * >( substates_[_S::substate_type]); }
56 template < class _S >
57 _S & get_substate_ref()
58 { return *get_substate< _S >(); }
59
64 template < class _S >
65 _S const * get_substate() const
66 { return const_cast< MoBiLE_State * >( this)->get_substate< _S >(); }
71 template < class _S >
72 _S const & get_substate_ref() const
73 { return *const_cast< MoBiLE_State * >( this)->get_substate< _S >(); }
74
75 MoBiLE_Substate * get_substate( substate_type_e);
76 MoBiLE_Substate const * get_substate( substate_type_e) const;
77 /* get substate by name */
78 MoBiLE_Substate * get_substate( char const * /*substate name*/);
79 MoBiLE_Substate const * get_substate( char const * /*substate name*/) const;
80
86 size_t full_substate_cnt() const;
91 size_t substate_cnt() const;
97 size_t full_substate_member_cnt() const;
103 size_t substate_member_cnt() const;
109 size_t alloc_size() const;
110
115 lerr_t resize_entities( cbm::io_kcomm_t *);
116
117#ifdef _HAVE_SERIALIZE
118 public:
119 int create_checkpoint( cbm::io_kcomm_t *);
120 int restore_checkpoint( cbm::io_kcomm_t *, ldate_t const *);
121 private:
122 int substate_checkpoint_write_context_init(
123 cbm::io_kcomm_t *, substate_checkpoint_write_context_t *);
124 int substate_checkpoint_write_context_deinit(
125 cbm::io_kcomm_t *, substate_checkpoint_write_context_t *);
126
127 int substate_checkpoint_read_context_init(
128 cbm::io_kcomm_t *, ldate_t const *,
129 substate_checkpoint_read_context_t *);
130 int substate_checkpoint_read_context_deinit(
131 cbm::io_kcomm_t *, substate_checkpoint_read_context_t *);
132#endif
133#ifdef _LDNDC_HAVE_ONLINECONTROL
134 public:
135 virtual int process_request(
136 lreply_t * /*reply*/, lrequest_t const * /*request*/);
137 private:
138 int substate_request_putget(
139 lreply_t * /*reply*/, lrequest_t const * /*request*/);
140#endif
141
142 public:
143
144 cbm::string_t wr_type;
145
146private:
147 /* convenience array: holds pointers to substate objects */
148 MoBiLE_Substate * substates_[SUBSTATE_CNT];
149
150 /* hide copy construction and assignment operator */
151 MoBiLE_State( MoBiLE_State const &);
152 MoBiLE_State & operator=( MoBiLE_State const &);
153};
154
155}
156
157#endif /* !MoBiLE_STATE_H_ */
158
Spatially explicit groundwater model.
Definition: airchemistryput.h:15