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

Generated by: LCOV version 2.0-1