Plugins
Loading...
Searching...
No Matches
river_observer.h
Go to the documentation of this file.
1
6#ifndef D3F_UG4_RIVER_OBSERVER_H
7#define D3F_UG4_RIVER_OBSERVER_H
8
10#include "common/common.h"
11#include "add_river_sss.h"
14
15namespace ug {
16namespace d3f {
17
28template <typename TDomain, typename TAlgebra>
30 public ITimeIntegratorObserver<TDomain, TAlgebra>,
31 public ITimeIntegratorStageObserver_finalize<TDomain, TAlgebra>
32{
33public:
39 static const int dim = TDomain::dim;
40
48 m_sp_submodule->init(filename);
49
51 m_sp_submodule->get_grid_function(),
52 u
53 ));
54 }
55
56 virtual ~RiverObserver() = default;
57
61 void set_density(SmartPtr<CplUserData<number, dim>> density) { m_sp_sss_mngr->set_density(density); }
63 void set_bottom_permeability(number perm) { m_sp_sss_mngr->set_bottom_permeability(perm); }
64 void set_bottom_thickness(number thickness) { m_sp_sss_mngr->set_bottom_thickness(thickness); }
65 void set_river_width(number width) { m_sp_sss_mngr->set_river_width(width); }
66
71 m_sp_sss_mngr->push_sss_manager(ssmngr);
72 }
73
77 void init() {
78 m_sp_sss_mngr->init_line_sss();
79 m_sp_submodule->run(0.0, 1e6, 0.1);
80 }
81
85 bool step_process(SmartPtr<grid_function_type> u, int step, number time, number dt) override {
86 return solve_submodule(u, time, dt, "STEP PROCESS");
87 }
88
92 bool finalize_action(SmartPtr<grid_function_type> u, int step, number time, number dt) override {
93 return solve_submodule(u, time, dt, "FINALIZE STEP");
94 }
95
100 return m_sp_submodule->get_grid_function();
101 }
102
103private:
107 bool solve_submodule(SmartPtr<grid_function_type> u, number time, number dt, const char* context) {
108 // 1. Evaluate current exchange flux based on subsurface state (u)
109 m_sp_sss_mngr->evaluate_exchange_flux(u);
110
111 UG_LOG("RIVEROBSERVER: " << context << " | time: " << time << " | dt: " << dt << "\n");
112
113 // 2. Pass flux to 1D river submodule and run it
114 m_sp_submodule->set_exfiltration_flux(m_sp_sss_mngr->get_qex());
115 m_sp_submodule->run(time - dt, time, 1.0);
116
117 // 3. Update the singular sources for the next subsurface step
118 m_sp_sss_mngr->update_line_sss(dt);
119
120 return true;
121 }
122
125};
126
127} // namespace d3f
128} // namespace ug
129
130#endif // D3F_UG4_RIVER_OBSERVER_H
Management of 1D-3D coupling via line singular sources and sinks (SSS).
Handles river networks as a post-process of a flow problem.
Definition river_observer.h:32
void set_bottom_permeability(number perm)
Definition river_observer.h:63
TSubModule m_sp_submodule
Definition river_observer.h:123
bool solve_submodule(SmartPtr< grid_function_type > u, number time, number dt, const char *context)
Unified logic for updating exchange fluxes and running the 1D solver.
Definition river_observer.h:107
TRiverSSSMngr m_sp_sss_mngr
Definition river_observer.h:124
bool finalize_action(SmartPtr< grid_function_type > u, int step, number time, number dt) override
Called at the end of each stage (if applicable).
Definition river_observer.h:92
RiverObserver(const char *filename, SmartPtr< grid_function_type > u)
Constructor.
Definition river_observer.h:46
RiverSingularSourcesAndSinks< TDomain::dim > TSSSManager
Definition river_observer.h:38
GridFunction< TDomain, TAlgebra > grid_function_type
Definition river_observer.h:35
SmartPtr< RiverSSSManager< TDomain, TAlgebra > > TRiverSSSMngr
Definition river_observer.h:37
void init()
Initializes the SSS managers and performs an initial submodule run.
Definition river_observer.h:77
SmartPtr< StVenantSubmodule< grid_function_type > > TSubModule
Definition river_observer.h:36
virtual ~RiverObserver()=default
void set_density(SmartPtr< CplUserData< number, dim > > density)
Setters for coupling and physical parameters.
Definition river_observer.h:61
void set_river_width(number width)
Definition river_observer.h:65
static const int dim
Definition river_observer.h:39
void set_bottom_thickness(number thickness)
Definition river_observer.h:64
void set_rainfall_rate(number qr)
Definition river_observer.h:62
ITimeIntegratorObserver< TDomain, TAlgebra > TBase
Definition river_observer.h:34
bool step_process(SmartPtr< grid_function_type > u, int step, number time, number dt) override
Called after each successful time step.
Definition river_observer.h:85
void push_sss_manager(SmartPtr< TSSSManager > ssmngr)
Attaches a singular source/sink manager to the observer.
Definition river_observer.h:70
SmartPtr< grid_function_type > get_river_u()
Returns the 1D river grid function.
Definition river_observer.h:99
Orchestrates the mass exchange between a 1D river and a 3D subsurface.
Definition add_river_sss.h:106
Specialization of the optimized SSS manager for river networks.
Definition river_sss.h:357
Handles the setup, assembly, and time-integration of the 1D Shallow Water Equations.
Definition st_venant_submodule.h:60
#define UG_LOG(msg)
double number
SmartPtr< T, FreePolicy > make_sp(T *inst)
Submodule for solving the 1D St. Venant (Shallow Water) equations.