-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd3f_plugin_ls.cpp
More file actions
234 lines (204 loc) · 11.4 KB
/
Copy pathd3f_plugin_ls.cpp
File metadata and controls
234 lines (204 loc) · 11.4 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
/*
* SPDX-FileCopyrightText: 2025 Gesellschaft fuer Anlagen- und Reaktorsicherheit gGmbH
* SPDX-License-Identifier: EUPL-1.2
* SPDX-FileContributor: Andreas Vogel
* 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
*/
/**
* File for registration of d3f routines.
*/
#include "bridge/util.h"
#include "bridge/util_domain_dependent.h"
#include "bridge/util_domain_algebra_dependent.h"
#include "lib_disc/spatial_disc/dom_disc_embb.h"
#include "lib_disc/time_disc/finished_conditions.hpp"
#include "util/richards/richards_fs_height.h"
#include "level_set_pos.h"
#include "rivers.h"
#include "fs_measurement.hpp"
#include "fs_equilibirum_finished_condition.hpp"
#include "d3f_plugin_ls.h"
using namespace std;
using namespace ug::bridge;
namespace ug{
namespace d3f{
/**
* Class exporting the functionality of the plugin. All functionality that is to
* be used in scripts or visualization must be registered here.
*/
struct LevelSetFunctionality
{
/**
* Function called for the registration of Domain dependent parts
* of the plugin. All Functions and Classes depending on the Domain
* are to be placed here when registering. The method is called for all
* available Domain types, based on the current build options.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <typename TDomain>
static void Domain(Registry& reg, string grp)
{
string suffix = GetDomainSuffix<TDomain>();
string tag = GetDomainTag<TDomain>();
static const int dim = TDomain::dim;
typedef CPUAlgebra TLSFAlgebra;
typedef GridFunction<TDomain, TLSFAlgebra> TLSFct;
// LSPositionZ: Determining the depth of the free surface in the domain
{
typedef LSPositionZ<TLSFct> T;
string name = string("LSPositionZ").append(suffix);
reg.add_class_<T>(name, grp)
.template add_constructor<void (*) (SmartPtr<TLSFct>)> ("LSF")
.template add_constructor<void (*) (SmartPtr<TLSFct>, const char *, number)> ("LSF#cmp#value")
.add_method("reinit", static_cast<void (T::*) ()> (&T::reinit), "", "Initialize for computations")
# ifdef UG_FOR_LUA
.add_method("height_at", static_cast<number (T::*) (std::vector<number>)> (&T::height_at), "point", "Get the position of the free surface at")
# endif
.add_method("set_transform_tol", static_cast<void (T::*) (number, size_t)> (&T::set_transform_tol), "epsilon#Niter", "Set the inv. transform. tolerances")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LSPositionZ", tag);
}
// LSPosZData: A user data object of the depth of the free surface
{
typedef LSPosZData<TLSFct> T;
typedef UserData<number, dim> TBase;
string name = string("LSPosZData").append(suffix);
reg.add_class_<T,TBase>(name, grp)
.template add_constructor<void (*) (SmartPtr<LSPositionZ<TLSFct> >, const char *)> ("measurer#subsets")
.add_method("set_default_height", static_cast<void (T::*) (number)> (&T::set_default_height), "Sets the value for the points with no level set", "defaultHeight")
.add_method("reinit", static_cast<void (T::*) ()> (&T::reinit), "", "Initialize for computations")
.add_method("reinit_for", static_cast<void (T::*) (int)> (&T::reinit_for), "dim", "Initialize for computations")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LSPosZData", tag);
}
// LSPosZCellToVrtData: A user data object of the depth of the free surface (averaged in vertices)
{
typedef LSPosZCellToVrtData<TLSFct> T;
typedef UserData<number, dim> TBase;
string name = string("LSPosZCellToVrtData").append(suffix);
reg.add_class_<T,TBase>(name, grp)
.template add_constructor<void (*) (SmartPtr<LSPositionZ<TLSFct> >, const char *)> ("measurer#subsets")
.add_method("set_default_height", static_cast<void (T::*) (number)> (&T::set_default_height), "Sets the value for the points with no level set", "defaultHeight")
.add_method("reinit", static_cast<void (T::*) ()> (&T::reinit), "", "Initialize for computations")
.add_method("reinit_for", static_cast<void (T::*) (int)> (&T::reinit_for), "dim", "Initialize for computations")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LSPosZCellToVrtData", tag);
}
// LSPositionAtPoints: Computing the depth at given points
{
typedef LSPositionZ<TLSFct> TMeas;
typedef LSPositionAtPoints<TMeas> T;
string name = string("LSPositionAtPoints").append(suffix);
reg.add_class_<T>(name, grp)
.template add_constructor<void (*) (SmartPtr<TMeas>)> ("measurer")
.add_method("add_pnt", static_cast<void (T::*) (std::vector<number>)> (&T::add_pnt), "xyz", "Add a point to the set")
.add_method("load_points_from", static_cast<void (T::*) (const char *, bool)> (&T::load_points_from), "filename#ref", "Load points from a file")
.add_method("compute", static_cast<void (T::*) ()> (&T::compute), "", "Compute the height at the points")
.add_method("n_points", static_cast<size_t (T::*) ()> (&T::n_points), "", "Returns the number of the registered points")
.add_method("print_to", static_cast<void (T::*) (const char *, bool)> (&T::print_to), "filename#printdiff", "Print points to a file")
.add_method("print", static_cast<void (T::*) (bool)> (&T::print), "printdiff", "Print points to the shell")
.add_method("append_to_table", static_cast<void (T::*) (const char *, size_t, number)> (&T::append_to_table), "fname#step#time", "Append positions to a table")
.add_method("print_table_header", static_cast<void (T::*) (const char *)> (&T::print_table_header), "fname", "Print the header of the table")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LSPositionAtPoints", tag);
}
// Projects FS of Richards equation to top subset
{
typedef RichardsFreeSurfaceHeight<TLSFct> T;
typedef UserData<number, dim> TBase;
string name = string("RichardsFreeSurfaceHeight").append(suffix);
reg.add_class_<T,TBase>(name, grp)
.template add_constructor<void (*) (SmartPtr<TLSFct>, const char *, const char *)> ("GF#subsets#cmp")
.add_method("reinit", static_cast<void (T::*) ()> (&T::reinit), "", "Initialize for computations")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "RichardsFreeSurfaceHeight", tag);
}
}
/**
* 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;
// Step control and termination conditions
{
typedef FSFileMeasurer<TDomain, TAlgebra> T;
typedef GridFunction<TDomain, TAlgebra> TLSFct;
typedef ITimeIntegratorObserver<TDomain, TAlgebra> TBase;
string name = string("FSFileMeasurer").append(suffix);
reg.add_class_<T, TBase>(name, grp)
.template add_constructor<void (*) (SmartPtr<TLSFct>)> ("lsf")
.template add_constructor<void (*) (SmartPtr<TLSFct>, const char*, number)> ("lsf#cmp#zero")
.add_method("add_measurement_point", static_cast<void (T::*) (std::vector<number>)> (&T::add_measurement_point), "position", "")
.add_method("add_measurement_point", static_cast<void (T::*) (std::vector<number>, number given_z)> (&T::add_measurement_point), "position#given z", "")
.add_method("set_title_text", static_cast<void (T::*) (const char*)> (&T::set_title_text), "text", "Set title")
.add_method("enable_print_output", static_cast<void (T::*) ()> (&T::enable_print_output), "", "Switches On the printing of the measurment")
.add_method("enable_binary_output", static_cast<void (T::*) (const char *)> (&T::enable_binary_output), "filename", "Enable binary output to the specified file")
.add_method("enable_csv_output", static_cast<void (T::*) (const char *)> (&T::enable_csv_output), "filename", "Enable csv output to the specified file")
.add_method("enable_tsv_output", static_cast<void (T::*) (const char *)> (&T::enable_tsv_output), "filename", "Enable tab separated output to the specified file")
.add_method("enable_step_file_output", static_cast<void (T::*) (const char *)> (&T::enable_step_file_output), "filename", "Enable output writing a file for every time step")
.add_method("enable_table_output", static_cast<void (T::*) (const char *)> (&T::enable_table_output), "filename", "Enable table output to the specified file")
.add_method("read_measurement_points", static_cast<void (T::*) (const char *, bool)> (&T::read_measurement_points), "filename#zgiven", "Read tab separated values as measurement points")
.add_method("enable_difference_output", static_cast<void (T::*) (bool)> (&T::enable_difference_output), "OnOff", "Adds the difference to the expected value to the selected outputs")
.add_method("set_measurement_interval", static_cast<void (T::*) (int)> (&T::set_measurement_interval), "interval", "Measure only every x steps")
.add_method("get_finished_observer", &T::get_finished_observer, "", "")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "FSFileMeasurer", tag);
}
{
typedef FSFileMeasurerFinishedObserver<TDomain, TAlgebra> T;
typedef FSFileMeasurer<TDomain, TAlgebra> TMeasurer;
typedef ITimeIntegratorObserver<TDomain, TAlgebra> TBase;
string name = string("FSFileMeasurerFinishedObserver").append(suffix);
reg.add_class_<T, TBase>(name, grp)
.template add_constructor<void (*) (SmartPtr<TMeasurer>)> ("FSFileMeasurer")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "FSFileMeasurerFinishedObserver", tag);
}
{
typedef FSInEquilibriumFinishedCondition<TDomain, TAlgebra> T;
typedef GridFunction<TDomain, TAlgebra> TLSFct;
typedef ITimeIntegratorObserver<TDomain, TAlgebra> TBase;
typedef IFinishedCondition TBase2;
string name = string("FSInEquilibriumFinishedCondition").append(suffix);
reg.add_class_<T, TBase, TBase2>(name, grp)
.template add_constructor<void (*) (SmartPtr<TLSFct>, number)> ("LSF, equilibrium factor")
.add_method("add_measurement_point", static_cast<void (T::*) (std::vector<number>)> (&T::add_measurement_point), "position", "")
.add_method("read_measurement_points", static_cast<void (T::*) (const char *)> (&T::read_measurement_points), "filename", "")
.add_method("set_equilibrium_factor", static_cast<void (T::*) (number)> (&T::set_equilibrium_factor), "equilibriumFactor", "Sets minimum equilibrium factor to stop the computation at")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "FSInEquilibriumFinishedCondition", tag);
}
}
}; // end LevelSetFunctionality
} // end namespace d3f
/**
* This function is called when the plugin is loaded.
*/
void
InitUGPlugin_d3f_ls(Registry* reg, string grp)
{
grp.append("/SpatialDisc/d3f");
typedef d3f::LevelSetFunctionality LevelSetFunctionality;
try{
RegisterDomain2d3dDependent<LevelSetFunctionality>(*reg,grp);
RegisterDomain2d3dAlgebraDependent<LevelSetFunctionality>(*reg,grp);
}
UG_REGISTRY_CATCH_THROW(grp);
}
}// namespace ug