GeMA
The GeMA main application
Stress Functions Lib

Introduction

The Stress Functions Lib is a set of utilitary functions for creating node and cell user functions for calculating derived stress results (like principal stresses) from physics calculated values.

When loading the library, instead of polluting the model with a great number of user functions, it will publish two functions: nodeFunctionDef() and cellFunctionDef(), responsible for returning the desired user function definitions. Available stress functions are documented on the next section.

Since user functions are by definition shared entities, that must be defined in every thread when the simulation environment allows for multi-threading, the dofile() call used to load the stress function library should be surrounded by a shared code block definition. This is optional only if the simulation disabled threading, by adding a maxThreads = 0 option to the simulation object.

Important: Please rememeber that the library must be loaded, before the first call to one of its exported methods, by a call to dofile("$SCRIPTS/stressFunctionsLib.lua").

stressFunctionsLib.nodeFunctionDef(name, userName, parNames)
Description: Returns the table storing the definition for the requested node function, optionally renaming it to userName, and also optionally renaming parameters in parNames. The returned table should be used as an argument to the standard NodeFunction() call. See the example bellow.
Important: notice, in the example, that the returned table is surrounded by parenthesis in the call, and not by curly braces, since the value returned by the library is already a table.
Parameters: name The name of the requested user function. See the section below for available functions.
userName An optional user name that will be used instead of name.
parNames A map with optional names for the function parameters in case that they have been renamed on the model. Map keys are the default expected parameters (documented together with the avilable functions) and values the actual names.
Returns: Returns the table with the desired node user function definition.


stressFunctionsLib.cellFunctionDef(name, userName, parNames)
Description: Returns the table storing the definition for the requested cell function, optionally renaming it to userName, and also optionally renaming parameters in parNames. The returned table should be used as an argument to the standard CellFunction() call. See the example bellow.
Important: notice, in the example, that the returned table is surrounded by parenthesis in the call, and not by curly braces, since the value returned by the library is already a table.
Parameters: name The name of the requested user function. See the section below for available functions.
userName An optional user name that will be used instead of name.
parNames A map with optional names for the function parameters in case that they have been renamed on the model. Map keys are the default expected parameters (documented together with the avilable functions) and values the actual names.
Returns: Returns the table with the desired cell user function definition.

Example:

SharedCodeBegin{}
dofile('$SCRIPTS/stressFunctionsLib.lua')
NodeFunction(stressFunctionsLib.nodeFunctionDef('sigma1n'))
CellFunction(stressFunctionsLib.cellFunctionDef('sigma1'))
SharedCodeEnd{}

Stress functions

sigma1

A cell user function for calculating the first principal stress value. Also named sigma1n for a node user function. Calculated value:

\[\sigma_1 = \frac{\sigma_{xx}+\sigma_{yy}}{2} + \sqrt{\frac{(\sigma_{xx}-\sigma_{yy})^2}{4} + \sigma_{xy}^2}\]

Parameters: S - The stress tensor.


sigma2

A cell user function for calculating the second principal stress value. Also named sigma2n for a node user function. Calculated value:

\[\sigma_2 = \frac{\sigma_{xx}+\sigma_{yy}}{2} - \sqrt{\frac{(\sigma_{xx}-\sigma_{yy})^2}{4} + \sigma_{xy}^2}\]

Parameters: S - The stress tensor.