9#ifndef INTEGRATABLES_H_
10#define INTEGRATABLES_H_
12#define CMFCOLUMN_DBKEY_MAXLEN 64
14#include "mbe_legacymodel.h"
17#ifdef CMFCOLUMN_HAVE_INTEGRATABLES
38 class flux_connection;
44struct cmfcolumn_dbkeygen_t
46 static char const * solute_key(
47 char * ,
char const * ,
53 ITG_rainthroughfall = 0,
54 ITG_canopythroughfall,
57 ITG_canopyevaporation,
58 ITG_surfacewaterevaporation,
63 ITG_groundwaterdischarge,
76extern char const *
const itg_names[ITG_count];
78#define noID CMFIntegratables::IPos::NOID
79struct CMFIntegratables
83 static const int NOID = -1;
84 IPos(
int _id = NOID,
size_t _layer = 0)
85 : id( _id), layer( _layer) { }
90 bool operator<( IPos
const & _rhs)
91 {
return this->
id < _rhs.id; };
92 bool operator<( IPos
const & _rhs)
const
93 {
return this->
id < _rhs.id; };
96 double query( integratable_e _fx, IPos
const & _i)
const
97 {
return this->m_query( _fx, _i); }
98 int initialize( CMFConfig
const & _cfg,
99 CMFObjects & _cmf_objects)
100 {
return this->m_initialize( _cfg, _cmf_objects); }
103 struct CMFIntegratableInfo
105 CMFIntegratableInfo() : I( NULL), n_queries( 0) { }
106 cmf::math::integratable * I;
107 mutable int n_queries;
109#ifdef CMFCOLUMN_HAVE_INTEGRATABLES
110 double m_query( integratable_e, IPos
const &)
const;
111 int m_initialize( CMFConfig
const &, CMFObjects &);
113 typedef std::vector< CMFIntegratableInfo > CMFVerticalIntegratables;
114 typedef std::map< IPos, CMFVerticalIntegratables > CMFHorizontalIntegratables;
115 CMFHorizontalIntegratables m_integratables[ITG_count];
117 typedef std::shared_ptr< cmf::water::flux_connection > CMFFluxConnection;
118 lerr_t add_cmf_integratable( cmf::math::Integrator * _solver,
119 integratable_e, IPos, CMFFluxConnection);
120 typedef std::shared_ptr< cmf::water::flux_node > CMFFluxNode;
121 lerr_t add_cmf_integratable( cmf::math::Integrator * _solver,
122 integratable_e, IPos, CMFFluxNode);
123 lerr_t add_cmf_integratable( cmf::math::Integrator * _solver,
124 integratable_e, IPos, CMFFluxNode, CMFFluxNode);
125 typedef std::shared_ptr< cmf::math::integratable > CMFIntegratable;
126 lerr_t add_cmf_integratable( cmf::math::Integrator * _solver,
127 integratable_e, IPos, CMFIntegratable);
129 double m_query( integratable_e, IPos
const &)
const
131 int m_initialize( CMFConfig
const &, CMFObjects &)
138 CMFIntegratables m_itg;
140 CMFFluxes( cbm::io_kcomm_t * _io_kcomm = NULL)
141 : io_kcomm( _io_kcomm)
144 cbm::io_kcomm_t * io_kcomm;
147 typedef char keybuffer_t[CMFCOLUMN_DBKEY_MAXLEN];
149 void db_set(
double ,
150 char const * ,
char const * = NULL );
151 void db_add(
double ,
152 char const * ,
char const * = NULL );
153 double db_get(
char const * ,
char const * = NULL );
154 double db_getdel(
char const * ,
char const * = NULL );
157 double query( integratable_e _fx)
const
159 CMFIntegratables::IPos
const i;
160 return this->m_itg.query( _fx, i);
162 double query( integratable_e _fx,
int _id )
const
164 CMFIntegratables::IPos
const i( _id);
165 return this->m_itg.query( _fx, i);
167 double query( integratable_e _fx,
168 int _id ,
size_t _layer )
const
170 CMFIntegratables::IPos
const i( _id, _layer);
171 return this->m_itg.query( _fx, i);
174 int initialize( CMFConfig
const & _conf,
175 CMFObjects & _cmf_objects)
177 return this->m_itg.initialize(
178 _conf, _cmf_objects);
182 std::map< uintptr_t, double > watervolumes;
184 void set_watervolume(
double,
void * );
185 double get_watervolume(
void * );
186 void get_watervolumes(
double * ,
size_t );
187 size_t watervolumes_count()
const
188 {
return this->watervolumes.size(); }