34 #ifndef __H__UG_BRIDGE__BRIDGES__USER_DATA__USER_DATA__
35 #define __H__UG_BRIDGE__BRIDGES__USER_DATA__USER_DATA__
46 #include "externals/lua/lua.h"
81 template <
typename TData,
int dim,
typename TRet =
void>
93 template <
typename TData,
int dim,
typename TRet =
void>
95 :
public StdGlobPosData<LuaUserData<TData, dim, TRet>, TData, dim, TRet>
121 static std::string
name();
125 const bool bThrow =
false);
129 const bool bThrow =
false);
133 const bool bThrow =
false);
178 template <
typename TData,
int dim,
typename TRet>
200 const std::string&
name);
206 static std::map<std::string, std::pair<LuaUserData<TData,dim,TRet>*,
int*> >
m_mData;
239 template <
typename TData,
int dim,
typename TDataIn>
241 :
public StdDataLinker<LuaUserFunction<TData, dim, TDataIn>, TData, dim>
256 LuaUserFunction(
const char* luaCallback,
size_t numArgs,
bool bPosTimeNeed);
269 void set_deriv(
size_t arg,
const char* luaCallback);
289 virtual void operator() (TData& out,
int numArgs, ...)
const;
295 template <
int refDim>
296 inline void evaluate(TData vValue[],
306 template <
int refDim>
317 std::vector<std::vector<TData> > vvvDeriv[],
332 void eval_value(TData& out,
const std::vector<TDataIn>& dataIn,
336 void eval_deriv(TData& out,
const std::vector<TDataIn>& dataIn,
360 std::vector<bridge::LUACompiler > m_luaComp_Deriv;
398 template <
typename TData,
typename TDataIn>
415 virtual void operator() (TData& out,
int numArgs, ...);
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:108
Type based UserData.
Definition: user_data.h:501
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
number time() const
get the current evaluation time
Definition: user_data.h:285
Definition: user_function.h:40
Definition: local_algebra.h:198
Handle for a lua reference.
Definition: lua_function_handle.h:40
Definition: lua_user_data.h:400
int m_cbValueRef
reference to lua function
Definition: lua_user_data.h:422
virtual void operator()(TData &out, int numArgs,...)
evaluates the data
Definition: lua_user_data_impl.h:1111
lua_State * m_L
lua state
Definition: lua_user_data.h:425
std::string m_cbValueName
callback name as string
Definition: lua_user_data.h:419
LuaFunction()
constructor
Definition: lua_user_data_impl.h:1082
size_t m_numArgs
number of arguments to use
Definition: lua_user_data.h:428
virtual ~LuaFunction()
Definition: lua_user_data.h:404
void set_lua_callback(const char *luaCallback, size_t numArgs)
sets the Lua function used to compute the data
Definition: lua_user_data_impl.h:1089
Factory providing LuaUserData.
Definition: lua_user_data.h:180
LuaUserDataFactory(const LuaUserDataFactory &)
LuaUserDataFactory()
private constructor, since singleton
Definition: lua_user_data.h:185
static void remove(const std::string &name)
removes the user data
Definition: lua_user_data_impl.h:417
static LuaUserDataFactory< TData, dim, TRet > & instance()
singleton provider
Definition: lua_user_data.h:192
static SmartPtr< LuaUserData< TData, dim, TRet > > create(const std::string &name)
Definition: lua_user_data.h:223
static std::map< std::string, std::pair< LuaUserData< TData, dim, TRet > *, int * > > m_mData
storage of already created data
Definition: lua_user_data.h:206
static SmartPtr< LuaUserData< TData, dim, TRet > > provide_or_create(const std::string &name)
returns new Data if not already created, already existing else
Definition: lua_user_data_impl.h:370
LuaUserDataFactory & operator=(const LuaUserDataFactory &)
provides data specified in the lua script
Definition: lua_user_data.h:96
static bool check_callback_returns(const char *callName, const bool bThrow=false)
returns true if callback has correct return values
Definition: lua_user_data_impl.h:249
lua_State * m_L
lua state
Definition: lua_user_data.h:157
int m_callbackRef
reference to lua function
Definition: lua_user_data.h:147
static std::string signature()
returns string of required callback signature
Definition: lua_user_data_impl.h:67
static std::string name()
returns name of UserData
Definition: lua_user_data_impl.h:84
std::string m_callbackName
callback name as string
Definition: lua_user_data.h:144
LuaUserData(const char *luaCallback)
Constructor.
Definition: lua_user_data_impl.h:94
TRet evaluate(TData &D, const MathVector< dim > &x, number time, int si) const
evaluates the data at a given point and time
Definition: lua_user_data_impl.h:284
void set_created_from_factory(bool bFromFactory)
sets that LuaUserData is created by LuaUserDataFactory
Definition: lua_user_data.h:140
bool m_bFromFactory
flag, indicating if created from factory
Definition: lua_user_data.h:154
virtual ~LuaUserData()
}
Definition: lua_user_data_impl.h:355
maps several data values to an output data value using a lua callback
Definition: lua_user_data.h:242
LuaUserFunction(const char *luaCallback, size_t numArgs)
constructor
Definition: lua_user_data_impl.h:445
std::vector< SmartPtr< CplUserData< TDataIn, dim > > > m_vpUserData
LUACompiler types for compiled LUA code.
Definition: lua_user_data.h:365
void eval_value(TData &out, const std::vector< TDataIn > &dataIn, const MathVector< dim > &x, number time, int si) const
evaluates the data at a given point and time
Definition: lua_user_data_impl.h:740
virtual ~LuaUserFunction()
destructor frees the reference
Definition: lua_user_data_impl.h:510
std::vector< SmartPtr< DependentUserData< TDataIn, dim > > > m_vpDependData
data input casted to dependend data
Definition: lua_user_data.h:368
void free_deriv_callback_ref(size_t arg)
frees callback-references for derivate callbacks
Definition: lua_user_data_impl.h:531
void evaluate(TData &value, const MathVector< dim > &globIP, number time, int si) const
Definition: lua_user_data_impl.h:909
void set_input_and_deriv(size_t i, SmartPtr< CplUserData< TDataIn, dim > > input, LuaFunctionHandle deriv)
Definition: lua_user_data.h:285
void set_input(size_t i, SmartPtr< CplUserData< TDataIn, dim > > data)
set input value for paramter i
Definition: lua_user_data_impl.h:1049
std::vector< int > m_cbDerivRef
Definition: lua_user_data.h:346
void eval_deriv(TData &out, const std::vector< TDataIn > &dataIn, const MathVector< dim > &x, number time, int si, size_t arg) const
evaluates the data at a given point and time
Definition: lua_user_data_impl.h:823
void eval_and_deriv(TData vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< TData > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL)
Definition: lua_user_data_impl.h:959
lua_State * m_L
lua state
Definition: lua_user_data.h:349
size_t m_numArgs
number of arguments to use
Definition: lua_user_data.h:352
std::string m_cbValueName
callback name as string
Definition: lua_user_data.h:341
void free_callback_ref()
frees the callback-reference, if a callback was set.
Definition: lua_user_data_impl.h:522
int m_cbValueRef
reference to lua function
Definition: lua_user_data.h:345
StdDataLinker< LuaUserFunction< TData, dim, TDataIn >, TData, dim > base_type
Definition: lua_user_data.h:245
bool m_bPosTimeNeed
flag for position and time data
Definition: lua_user_data.h:355
void set_deriv(size_t arg, const char *luaCallback)
sets the Lua function used to compute the derivative
Definition: lua_user_data_impl.h:601
std::vector< std::string > m_cbDerivName
Definition: lua_user_data.h:342
void set_lua_value_callback(const char *luaCallback, size_t numArgs)
sets the Lua function used to compute the data
Definition: lua_user_data_impl.h:541
void set_num_input(size_t num)
set number of needed inputs
Definition: lua_user_data_impl.h:1037
virtual void operator()(TData &out, int numArgs,...) const
evaluates the data
Definition: lua_user_data_impl.h:661
this class maps a scalar value an output scalar value using a lua callback
Definition: lua_user_data.h:375
void set_lua_callback(const char *luaCallback)
Definition: lua_user_data.cpp:70
number operator()(int numArgs,...) const
Definition: lua_user_data.cpp:85
std::string m_callbackName
Definition: lua_user_data.h:384
LuaUserNumberNumberFunction()
Definition: lua_user_data.cpp:64
lua_State * m_L
Definition: lua_user_data.h:386
int m_callbackRef
Definition: lua_user_data.h:385
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
combines several UserDatas to a new UserData of a specified type
Definition: linker.h:54
virtual void set_input(size_t i, SmartPtr< ICplUserData< dim > > input, SmartPtr< UserDataInfo > info)
sets an input
Definition: linker.h:114
Definition: std_glob_pos_data.h:55
Definition: lua_compiler.h:50
Registry for functions and classes that are exported to scripts and visualizations.
Definition: registry.h:138
double number
Definition: types.h:124
struct lua_State lua_State
Definition: lua_table_handle.h:40
void RegisterLuaUserData(Registry ®, string grp)
Definition: lua_user_data.cpp:284
bool CheckLuaCallbackName(const char *name)
returns true if callback exists
Definition: lua_user_data.cpp:50