LCOV - code coverage report
Current view: top level - /builds/ug4-project/ugcore/ug4-new/plugins/Limex - limex_plugin.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 98.8 % 255 252
Test Date: 2026-06-01 23:54:59 Functions: 93.3 % 15 14

            Line data    Source code
       1              : /*
       2              :  * SPDX-FileCopyrightText: Copyright (c) 2014-2025:  Goethe University Frankfurt
       3              :  * SPDX-License-Identifier: LicenseRef-UG4-LGPL-3.0
       4              :  *
       5              :  * Author: Arne Naegel
       6              :  *
       7              :  * This file is part of UG4.
       8              :  *
       9              :  * UG4 is free software: you can redistribute it and/or modify it under the
      10              :  * terms of the GNU Lesser General Public License version 3 (as published by the
      11              :  * Free Software Foundation) with the following additional attribution
      12              :  * requirements (according to LGPL/GPL v3 §7):
      13              :  *
      14              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      15              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      16              :  *
      17              :  * (2) The following notice must be displayed at a prominent place in the
      18              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      19              :  *
      20              :  * (3) The following bibliography is recommended for citation and must be
      21              :  * preserved in all covered files:
      22              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      23              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      24              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      25              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      26              :  *   flexible software system for simulating pde based models on high performance
      27              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      28              :  *
      29              :  * This program is distributed in the hope that it will be useful,
      30              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      31              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      32              :  * GNU Lesser General Public License for more details.
      33              :  */
      34              : 
      35              : 
      36              : #include <string>
      37              : 
      38              : // bridge
      39              : #include "bridge/util.h"
      40              : #include "bridge/util_overloaded.h"
      41              : #include "bridge/util_domain_algebra_dependent.h"
      42              : // replace this with util_domain_dependent.h or util_algebra_dependent.h
      43              : // to speed up compilation time
      44              : 
      45              : 
      46              : // ug
      47              : #include "lib_disc/function_spaces/grid_function.h"
      48              : #include "lib_disc/function_spaces/metric_spaces.h"
      49              : #include "lib_disc/time_disc/theta_time_step.h"
      50              : #include "common/ug_config.h"
      51              : #include "common/error.h"
      52              : #include "common/math/math_vector_matrix/math_vector.h"
      53              : 
      54              : 
      55              : // plugin
      56              : #include "time_disc/time_integrator.hpp"
      57              : #include "time_disc/simple_integrator.hpp"
      58              : #include "time_disc/time_extrapolation.h"
      59              : #include "time_disc/linear_implicit_timestep.h"
      60              : #include "time_disc/limex_integrator.hpp"
      61              : #include "time_disc/data_output_observer.hpp"
      62              : #include "time_disc/aux_output_observer.hpp"
      63              : #include "newton_limex.h"
      64              : 
      65              : 
      66              : // include for plugins
      67              : using namespace std;
      68              : using namespace ug::bridge;
      69              : 
      70              : #ifdef UG_PARALLEL
      71              : #include "pcl/pcl_util.h"
      72              : #endif
      73              : 
      74              : namespace ug{
      75              : 
      76              : /* Define LIB_LIMEX DebugID */
      77              : DebugID LIB_LIMEX("LIB_LIMEX");
      78              : 
      79              : namespace Limex{
      80              : 
      81              : /**
      82              :  *  \defgroup limex Limex
      83              :  *  \ingroup plugins
      84              :  *  This plugin provides the basic mechanisms for linearly implicit extrapolation methods.
      85              :  *  \{
      86              :  */
      87              : 
      88              : 
      89              : /**
      90              :  * Class exporting the functionality of the plugin. All functionality that is to
      91              :  * be used in scripts or visualization must be registered here.
      92              :  */
      93              : struct Functionality
      94              : {
      95              : 
      96              : /**
      97              :  * Function called for the registration of Domain and Algebra dependent parts
      98              :  * of the plugin. All Functions and Classes depending on both Domain and Algebra
      99              :  * are to be placed here when registering. The method is called for all
     100              :  * available Domain and Algebra types, based on the current build options.
     101              :  *
     102              :  * @param reg                           registry
     103              :  * @param parentGroup           group for sorting of functionality
     104              :  */
     105              : template <typename TDomain, typename TAlgebra, typename TRegistry=ug::bridge::Registry>
     106            9 : static void DomainAlgebra(TRegistry& reg, string grp)
     107              : {
     108              :         //      some defines/typedefs
     109              :         string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
     110              :         string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
     111              :         typedef MultiStepTimeDiscretization<TAlgebra> TMultiStepTimeDisc;
     112              :         typedef ITimeDiscretization<TAlgebra> TTimeDisc;
     113              :         typedef typename TAlgebra::vector_type TVector;
     114              :         typedef GridFunction<TDomain,TAlgebra> TGridFunction;
     115              : 
     116              :         {
     117              :                 /// GridFunctionEstimator (REPLACED, sub-diagonal)
     118              :                 typedef ISubDiagErrorEst<TVector> TBase;
     119              :                 typedef GridFunctionEstimator<TDomain, TAlgebra> T;
     120              :                 typedef typename T::subspace_type  TSubSpace;
     121              :                 //typedef typename T::composite_type TCompositeSpace;
     122              : 
     123            9 :                 string name = string("GridFunctionEstimator").append(suffix);
     124              : 
     125           27 :                 reg.template add_class_<T, TBase>(name, grp)
     126           18 :                                            .template add_constructor<void (*)() >("")
     127           18 :                                            .template add_constructor<void (*)(number) >("")
     128           27 :                                            .add_method("set_reference_norm", &T::set_reference_norm)
     129           27 :                                            .add_method("add", static_cast<void (T::*)(SmartPtr<TSubSpace>) > (&T::add))
     130           18 :                                            .add_method("add", static_cast<void (T::*)(SmartPtr<TSubSpace>, number) > (&T::add))
     131              :                                         //   .add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
     132           18 :                                            .add_method("config_string", &T::config_string)
     133            9 :                                            .set_construct_as_smart_pointer(true);
     134           27 :                 reg.add_class_to_group(name, "GridFunctionEstimator", tag);
     135              :         }
     136              : 
     137              :         {
     138              :                 // SupErrorEvaluator
     139              :                 typedef SupErrorEvaluator<TGridFunction> T;
     140              :                 typedef IComponentSpace<TGridFunction> TBase;
     141              : 
     142            9 :                 string name = string("SupErrorEvaluator").append(suffix);
     143           27 :                 reg.template add_class_<T, TBase>(name, grp)
     144           18 :                    .template add_constructor<void (*)(const char *) >("fctNames")
     145              :                  //  .template add_constructor<void (*)(const char *, number) >("fctNames, scale")
     146           18 :                    .template add_constructor<void (*)(const char *, const char */*, number*/) >("fctNames, subsetNames, scale")
     147            9 :                    .set_construct_as_smart_pointer(true);
     148           27 :                 reg.add_class_to_group(name, "SupErrorEvaluator", tag);
     149              :         }
     150              : 
     151              :         {
     152              :                         // UserDataSpaceNumber
     153              :                         typedef UserDataSpace<TGridFunction, number > T;
     154              :                         typedef IComponentSpace<TGridFunction> TBase;
     155              : 
     156            9 :                         string name = string("UserDataSpaceNumber").append(suffix);
     157           27 :                         reg.template add_class_<T, TBase>(name, grp)
     158           18 :                            .template add_constructor<void (*)(const char *) >("fctNames")
     159           18 :                            .template add_constructor<void (*)(const char *, int) >("fctNames, scale")
     160              :                           // .template add_constructor<void (*)(const char *, int, number) >("fctNames, subsetNames, scale")
     161           18 :                            .add_method("set_user_data", &T::set_user_data)
     162            9 :                            .set_construct_as_smart_pointer(true);
     163           27 :                         reg.add_class_to_group(name, "UserDataSpaceNumber", tag);
     164              :         }
     165              : 
     166              :         {
     167              :                         // UserDataSpaceVector
     168              :                         typedef UserDataSpace<TGridFunction, MathVector<TGridFunction::dim> > T;
     169              :                         typedef IComponentSpace<TGridFunction> TBase;
     170              : 
     171            9 :                         string name = string("UserDataSpaceVector").append(suffix);
     172           27 :                         reg.template add_class_<T, TBase>(name, grp)
     173           18 :                                 .template add_constructor<void (*)(const char *) >("fctNames")
     174           18 :                                 .template add_constructor<void (*)(const char *, int) >("fctNames, scale")
     175              :                                 //.template add_constructor<void (*)(const char *, int, number) >("fctNames, subsetNames, scale")
     176           18 :                                 .add_method("set_user_data", &T::set_user_data)
     177            9 :                                 .set_construct_as_smart_pointer(true);
     178           27 :                         reg.add_class_to_group(name, "UserDataSpaceVector", tag);
     179              :         }
     180              : 
     181              : 
     182              :         {
     183              :                 // ScaledGridFunctionEstimator (sub-diagonal)
     184              :                 typedef ISubDiagErrorEst<TVector> TBase;
     185              :                 typedef ScaledGridFunctionEstimator<TDomain, TAlgebra> T;
     186              :                 typedef IComponentSpace<TGridFunction> TCompSpace;
     187              :                 typedef typename T::composite_type TCompositeSpace;
     188              : 
     189            9 :                 string name = string("ScaledGridFunctionEstimator").append(suffix);
     190              : 
     191           27 :                 reg.template add_class_<T, TBase>(name, grp)
     192           18 :                    .template add_constructor<void (*)() >("Default constructor")
     193           18 :                    .add_method("add", static_cast<void (T::*)(SmartPtr<TCompSpace>) > (&T::add))
     194           18 :                    .add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
     195           18 :                    .add_method("config_string", &T::config_string)
     196            9 :                    .set_construct_as_smart_pointer(true);
     197           27 :                 reg.add_class_to_group(name, "ScaledGridFunctionEstimator", tag);
     198              :         }
     199              : 
     200              : 
     201              :         {
     202              :                         // CompositeGridFunctionEstimator (sub-diagonal)
     203              :                         typedef ISubDiagErrorEst<TVector> TBase;
     204              :                         typedef CompositeGridFunctionEstimator<TDomain, TAlgebra> T;
     205              :                         typedef IComponentSpace<TGridFunction> TCompSpace;
     206              :                         typedef typename T::composite_type TCompositeSpace;
     207              : 
     208            9 :                         string name = string("CompositeGridFunctionEstimator").append(suffix);
     209              : 
     210           27 :                         reg.template add_class_<T, TBase>(name, grp)
     211           18 :                            .template add_constructor<void (*)() >("Default constructor")
     212           18 :                            .add_method("add", static_cast<void (T::*)(SmartPtr<TCompSpace>) > (&T::add))
     213           18 :                            .add_method("add", static_cast<void (T::*)(SmartPtr<TCompositeSpace>) > (&T::add))
     214           27 :                            .add_method("config_string", &T::config_string)
     215              :                            //.add_method("use_strict_relative_norms", &T::use_strict_relative_norms)
     216           27 :                            .add_method("use_strict_relative_norms",OVERLOADED_METHOD_PTR(void, T, use_strict_relative_norms, (bool)), "", "", "Use relative norm?")
     217           18 :                            .add_method("use_strict_relative_norms",OVERLOADED_METHOD_PTR(void, T, use_strict_relative_norms, (int)), "", "", "Which norm model? 0:abs,1:rel(add),2:rel(sqrt),3:rel(add,cmp),4:(sqrt,cmp)")
     218            9 :                            .set_construct_as_smart_pointer(true);
     219           27 :                         reg.add_class_to_group(name, "CompositeGridFunctionEstimator", tag);
     220              :                 }
     221              : 
     222              :         {
     223              :                 // VTKOutputObserver
     224              :                 typedef VTKOutputObserver<TDomain, TAlgebra> T;
     225              : 
     226            9 :                 string name = string("VTKOutputObserver").append(suffix);
     227           27 :                 reg.template add_class_<T, typename T::base_type>(name, grp)
     228           18 :                         .template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>) >("")
     229           18 :                         .template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>, number) >("")
     230           18 :                         .add_method("set_output_scales", &T::set_output_scales)
     231              :                         //.add_method("close", &T::close)
     232            9 :                         .set_construct_as_smart_pointer(true);
     233           27 :                 reg.add_class_to_group(name, "VTKOutputObserver", tag);
     234              :         }
     235              : 
     236              :         {
     237              :                 // ConnectionViewerOutputObserver
     238              :                 typedef ConnectionViewerOutputObserver<TDomain, TAlgebra> T;
     239              : 
     240            9 :                 string name = string("ConnectionViewerOutputObserver").append(suffix);
     241           27 :                 reg.template add_class_<T, typename T::base_type>(name, grp)
     242           18 :                    .template add_constructor<void (*)(const char*) >("")
     243           18 :                    .template add_constructor<void (*)(const char*, number) >("")
     244            9 :                    .set_construct_as_smart_pointer(true);
     245           27 :                 reg.add_class_to_group(name, "ConnectionViewerOutputObserver", tag);
     246              :         }
     247              : #ifdef UG_FOR_LUA
     248              :         {
     249              :                                 // PlotRefOutputObserver
     250              :                                 typedef PlotRefOutputObserver<TDomain, TAlgebra> T;
     251              : 
     252            9 :                                 string name = string("PlotRefOutputObserver").append(suffix);
     253           27 :                                 reg.template add_class_<T, typename T::base_type>(name, grp)
     254           18 :                                     .template add_constructor<void (*)(const char*) >("")
     255           18 :                                         .template add_constructor<void (*)(const char*, SmartPtr<typename T::vtk_type>) >("")
     256            9 :                                         .set_construct_as_smart_pointer(true);
     257           27 :                                 reg.add_class_to_group(name, "PlotRefOutputObserver", tag);
     258              :         }
     259              : #endif
     260              : 
     261              :         {
     262              :                         // IntegrationOutputObserver
     263              :                         typedef IntegrationOutputObserver<TDomain, TAlgebra> T;
     264              : 
     265            9 :                         string name = string("IntegrationOutputObserver").append(suffix);
     266           27 :                         reg.template add_class_<T, typename T::base_type>(name, grp)
     267           18 :                                     .template add_constructor<void (*)() >("")
     268           18 :                                          .add_method("add_integral_specs", &T::add_integral_specs)
     269            9 :                                         .set_construct_as_smart_pointer(true);
     270           27 :                                 reg.add_class_to_group(name, "IntegrationOutputObserver", tag);
     271              :                 }
     272              : 
     273              :         {
     274              :                 // ITimeIntegrator (virtual base class)
     275              :                 typedef ITimeIntegrator<TDomain, TAlgebra> T;
     276              :                 typedef TimeIntegratorSubject<TDomain, TAlgebra> TBase;
     277            9 :                 string name = string("ITimeIntegrator").append(suffix);
     278           27 :                 reg.template add_class_<T, TBase>(name, grp)
     279           27 :                                   .add_method("set_time_step", &T::set_time_step)
     280           36 :                                   .add_method("set_precision_bound", &T::set_precision_bound)
     281           36 :                                   .add_method("set_no_log_out", &T::set_no_log_out)
     282           27 :                                   .add_method("init", (void (T::*)(TGridFunction const&u) ) &T::init, "","")
     283           27 :                                   .add_method("attach_observer", &T::attach_observer)
     284           36 :                                   .add_method("attach_init_observer", &T::attach_init_observer)
     285           36 :                                   .add_method("attach_rewind_observer", &T::attach_rewind_observer)
     286           27 :                                   .add_method("attach_finalize_observer", &T::attach_finalize_observer);
     287           27 :                 reg.add_class_to_group(name, "ITimeIntegrator", tag);
     288              :         }
     289              : 
     290              :         {
     291              :                 // ILinearTimeIntegrator
     292              :                 typedef ITimeIntegrator<TDomain, TAlgebra> TBase;
     293              :                 typedef ILinearTimeIntegrator<TDomain, TAlgebra> T;
     294            9 :                 string name = string("ILinearTimeIntegrator").append(suffix);
     295           27 :                 reg.template add_class_<T, TBase>(name, grp)
     296           18 :                                           .add_method("set_linear_solver", &T::set_linear_solver);
     297           27 :                 reg.add_class_to_group(name, "ILinearTimeIntegrator", tag);
     298              :         }
     299              : 
     300              :         {
     301              :                 // LinearTimeIntegrator
     302              :                 // (e.g., implicit Euler for linear problem)
     303              :                 typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
     304              :                 typedef LinearTimeIntegrator<TDomain, TAlgebra> T;
     305              : 
     306            9 :                 string name = string("LinearTimeIntegrator").append(suffix);
     307           27 :                 reg.template add_class_<T,TBase>(name, grp)
     308           18 :                                   .template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
     309              :                                   // .template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TSolver>) >("")
     310           18 :                                   .add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
     311           18 :                                   .add_method("get_time_disc", &T::get_time_disc)
     312            9 :                                   .set_construct_as_smart_pointer(true);
     313           27 :                 reg.add_class_to_group(name, "LinearTimeIntegrator", tag);
     314              : 
     315              :         }
     316              : 
     317              :         {
     318              :                 // ConstStepLinearTimeIntegrator
     319              :                 // (e.g., implicit Euler for linear problem)
     320              :                 typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
     321              :                 typedef ConstStepLinearTimeIntegrator<TDomain, TAlgebra> T;
     322              :                 typedef typename T::linear_solver_type TSolver;
     323              : 
     324            9 :                 string name = string("ConstStepLinearTimeIntegrator").append(suffix);
     325           27 :                 reg.template add_class_<T,TBase>(name, grp)
     326           18 :                                           .template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
     327           18 :                                           .template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TSolver>) >("")
     328           18 :                                           .add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
     329           27 :                                           .add_method("get_time_disc", &T::get_time_disc)
     330           27 :                                           .add_method("set_num_steps", &T::set_num_steps)
     331            9 :                                           .set_construct_as_smart_pointer(true);
     332           27 :                 reg.add_class_to_group(name, "ConstStepLinearTimeIntegrator", tag);
     333              : 
     334              :         }
     335              : 
     336              :         {
     337              :                 // Adaptive LinearTimeIntegrator
     338              :                 typedef ILinearTimeIntegrator<TDomain, TAlgebra> TBase;
     339              :                 typedef TimeIntegratorLinearAdaptive<TDomain, TAlgebra> T;
     340              : 
     341            9 :                 string name = string("TimeIntegratorLinearAdaptive").append(suffix);
     342           27 :                 reg.template add_class_<T,TBase>(name, grp)
     343           18 :                                   .template add_constructor<void (*)(SmartPtr<TTimeDisc>, SmartPtr<TTimeDisc>) >("tdisc1, tdisc2")
     344           18 :                                   .add_method("apply", (void (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
     345           27 :                                   .add_method("get_time_disc", &T::get_time_disc)
     346           36 :                                   .add_method("set_tol", &T::set_tol)
     347           36 :                                   .add_method("set_time_step_max", &T::set_time_step_max)
     348           27 :                                   .add_method("set_time_step_min", &T::set_time_step_min)
     349            9 :                                   .set_construct_as_smart_pointer(true);
     350           27 :                 reg.add_class_to_group(name, "TimeIntegratorLinearAdaptive", tag);
     351              :         }
     352              : 
     353              :         {
     354              :                         // INonlinearTimeIntegrator
     355              :                         typedef ITimeIntegrator<TDomain, TAlgebra> TBase;
     356              :                         typedef INonlinearTimeIntegrator<TDomain, TAlgebra> T;
     357            9 :                         string name = string("INonlinearTimeIntegrator").append(suffix);
     358           27 :                         reg.template add_class_<T, TBase>(name, grp)
     359           27 :                                                   .add_method("set_solver", &T::set_solver)
     360           36 :                                                   .add_method("set_dt_min", &T::set_dt_min)
     361           36 :                                                   .add_method("set_dt_max", &T::set_dt_max)
     362           36 :                                                   .add_method("set_reduction_factor", &T::set_reduction_factor)
     363           27 :                                                   .add_method("set_increase_factor", &T::set_increase_factor);
     364           27 :                         reg.add_class_to_group(name, "INonlinearTimeIntegrator", tag);
     365              :         }
     366              : 
     367              :         /*{
     368              :                 // INonlinearTimeIntegratorWithBounds
     369              : 
     370              :                 typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
     371              :                 typedef INonlinearTimeIntegratorWithBounds<TDomain, TAlgebra> T;
     372              :                 string name = string("ITimeIntegratorWithBounds").append(suffix);
     373              :                 reg.add_class_<T, TBase>(name, grp)
     374              : 
     375              :                 reg.add_class_to_group(name, "ITimeIntegratorWithBounds", tag);
     376              :         }*/
     377              : 
     378              :         {
     379              :                 // SimpleTimeIntegrator
     380              :                 // (e.g., implicit Euler for linear problem)
     381              :                 typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
     382              :                 typedef DebugWritingObject<TAlgebra> TDebugBase;
     383              :                 typedef SimpleTimeIntegrator<TDomain, TAlgebra> T;
     384              :                 //typedef DomainDiscretization<TDomain, TAlgebra> TDomainDisc;
     385              :                 //typedef MultiStepTimeDiscretization<TAlgebra> TTimeDisc;
     386              : 
     387            9 :                 string name = string("SimpleTimeIntegrator").append(suffix);
     388           27 :                 reg.template add_class_<T,TBase,TDebugBase>(name, grp)
     389           18 :                                                           .template add_constructor<void (*)(SmartPtr<TTimeDisc>) >("")
     390           18 :                                                           .add_method("apply", (bool (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
     391            9 :                                                           .set_construct_as_smart_pointer(true);
     392           27 :                 reg.add_class_to_group(name, "SimpleTimeIntegrator", tag);
     393              :         }
     394              : 
     395              :         {
     396              :                         // LimexTimeIntegrator
     397              :                         typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
     398              :                         typedef DebugWritingObject<TAlgebra> TDebugBase;
     399              :                         typedef LimexTimeIntegrator<TDomain, TAlgebra> T;
     400              :                         
     401              :                         //typedef DomainDiscretization<TDomain, TAlgebra> TDomainDisc;
     402              : 
     403            9 :                         string name = string("LimexTimeIntegrator").append(suffix);
     404           27 :                         reg.template add_class_<T,TBase,TDebugBase>(name, grp)
     405              : 
     406              :                           //.template add_constructor<void (*)() >("")
     407              :                           //.ADD_CONSTRUCTOR( (SmartPtr<TDomainDisc>, int) ) ("Domain disc|number of steps (vector)")
     408           18 :                           .ADD_CONSTRUCTOR( (int) ) ("number of stages")
     409           27 :                           .add_method("set_tolerance", &T::set_tolerance)
     410           36 :                           .add_method("set_stepsize_safety_factor",&T::set_stepsize_safety_factor)
     411           36 :                           .add_method("set_stepsize_reduction_factor", &T::set_stepsize_reduction_factor)
     412           36 :                           .add_method("set_stepsize_greedy_order_factor", &T::set_stepsize_greedy_order_factor)
     413           36 :                           .add_method("set_start_step", &T::set_start_step)
     414           36 :                           .add_method("add_error_estimator", &T::add_error_estimator)
     415           27 :                           .add_method("add_stage", (void (T::*)(size_t, size_t,  SmartPtr<typename T::domain_discretization_type>, SmartPtr<typename T::solver_type>) ) &T::add_stage)
     416           18 :                           .add_method("add_stage", (void (T::*)(size_t, SmartPtr<typename T::solver_type>, SmartPtr<typename T::domain_discretization_type>) ) &T::add_stage)
     417           18 :                           .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)
     418              :                          // .add_method("set_debug", &T::set_debug)
     419           27 :                           .add_method("set_debug_for_timestepper", &T::set_debug_for_timestepper)
     420           36 :                           .add_method("has_time_derivative", &T::has_time_derivative)
     421           36 :                           .add_method("get_time_derivative", &T::get_time_derivative)
     422           36 :                           .add_method("set_time_derivative", &T::set_time_derivative)
     423           36 :                           .add_method("enable_matrix_cache", &T::enable_matrix_cache)
     424           36 :                           .add_method("disable_matrix_cache", &T::disable_matrix_cache)
     425              :                          // .add_method("enable_linear_mode", &T::enable_linear_mode)
     426              :                          // .add_method("disable_linear_mode", &T::disable_linear_mode)
     427           36 :                           .add_method("select_cost_strategy", &T::select_cost_strategy)
     428           36 :                           .add_method("set_max_reductions", &T::set_max_reductions)
     429           36 :                           .add_method("set_asymptotic_order", &T::set_asymptotic_order)
     430           36 :                           .add_method("set_space", &T::set_space)
     431           27 :                           .add_method("apply", (bool (T::*)(SmartPtr<TGridFunction> u, number time, ConstSmartPtr<TGridFunction> u0, number time0) ) &T::apply, "","")
     432           27 :                           .add_method("interrupt", &T::interrupt, "", "", "interrupt execution of apply()")
     433           36 :                           .add_method("set_conservative", &T::set_conservative)
     434           27 :                           .add_method("config_string", &T::config_string)
     435            9 :                           .set_construct_as_smart_pointer(true);
     436              : 
     437           27 :                         reg.add_class_to_group(name, "LimexTimeIntegrator", tag);
     438              :         }
     439              : 
     440              :         {
     441              :                 // DiscontinuityIntegrator
     442              : 
     443              :                 typedef DiscontinuityIntegrator<TDomain, TAlgebra> T;
     444              :                 typedef INonlinearTimeIntegrator<TDomain, TAlgebra> TBase;
     445              :                 // typedef typename T::base_type TBase;
     446              : 
     447            9 :                 string name = string("DiscontinuityIntegrator").append(suffix);
     448           27 :                 reg.template add_class_<T,TBase>(name, grp)
     449           18 :                         .template add_constructor<void (*)(SmartPtr<TBase>) >("")
     450           27 :                         .add_method("apply", &T::apply)
     451           27 :                         .add_method("insert_points", &T::insert_points)
     452            9 :                         .set_construct_as_smart_pointer(true);
     453           27 :                 reg.add_class_to_group(name, "DiscontinuityIntegrator", tag);
     454              :         }
     455              : 
     456            9 : }
     457              : 
     458              : /**
     459              :  * Function called for the registration of Domain dependent parts
     460              :  * of the plugin. All Functions and Classes depending on the Domain
     461              :  * are to be placed here when registering. The method is called for all
     462              :  * available Domain types, based on the current build options.
     463              :  *
     464              :  * @param reg                           registry
     465              :  * @param parentGroup           group for sorting of functionality
     466              :  */
     467              : template <typename TDomain>
     468              : static void Domain(Registry& reg, string grp)
     469              : {
     470              : //      useful defines
     471              :         string suffix = GetDomainSuffix<TDomain>();
     472              :         string tag = GetDomainTag<TDomain>();
     473              : 
     474              : }
     475              : 
     476              : /**
     477              :  * Function called for the registration of Dimension dependent parts
     478              :  * of the plugin. All Functions and Classes depending on the Dimension
     479              :  * are to be placed here when registering. The method is called for all
     480              :  * available Dimension types, based on the current build options.
     481              :  *
     482              :  * @param reg                           registry
     483              :  * @param parentGroup           group for sorting of functionality
     484              :  */
     485              : template <int dim>
     486              : static void Dimension(Registry& reg, string grp)
     487              : {
     488              : //      useful defines
     489              :         string suffix = GetDimensionSuffix<dim>();
     490              :         string tag = GetDimensionTag<dim>();
     491              : 
     492              : }
     493              : 
     494              : /**
     495              :  * Function called for the registration of Algebra dependent parts
     496              :  * of the plugin. All Functions and Classes depending on Algebra
     497              :  * are to be placed here when registering. The method is called for all
     498              :  * available Algebra types, based on the current build options.
     499              :  *
     500              :  * @param reg                           registry
     501              :  * @param parentGroup           group for sorting of functionality
     502              :  */
     503              : template <typename TAlgebra, typename TRegistry=ug::bridge::Registry>
     504            3 : static void Algebra(TRegistry& reg, string parentGroup)
     505              : {
     506              : 
     507              :         //      typedefs for Vector and Matrix
     508              :         typedef typename TAlgebra::vector_type vector_type;
     509              :         typedef typename TAlgebra::matrix_type matrix_type;
     510              : 
     511              :         //      useful defines
     512            3 :         string suffix = GetAlgebraSuffix<TAlgebra>();
     513            3 :         string tag = GetAlgebraTag<TAlgebra>();
     514              : 
     515              : /*
     516              :         {
     517              :                 // IErrorEvaluator (abstract base class)
     518              :                 typedef IBanachSpace<vector_type> T;
     519              : 
     520              :                 string name = string("IBanachSpace").append(suffix);
     521              :                 reg.add_class_<T>(name, parentGroup)
     522              :                                                         .add_method("norm", &T::norm)
     523              :                                                         .add_method("distance", &T::distance);
     524              :                 reg.add_class_to_group(name, "IBanachSpace", tag);
     525              :         }
     526              : */
     527              :         //      LinearlyImplicitEuler
     528              :         {
     529            3 :                 std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     530              :                 typedef ITimeDiscretization<TAlgebra> TBase;
     531              :                 typedef LinearImplicitEuler<TAlgebra> T;
     532            3 :                 string name = string("LinearImplicitEuler").append(suffix);
     533            9 :                 reg.template add_class_<T, TBase>(name, grp)
     534            6 :                                                                 .template add_constructor<void (*)(SmartPtr<IDomainDiscretization<TAlgebra> >)>("LinearImplicitEuler")
     535            9 :                                                                 .add_method("set_gamma_disc", &T::set_gamma_disc)
     536           12 :                                                                 .add_method("enable_matrix_cache", &T::enable_matrix_cache)
     537            9 :                                                                 .add_method("disable_matrix_cache", &T::disable_matrix_cache)
     538            3 :                                                                 .set_construct_as_smart_pointer(true);
     539            9 :                 reg.add_class_to_group(name, "LinearImplicitEuler", tag);
     540              :         }
     541              : 
     542              :         //      Time extrapolation
     543              :                 {
     544            3 :                         std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     545              :                         typedef typename TAlgebra::vector_type VT;
     546              :                         typedef ISubDiagErrorEst<VT> ET;
     547              :                         typedef AitkenNevilleTimex<VT> T;
     548            3 :                         string name = string("AitkenNevilleTimex").append(suffix);
     549            9 :                         reg.template add_class_<T>(name, grp)
     550            6 :                                                 .ADD_CONSTRUCTOR( (std::vector<size_t> nsteps) ) ("number of steps (vector)")
     551            6 :                                                 .ADD_CONSTRUCTOR( (std::vector<size_t> nsteps, SmartPtr<ET> ) ) ("number of steps (vector)")
     552            9 :                                                 .add_method("set_solution", &T::set_solution)
     553           12 :                                                 .add_method("get_solution", &T::get_solution)
     554            9 :                                                 .add_method("apply", (void (T::*)()) &T::apply)
     555            6 :                                                 .add_method("apply", (void (T::*)(size_t, bool)) &T::apply)
     556              :                                                 //.add_method("get_error_estimate", &T::get_error_estimate())
     557              :                                                 //.add_method("get_error_estimate", &T::get_error_estimate(int))
     558            6 :                                                 .add_method("get_error_estimate",  (double (T::*)(void)) &T::get_error_estimate, "","")
     559            6 :                                             .add_method("get_error_estimate",  (double (T::*)(int)) &T::get_error_estimate, "","")
     560            6 :                                                 .add_method("set_error_estimate", &T::set_error_estimate)
     561            3 :                                                 .set_construct_as_smart_pointer(true);
     562            9 :                         reg.add_class_to_group(name, "AitkenNevilleTimex", tag);
     563              :                 }
     564              : 
     565              :                 // interface for error estimator for time extrapolation
     566              :                 {
     567            3 :                                 std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     568              :                                 typedef ISubDiagErrorEst<vector_type> T;
     569            3 :                                 string name = string("ISubDiagErrorEst").append(suffix);
     570            9 :                                 reg.template add_class_<T>(name, grp)
     571            6 :                                    .add_method("config_string", &T::config_string);
     572            9 :                                 reg.add_class_to_group(name, "ISubDiagErrorEst", tag);
     573              :                 }
     574              : 
     575              :                 // L2 norm error estimator for time extrapolation
     576              :                 {
     577            3 :                         std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     578              :                         typedef Norm2Estimator<vector_type> T;
     579              :                         typedef ISubDiagErrorEst<vector_type> TBase;
     580            3 :                         string name = string("Norm2Estimator").append(suffix);
     581            9 :                         reg.template add_class_<T, TBase>(name, grp)
     582            6 :                            .ADD_CONSTRUCTOR( (void) ) ("")
     583            9 :                            .add_method("set_stride", &T::set_stride)
     584            9 :                            .add_method("set_offset", &T::set_offset)
     585            3 :                            .set_construct_as_smart_pointer(true);
     586            9 :                         reg.add_class_to_group(name, "Norm2Estimator", tag);
     587              :                 }
     588              : 
     589              :                 // Inf norm error estimator for time extrapolation
     590              :                 {
     591            3 :                         std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     592              :                         typedef NormInfEstimator<vector_type> T;
     593              :                         typedef ISubDiagErrorEst<vector_type> TBase;
     594            3 :                         string name = string("NormInfEstimator").append(suffix);
     595            9 :                         reg.template add_class_<T,TBase>(name, grp)
     596            6 :                            .ADD_CONSTRUCTOR( (void) ) ("")
     597            9 :                            .add_method("set_stride", &T::set_stride)
     598            9 :                            .add_method("set_offset", &T::set_offset)
     599            3 :                            .set_construct_as_smart_pointer(true);
     600            9 :                         reg.add_class_to_group(name, "NormInfEstimator", tag);
     601              :                 }
     602              : 
     603              :                 // Rel norm error estimator for time extrapolation
     604              :                 {
     605            3 :                         std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     606              :                         typedef NormRelEstimator<vector_type> T;
     607              :                         typedef ISubDiagErrorEst<vector_type> TBase;
     608            3 :                         string name = string("NormRelEstimator").append(suffix);
     609            9 :                         reg.template add_class_<T,TBase>(name, grp)
     610            6 :                            .ADD_CONSTRUCTOR( (void) ) ("")
     611            3 :                            .set_construct_as_smart_pointer(true);
     612            9 :                         reg.add_class_to_group(name, "NormRelEstimator", tag);
     613              :                 }
     614              : 
     615              :                 // LimexNewton
     616              :                 {
     617              :                         std::string grp = parentGroup;
     618            3 :                         grp.append("/Discretization/Nonlinear");
     619              :                         typedef LimexNewtonSolver<TAlgebra> T;
     620              :                         typedef IOperatorInverse<vector_type> TBase;
     621            3 :                         string name = string("LimexNewtonSolver").append(suffix);
     622            9 :                         reg.template add_class_<T, TBase>(name, grp)
     623            3 :                                 .add_constructor()
     624            6 :                                 .template add_constructor<void (*)(SmartPtr<IOperator<vector_type> >)>("Operator")
     625            6 :                                 .template add_constructor<void (*)(SmartPtr<IAssemble<TAlgebra> >)>("AssemblingRoutine")
     626            9 :                                 .add_method("set_linear_solver", &T::set_linear_solver, "", "linear solver")
     627           12 :                                 .add_method("init", &T::init, "success", "op")
     628           12 :                                 .add_method("prepare", &T::prepare, "success", "u")
     629           12 :                                 .add_method("apply", &T::apply, "success", "u")
     630           12 :                                 .add_method("linear_solver_rate", &T::linear_solver_rate)
     631           12 :                                 .add_method("linear_solver_steps", &T::linear_solver_steps)
     632            9 :                                 .add_method("config_string", &T::config_string)
     633            3 :                                 .set_construct_as_smart_pointer(true);
     634            9 :                         reg.add_class_to_group(name, "LimexNewtonSolver", tag);
     635              :                 }
     636              : 
     637            3 : }
     638              : 
     639              : /**
     640              :  * Function called for the registration of Domain and Algebra independent parts
     641              :  * of the plugin. All Functions and Classes not depending on Domain and Algebra
     642              :  * are to be placed here when registering.
     643              :  *
     644              :  * @param reg                           registry
     645              :  * @param parentGroup           group for sorting of functionality
     646              :  */
     647              : template <typename TRegistry=ug::bridge::Registry>
     648            1 : static void Common(TRegistry& reg, string parentGroup)
     649              : {
     650              : 
     651            1 :         std::string grp = parentGroup; grp.append("/Discretization/TimeDisc");
     652              :         typedef ILimexCostStrategy TBase;
     653            3 :         reg.template add_class_<TBase>(std::string("ILimexCostStrategy"), grp);
     654              : 
     655              :         {
     656              :                 typedef LimexDefaultCost T;
     657            1 :                 string name = string("LimexDefaultCost");
     658            3 :                 reg.template add_class_<T, TBase>(name, grp)
     659            1 :                    .add_constructor()
     660            1 :                    .set_construct_as_smart_pointer(true);
     661              :         }
     662              : 
     663              :         {
     664              :                         typedef LimexNonlinearCost T;
     665            1 :                         string name = string("LimexNonlinearCost");
     666            3 :                         reg.template add_class_<T, TBase>(name, grp)
     667            1 :                            .add_constructor()
     668            1 :                            .set_construct_as_smart_pointer(true);
     669              :         }
     670              : 
     671              : 
     672              :         // reg.add_function("BesselJ0", &BesselJ0, grp); => Poroelasticity plugin
     673              :         // reg.add_function("BesselJ1", &BesselJ1, grp);
     674            1 : }
     675              : 
     676              : }; // end Functionality
     677              : 
     678              : // end group limex
     679              : /// \}
     680              : 
     681              : }// end of namespace Sample
     682              : 
     683              : 
     684              : /**
     685              :  * This function is called when the plugin is loaded.
     686              :  */
     687              : 
     688              : #ifndef UG_USE_PYBIND11
     689              : 
     690              : extern "C" void
     691            1 : InitUGPlugin_Limex(Registry* reg, string grp)
     692              : {
     693            1 :         grp.append("/Limex");
     694              :         typedef Limex::Functionality Functionality;
     695              : 
     696              :         try{
     697            2 :                 RegisterCommon<Functionality>(*reg,grp);
     698              :         //      RegisterDimensionDependent<Functionality>(*reg,grp);
     699              :         //      RegisterDomainDependent<Functionality>(*reg,grp);
     700            2 :                 RegisterAlgebraDependent<Functionality>(*reg,grp);
     701            1 :                 RegisterDomainAlgebraDependent<Functionality>(*reg,grp);
     702              :         }
     703            0 :         UG_REGISTRY_CATCH_THROW(grp);
     704            1 : }
     705              : #else
     706              : template <typename TRegistry=ug::bridge::Registry>
     707              : void InitUGPlugin_Limex_(TRegistry* reg, string grp)
     708              : {
     709              :         grp.append("/Limex");
     710              :         typedef Limex::Functionality Functionality;
     711              : 
     712              :         try{
     713              :                 RegisterCommon<Functionality>(*reg,grp);
     714              :                 // RegisterDimensionDependent<Functionality>(*reg,grp);
     715              :                 // RegisterDomainDependent<Functionality, TRegistry>(*reg,grp);
     716              :                 RegisterAlgebraDependent<Functionality, TRegistry>(*reg,grp);
     717              :                 RegisterDomainAlgebraDependent<Functionality, TRegistry>(*reg,grp);
     718              :         }
     719              :         UG_REGISTRY_CATCH_THROW(grp);
     720              : }
     721              : 
     722              : extern "C" void
     723              : InitUGPlugin_Limex(ug::bridge::Registry* reg, string grp)
     724              : { InitUGPlugin_Limex_<ug::bridge::Registry>(reg, grp); }
     725              : 
     726              : #endif
     727              : 
     728              : #ifdef UG_USE_PYBIND11
     729              : // Expose for pybind11.
     730              : namespace Limex{
     731              :         void InitUGPlugin(ug::pybind::Registry* reg, string grp)
     732              :         { InitUGPlugin_Limex_<ug::pybind::Registry>(reg, grp); }
     733              : }
     734              : #endif
     735              : 
     736              : 
     737              : extern "C" UG_API void
     738            0 : FinalizeUGPlugin_Limex()
     739              : {
     740            0 : }
     741              : 
     742              : }//     end of namespace ug
        

Generated by: LCOV version 2.0-1