GeMA
The GeMA main application
Boundary condition object methods

Boundary condition objects are a Lua wrapper over a GeMA boundary condition providing a rich set of methods for querying and updating its properties. Those include querying and updating boundary condition property values, as well as their application points. Boundary condition objects can be obtained in the orchestration by calling the modelData:boundaryCondition() method.

Example:

local bc = modelData:boundaryCondition('bcName')

Index:

Metadata methods

bc:id()
Description: Returns the boundary condition name.
Parameters: None.
Returns: Returns a string with the boundary condition name (the id attribute given during its model definition).

Example:

-- Print the boundary condition name
print(bc:id())


bc:description()
Description: Returns the boundary condition description.
Parameters: None.
Returns: Returns a string with the boundary condition description

Example:

-- Print the boundary condition description
print(bc:description())


bc:type()
Description: Returns the boundary condition type. Boundary condition types are standard names defining the semanticas of the boundary condition data, and are interpreted by the physics responsible for applying the condition.
Parameters: None.
Returns: Returns a string with the boundary condition type.

Example:

-- Print the boundary condition type
print(bc:type())


bc:mesh()
Description: Returns the mesh object owning the nodes or cells included in this condition.
Parameters: None.
Returns: Returns the associated mesh object.

Example:

local mesh = bc:mesh()


bc:bcType()
Description: Returns the type of application point expected by this boundary condition. Conditions can be applied over nodes, cells, cell edges or cell faces.
Parameters: None.
Returns: Returns a string with the condition application point type. Can be either "node", "edge", "face" or "cell".

Example:

-- Check that the boundary condition is being applied over mesh nodes
if bc:bcType() == 'node' then
...
end


Property (column) querying methods

bc:numProperties()
Description: Returns the number of properties (attribute columns) on the boundary condition.
Parameters: None.
Returns: Returns the number of properties.

Example:

local nproperties = bc:numProperties()


bc:propertyIds()
Description: Returns a list with the name (id) of every property (attribute column) on the boundary condition.
Parameters: None.
Returns: Returns a table with property ids (strings).

Example:

local propertyIds = bc:propertyIds()


bc: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 boundary condition.

Example:

local info = bc:propertyInfo('propertyName')


bc:propertyAccessor(name, unit)
Description: Returns a Bc accessor object that can be used to retrieve and update data for boundary condition properties. Unlike other accessor types, a boundary condition property accessor always retrieves data from the current state.
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 Bc 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 fAc = bc:propertyAccessor('f') -- An accessor to the 'f' b.c. property
local fAc2 = bc:propertyAccessor('f', 'lbf') -- An accessor to the 'f' b.c. property with values converted to 'lbf'


Value (line) querying methods

bc:numValues()
Description: Returns the number of boundary conditions (lines) stored in the object.
Parameters: None.
Returns: Returns the number of 'lines' in the boundary condition table.

Example:

local nbc = bc:numValues()


bc:numNodes(bcIndex)
Description: Returns the number of nodes in the given application point (line), stored in the boundary condition object. The returned size will be greater than one when the application point is defined by the way of a cell boundary object or by a node set object. Meaningful only if the application point type is equal to "node".
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Returns the number of nodes associated with the given boundary condition line or nil if bc:bcType() is different from "node".

Example:

local nnodes = bc:numNodes(1) -- Number of nodes for the first BC application point


bc:node(bcIndex, nodeIndex)
Description: Returns a node from the set of nodes in the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "node".
Parameters: bcIndex A boundary condition index (between 1 and bc:numValues()).
nodeIndex A node list index (between 1 and bc:numNodes(bcIndex)).
Returns: Returns the node number or nil if bc:bcType() is different from "node". If the node is a ghost node, it will have its high bit set.

Example:

-- Print the set of nodes serving as the application point for the first condition stored on bc.
for i = 1, bc:numNodes(1) do
print(bc:node(1, i))
end


bc:cell(bcIndex)
Description: Returns the cell associated with the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "cell".
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Returns a cell mesh index or nil if bc:bcType() is different from "cell".

Example:

-- Get the index of the cell serving as the application point for the first condition stored on bc.
local cellId = bc:cell(1)


bc:numBoundaryCells(bcIndex)
Description: Returns the number of (cell, border) pairs in the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "edge" or "face".
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Returns the number of (cell, border) pairs associated with the given boundary condition line or nil if bc:bcType() is different from "edge" or "face".

Example:

local nborders = bc:numBoundaryCells(1) -- Number of borders (edges or faces) for the first BC application point


bc:boundaryCell(bcIndex, borderIndex)
Description: Returns a (cell, border) pair from the set of pairs in the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "edge" or "face".
Parameters: bcIndex A boundary condition index (between 1 and bc:numValues()).
borderIndex A border list index (between 1 and bc:numBoundaryCells(bcIndex)).
Returns: Returns the cell object, followed by the border number (see the Element types documentation for a reference about border numbering) or nil if bc:bcType() is different from "edge" or "face".

Example:

-- Print the set of borders serving as the application point for the first condition stored on bc.
for i = 1, bc:numBoundaryCells(1) do
local cell, border = bc:boundaryCell(1, i)
print(cell:id(), border)
end


bc:boundary(bcIndex)
Description: Returns the cell boundary object associated with the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "edge", "face" or "node" (and in the later case only if the application point was defined by a boundary object).
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Returns a cell boundary object or nil if there is no boundary object associated with this condition (bc:bcType() is equal to "cell" or equal to "node" and the application point was not defined through a boundary object).

Example:

-- Get the border serving as the application point for the first condition stored on bc.
local border = bc:boundary(1)


bc:nodeSet(bcIndex)
Description: Returns the node set object associated with the given application point (line), stored in the boundary condition object. Meaningful only if the application point type is equal to "node" and the application point was defined by a node set.
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Returns a node set object or nil if there is no node set object associated with this condition (bc:bcType() is different from "node" or the application point was not defined through a node set object).

Example:

-- Get the node set serving as the application point for the first condition stored on bc.
local border = bc:nodeSet(1)


Value (line) updating methods

bc:setNode(bcIndex, value)
Description: Updates the set of nodes defining the application point associated to a boundary condition (line) stored in the object. Can be called only if the application point type is equal to "node". Please remember that the properties associated with this application point can be updated through an accessor returned by bc:propertyAccessor().
Parameters: bcIndex A boundary condition index (between 1 and bc:numValues()).
value Either a mesh node index (ghost nodes should have their high bit set), a cell boundary object, a node set object or a table with a list of node indices (ghost nodes should have their high bit set).
Returns: Nothing.

Example:

-- Updates the application point node for the first condition stored on bc to node 27
bc:setNode(1, 27)
-- Updates the application point node for the first condition stored on bc to
-- nodes 1, 2, 3 + the first ghost node
bc:setNode(1, {1, 2, 3, setMeshGhostFlag(1)})
-- Updates the application point for the second condition stored on bc to the border named 'myBorder'
local border = mesh:cellBoundaryGroups()['myBorder']
bc:setNode(2, border)
-- Updates the application point for the second condition stored on bc to the node set named 'mySet'
local ns = mesh:nodeSets()['mySet']
bc:setNode(2, ns)


bc:setCell(bcIndex, cellId)
Description: Updates the cell defining the application point associated to a boundary condition (line) stored in the object. Can be called only if the application point type is equal to "cell". Please remember that the properties associated with this application point can be updated through an accessor returned by bc:propertyAccessor().
Parameters: bcIndex A boundary condition index (between 1 and bc:numValues()).
cellId The mesh cell index (a value between 1 and mesh:numCells()).
Returns: Nothing.

Example:

-- Updates the application point cell for the first condition stored on bc to cell 32
bc:setCell(1, 32)


bc:setBoundary(bcIndex, boundary)
bc:setBoundary(bcIndex, cellId, borderId)
bc:setBoundary(bcIndex, cellList, borderList)
Description: Updates the border defining the application point associated to a boundary condition (line) stored in the object. Can be called with three different signatures: on the first the border is specified by a cell boundary object. On the second, by a pair of arguments providing the cell and border ids, and on the third, by a pair of equal sized lists providing a set of cell + border pairs. This function should be called only if the application point type is equal to "edge" or "face". Please remember that the properties associated with this application point can be updated through an accessor returned by bc:propertyAccessor().
Parameters: bcIndex A boundary condition index (between 1 and bc:numValues()).
boundary The cell boundary object with the new set of edges / faces or nodes.
cellId The mesh cell index (a value between 1 and mesh:numCells()).
borderId The edge or face number (between 1 and either geometry:numEdges() or geometry:numFaces()). See the Element types page for the edge/face organization for each cell type.
cellList A table storing a set of cell ids with the same semantics as a cellId parameter.
borderList A table storing a set of border ids with the same semantics as a borderId parameter. The table size must be equal to the cellList size.
Returns: Nothing.

Example:

-- Updates the application point for the first condition stored on bc to edge 3 of cell 15
bc:setBoundary(1, 15, 3)
-- Updates the application point for the first condition stored on bc to edge 3 of cells 15, 16 and 17
bc:setBoundary(1, {15, 16, 17}, {3, 3, 3})
-- Updates the application point for the second condition stored on bc to the border named 'myBorder'
local border = mesh:cellBoundaryGroups()['myBorder']
bc:setBoundary(2, border)


bc:reloadNodeBoundaryData(bcIndex)
Description: Reloads node information for a boundary condition applied on nodes, where the set of nodes was specified by a cell boundary object. This is needed for the boundary condition to recognize changes in the boundary object contents.
Parameters: bcIndex - A boundary condition index (between 1 and bc:numValues()).
Returns: Nothing.

Example:

-- Updates the boundary 'myBorder' with the following pairs of {cell, edge} : {{2, 3}, {3, 2}, {1, 3}}
local border = m:cellBoundaryGroups()['myBorder']
local newCells = {m:cell(2), m:cell(3), m:cell(1)}
local newBorders = {3, 2, 3}
border:setBoundaryData(newCells, newBorders)
-- Assuming that the application point for the first condition stored on bc is the 'MyBorder' border,
-- tells the boundary condition that its contents has changed.
bc:reloadNodeBoundaryData(1)


bc:clear()
Description: Clears all the application point (line) data stored in this boundary condition, including attribute values.
Parameters: None.
Returns: Nothing.

Example:

-- Clear BC data
bc:clear()


bc:addLines(nlines)
Description: Adds the given number of lines to the boundary condition. Their application points must be filled by calls to bc:setNode(), bc:setCell() or bc:setBoundary(). Properties are initialized with their default values and can be updated through accessors returned by bc:propertyAccessor().
Parameters: nlines - Optional number of lines (conditions) to add to the object. If this parameter is missing, only one line will be added.
Returns: Returns the index of the first newly added condition.

Example:

-- Adds 5 new lines and initializes their application points with nodes 10, 12, 25, 37 and 42
local nextIndex = bc:addLines(5)
local nodes = {10, 12, 25, 37, 42}
for i = 1, 5 do
bc:setNode(nextIndex + i - 1, nodes[i])
end


bc:removeLines(bcIndex, nlines)
Description: Removes the given number of lines frome the boundary condition starting at the given position. Both the application point data and the properties data from the specified lines are removed.
Parameters: bcIndex The boundary condition index (between 1 and bc:numValues()) of the first line to be removed.
nlines Optional number of lines that will be removed. If missing, only one line will be removed.
Returns: Nothing.

Example:

-- Removes 3 lines, starting (and including) at the 10th one
bc:removeLines(10, 3)


bc:addNodeLine(value)
Description: Adds a single line to the boundary condition, filling its application point with the provided node information. Can be called only if the application point type is equal to "node". Equivalent to calling pos = bc:addLines(1) followed by bc:setNode(pos, value). Properties are initialized with their default values and can be updated through accessors returned by bc:propertyAccessor().
Parameters: value - Either a mesh node index (ghost nodes should have their high bit set), a cell boundary object, a node set object or a table with a list of node indices (ghost nodes should have their high bit set).
Returns: Returns the index of the newly added condition.

Example:

-- Adds a new condition with an application point equal to the border named 'myBorder'
local border = mesh:cellBoundaryGroups()['myBorder']
local index = bc:addNodeLine(border)


bc:addCellLine(cellId)
Description: Adds a single line to the boundary condition, filling its application point with the provided cell. Can be called only if the application point type is equal to "cell". Equivalent to calling pos = bc:addLines(1) followed by bc:setCell(pos, cellId). Properties are initialized with their default values and can be updated through accessors returned by bc:propertyAccessor().
Parameters: cellId - The mesh cell index (a value between 1 and mesh:numCells()).
Returns: Returns the index of the newly added condition.

Example:

-- Adds a new condition with an application point equal to cell 15
local index = bc:addCellLine(15)


bc:addBoundaryLine(boundary)
bc:addBoundaryLine(cellId, borderId)
bc:addBoundaryLine(cellList, borderList)
Description: Adds a single line to the boundary condition, filling its application point with the provided border. Can be called with three different signatures: on the first the border is specified by a cell boundary object. On the second, by a pair of arguments providing the cell and border ids, and on the third, by a pair of equal sized lists providing a set of cell + border pairs. This function should be called only if the application point type is equal to "edge" or "face". Equivalent to calling pos = bc:addLines(1) followed by bc:setBoundary(pos, boundary), bc:setBoundary(cellId, borderId) or bc:setBoundary(cellList, borderList). Properties are initialized with their default values and can be updated through accessors returned by bc:propertyAccessor().
Parameters: boundary The cell boundary object with the new set of edges / faces or nodes.
cellId The mesh cell index (a value between 1 and mesh:numCells()).
borderId The edge or face number (between 1 and either geometry:numEdges() or geometry:numFaces()). See the Element types page for the edge/face organization for each cell type.
cellList A table storing a set of cell ids with the same semantics as a cellId parameter.
borderList A table storing a set of border ids with the same semantics as a borderId parameter. The table size must be equal to the cellList size.
Returns: Returns the index of the newly added condition.

Example:

-- Adds a new condition with an application point equal to the border named 'myBorder'
local border = mesh:cellBoundaryGroups()['myBorder']
local index = bc:addBoundaryLine(border)


Other methods

bc:print()
Description: Prints information about the boundary condition. This includes metadata and values (application point and property data) for each condition inside the object.
Parameters: None.
Returns: Nothing.

Example:

bc:print()