LCOV - code coverage report
Current view: top level - ugbase/bridge/disc_bridges - user_data_bridge.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 96.1 % 280 269
Test Date: 2026-06-01 23:54:59 Functions: 63.2 % 76 48

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) 2010-2015:  G-CSC, Goethe University Frankfurt
       3              :  * Author: Andreas Vogel
       4              :  * 
       5              :  * This file is part of UG4.
       6              :  * 
       7              :  * UG4 is free software: you can redistribute it and/or modify it under the
       8              :  * terms of the GNU Lesser General Public License version 3 (as published by the
       9              :  * Free Software Foundation) with the following additional attribution
      10              :  * requirements (according to LGPL/GPL v3 §7):
      11              :  * 
      12              :  * (1) The following notice must be displayed in the Appropriate Legal Notices
      13              :  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
      14              :  * 
      15              :  * (2) The following notice must be displayed at a prominent place in the
      16              :  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
      17              :  * 
      18              :  * (3) The following bibliography is recommended for citation and must be
      19              :  * preserved in all covered files:
      20              :  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
      21              :  *   parallel geometric multigrid solver on hierarchically distributed grids.
      22              :  *   Computing and visualization in science 16, 4 (2013), 151-164"
      23              :  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
      24              :  *   flexible software system for simulating pde based models on high performance
      25              :  *   computers. Computing and visualization in science 16, 4 (2013), 165-179"
      26              :  * 
      27              :  * This program is distributed in the hope that it will be useful,
      28              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      29              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
      30              :  * GNU Lesser General Public License for more details.
      31              :  */
      32              : 
      33              : #include <iostream>
      34              : #include <sstream>
      35              : #include <cmath>
      36              : 
      37              : // include bridge
      38              : #include "bridge/bridge.h"
      39              : #include "bridge/util.h"
      40              : #include "bridge/util_domain_dependent.h"
      41              : 
      42              : // common
      43              : #include "common/common.h"
      44              : 
      45              : // lib disc
      46              : #include "lib_disc/spatial_disc/user_data/const_user_data.h"
      47              : #include "lib_disc/spatial_disc/user_data/std_glob_pos_data.h"
      48              : #include "lib_disc/spatial_disc/user_data/common_user_data/common_user_data.h"
      49              : #include "lib_disc/spatial_disc/user_data/common_user_data/raster_user_data.h"
      50              : 
      51              : #include "lib_disc/spatial_disc/user_data/linker/linker.h"
      52              : #include "lib_disc/spatial_disc/user_data/linker/scale_add_linker.h"
      53              : #include "lib_disc/spatial_disc/user_data/linker/inverse_linker.h"
      54              : #include "lib_disc/spatial_disc/user_data/linker/darcy_velocity_linker.h"
      55              : #include "lib_disc/spatial_disc/user_data/linker/bingham_viscosity_linker.h"
      56              : #include "lib_disc/spatial_disc/user_data/linker/projection_linker.h"
      57              : #include "lib_disc/spatial_disc/user_data/linker/adapter.h"
      58              : #include "lib_disc/spatial_disc/user_data/linker/interval_linker.h"
      59              : #include "lib_disc/spatial_disc/user_data/user_function.h"
      60              : 
      61              : 
      62              : using namespace std;
      63              : 
      64              : namespace ug{
      65              : 
      66              : template <class TData, int dim>
      67            0 : void PrintUserDataValue(const UserData<TData, dim>& ud, const MathVector<dim>& globIP,
      68              :                                                 number time, int si)
      69              : {
      70            0 :         TData data;
      71            0 :         ud(data, globIP, time, si);
      72            0 :         UG_LOG(data);
      73            0 : }
      74              : 
      75              : template <class TData, int dim>
      76            0 : void PrintCondUserDataValue(const UserData<TData, dim, bool>& ud, const MathVector<dim>& globIP,
      77              :                                                         number time, int si)
      78              : {
      79            0 :         TData data;
      80            0 :         bool ret = ud(data, globIP, time, si);
      81            0 :         UG_LOG(ret << ", " << data);
      82            0 : }
      83              : 
      84              : 
      85              : namespace bridge{
      86              : 
      87              : /**
      88              :  * \defgroup userdata_bridge User Data Bridge
      89              :  * \ingroup disc_bridge
      90              :  * \{
      91              :  */
      92              : 
      93              : template <typename TData, int dim, typename TTraits=user_data_traits<TData> >
      94           14 : void RegisterUserDataTypeA(Registry& reg, string grp)
      95              : {
      96           14 :         string dimSuffix = GetDimensionSuffix<dim>();
      97           14 :         string dimTag = GetDimensionTag<dim>();
      98              : 
      99              :         string type = TTraits::name();
     100              : 
     101              : //      User"Type"
     102              : //      NOTE: For better readability this class is named User"Type"
     103              : //            in vrl and lua. E.g. UserNumber, UserVector, ...
     104              :         {
     105              :                 typedef UserData<TData, dim> T;
     106              :                 typedef UserDataInfo TBase1;
     107           16 :                 string name = string("User").append(type).append(dimSuffix);
     108           42 :                 reg.add_class_<T,TBase1>(name, grp)
     109           42 :                         .add_method("get_dim", &T::get_dim)
     110           42 :                         .add_method("type", &T::type);
     111           56 :                 reg.add_class_to_group(name, string("User").append(type), dimTag);
     112           42 :                 reg.add_function("PrintUserDataValue", &PrintUserDataValue<TData, dim>,
     113              :                                                  grp, "", "userData#position#time#subsetIndex",
     114              :                                                  "Prints the value of the given user data at the given global position at the given time on the given subset.");
     115              :         }
     116              : 
     117              : //      CondUser"Type"
     118              : //      NOTE: For better readability this class is named CondUser"Type"
     119              : //                in vrl and lua. E.g. CondUserNumber, CondUserVector, ...
     120              :         {
     121              :                 typedef UserData<TData, dim, bool> T;
     122              :                 typedef UserDataInfo TBase1;
     123           14 :                 string name = string("CondUser").append(type).append(dimSuffix);
     124           42 :                 reg.add_class_<T,TBase1>(name, grp);
     125           56 :                 reg.add_class_to_group(name, string("CondUser").append(type), dimTag);
     126           42 :                 reg.add_function("PrintUserDataValue", &PrintCondUserDataValue<TData, dim>,
     127              :                                                  grp, "", "userData#position#time#subsetIndex",
     128              :                                                  "Prints the value of the given user data at the given global position at the given time on the given subset.");
     129              :         }
     130              : 
     131              : //      CplUser"Type"
     132              :         {
     133              :                 typedef CplUserData<TData, dim> T;
     134              :                 typedef UserData<TData,dim> TBase1;
     135           14 :                 string name = string("CplUser").append(type).append(dimSuffix);
     136           42 :                 reg.add_class_<T,TBase1>(name, grp)
     137           42 :                         .add_method("get_dim", &T::get_dim)
     138           42 :                         .add_method("type", &T::type);
     139           56 :                 reg.add_class_to_group(name, string("CplUser").append(type), dimTag);
     140              :         }
     141              : 
     142              : //      CondCplUser"Type"
     143              :         {
     144              :                 typedef CplUserData<TData, dim, bool> T;
     145              :                 typedef UserData<TData,dim,bool> TBase1;
     146           14 :                 string name = string("CondCplUser").append(type).append(dimSuffix);
     147           42 :                 reg.add_class_<T,TBase1>(name, grp);
     148           56 :                 reg.add_class_to_group(name, string("CondCplUser").append(type), dimTag);
     149              :         }
     150              : 
     151              : //      DependentUserData"Type"
     152              :         {
     153              :                 typedef DependentUserData<TData, dim> T;
     154              :                 typedef CplUserData<TData, dim> TBase;
     155           14 :                 string name = string("DependentUserData").append(type).append(dimSuffix);
     156           42 :                 reg.add_class_<T, TBase >(name, grp);
     157           56 :                 reg.add_class_to_group(name, string("DependentUserData").append(type), dimTag);
     158              :         }
     159              : 
     160              : 
     161           14 : }
     162              : 
     163              : template <typename TData, int dim, typename TTraits=user_data_traits<TData> >
     164           12 : void RegisterUserDataTypeB(Registry& reg, string grp)
     165              : {
     166           12 :         string dimSuffix = GetDimensionSuffix<dim>();
     167           12 :         string dimTag = GetDimensionTag<dim>();
     168              : 
     169              :         string type = TTraits::name();
     170              : 
     171              :         //      ScaleAddLinker"Type"
     172              :         {
     173              :                         typedef ScaleAddLinker<TData, dim, number> T;
     174              :                         typedef DependentUserData<TData, dim> TBase;
     175           12 :                         string name = string("ScaleAddLinker").append(type).append(dimSuffix);
     176           36 :                         reg.add_class_<T, TBase>(name, grp)
     177           24 :                                 .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> > , SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     178           24 :                                 .add_method("add", static_cast<void (T::*)(number, SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     179           24 :                                 .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> > , number)>(&T::add))
     180           24 :                                 .add_method("add", static_cast<void (T::*)(number,number)>(&T::add))
     181           12 :                                 .add_constructor()
     182           24 :                                 .template add_constructor<void (*)(const ScaleAddLinker<TData, dim, number>&)>()
     183           12 :                                 .set_construct_as_smart_pointer(true);
     184           48 :                         reg.add_class_to_group(name, string("ScaleAddLinker").append(type), dimTag);
     185              :         }
     186              : 
     187           12 : }
     188              : 
     189              : template <typename TData, int dim, typename TTraits=user_data_traits<TData> >
     190           12 : void RegisterUserDataType(Registry& reg, string grp)
     191              : {
     192           24 :         RegisterUserDataTypeA<TData, dim, TTraits>(reg, grp);
     193           12 :         RegisterUserDataTypeB<TData, dim, TTraits>(reg, grp);
     194           12 : }
     195              : // end group userdata_bridge
     196              : /// \}
     197              : 
     198              : namespace UserDataBridge{
     199              : 
     200              : /// \addtogroup userdata_bridge
     201              : /// \{
     202              : 
     203              : /**
     204              :  * Class exporting the functionality. All functionality that is to
     205              :  * be used in scripts or visualization must be registered here.
     206              :  */
     207              : struct Functionality
     208              : {
     209              : 
     210              : /**
     211              :  * Function called for the registration of Dimension dependent parts.
     212              :  * All Functions and Classes depending on the Dimension
     213              :  * are to be placed here when registering. The method is called for all
     214              :  * available Dimension types, based on the current build options.
     215              :  *
     216              :  * @param reg                           registry
     217              :  * @param parentGroup           group for sorting of functionality
     218              :  */
     219              :         /*
     220              :         typedef std::tuple<number, number> MathPair;
     221              :                 typedef std::tuple<number, number, number> MathTriple;
     222              :         template <>
     223              :                 struct user_data_traits<MathPair>{static std::string name()       {return "Pair";}};*/
     224              : template <int dim>
     225            3 : static void Dimension(Registry& reg, string grp)
     226              : {
     227            3 :         string dimSuffix = GetDimensionSuffix<dim>();
     228            3 :         string dimTag = GetDimensionTag<dim>();
     229              : 
     230            6 :         RegisterUserDataType<number, dim>(reg, grp);
     231            6 :         RegisterUserDataType<MathVector<dim>, dim>(reg, grp);
     232            6 :         RegisterUserDataType<MathMatrix<dim,dim>, dim>(reg, grp);
     233            5 :         RegisterUserDataType<MathTensor<4,dim>, dim>(reg, grp);
     234              : 
     235              : 
     236              : 
     237              : 
     238              :         // RegisterUserDataType<MathPair, dim>(reg, grp);
     239              : 
     240              :         if (dim!=2)
     241              :         {
     242              :                 // Register pair (corresponds to vector for dim==2)
     243            2 :                 struct pair_traits {static std::string name()   {return "Pair";}};
     244            2 :                 RegisterUserDataTypeA<MathVector<2>, dim, pair_traits>(reg, grp); // Pair
     245              :         }
     246              : /*
     247              :         if (dim!=3)
     248              :         {
     249              :                 // Register triple (corresponds to vector for dim==3)
     250              :                 struct triple_traits {static std::string name() {return "Triple";}};
     251              :                 RegisterUserDataType<MathVector<3>, dim, triple_traits, false>(reg, grp);
     252              :         }
     253              : 
     254              : */
     255              : 
     256              : //      ConstUserNumber
     257              :         {
     258              :                 typedef ConstUserNumber<dim> T;
     259              :                 typedef CplUserData<number, dim> TBase;
     260            3 :                 string name = string("ConstUserNumber").append(dimSuffix);
     261            9 :                 reg.add_class_<T, TBase>(name, grp)
     262            3 :                         .add_constructor()
     263            6 :                         .template add_constructor<void (*)(number)>("Value")
     264            9 :                         .add_method("set", &T::set, "", "Value")
     265           12 :                         .add_method("print", &T::print)
     266            9 :                         .add_method("get", &T::get)
     267            3 :                         .set_construct_as_smart_pointer(true);
     268            9 :                 reg.add_class_to_group(name, "ConstUserNumber", dimTag);
     269              :         }
     270              : 
     271              : //      ConstUserVector
     272              :         {
     273              :                 typedef ConstUserVector<dim> T;
     274              :                 typedef CplUserData<MathVector<dim>, dim> TBase;
     275            3 :                 string name = string("ConstUserVector").append(dimSuffix);
     276            9 :                 reg.add_class_<T, TBase>(name, grp)
     277            3 :                         .add_constructor()
     278            6 :                         .template add_constructor<void (*)(number)>("Values")
     279            6 :                         .template add_constructor<void (*)(const std::vector<number>&)>("Values")
     280            9 :                         .add_method("set_all_entries", &T::set_all_entries)
     281           12 :                         .add_method("set_entry", &T::set_entry)
     282            9 :                         .add_method("print", &T::print)
     283            3 :                         .set_construct_as_smart_pointer(true);
     284            9 :                 reg.add_class_to_group(name, "ConstUserVector", dimTag);
     285              :         }
     286              : 
     287              : //      ConstUserMatrix
     288              :         {
     289              :                 typedef ConstUserMatrix<dim> T;
     290              :                 typedef CplUserData<MathMatrix<dim, dim>, dim> TBase;
     291            3 :                 string name = string("ConstUserMatrix").append(dimSuffix);
     292            9 :                 reg.add_class_<T, TBase>(name, grp)
     293            3 :                         .add_constructor()
     294            6 :                         .template add_constructor<void (*)(number)>("Diagonal Value")
     295            9 :                         .add_method("set_diag_tensor", &T::set_diag_tensor)
     296           12 :                         .add_method("set_all_entries", &T::set_all_entries)
     297           12 :                         .add_method("set_entry", &T::set_entry)
     298            9 :                         .add_method("print", &T::print)
     299            3 :                         .set_construct_as_smart_pointer(true);
     300            9 :                 reg.add_class_to_group(name, "ConstUserMatrix", dimTag);
     301              :         }
     302              : 
     303              :         // UserVectorEntryAdapter
     304              :         {
     305            3 :                 string name = string("UserVectorEntryAdapter").append(dimSuffix);
     306              :                 typedef UserVectorEntryAdapter<dim> T;
     307              :                 typedef CplUserData<number, dim> TCplData;
     308              :                 typedef typename T::encapsulated_type TEncaps;
     309              : 
     310            9 :                 reg.template add_class_<T, TCplData>(name, grp)
     311            6 :                    .template add_constructor<void (*)() >("")
     312            6 :                         .add_method("set_vector", &T::set_vector)
     313            3 :                         .set_construct_as_smart_pointer(true);
     314              : 
     315            9 :                 reg.add_class_to_group(name, "UserVectorEntryAdapter", dimTag);
     316              : 
     317              :         }
     318              : 
     319              : 
     320              : //      ScaleAddLinkerMatrixVector
     321              :         {
     322              :                 typedef MathVector<dim> TData;
     323              :                 typedef MathMatrix<dim,dim> TDataScale;
     324              :                 typedef ScaleAddLinker<TData, dim, TDataScale> T;
     325              :                 typedef DependentUserData<TData, dim> TBase;
     326            3 :                 string name = string("ScaleAddLinkerVectorMatrix").append(dimSuffix);
     327            9 :                 reg.add_class_<T, TBase>(name, grp)
     328            6 :                         .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<TDataScale,dim> > , SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     329            6 :                         .add_method("add", static_cast<void (T::*)(number , SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     330            6 :                         .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<TDataScale,dim> > , number)>(&T::add))
     331            6 :                         .add_method("add", static_cast<void (T::*)(number,number)>(&T::add))
     332            3 :                         .add_constructor()
     333            6 :                         .template add_constructor<void (*)(const ScaleAddLinker<TData, dim, TDataScale>&)>()
     334            3 :                         .set_construct_as_smart_pointer(true);
     335            9 :                 reg.add_class_to_group(name, string("ScaleAddLinkerVectorMatrix"), dimTag);
     336              :         }
     337              : 
     338              : //      ScaleAddLinkerVectorVector
     339              :         {
     340              :                 typedef MathVector<dim> TData;
     341              :                 typedef MathVector<dim> TDataScale;
     342              :                 typedef ScaleAddLinker<TData, dim, TDataScale, number> T;
     343              :                 typedef DependentUserData<number, dim> TBase;
     344            3 :                 string name = string("ScaleAddLinkerVectorVector").append(dimSuffix);
     345            9 :                 reg.add_class_<T, TBase>(name, grp)
     346            6 :                         .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<TDataScale,dim> > , SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     347            6 :                         .add_method("add", static_cast<void (T::*)(number , SmartPtr<CplUserData<TData,dim> >)>(&T::add))
     348            6 :                         .add_method("add", static_cast<void (T::*)(SmartPtr<CplUserData<TDataScale,dim> > , number)>(&T::add))
     349            6 :                         .add_method("add", static_cast<void (T::*)(number,number)>(&T::add))
     350            3 :                         .add_constructor()
     351            6 :                         .template add_constructor<void (*)(const ScaleAddLinker<TData, dim, TDataScale,number>&)>()
     352            3 :                         .set_construct_as_smart_pointer(true);
     353            9 :                 reg.add_class_to_group(name, string("ScaleAddLinkerVectorVector"), dimTag);
     354              :         }
     355              : 
     356              : //      DarcyVelocityLinker
     357              :         {
     358              :                 typedef DarcyVelocityLinker<dim> T;
     359              :                 typedef DependentUserData<MathVector<dim>, dim> TBase;
     360            3 :                 string name = string("DarcyVelocityLinker").append(dimSuffix);
     361            9 :                 reg.add_class_<T, TBase>(name, grp)
     362            9 :                         .add_method("set_gravity", &T::set_gravity)
     363            9 :                         .add_method("set_permeability", static_cast<void (T::*)(number)>(&T::set_permeability))
     364            6 :                         .add_method("set_permeability", static_cast<void (T::*)(SmartPtr<CplUserData<MathMatrix<dim,dim>,dim> >)>(&T::set_permeability))
     365              : #ifdef UG_FOR_LUA
     366            6 :                         .add_method("set_permeability", static_cast<void (T::*)(const char* fctName)>(&T::set_permeability))
     367            6 :                         .add_method("set_permeability", static_cast<void (T::*)(LuaFunctionHandle fct)>(&T::set_permeability))
     368              : #endif
     369            9 :                         .add_method("set_pressure_gradient", &T::set_pressure_gradient)
     370            9 :                         .add_method("set_viscosity", static_cast<void (T::*)(number)>(&T::set_viscosity))
     371            6 :                         .add_method("set_viscosity", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> >)>(&T::set_viscosity))
     372            6 :                         .add_method("set_density", static_cast<void (T::*)(number)>(&T::set_density))
     373            6 :                         .add_method("set_density", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> >)>(&T::set_density))
     374            9 :                         .add_method("set_derivative_mask",  &T::set_derivative_mask)
     375            6 :                         .add_constructor()
     376            3 :                         .set_construct_as_smart_pointer(true);
     377            9 :                 reg.add_class_to_group(name, "DarcyVelocityLinker", dimTag);
     378              :         }
     379              : 
     380              : //      BinghamViscosityLinker
     381              :         {
     382              :                 typedef BinghamViscosityLinker<dim> T;
     383              :                 typedef DependentUserData<number, dim> TBase;
     384            3 :                 string name = string("BinghamViscosityLinker").append(dimSuffix);
     385            9 :                 reg.add_class_<T, TBase>(name, grp)
     386            9 :                         .add_method("set_velocity_gradient", &T::set_velocity_gradient)
     387            9 :                         .add_method("set_yield_stress", static_cast<void (T::*)(number)>(&T::set_yield_stress))
     388            6 :                         .add_method("set_yield_stress", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> >)>(&T::set_yield_stress))
     389            6 :                         .add_method("set_viscosity", static_cast<void (T::*)(number)>(&T::set_viscosity))
     390            6 :                         .add_method("set_viscosity", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> >)>(&T::set_viscosity))
     391            6 :                         .add_method("set_density", static_cast<void (T::*)(number)>(&T::set_density))
     392            6 :                         .add_method("set_density", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> >)>(&T::set_density))
     393            3 :                         .add_constructor()
     394            3 :                         .set_construct_as_smart_pointer(true);
     395            9 :                 reg.add_class_to_group(name, "BinghamViscosityLinker", dimTag);
     396              :         }
     397              : 
     398              : //      InverseLinker"Type"
     399              :         {
     400              :                 typedef InverseLinker<dim> T;
     401              :                 typedef DependentUserData<number,dim> TBase;
     402              : 
     403            3 :                         string name = string("InverseLinker").append(dimSuffix);
     404            9 :                         reg.add_class_<T,TBase>(name, grp)
     405            6 :                         .add_method("divide", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> > , SmartPtr<CplUserData<number,dim> >)>(&T::divide))
     406            6 :                         .add_method("divide", static_cast<void (T::*)(number , SmartPtr<CplUserData<number,dim> >)>(&T::divide))
     407            6 :                         .add_method("divide", static_cast<void (T::*)(SmartPtr<CplUserData<number,dim> > , number)>(&T::divide))
     408            6 :                         .add_method("divide", static_cast<void (T::*)(number,number)>(&T::divide))
     409            3 :                         .add_constructor()
     410            6 :                         .template add_constructor<void (*)(const InverseLinker<dim>&)>()
     411            3 :                         .set_construct_as_smart_pointer(true);
     412            9 :                 reg.add_class_to_group(name, string("InverseLinker"), dimTag);
     413              : 
     414              :         }
     415              : 
     416              : //      ProjectionLinker
     417              :         {
     418              :                 typedef ProjectionLinker<dim> T;
     419              :                 typedef DependentUserData<MathVector<dim>, dim> TBase;
     420            3 :                 string name = string("ProjectionLinker").append(dimSuffix);
     421            9 :                 reg.add_class_<T, TBase>(name, grp)
     422            6 :                    .template add_constructor<void (*) (SmartPtr<CplUserData<MathVector<dim>, dim> >)>()
     423            3 :                    .set_construct_as_smart_pointer(true);
     424            9 :                 reg.add_class_to_group(name, "ProjectionLinker", dimTag);
     425              :         }
     426              : 
     427              : //      LognormalRandomField
     428              :         {
     429              :                 typedef ug::LognormalRandomField<MathMatrix<dim, dim>, dim> T;
     430              :                 typedef CplUserData<MathMatrix<dim, dim>, dim> TBase;
     431            3 :                 string name = string("LognormalRandomField").append(dimSuffix);;
     432            9 :                 reg.add_class_<T, TBase>(name, grp)
     433              :                         //.add_constructor()
     434            6 :                         .template add_constructor<void (*)()>("LognormalRandomField")
     435            6 :                         .template add_constructor<void (*)(size_t N, double mean_f, double sigma_f, double sigma)>("LognormalRandomField", "N#mean_f#sigma_f#sigma")
     436            9 :                         .add_method("set_config",  &T::set_config, "", "N#mean_f#sigma_f#sigma")
     437            9 :                         .add_method("set_no_exp",  &T::set_no_exp, "", "", "use this for display of log of the field")
     438            3 :                         .set_construct_as_smart_pointer(true);
     439            9 :                 reg.add_class_to_group(name, string("LognormalRandomField"), dimTag);
     440              :         }
     441              : 
     442              : //      Inverse-distance-weighting interpolation
     443              :         {
     444              :                 typedef IDWUserData<dim, number> T;
     445              :                 typedef CplUserData<number, dim> TBase;
     446            3 :                 string name = string("IDWUserData").append(dimSuffix);
     447            9 :                 reg.add_class_<T, TBase>(name, grp)
     448            6 :                    .add_method("load_data_from", static_cast<void (T::*)(const char*)>(&T::load_data_from), "loads data from a file", "file name")
     449            6 :                    .add_method("set_order", static_cast<void (T::*)(number)>(&T::set_order), "sets order of the IDW-interpolation", "order")
     450            6 :                    .add_method("set_radius", static_cast<void (T::*)(number)>(&T::set_radius), "sets radius of the neighbourhood for the IDW-interpolation", "radius")
     451            3 :                    .add_constructor()
     452            6 :                    .template add_constructor<void(*)(number,number)> ("order#radius")
     453            3 :                    .set_construct_as_smart_pointer(true);
     454            9 :                 reg.add_class_to_group(name, "IDWUserData", dimTag);
     455              :         }
     456              : 
     457              :         // Composite user data (number)
     458              :         {
     459            3 :                         string name = string("CompositeUserNumber").append(dimSuffix);
     460              :                         typedef CompositeUserData<number, dim, void> T;
     461            9 :                         reg.add_class_<T,typename T::base_type>(name, grp)
     462            6 :                                 .template add_constructor<void (*)()>()
     463            6 :                                 .template add_constructor<void (*)(bool)>("continuous")
     464            6 :                                 .add_method("add", static_cast<void (T::*)(int, typename T::ref_type)>(&T::add), "assign a user data object to a subset index", "si#userdata")
     465            6 :                                 .add_method("add", static_cast<void (T::*)(ConstSmartPtr<ISubsetHandler>, const char *, typename T::ref_type)>(&T::add), "assign a user data object to subsets by names", "names#userdata")
     466            9 :                                 .add_method("has", &T::has)
     467           12 :                                 .add_method("get", &T::get)
     468           12 :                                 .add_method("is_coupled", &T::is_coupled)
     469            9 :                                 .add_method("get_coupled", &T::get_coupled)
     470            3 :                                 .set_construct_as_smart_pointer(true);
     471              : 
     472            9 :                         reg.add_class_to_group(name, "CompositeUserNumber", dimTag);
     473              :         }
     474              : 
     475              :         // Composite user data (vector)
     476              :         {
     477            3 :                         string name = string("CompositeUserVector").append(dimSuffix);
     478              :                         typedef CompositeUserData<MathVector<dim>, dim, void> T;
     479            9 :                         reg.add_class_<T,typename T::base_type>(name, grp)
     480            6 :                                 .template add_constructor<void (*)()>()
     481            6 :                                 .template add_constructor<void (*)(bool)>("continuous")
     482            6 :                                 .add_method("add", static_cast<void (T::*)(int, typename T::ref_type)>(&T::add), "assign a user data object to a subset index", "si#userdata")
     483            6 :                                 .add_method("add", static_cast<void (T::*)(ConstSmartPtr<ISubsetHandler>, const char *, typename T::ref_type)>(&T::add), "assign a user data object to subsets by names", "names#userdata")
     484            9 :                                 .add_method("has", &T::has)
     485           12 :                                 .add_method("get", &T::get)
     486           12 :                                 .add_method("is_coupled", &T::is_coupled)
     487            9 :                                 .add_method("get_coupled", &T::get_coupled)
     488            3 :                                 .set_construct_as_smart_pointer(true);
     489              : 
     490            9 :                         reg.add_class_to_group(name, "CompositeUserVector", dimTag);
     491              :         }
     492              : 
     493              : //      Interval filter linker
     494              :         {
     495              :                 typedef IntervalNumberLinker<dim> T;
     496              :                 typedef DependentUserData<number, dim> TBase;
     497            3 :                 string name = string("IntervalNumberLinker").append(dimSuffix);
     498            9 :                 reg.add_class_<T, TBase>(name, grp)
     499            6 :                    .add_method("set_default", static_cast<void (T::*)(number)>(&T::set_default), "sets the value out of the interval", "value")
     500            6 :                    .template add_constructor<void (*) (SmartPtr<CplUserData<number, dim> >, MathVector<dim>&, MathVector<dim>&)>("data#left#right")
     501            6 :                    .template add_constructor<void (*) (SmartPtr<CplUserData<number, dim> >, std::vector<number>, std::vector<number>)>("data#left#right")
     502            3 :                    .set_construct_as_smart_pointer(true);
     503            9 :                 reg.add_class_to_group(name, "IntervalNumberLinker", dimTag);
     504              :         }
     505              : 
     506              : //      GlobAttachmentElementUserData
     507              :         {
     508              :                 typedef GlobAttachmentElementUserData<dim, number> T;
     509              :                 typedef CplUserData<number, dim> TBase;
     510            3 :                 string name = string("GlobAttachmentElementNumberData").append(dimSuffix);
     511            9 :                 reg.add_class_<T, TBase>(name, grp)
     512            6 :                         .template add_constructor<void (*)(SmartPtr<Grid>, const char *) >("AttachmentName")
     513            3 :                         .set_construct_as_smart_pointer(true);
     514            9 :                 reg.add_class_to_group(name, "GlobAttachmentElementNumberData", dimTag);
     515              :         }
     516              :         
     517            3 : }
     518              : 
     519              : /**
     520              :  * Function called for the registration of Domain dependent parts.
     521              :  * All Functions and Classes depending on the Domain
     522              :  * are to be placed here when registering. The method is called for all
     523              :  * available Domain types, based on the current build options.
     524              :  *
     525              :  * @param reg   registry
     526              :  * @param grp   group for sorting of functionality
     527              :  */
     528              : template <typename TDomain>
     529            3 : static void Domain(Registry& reg, string grp)
     530              : {
     531              :         static const int dim = TDomain::dim;
     532              :         
     533              :         string suffix = GetDomainSuffix<TDomain>();
     534              :         string tag = GetDomainTag<TDomain>();
     535              :         
     536              : //      User data of a subset indicator (1 in the subset, 0 everywhere else)
     537              :         {
     538            3 :                 string name = string("SubsetIndicatorUserData").append(suffix);
     539              :                 typedef SubsetIndicatorUserData<TDomain> T;
     540              :                 typedef UserData<number, dim> TBase;
     541              :                 
     542            9 :                 reg.add_class_<T, TBase> (name, grp)
     543            6 :                         .template add_constructor<void (*)(ConstSmartPtr<TDomain>, const char*)>("Domain#Subsets")
     544            3 :                         .set_construct_as_smart_pointer(true);
     545            9 :                 reg.add_class_to_group(name, "SubsetIndicatorUserData", tag);
     546              :         }
     547              : 
     548              : //      User data of a value indicator (1 in the subset, 0 everywhere else)
     549              :         {
     550            3 :                 string name = string("ValueIndicatorUserData").append(suffix);
     551              :                 typedef ValueIndicatorUserData<TDomain> T;
     552              :                 typedef UserData<number, dim> TBase;
     553              :                 
     554            9 :                 reg.add_class_<T, TBase> (name, grp)
     555            6 :                         .template add_constructor<void (*)(SmartPtr<TBase>, number, bool)>("Domain#threshold#greater")
     556            3 :                         .set_construct_as_smart_pointer(true);
     557            9 :                 reg.add_class_to_group(name, "ValueIndicatorUserData", tag);
     558              :         }
     559              : 
     560              : // EdgeOrientation (vector)
     561              :         {
     562            3 :                 string name = string("EdgeOrientation").append(suffix);
     563              :                 typedef EdgeOrientation<TDomain> T;
     564              :                 typedef CplUserData<MathVector<dim>, dim> TBase;
     565              : 
     566            9 :                 reg.add_class_<T,TBase>(name, grp)
     567            6 :                    .template add_constructor<void (*)(SmartPtr<TDomain> ) >("")
     568            3 :                    .set_construct_as_smart_pointer(true);
     569              : 
     570            9 :                 reg.add_class_to_group(name, "EdgeOrientation", tag);
     571              : 
     572              :         }
     573              :         
     574              : //      User data for evaluation of full-dimensional vector fields on hypersurfaces
     575              :         {
     576            3 :                 string name = string("OutNormCmp").append(suffix);
     577              :                 typedef OutNormCmp<TDomain> T;
     578              :                 typedef UserData<MathVector<dim>, dim> TBase;
     579              :                 
     580            9 :                 reg.add_class_<T, TBase> (name, grp)
     581            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TBase>, const char*)>("Domain#Data#Subsets")
     582            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TBase>)>("Domain#Data")
     583            3 :                         .set_construct_as_smart_pointer(true);
     584            9 :                 reg.add_class_to_group(name, "OutNormCmp", tag);
     585              :         }
     586              :         
     587              : //      User data for evaluation of scaled full-dimensional vector fields on hypersurfaces
     588              :         {
     589            3 :                 string name = string("ScaledOutNormCmp").append(suffix);
     590              :                 typedef ScaledOutNormCmp<TDomain> T;
     591              :                 typedef UserData<MathVector<dim>, dim> TBase;
     592              :                 typedef UserData<number, dim> TScale;
     593              :                 
     594            9 :                 reg.add_class_<T, TBase> (name, grp)
     595            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TScale>, SmartPtr<TBase>, const char*)>("Domain#Scaling#Vector#Subsets")
     596            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TScale>, SmartPtr<TBase>)>("Domain#Scaling#Vector")
     597            3 :                         .set_construct_as_smart_pointer(true);
     598            9 :                 reg.add_class_to_group(name, "ScaledOutNormCmp", tag);
     599              :         }
     600              : 
     601              : //      User data for evaluation of scaled flux of a vector fields on hypersurfaces
     602              :         {
     603            3 :                 string name = string("ScaledFluxData").append(suffix);
     604              :                 typedef ScaledFluxData<TDomain> T;
     605              :                 typedef UserData<number, dim> TBase;
     606              :                 typedef UserData<MathVector<dim>, dim> TVec;
     607              :                 typedef UserData<number, dim> TScale;
     608              :                 
     609            9 :                 reg.add_class_<T, TBase> (name, grp)
     610            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TScale>, SmartPtr<TVec>, const char*)>("Domain#Scaling#Vector#Subsets")
     611            6 :                         .template add_constructor<void (*)(SmartPtr<TDomain>, SmartPtr<TScale>, SmartPtr<TVec>)>("Domain#Scaling#Vector")
     612            3 :                         .set_construct_as_smart_pointer(true);
     613            9 :                 reg.add_class_to_group(name, "ScaledFluxData", tag);
     614              :         }
     615              : 
     616            3 : }
     617              :                 
     618              : /**
     619              :  * Function called for the registration of Domain and Algebra independent parts.
     620              :  * All Functions and Classes not depending on Domain and Algebra
     621              :  * are to be placed here when registering.
     622              :  *
     623              :  * @param reg                           registry
     624              :  * @param parentGroup           group for sorting of functionality
     625              :  */
     626            1 : static void Common(Registry& reg, string grp)
     627              : {
     628            3 :         reg.add_class_<IFunction<number> >("IFunctionNumber", grp);
     629              : 
     630              : //      UserDataInfo
     631              :         {
     632            3 :                 reg.add_class_<UserDataInfo>("UserDataInfo", grp)
     633            2 :                         .add_method("set_obj_name", &UserDataInfo::set_obj_name)
     634            2 :                         .add_method("obj_name", &UserDataInfo::obj_name);
     635              :         }
     636              : 
     637              : #ifdef UG_DIM_2
     638              :         {
     639              :                 typedef CplUserData<number, 2> TBase1;
     640            3 :                 reg.add_class_<RotatingCone2d, TBase1>("RotatingCone2d", grp)
     641            2 :                                 .add_constructor<void (*)(double,double,double,double,double,double,double)>()
     642            1 :                                 .set_construct_as_smart_pointer(true);
     643              :                 typedef CplUserData<MathVector<2>, 2> TBase2;
     644            3 :                 reg.add_class_<RotatingVelocity2d, TBase2>("RotatingVelocity2d", grp)
     645            2 :                                 .add_constructor<void (*)(double,double,double)>()
     646            1 :                                 .set_construct_as_smart_pointer(true);
     647              :         }
     648              : #endif
     649            1 : }
     650              : 
     651              : }; // end Functionality
     652              : 
     653              : // end group userdata_bridge
     654              : /// \}
     655              : 
     656              : }// end UserData
     657              : 
     658              : 
     659              : template <class TValue, int dim>
     660            2 : static void RegisterRasterUserData(Registry& reg, string name, string grp)
     661              : {
     662              : 
     663            2 :         string suffix = GetDimensionSuffix<dim>();
     664            2 :         string tag = GetDimensionTag<dim>();
     665              : 
     666              :         { // Raster
     667              :                 typedef RasterUserData<dim> T;
     668              :                 typedef typename T::base_type TBase;
     669              :                 string fullName = name + suffix;
     670              : 
     671            6 :                 reg.add_class_<T,TBase>(fullName, grp)
     672            4 :                         .template add_constructor<void (*)(typename T::input_type)>("RasterNumberData")
     673            6 :                         .add_method("set_order", &T::set_order)
     674            6 :                         .add_method("set_scale", &T::set_scale)
     675            2 :                         .set_construct_as_smart_pointer(true);
     676              : 
     677            4 :                 reg.add_class_to_group(fullName, name, tag);
     678              :         }
     679              : 
     680            2 : }
     681              : 
     682              : /// \addtogroup userdata_bridge
     683            1 : void RegisterBridge_UserData(Registry& reg, string grp)
     684              : {
     685              : //      get group string
     686            1 :         grp.append("/Discretization/SpatialDisc/UserData");
     687              :         typedef UserDataBridge::Functionality Functionality;
     688              : 
     689              :         try{
     690            2 :                 RegisterCommon<Functionality>(reg,grp);
     691            2 :                 RegisterDimensionDependent<Functionality>(reg,grp);
     692            2 :                 RegisterDomainDependent<Functionality>(reg,grp);
     693              : 
     694              : #ifdef UG_DIM_2 // only for 2D/3D
     695            2 :                 RegisterRasterUserData<number, 2>(reg, "RasterNumberData", grp);
     696              : #endif
     697              : 
     698              : #ifdef UG_DIM_3
     699            2 :                 RegisterRasterUserData<number, 3>(reg, "RasterNumberData", grp);
     700              : #endif
     701              :         }
     702            0 :         UG_REGISTRY_CATCH_THROW(grp);
     703            1 : }
     704              : 
     705              : } // end namespace
     706              : } // end namepace
        

Generated by: LCOV version 2.0-1