ug4
UserData Utility

Functions

function FreeUserData ()
 
function FreeUserDataInTable (t)
 
function ListUserData ()
 
function ListUserDataInTable (t, name)
 
function ToUserMatrix (o, my_dim)
 
function ToUserNumber (o, my_dim)
 
function ToUserVector (o, my_dim)
 

Detailed Description

Some usage info: FreeUserDataInTable, FreeUserData.

Name of instance of ug4-object: ug_class_name(obj) (returns "" if not a ug4 class) Check if class is base class: ug_is_base_class("BaseClass", "DerivClass") Check if dimension compiled in: ug_dim_compiled(dim) Returning metatable for a ug4-class: ug_get_metatable("ClassName")

Function Documentation

◆ FreeUserData()

function FreeUserData ( )

sets all userdata to nil (even in tables) and calls garbage collector

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :95-111

function FreeUserData()
for n,v in pairs(_G) do
if type(v) == "userdata" then
_G[n] = nil
end
if type(v) == "table" then
if(n ~= "_G" and n ~= "io" and n ~= "package" and n ~= "gnuplot") then
end
end
end
collectgarbage("collect")
end
function FreeUserData()
function FreeUserDataInTable(t)
if(!(yy_init))
Definition: lexer.cpp:997
for(yylen=0;yystr[yylen];yylen++) continue

◆ FreeUserDataInTable()

function FreeUserDataInTable ( )

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :79-92

for n,v in pairs(t) do
if type(v) == "userdata" then
t[n] = nil
end
if type(v) == "table" then
if(n ~= "_G" and n ~= "io" and n ~= "package" and n ~= "gnuplot") then
end
end
end
end

◆ ListUserData()

function ListUserData ( )

Lists all user data (even in tables)

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :63-77

function ListUserData()
for n,v in pairs(_G) do
if type(v) == "userdata" then
print(n)
end
if type(v) == "table" then
if(n ~= "_G" and n ~= "io" and n ~= "package" and n ~= "gnuplot") then
end
end
end
end
function table print(data, style)
function ListUserData()
function ListUserDataInTable(t, name)

◆ ListUserDataInTable()

function ListUserDataInTable ( ,
name   
)

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :48-60

for n,v in pairs(t) do
if type(v) == "userdata" then
print(name.."["..n.."]")
end
if type(v) == "table" then
if(n ~= "_G" and n ~= "io" and n ~= "package" and n ~= "gnuplot") then
ListUserDataInTable(v, name.."["..n.."]")
end
end
end
end
location name
Definition: checkpoint_util.lua:128

References name, and print().

◆ ToUserMatrix()

function ToUserMatrix ( ,
my_dim   
)

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :147-178

◆ ToUserNumber()

function ToUserNumber ( ,
my_dim   
)

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :117-130

function ToUserNumber (o, my_dim)
if my_dim == nil then my_dim = GetUGDim() end
if type(o) == "number" then
return _G["ConstUserNumber"..my_dim.."d"](o)
elseif type(o) == "function" then
return _G["LuaUserNumber"..my_dim.."d"](o)
elseif type(o) == "string" then
return _G["LuaUserNumber"..my_dim.."d"](_G[o]) -- we assume a function as the argument
elseif type(o) == "userdata" then -- ToDo: Provide a better condition!
return o
end
return nil -- this indicates an error
end
int GetUGDim()
returns the dimension to which UG was initialized through InitUG
Definition: bridge.cpp:205
function ToUserNumber(o, my_dim)
double number
Definition: types.h:124

◆ ToUserVector()

function ToUserVector ( ,
my_dim   
)

location: /home/runner/work/docs/docs/ug4/ugcore/scripts/util / user_data_util.lua :132-145

function ToUserVector (o, my_dim)
if my_dim == nil then my_dim = GetUGDim() end
if type(o) == "table" then
return _G["ConstUserVector"..my_dim.."d"](o)
elseif type(o) == "function" then
return _G["LuaUserVector"..my_dim.."d"](o)
elseif type(o) == "string" then
return _G["LuaUserVector"..my_dim.."d"](_G[o]) -- we assume a function as the argument
elseif type(o) == "userdata" then -- ToDo: Provide a better condition!
return o
end
return nil -- this indicates an error
end
function ToUserVector(o, my_dim)