-
Notifications
You must be signed in to change notification settings - Fork 2
/
limex_plugin.cpp
732 lines (630 loc) · 28.3 KB
/
limex_plugin.cpp
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
/*
* Copyright (c) 2014-2016: G-CSC, Goethe University Frankfurt
* Author: Arne Naegel
*
* This file is part of UG4.
*
* UG4 is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License version 3 (as published by the
* Free Software Foundation) with the following additional attribution
* requirements (according to LGPL/GPL v3 §7):
*
* (1) The following notice must be displayed in the Appropriate Legal Notices
* of covered and combined works: "Based on UG4 (www.ug4.org/license)".
*
* (2) The following notice must be displayed at a prominent place in the
* terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
*
* (3) The following bibliography is recommended for citation and must be
* preserved in all covered files:
* "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
* parallel geometric multigrid solver on hierarchically distributed grids.
* Computing and visualization in science 16, 4 (2013), 151-164"
* "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
* flexible software system for simulating pde based models on high performance
* computers. Computing and visualization in science 16, 4 (2013), 165-179"
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*/
#include <string>
// bridge
#include "bridge/util.h"
#include "bridge/util_overloaded.h"
#include "bridge/util_domain_algebra_dependent.h"
// replace this with util_domain_dependent.h or util_algebra_dependent.h
// to speed up compilation time
// ug
#include "lib_disc/function_spaces/grid_function.h"
#include "lib_disc/function_spaces/metric_spaces.h"
#include "lib_disc/time_disc/theta_time_step.h"
#include "common/ug_config.h"
#include "common/error.h"
#include "common/math/math_vector_matrix/math_vector.h"
// plugin
#include "time_disc/time_integrator.hpp"
#include "time_disc/time_extrapolation.h"
#include "time_disc/linear_implicit_timestep.h"
#include "time_disc/limex_integrator.hpp"
#include "newton_limex.h"
// include for plugins
using namespace std;
using namespace ug::bridge;
#ifdef UG_PARALLEL
#include "pcl/pcl_util.h"
#endif
namespace ug{
/* Define LIB_LIMEX DebugID */
DebugID LIB_LIMEX("LIB_LIMEX");
namespace Limex{
/**
* \defgroup limex Limex
* \ingroup plugins
* This plugin provides the basic mechanisms for linearly implicit extrapolation methods.
* \{
*/
/**
* Class exporting the functionality of the plugin. All functionality that is to
* be used in scripts or visualization must be registered here.
*/
struct Functionality
{
/**
* 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, typename TRegistry=ug::bridge::Registry>
static void DomainAlgebra(TRegistry& reg, string grp)
{
// some defines/typedefs
string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
typedef MultiStepTimeDiscretization<TAlgebra> TMultiStepTimeDisc;
typedef ITimeDiscretization<TAlgebra> TTimeDisc;
typedef typename TAlgebra::vector_type TVector;
typedef GridFunction<TDomain,TAlgebra> TGridFunction;
{
/// GridFunctionEstimator (REPLACED, sub-diagonal)
typedef ISubDiagErrorEst<TVector> TBase;
typedef GridFunctionEstimator<TDomain, TAlgebra> T;
typedef typename T::subspace_type TSubSpace;
//typedef typename T::composite_type TCompositeSpace;
string name = string("GridFunctionEstimator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)() >("")
.template add_constructor<void (*)(number) >("")
.add_method("set_reference_norm", &T::set_reference_norm)
.add_method("add", static_cast<void (T::*)(SmartPtr<TSubSpace>) > (&T::add))
.add_method("add", static_cast<void (T::*)(SmartPtr<TSubSpace>, number) > (&T::add))
// .add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
.add_method("config_string", &T::config_string)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "GridFunctionEstimator", tag);
}
{
// SupErrorEvaluator
typedef SupErrorEvaluator<TGridFunction> T;
typedef IComponentSpace<TGridFunction> TBase;
string name = string("SupErrorEvaluator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)(const char *) >("fctNames")
// .template add_constructor<void (*)(const char *, number) >("fctNames, scale")
.template add_constructor<void (*)(const char *, const char */*, number*/) >("fctNames, subsetNames, scale")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "SupErrorEvaluator", tag);
}
{
// UserDataSpaceNumber
typedef UserDataSpace<TGridFunction, number > T;
typedef IComponentSpace<TGridFunction> TBase;
string name = string("UserDataSpaceNumber").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)(const char *) >("fctNames")
.template add_constructor<void (*)(const char *, int) >("fctNames, scale")
// .template add_constructor<void (*)(const char *, int, number) >("fctNames, subsetNames, scale")
.add_method("set_user_data", &T::set_user_data)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "UserDataSpaceNumber", tag);
}
{
// UserDataSpaceVector
typedef UserDataSpace<TGridFunction, MathVector<TGridFunction::dim> > T;
typedef IComponentSpace<TGridFunction> TBase;
string name = string("UserDataSpaceVector").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)(const char *) >("fctNames")
.template add_constructor<void (*)(const char *, int) >("fctNames, scale")
//.template add_constructor<void (*)(const char *, int, number) >("fctNames, subsetNames, scale")
.add_method("set_user_data", &T::set_user_data)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "UserDataSpaceVector", tag);
}
{
// ScaledGridFunctionEstimator (sub-diagonal)
typedef ISubDiagErrorEst<TVector> TBase;
typedef ScaledGridFunctionEstimator<TDomain, TAlgebra> T;
typedef IComponentSpace<TGridFunction> TCompSpace;
typedef typename T::composite_type TCompositeSpace;
string name = string("ScaledGridFunctionEstimator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)() >("Default constructor")
.add_method("add", static_cast<void (T::*)(SmartPtr<TCompSpace>) > (&T::add))
.add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
.add_method("config_string", &T::config_string)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "ScaledGridFunctionEstimator", tag);
}
{
// CompositeGridFunctionEstimator (sub-diagonal)
typedef ISubDiagErrorEst<TVector> TBase;
typedef CompositeGridFunctionEstimator<TDomain, TAlgebra> T;
typedef IComponentSpace<TGridFunction> TCompSpace;
typedef typename T::composite_type TCompositeSpace;
string name = string("CompositeGridFunctionEstimator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)() >("Default constructor")
.add_method("add", static_cast<void (T::*)(SmartPtr<TCompSpace>) > (&T::add))
.add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
.add_method("config_string", &T::config_string)
.add_method("use_strict_relative_norms", &T::use_strict_relative_norms)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "CompositeGridFunctionEstimator", tag);
}
{
// VTKOutputObserver
typedef VTKOutputObserver<TDomain, TAlgebra> T;
string name = string("VTKOutputObserver").append(suffix);
reg.template add_class_<T, typename T::base_type>(name, grp)
.template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>) >("")
.template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>, number) >("")
.add_method("set_output_scales", &T::set_output_scales)
//.add_method("close", &T::close)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "VTKOutputObserver", tag);
}
{
// ConnectionViewerOutputObserver
typedef ConnectionViewerOutputObserver<TDomain, TAlgebra> T;
string name = string("ConnectionViewerOutputObserver").append(suffix);
reg.template add_class_<T, typename T::base_type>(name, grp)
.template add_constructor<void (*)(const char*) >("")
.template add_constructor<void (*)(const char*, number) >("")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "ConnectionViewerOutputObserver", tag);
}
#ifdef UG_FOR_LUA
{
// PlotRefOutputObserver
typedef PlotRefOutputObserver<TDomain, TAlgebra> T;
string name = string("PlotRefOutputObserver").append(suffix);
reg.template add_class_<T, typename T::base_type>(name, grp)
.template add_constructor<void (*)(const char*) >("")
.template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>) >("")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "PlotRefOutputObserver", tag);
}
#endif
{
// IntegrationOutputObserver
typedef IntegrationOutputObserver<TDomain, TAlgebra> T;
string name = string("IntegrationOutputObserver").append(suffix);
reg.template add_class_<T, typename T::base_type>(name, grp)
.template add_constructor<void (*)() >("")
.add_method("add_integral_specs", &T::add_integral_specs)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "IntegrationOutputObserver", tag);
}
{
// ITimeIntegrator (virtual base class)
typedef ITimeIntegrator<TDomain, TAlgebra> T;
typedef TimeIntegratorSubject<TDomain, TAlgebra> TBase;
string name = string("ITimeIntegrator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.add_method("set_time_step", &T::set_time_step)
.add_method("set_precision_bound", &T::set_precision_bound)
.add_method("set_no_log_out", &T::set_no_log_out)
.add_method("init", (void (T::*)(TGridFunction const&u) ) &T::init, "","")
.add_method("attach_observer", &T::attach_observer)
.add_method("attach_init_observer", &T::attach_init_observer)
.add_method("attach_rewind_observer", &T::attach_rewind_observer)
.add_method("attach_finalize_observer", &T::attach_finalize_observer);
reg.add_class_to_group(name, "ITimeIntegrator", tag);
}
{
// ILinearTimeIntegrator
typedef ITimeIntegrator<TDomain, TAlgebra> TBase;
typedef ILinearTimeIntegrator<TDomain, TAlgebra> T;
string name = string("ILinearTimeIntegrator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.add_method("set_linear_solver", &T::set_linear_solver);
reg.add_class_to_group(name, "ILinearTimeIntegrator", tag);
}
{
// LinearTimeIntegrator
// (e.g., implicit Euler for linear problem)
typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef LinearTimeIntegrator<TDomain, TAlgebra> T;
string name = string("LinearTimeIntegrator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
// .template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TSolver>) >("")
.add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
.add_method("get_time_disc", &T::get_time_disc)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LinearTimeIntegrator", tag);
}
{
// ConstStepLinearTimeIntegrator
// (e.g., implicit Euler for linear problem)
typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef ConstStepLinearTimeIntegrator<TDomain, TAlgebra> T;
typedef typename T::linear_solver_type TSolver;
string name = string("ConstStepLinearTimeIntegrator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
.template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TSolver>) >("")
.add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
.add_method("get_time_disc", &T::get_time_disc)
.add_method("set_num_steps", &T::set_num_steps)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "ConstStepLinearTimeIntegrator", tag);
}
{
// Adaptive LinearTimeIntegrator
typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef TimeIntegratorLinearAdaptive<TDomain, TAlgebra> T;
string name = string("TimeIntegratorLinearAdaptive").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TTimeDisc>) >("tdisc1, tdisc2")
.add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
.add_method("get_time_disc", &T::get_time_disc)
.add_method("set_tol", &T::set_tol)
.add_method("set_time_step_max", &T::set_time_step_max)
.add_method("set_time_step_min", &T::set_time_step_min)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "TimeIntegratorLinearAdaptive", tag);
}
{
// INonlinearTimeIntegrator
typedef ITimeIntegrator<TDomain, TAlgebra> TBase;
typedef INonlinearTimeIntegrator<TDomain, TAlgebra> T;
string name = string("INonlinearTimeIntegrator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.add_method("set_solver", &T::set_solver)
.add_method("set_dt_min", &T::set_dt_min)
.add_method("set_dt_max", &T::set_dt_max)
.add_method("set_reduction_factor", &T::set_reduction_factor)
.add_method("set_increase_factor", &T::set_increase_factor);
reg.add_class_to_group(name, "INonlinearTimeIntegrator", tag);
}
/*{
// INonlinearTimeIntegratorWithBounds
typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef INonlinearTimeIntegratorWithBounds<TDomain, TAlgebra> T;
string name = string("ITimeIntegratorWithBounds").append(suffix);
reg.add_class_<T, TBase>(name, grp)
reg.add_class_to_group(name, "ITimeIntegratorWithBounds", tag);
}*/
{
// SimpleTimeIntegrator
// (e.g., implicit Euler for linear problem)
typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef DebugWritingObject<TAlgebra> TDebugBase;
typedef SimpleTimeIntegrator<TDomain, TAlgebra> T;
//typedef DomainDiscretization<TDomain, TAlgebra> TDomainDisc;
//typedef MultiStepTimeDiscretization<TAlgebra> TTimeDisc;
string name = string("SimpleTimeIntegrator").append(suffix);
reg.template add_class_<T,TBase,TDebugBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
.add_method("apply", (bool (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "SimpleTimeIntegrator", tag);
}
{
// LimexTimeIntegrator
typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
typedef LimexTimeIntegrator<TDomain, TAlgebra> T;
typedef DomainDiscretization<TDomain, TAlgebra> TDomainDisc;
string name = string("LimexTimeIntegrator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
//.template add_constructor<void (*)() >("")
//.ADD_CONSTRUCTOR( (SmartPtr<TDomainDisc>, int) ) ("Domain disc|number of steps (vector)")
.ADD_CONSTRUCTOR( (int) ) ("number of stages")
.add_method("set_tolerance", &T::set_tolerance)
.add_method("set_stepsize_safety_factor",&T::set_stepsize_safety_factor)
.add_method("set_stepsize_reduction_factor", &T::set_stepsize_reduction_factor)
.add_method("set_stepsize_greedy_order_factor", &T::set_stepsize_greedy_order_factor)
.add_method("add_error_estimator", &T::add_error_estimator)
.add_method("add_stage", (void (T::*)(size_t, size_t, SmartPtr<typename T::domain_discretization_type>, SmartPtr<typename T::solver_type>) ) &T::add_stage)
.add_method("add_stage", (void (T::*)(size_t, SmartPtr<typename T::solver_type>, SmartPtr<typename T::domain_discretization_type>) ) &T::add_stage)
.add_method("add_stage", (void (T::*)(size_t, SmartPtr<typename T::solver_type>, SmartPtr<typename T::domain_discretization_type>, SmartPtr<typename T::domain_discretization_type>) ) &T::add_stage_ext)
.add_method("set_debug", &T::set_debug)
.add_method("set_debug_for_timestepper", &T::set_debug_for_timestepper)
.add_method("has_time_derivative", &T::has_time_derivative)
.add_method("get_time_derivative", &T::get_time_derivative)
.add_method("set_time_derivative", &T::set_time_derivative)
.add_method("enable_matrix_cache", &T::enable_matrix_cache)
.add_method("disable_matrix_cache", &T::disable_matrix_cache)
// .add_method("enable_linear_mode", &T::enable_linear_mode)
// .add_method("disable_linear_mode", &T::disable_linear_mode)
.add_method("select_cost_strategy", &T::select_cost_strategy)
.add_method("set_max_reductions", &T::set_max_reductions)
.add_method("set_asymptotic_order", &T::set_asymptotic_order)
.add_method("set_space", &T::set_space)
.add_method("apply", (bool (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
.add_method("interrupt", &T::interrupt, "", "", "interrupt execution of apply()")
.add_method("set_conservative", &T::set_conservative)
.add_method("config_string", &T::config_string)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LimexTimeIntegrator", tag);
}
{
// DiscontinuityIntegrator
typedef DiscontinuityIntegrator<TDomain, TAlgebra> T;
typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
// typedef typename T::base_type TBase;
string name = string("DiscontinuityIntegrator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<TBase>) >("")
.add_method("apply", &T::apply)
.add_method("insert_points", &T::insert_points)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "DiscontinuityIntegrator", tag);
}
}
/**
* 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)
{
// useful defines
string suffix = GetDomainSuffix<TDomain>();
string tag = GetDomainTag<TDomain>();
}
/**
* Function called for the registration of Dimension dependent parts
* of the plugin. All Functions and Classes depending on the Dimension
* are to be placed here when registering. The method is called for all
* available Dimension types, based on the current build options.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <int dim>
static void Dimension(Registry& reg, string grp)
{
// useful defines
string suffix = GetDimensionSuffix<dim>();
string tag = GetDimensionTag<dim>();
}
/**
* Function called for the registration of Algebra dependent parts
* of the plugin. All Functions and Classes depending on Algebra
* are to be placed here when registering. The method is called for all
* available Algebra types, based on the current build options.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <typename TAlgebra, typename TRegistry=ug::bridge::Registry>
static void Algebra(TRegistry& reg, string parentGroup)
{
// typedefs for Vector and Matrix
typedef typename TAlgebra::vector_type vector_type;
typedef typename TAlgebra::matrix_type matrix_type;
// useful defines
string suffix = GetAlgebraSuffix<TAlgebra>();
string tag = GetAlgebraTag<TAlgebra>();
/*
{
// IErrorEvaluator (abstract base class)
typedef IBanachSpace<vector_type> T;
string name = string("IBanachSpace").append(suffix);
reg.add_class_<T>(name, parentGroup)
.add_method("norm", &T::norm)
.add_method("distance", &T::distance);
reg.add_class_to_group(name, "IBanachSpace", tag);
}
*/
// LinearlyImplicitEuler
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef ITimeDiscretization<TAlgebra> TBase;
typedef LinearImplicitEuler<TAlgebra> T;
string name = string("LinearImplicitEuler").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.template add_constructor<void (*)(SmartPtr<IDomainDiscretization<TAlgebra> >)>("LinearImplicitEuler")
.add_method("set_gamma_disc", &T::set_gamma_disc)
.add_method("enable_matrix_cache", &T::enable_matrix_cache)
.add_method("disable_matrix_cache", &T::disable_matrix_cache)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LinearImplicitEuler", tag);
}
// Time extrapolation
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef typename TAlgebra::vector_type VT;
typedef ISubDiagErrorEst<VT> ET;
typedef AitkenNevilleTimex<VT> T;
string name = string("AitkenNevilleTimex").append(suffix);
reg.template add_class_<T>(name, grp)
.ADD_CONSTRUCTOR( (std::vector<size_t> nsteps) ) ("number of steps (vector)")
.ADD_CONSTRUCTOR( (std::vector<size_t> nsteps, SmartPtr<ET> ) ) ("number of steps (vector)")
.add_method("set_solution", &T::set_solution)
.add_method("get_solution", &T::get_solution)
.add_method("apply", (void (T::*)()) &T::apply)
.add_method("apply", (void (T::*)(size_t, bool)) &T::apply)
//.add_method("get_error_estimate", &T::get_error_estimate())
//.add_method("get_error_estimate", &T::get_error_estimate(int))
.add_method("get_error_estimate", (double (T::*)(void)) &T::get_error_estimate, "","")
.add_method("get_error_estimate", (double (T::*)(int)) &T::get_error_estimate, "","")
.add_method("set_error_estimate", &T::set_error_estimate)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "AitkenNevilleTimex", tag);
}
// interface for error estimator for time extrapolation
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef ISubDiagErrorEst<vector_type> T;
string name = string("ISubDiagErrorEst").append(suffix);
reg.template add_class_<T>(name, grp)
.add_method("config_string", &T::config_string);
reg.add_class_to_group(name, "ISubDiagErrorEst", tag);
}
// L2 norm error estimator for time extrapolation
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef Norm2Estimator<vector_type> T;
typedef ISubDiagErrorEst<vector_type> TBase;
string name = string("Norm2Estimator").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.ADD_CONSTRUCTOR( (void) ) ("")
.add_method("set_stride", &T::set_stride)
.add_method("set_offset", &T::set_offset)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "Norm2Estimator", tag);
}
// Inf norm error estimator for time extrapolation
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef NormInfEstimator<vector_type> T;
typedef ISubDiagErrorEst<vector_type> TBase;
string name = string("NormInfEstimator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.ADD_CONSTRUCTOR( (void) ) ("")
.add_method("set_stride", &T::set_stride)
.add_method("set_offset", &T::set_offset)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "NormInfEstimator", tag);
}
// Rel norm error estimator for time extrapolation
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef NormRelEstimator<vector_type> T;
typedef ISubDiagErrorEst<vector_type> TBase;
string name = string("NormRelEstimator").append(suffix);
reg.template add_class_<T,TBase>(name, grp)
.ADD_CONSTRUCTOR( (void) ) ("")
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "NormRelEstimator", tag);
}
// LimexNewton
{
std::string grp = parentGroup;
grp.append("/Discretization/Nonlinear");
typedef LimexNewtonSolver<TAlgebra> T;
typedef IOperatorInverse<vector_type> TBase;
string name = string("LimexNewtonSolver").append(suffix);
reg.template add_class_<T, TBase>(name, grp)
.add_constructor()
.template add_constructor<void (*)(SmartPtr<IOperator<vector_type> >)>("Operator")
.template add_constructor<void (*)(SmartPtr<IAssemble<TAlgebra> >)>("AssemblingRoutine")
.add_method("set_linear_solver", &T::set_linear_solver, "", "linear solver")
.add_method("init", &T::init, "success", "op")
.add_method("prepare", &T::prepare, "success", "u")
.add_method("apply", &T::apply, "success", "u")
.add_method("linear_solver_rate", &T::linear_solver_rate)
.add_method("linear_solver_steps", &T::linear_solver_steps)
.add_method("config_string", &T::config_string)
.set_construct_as_smart_pointer(true);
reg.add_class_to_group(name, "LimexNewtonSolver", tag);
}
}
/**
* Function called for the registration of Domain and Algebra independent parts
* of the plugin. All Functions and Classes not depending on Domain and Algebra
* are to be placed here when registering.
*
* @param reg registry
* @param parentGroup group for sorting of functionality
*/
template <typename TRegistry=ug::bridge::Registry>
static void Common(TRegistry& reg, string parentGroup)
{
std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
typedef ILimexCostStrategy TBase;
reg.template add_class_<TBase>(std::string("ILimexCostStrategy"), grp);
{
typedef LimexDefaultCost T;
string name = string("LimexDefaultCost");
reg.template add_class_<T, TBase>(name, grp)
.add_constructor()
.set_construct_as_smart_pointer(true);
}
{
typedef LimexNonlinearCost T;
string name = string("LimexNonlinearCost");
reg.template add_class_<T, TBase>(name, grp)
.add_constructor()
.set_construct_as_smart_pointer(true);
}
// reg.add_function("BesselJ0", &BesselJ0, grp); => Poroelasticity plugin
// reg.add_function("BesselJ1", &BesselJ1, grp);
}
}; // end Functionality
// end group limex
/// \}
}// end of namespace Sample
/**
* This function is called when the plugin is loaded.
*/
#ifndef UG_USE_PYBIND11
extern "C" void
InitUGPlugin_Limex(Registry* reg, string grp)
{
grp.append("/Limex");
typedef Limex::Functionality Functionality;
try{
RegisterCommon<Functionality>(*reg,grp);
// RegisterDimensionDependent<Functionality>(*reg,grp);
// RegisterDomainDependent<Functionality>(*reg,grp);
RegisterAlgebraDependent<Functionality>(*reg,grp);
RegisterDomainAlgebraDependent<Functionality>(*reg,grp);
}
UG_REGISTRY_CATCH_THROW(grp);
}
#else
template <typename TRegistry=ug::bridge::Registry>
void InitUGPlugin_Limex_(TRegistry* reg, string grp)
{
grp.append("/Limex");
typedef Limex::Functionality Functionality;
try{
RegisterCommon<Functionality>(*reg,grp);
// RegisterDimensionDependent<Functionality>(*reg,grp);
// RegisterDomainDependent<Functionality, TRegistry>(*reg,grp);
RegisterAlgebraDependent<Functionality, TRegistry>(*reg,grp);
RegisterDomainAlgebraDependent<Functionality, TRegistry>(*reg,grp);
}
UG_REGISTRY_CATCH_THROW(grp);
}
extern "C" void
InitUGPlugin_Limex(ug::bridge::Registry* reg, string grp)
{ InitUGPlugin_Limex_<ug::bridge::Registry>(reg, grp); }
#endif
#ifdef UG_USE_PYBIND11
// Expose for pybind11.
namespace Limex{
void InitUGPlugin(ug::pybind::Registry* reg, string grp)
{ InitUGPlugin_Limex_<ug::pybind::Registry>(reg, grp); }
}
#endif
extern "C" UG_API void
FinalizeUGPlugin_Limex()
{
}
}// end of namespace ug