-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd3f_plugin_rivers.cpp
More file actions
284 lines (247 loc) · 14.6 KB
/
Copy pathd3f_plugin_rivers.cpp
File metadata and controls
284 lines (247 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/*
* SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
* SPDX-License-Identifier: EUPL-1.2
* SPDX-FileContributor: Sebastian Reiter
* SPDX-FileContributor: Goethe Universität Frankfurt
* SPDX-FileType: SOURCE
*
* This file is part of d3f++.
* d3f++ is an extension for UG4. Licensing information and citation requirements of UG4 are provided in LICENSES/UG4-LGPL_2.1
*/
#include "bridge/util.h"
#include "bridge/util_domain_dependent.h"
#include "bridge/util_domain_algebra_dependent.h"
#include "d3f_plugin_rivers.h"
#include "d3f_sss.h"
#include "river_networks/river_sss.h"
#include "segment_network.h"
#include "rivers.h"
#include "river_networks/river_tools.h"
#include "river_networks/add_river_sss.h"
#include "river_networks/river_observer.h"
using namespace std;
using namespace ug::bridge;
using namespace ug::d3f;
namespace ug{
namespace d3f{
/**
* Class exporting the functionality of the plugin in 3d. All functionality that is to
* be used in scripts or visualization must be registered here.
*/
struct RiverFunctionality3d
{
/**
* Function called for the registration of Domain and Algebra dependent parts
* of the plugin. All Functions and Classes depending on both Domain and Algebra
* are to be placed here when registering. The method is called for all
* available Domain and Algebra types, based on the current build options.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <typename TDomain, typename TAlgebra>
static void DomainAlgebra(Registry& reg, string grp)
{
string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
typedef GridFunction<TDomain, TAlgebra> TFct;
// VertexRiverRecharge: Implementation of the rivers as a type of the recharge
{
typedef VertexRiverRecharge<TFct> T;
string name = string("VertexRiverRecharge").append(suffix);
reg.add_class_<T>(name, grp)
.template add_constructor<void (*) (SmartPtr<SegmentNetwork>, number, SmartPtr<TFct>)> ("RiverNetwork,SmoothLen,LSF")
.add_method("compute", static_cast<void (T::*) (SmartPtr<TFct>)> (&T::compute), "recharge", "")
.add_method("simple_compute", static_cast<void (T::*) (SmartPtr<TFct>)> (&T::simple_compute), "recharge", "")
.add_method("set_river_width", static_cast<void (T::*) (number)> (&T::set_river_width), "scalar", "Sets the width of all the rivers")
.add_method("set_river_width", static_cast<void (T::*) (number, const char*)> (&T::set_river_width), "scalar", "Sets the width of the rivers in the given subset")
.add_method("set_permeability", static_cast<void (T::*) (number)> (&T::set_permeability), "scalar", "Sets the permeability of the river bottom")
.add_method("set_bottom_thickness", static_cast<void (T::*) (number)> (&T::set_bottom_thickness), "scalar", "Sets the thickness of the river bottom")
.add_method("set_density", static_cast<void (T::*) (number)> (&T::set_density), "scalar", "Sets the density of water")
.add_method("set_viscosity", static_cast<void (T::*) (number)> (&T::set_viscosity), "scalar", "Sets the viscosity of water")
.add_method("set_gravity", static_cast<void (T::*) (number)> (&T::set_gravity), "scalar", "Sets the gravity")
.add_method("restrict_depth", static_cast<void (T::*) (number)> (&T::restrict_depth), "maxDepthDiff", "Sets the maximum depth difference")
.add_method("set_no_inflow", static_cast<void (T::*) (bool)> (&T::set_no_inflow), "OnOff", "Switches of the possible inflow")
.add_method("set_relative_to", static_cast<void (T::*) (const char*, number,int)> (&T::set_relative_to), "Subsets#tolerance#gridLevel", "Sets the subsets of the top")
.add_method("set_relative_to", static_cast<void (T::*) (const char*, number)> (&T::set_relative_to), "Subsets#tolerance", "Sets the subsets of the top")
.add_method("set_relative_to", static_cast<void (T::*) (const char*)> (&T::set_relative_to), "Subsets", "Sets the subsets of the top")
.add_method("check_fs_covering", static_cast<void (T::*) (bool)> (&T::check_fs_covering), "Flag", "If to check whether the rivers are covered by the free surface")
.add_method("use_nodal_fs_height", static_cast<void (T::*) (bool)> (&T::use_nodal_fs_height), "Flag", "Measure depth of the FS at river nodes or river segments")
.add_method("check_top_covering", static_cast<void (T::*) (bool)> (&T::check_top_covering), "Flag", "If to check whether the rivers are covered by the top subset")
.add_method("set_constant_flux", static_cast<void (T::*) (number)> (&T::set_constant_flux), "scalar", "Sets the constant flux per unit length")
.add_method("print_total_recharge", static_cast<void (T::*) (bool)> (&T::print_total_recharge), "Flag", "If to print the total recharge due to the rivers")
.add_method("print_total_recharge", static_cast<void (T::*) (const char*)> (&T::print_total_recharge), "FileName", "If to append to a file the total recharge due to the rivers")
.add_method("file_output_prefix", static_cast<void (T::*) (const char*)> (&T::file_output_prefix), "Prefix", "Prefix to add to every line in the file")
.add_method("reset_river_depth", static_cast<void (T::*) ()> (&T::reset_river_depth), "", "Set the river depth to the fs depth")
.add_method("save_river_depth", static_cast<void (T::*) (const char*)> (&T::save_river_depth), "file name", "Save the river network with depths")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "VertexRiverRecharge", tag);
}
}
static void Independent (Registry& reg, string grp)
{
// Network of the rivers
{
reg.add_class_<SegmentNetwork>("SegmentNetwork", grp)
.add_constructor()
.add_method("load_from_file", &SegmentNetwork::load_from_file)
.add_method("set_gauge_values", &SegmentNetwork::set_gauge_values)
.add_method("save_to_file", &SegmentNetwork::save_to_file)
.set_construct_as_smart_pointer(true);
}
}
}; // end RiverFunctionality3d
/**
* Class exporting the functionality of the plugin in 2d. All functionality that is to
* be used in scripts or visualization must be registered here.
*/
struct RiverFunctionality{
template <int dim>
static void Dimension(Registry& reg, string grp) {
string dimSuffix = GetDimensionSuffix<dim>();
string dimTag = GetDimensionTag<dim>();
{
// point and line sources for rivers
{
typedef RiverSingularSourcesAndSinks<dim> T;
typedef typename T::point_sss_type TPointSSS;
typedef typename T::line_sss_type TLineSSS;
string point_name = string("d3fRiverPointSourcesSink").append(dimSuffix);
reg.add_class_<TPointSSS>(point_name, grp)
.template add_constructor<void (*) (const std::vector<number>&)> ()
.add_method ("set", static_cast<void (TPointSSS::*) (number, number, number, number, number)> (&TPointSSS::set))
.add_method ("set", static_cast<void (TPointSSS::*) (LuaFunctionHandle)> (&TPointSSS::set))
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(point_name, "d3fRiverPointSourcesSink", dimTag);
string line_name = string("d3fRiverLineSourcesSink").append(dimSuffix);
reg.add_class_<TLineSSS>(line_name, grp)
.template add_constructor<void (*) (MathVector<dim>&, MathVector<dim>&)> ()
.add_method ("set", static_cast<void (TLineSSS::*) (number, number, number, number, number)> (&TLineSSS::set))
.add_method ("set", static_cast<void (TLineSSS::*) (LuaFunctionHandle)> (&TLineSSS::set))
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(line_name, "d3fRiverLineSourcesSink", dimTag);
string name = string("d3fRiverSingularSourcesAndSinks").append(dimSuffix);
reg.add_class_<T>(name, grp)
.add_constructor()
.add_method ("add_point", static_cast<void (T::*) (SmartPtr<TPointSSS>)> (&T::add_point))
.add_method ("add_line", static_cast<void (T::*) (SmartPtr<TLineSSS>)> (&T::add_line))
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "d3fRiverSingularSourcesAndSinks", dimTag);
}
}
}
template <typename TDomain, typename TAlgebra>
static void DomainAlgebra(Registry& reg, string grp)
{
string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
typedef GridFunction<TDomain, TAlgebra> TFct;
{ static const int dim = TDomain::dim;
typedef SmartPtr<GridFunction<TDomain, TAlgebra>> TspGridFunction;
typedef SmartPtr<DDSingularSourcesAndSinks<dim>> TspSSSManager;
typedef RiverSSSManager<TDomain,TAlgebra> T;
string name = string("RiverSSSManager").append(suffix);
reg.add_class_<T>(name, grp)
.template add_constructor<void (*)(TspGridFunction, TspGridFunction)>()
.add_method("push_sss_manager", (&T::push_sss_manager), "adds the SSS-Manager for a given element discretization", "VolumeStabilizationData")
.add_method("init_line_sss", (&T::init_line_sss), "creates line sss segments and adds them to SSS-Manager", "VolumeStabilizationData")
.add_method("update_line_sss", (&T::update_line_sss), "updates flux calculation for line sss segments", "VolumeStabilizationData")
.add_method("get_qex", (&T::get_qex), "returns qex", "VolumeStabilizationData")
.add_method("set_bottom_permeability", (&T::set_bottom_permeability))
.add_method("set_bottom_thickness", (&T::set_bottom_thickness))
.add_method("set_river_width", (&T::set_river_width))
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "RiverSSSManager", tag);
}
{
typedef SmartPtr<GridFunction<TDomain, TAlgebra>> TspGridFunction;
typedef SmartPtr<RiverSSSManager<TDomain,TAlgebra>> TSSSMngr;
typedef GridFunction<TDomain, TAlgebra> TGf;
typedef RiverObserver<TDomain, TAlgebra> T;
string name = string("RiverObserver").append(suffix);
reg.add_class_<T,typename T::TBase>(name, grp)
.template add_constructor<void (*)( const char*, SmartPtr<TGf>)>()
.add_method("push_sss_manager", (&T::push_sss_manager), "returns qex", "VolumeStabilizationData")
.add_method("get_river_grid_function", (&T::get_river_u), "returns river grid function", "")
.add_method("init", (&T::init), "", "initializes river sss and evolves to steady state of river subomdule")
.add_method("set_bottom_permeability", (&T::set_bottom_permeability), "", "initializes river sss and evolves to steady state of river subomdule")
.add_method("set_bottom_thickness", (&T::set_bottom_thickness))
.add_method("set_river_width", (&T::set_river_width))
.add_method("set_qr", (&T::set_rainfall_rate), "", "sets rainfall rate")
.add_method("set_density", (&T::set_density), "sets subsurface density", "VolumeStabilizationData")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "RiverObserver", tag);
}
}
};
struct RiverFunctionality2d3d
{
template <typename TDomain>
static void Domain(Registry& reg, string grp) {
string suffix = GetDomainSuffix<TDomain>();
string tag = GetDomainTag<TDomain>();
{
string name = string("ProjectRiversOnTerrain").append(suffix);
reg.add_function("ProjectRiversOnTerrain", static_cast<void (*)(SmartPtr<TDomain>,SmartPtr<TDomain>, const char*)>(&project_rivers_on_terrain<TDomain>), grp,
"", "", "just for experimenting");
}
}
/**
* Function called for the registration of Domain and Algebra dependent parts
* of the plugin. All Functions and Classes depending on both Domain and Algebra
* are to be placed here when registering. The method is called for all
* available Domain and Algebra types, based on the current build options.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <typename TDomain, typename TAlgebra>
static void DomainAlgebra(Registry& reg, string grp)
{
string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
typedef GridFunction<TDomain, TAlgebra> TFct;
// VertexRiverRecharge: Implementation of the rivers as a type of the recharge
{
typedef VertexWellRecharge<TFct> T;
string name = string("VertexWellRecharge").append(suffix);
reg.add_class_<T>(name, grp)
.template add_constructor<void (*) (number, SmartPtr<TFct>)> ("SmoothLen,LSF")
.add_method("add_well", static_cast<void (T::*) (std::vector<number>, number)> (&T::add_well), "position,depth", "")
.add_method("compute", static_cast<void (T::*) (SmartPtr<TFct>)> (&T::compute), "recharge", "")
.add_method("set_width", static_cast<void (T::*) (number)> (&T::set_width), "scalar", "Sets the width of the rivers")
.add_method("set_permeability", static_cast<void (T::*) (number)> (&T::set_permeability), "scalar", "Sets the permeability of the river bottom")
.add_method("set_bottom_thickness", static_cast<void (T::*) (number)> (&T::set_bottom_thickness), "scalar", "Sets the thickness of the river bottom")
.add_method("set_density", static_cast<void (T::*) (number)> (&T::set_density), "scalar", "Sets the density of water")
.add_method("set_viscosity", static_cast<void (T::*) (number)> (&T::set_viscosity), "scalar", "Sets the viscosity of water")
.add_method("set_gravity", static_cast<void (T::*) (number)> (&T::set_gravity), "scalar", "Sets the gravity")
.add_method("restrict_depth", static_cast<void (T::*) (number)> (&T::restrict_depth), "maxDepthDiff", "Sets the maximum depth difference")
.add_method("set_no_inflow", static_cast<void (T::*) (bool)> (&T::set_no_inflow), "OnOff", "Switches of the possible inflow")
.add_method("set_relative_to", static_cast<void (T::*) (const char*, number,int)> (&T::set_relative_to), "Subsets#tolerance#gridLevel", "Sets the subsets of the top")
.add_method("set_relative_to", static_cast<void (T::*) (const char*, number)> (&T::set_relative_to), "Subsets#tolerance", "Sets the subsets of the top")
.add_method("set_relative_to", static_cast<void (T::*) (const char*)> (&T::set_relative_to), "Subsets", "Sets the subsets of the top")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "VertexWellRecharge", tag);
}
}
}; // end RiverFunctionality2d3d
} // end namespace d3f
void
InitUGPlugin_d3f_rivers(Registry* reg, string grp)
{
grp.append("/SpatialDisc/d3f");
typedef d3f::RiverFunctionality3d RiverFunctionality3d;
typedef d3f::RiverFunctionality2d3d RiverFunctionality2d3d;
typedef d3f::RiverFunctionality RiverFunctionality;
try{
RiverFunctionality3d::Independent(*reg,grp);
RegisterDomain3dAlgebraDependent<RiverFunctionality3d>(*reg,grp);
RegisterDomain2d3dAlgebraDependent<RiverFunctionality2d3d>(*reg,grp);
RegisterDomain2d3dDependent<RiverFunctionality2d3d>(*reg,grp);
//RegisterDimension2d3dDependent<RiverFunctionality2d3d>(*reg,grp);
RegisterDimensionDependent<RiverFunctionality>(*reg,grp);
RegisterDomainAlgebraDependent<RiverFunctionality>(*reg,grp);
}
UG_REGISTRY_CATCH_THROW(grp);
}
}// end of namespace