LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
mbe_state.h
1/*
2 * SPDX-FileCopyrightText: Karlsruhe Institute of Technology (KIT)
3 * SPDX-License-Identifier: LicenseRef-LandscapeDNDC
4 * This file is part of LandscapeDNDC. See LICENSE.
5 */
14
15#ifndef MoBiLE_STATE_H_
16#define MoBiLE_STATE_H_
17
18#include "ld_legacy.h"
19#include "state/mbe_substates.h"
20
21namespace ldndc {
22
23class MoBiLE_Substate;
24class LDNDC_API MoBiLE_State : public cbm::object_t
25{
26 MOBILE_OBJECT(MoBiLE_State)
27 public:
28 MoBiLE_State();
29 ~MoBiLE_State();
30
31 lerr_t initialize( cbm::io_kcomm_t *);
32
33 public:
34 double get_fh2o( ldndc::MoBiLE_Plant const * /* plant species */,
35 double /* water pressure at wilting point */,
36 double = 1.0 /* area fraction */,
37 bool = false /* use van genuchten */,
38 bool = true /* root weighted */,
39 bool = false /*root mass or length distribution */) const;
40
41 double get_fh2o_sl( substate_watercycle_t const * /* watercycle state */,
42 size_t /* soil layer */,
43 double const & /* water content at wilting point */,
44 double = 1.0 /* area fraction */) const;
45
46 public:
47 MoBiLE_PlantVegetation vegetation;
48
49 public:
54 template < class _S >
55 _S * get_substate()
56 { return static_cast< _S * >( substates_[_S::substate_type]); }
61 template < class _S >
62 _S & get_substate_ref()
63 { return *get_substate< _S >(); }
64
69 template < class _S >
70 _S const * get_substate() const
71 { return const_cast< MoBiLE_State * >( this)->get_substate< _S >(); }
76 template < class _S >
77 _S const & get_substate_ref() const
78 { return *const_cast< MoBiLE_State * >( this)->get_substate< _S >(); }
79
80 MoBiLE_Substate * get_substate( substate_type_e);
81 MoBiLE_Substate const * get_substate( substate_type_e) const;
82 /* get substate by name */
83 MoBiLE_Substate * get_substate( char const * /*substate name*/);
84 MoBiLE_Substate const * get_substate( char const * /*substate name*/) const;
85
91 size_t full_substate_cnt() const;
96 size_t substate_cnt() const;
102 size_t full_substate_member_cnt() const;
108 size_t substate_member_cnt() const;
114 size_t alloc_size() const;
115
120 lerr_t resize_entities( cbm::io_kcomm_t *);
121
122#ifdef _HAVE_SERIALIZE
123 public:
124 int create_checkpoint( cbm::io_kcomm_t *);
125 int restore_checkpoint( cbm::io_kcomm_t *, ldate_t const *);
126 private:
127 int substate_checkpoint_write_context_init(
128 cbm::io_kcomm_t *, substate_checkpoint_write_context_t *);
129 int substate_checkpoint_write_context_deinit(
130 cbm::io_kcomm_t *, substate_checkpoint_write_context_t *);
131
132 int substate_checkpoint_read_context_init(
133 cbm::io_kcomm_t *, ldate_t const *,
134 substate_checkpoint_read_context_t *);
135 int substate_checkpoint_read_context_deinit(
136 cbm::io_kcomm_t *, substate_checkpoint_read_context_t *);
137#endif
138#ifdef _LDNDC_HAVE_ONLINECONTROL
139 public:
140 virtual int process_request(
141 lreply_t * /*reply*/, lrequest_t const * /*request*/);
142 private:
143 int substate_request_putget(
144 lreply_t * /*reply*/, lrequest_t const * /*request*/);
145#endif
146
147 public:
148 cbm::string_t wr_type;
149 cbm::string_t pt_type;
150
151private:
152 /* convenience array: holds pointers to substate objects */
153 MoBiLE_Substate * substates_[SUBSTATE_CNT];
154
155 /* hide copy construction and assignment operator */
156 MoBiLE_State( MoBiLE_State const &);
157 MoBiLE_State & operator=( MoBiLE_State const &);
158};
159
160}
161
162#endif /* !MoBiLE_STATE_H_ */
163
Spatially explicit groundwater model.
Definition airchemistryput.h:21