LandscapeDNDC 1.37.0
cmfcolumn-solutes.h
1
10#ifndef WATERCYCLE_CMFCOLUMN_SOLUTES_H_
11#define WATERCYCLE_CMFCOLUMN_SOLUTES_H_
12
13#include "watercycle/cmfcolumn/cmfcolumn-config.h"
14
15#include <input/groundwater/groundwater.h>
16#include <comm/cbm_msg.h>
17
18namespace cmf { namespace water {
19 struct solute;
20}}
21
22namespace ldndc {
23
24class WaterCycleCMFColumn;
25struct CMFColumnSolute
26 {
27 cmf::water::solute const * cmf_solute;
28 double retention;
29 double * leach;
30 double * throughfall;
31
32 double * soil;
33 size_t n_soil;
34
35 double * bulk;
36 size_t n_bulk;
37
38 double const * rain;
39 };
40
41struct LDNDC_API CMFColumnSolutesTransportBase
42{
43 virtual ~CMFColumnSolutesTransportBase() {}
44 virtual char model() const = 0;
45 virtual int link( WaterCycleCMFColumn *) = 0;
46 virtual int publish_solute_buffers(
47 char const * /*solute name*/, cbm::reply_t *) { return 0; }
48 virtual int publish_fluxscale_buffer( cbm::reply_t *) { return 0; }
49 virtual bool need_integratables() const { return false; }
50 virtual void biogeochem_to_hydro(
51 int /*stage*/, cbm::reply_t *) = 0;
52 virtual void hydro_to_biogeochem(
53 int /*stage*/, cbm::reply_t *) = 0;
54
55 virtual void set_groundwaternitrate(
56 groundwater::input_class_groundwater_t const *)
57 { /*no op*/ }
58
59// sk:rm WaterCycleCMFColumn * obj;
60
61 CMFConfig * cfg;
62 CMFObjects * co;
63 CMFFluxes * fluxes;
64
65 double R; /*day fraction*/
66};
67
68struct LDNDC_API CMFColumnSolutesTransportNone
69 : public CMFColumnSolutesTransportBase
70{
71 virtual ~CMFColumnSolutesTransportNone() {}
72 char model() const { return 'N'; }
73
74 int link( WaterCycleCMFColumn *) { return 0; }
75 void biogeochem_to_hydro(
76 int /*stage*/, cbm::reply_t * _reply) { _reply->resend = 0; }
77 void hydro_to_biogeochem(
78 int /*stage*/, cbm::reply_t * _reply) { _reply->resend = 0; }
79};
80
81struct LDNDC_API CMFColumnSolutesTransportCoupled
82 : public CMFColumnSolutesTransportBase
83{
84 virtual ~CMFColumnSolutesTransportCoupled() {}
85 char model() const { return 'C'; }
86
87 int link( WaterCycleCMFColumn *);
88 void biogeochem_to_hydro( int /*stage*/, cbm::reply_t *);
89 void hydro_to_biogeochem( int /*stage*/, cbm::reply_t *);
90
91 std::vector< CMFColumnSolute > solutes;
92
93 void update_biogeochem();
94 void update_hydro();
95
96 void set_groundwaternitrate(
97 groundwater::input_class_groundwater_t const *);
98};
99struct LDNDC_API CMFColumnSolutesTransportWaterflux
100 : public CMFColumnSolutesTransportBase
101{
102 virtual ~CMFColumnSolutesTransportWaterflux() {}
103 char model() const { return 'W'; }
104 struct neighbor_t
105 {
106#ifdef LDNDC_MPI
107 std::shared_ptr< cmf::upslope::Cell > cell;
108#else
109 cmf::upslope::Cell const * cell;
110#endif
111 std::vector< double const * > solutes;
112 double const * flux_scale;
113 };
114
115 std::vector< neighbor_t > neighbors;
116 struct solute_t
117 {
118 std::string name;
119
120 double retention;
121 double * leach;
122
123 double * s0, * s1;
124 size_t n_sx;
125#ifdef CMFCOLUMN_HAVE_SURFACETRANSPORT
126 double * b0, * b1;
127 size_t n_bx;
128#endif
129 };
130 std::vector< solute_t > solutes;
131
132 double * flux_scale;
133
134 int link( WaterCycleCMFColumn *);
135 int publish_solute_buffers(
136 char const * /*solute name*/, cbm::reply_t *);
137 int publish_fluxscale_buffer( cbm::reply_t *);
138 bool need_integratables() const { return true; }
139 void biogeochem_to_hydro( int /*stage*/, cbm::reply_t *);
140 void hydro_to_biogeochem( int /*stage*/, cbm::reply_t *);
141
142 void storewatervolumes();
143 void fluxcorrection();
144 void displace();
145 void update_biogeochem();
146};
147} /* namespace ldndc */
148
149#endif /* !WATERCYCLE_CMFCOLUMN_SOLUTES_H_ */
150
Spatially explicit groundwater model.
Definition: airchemistryput.h:15