GeMA
The GeMA main application
Property Set object methods

Property set objects are a Lua wrapper over a GeMA property set providing a full set of methods for querying and updating property data. They can be obtained in the orchestration by calling modelData:propertySet() or by retrieving a list of property sets tied to a mesh by calling the mesh:propertySets() method.

Example:

-- Get a reference to the property set named 'myPs'
local ps = modelData:propertySet('myPs')
-- Get a list with the property sets tied to the mesh named 'myMesh'
local psets = modelData:mesh('myMesh'):propertySets()

Index:

Metadata methods

pset:id()
Description: Returns the property set name.
Parameters: None.
Returns: Returns a string with the property set name (the id attribute given during its model definition).

Example:

-- Print the property set name
print(pset:id())


Property (column) related methods

pset:numProperties()
Description: Returns the number of properties (columns) on the property set.
Parameters: None.
Returns: Returns the number of properties.

Example:

local nproperties = pset:numProperties()


pset:propertyIds()
Description: Returns a list with the name (id) of every property (column) on the property set.
Parameters: None.
Returns: Returns a table with property ids (strings).

Example:

local propertyIds = pset:propertyIds()


pset:propertyInfo(name)
Description: Returns an object with metadata information about the named property.
Parameters: name - The property name (id).
Returns: Returns a value info object or nil if the requested name was not found in the property set.

Example:

local rhoInfo = pset:propertyInfo('rho')


pset:propertyAccessor(name, unit)
Description: Returns a Value accessor object that can be used to retrieve data for properties. Unlike other accessor types, a property accessor always retrieves data from the current state. Property accessors retrieved from the property set can not be used to evaluate user functions since they are indexed by table row and not by mesh cells. Its main usage is for updating property set data. For evaluating functions, a property accessor retrieved through a mesh object should be used (refer to the mesh:cellPropertyAccessor() method).
Parameters: name The name (id) of the property.
unit An optional string with the desired unit for returned values. If different from the data unit, the accessor will automatically convert values.
Returns: A Value accessor object or nil on errors (the requested name is unknown, or the requested unit is incompatible with the data unit, for example).

Example:

local rhoAc = pset:propertyAccessor('rho') -- Get an accessor to the 'rho' property
local rhoAc2 = pset:propertyAccessor('rho', 'g/cm3') -- Get an accessor to the 'rho' property with values converted to g/cm3


Value (line) related methods

pset:numValues()
Description: Returns the number of property values (lines) stored on the property set.
Parameters: None.
Returns: Returns the number of values.

Example:

local nvalues = pset:numValues()


pset:valueIds()
Description: Returns a table with value ids, one for each line in the property set. If a line does not have a user defined id, a numeric one, equal to the line number (zero based and not 1 based), will be returned in the table.
Parameters: None.
Returns: A table with value ids (strings).

Example:

-- Print property set value ids
local valueIds = pset:valueIds()
for i = 1, #valueIds do
print(valueIds[i])
end


pset:valueIndex(valueName)
Description: Returns the index of a value identifier in the property set.
Parameters: valueName - The value name.
Returns: Returns an index between 1 and pset:numValues() or nil for invalid names.

Example:

local valueIndex = pset:valueIndex('lineId')


pset:addValues(numLines, idList)
Description: Adds new lines to the property set table, optionaly setting their ids.
Parameters: numLines The number of lines to add to the property set.
idList An optional list with line ids. If present, this table should have numLines entries with unique values (among each other and existing property set values).
Returns: Returns the index of the first new line in the set or nil on errors.

Example:

-- Add 3 new lines to the table, with ids equal to 'mat1', 'mat2' and 'mat3'
local pos = pset:addValues(3, {'mat1', 'mat2', 'mat3'})