13. User-defined element functions - Functions
The Functions module is used to register user-defined element functions to be used in ProSolve.
ProSolve offers default element functions so the ones provided through the object container Functions will override them if they are not set to NULL.
Currently we allow callbacks functions for types Solid3D and Shell3D, for functions Stiff (linear stiffness matrix), ElemLoad (body force vector) and DistLoad (distributed load vector).
Begin and end an instance of an object, generic object functions
vfe_FunctionsBegin()- create an instance of a Functions object
vfe_FunctionsEnd()- destroy an instance of a Functions object
vfe_FunctionsError()- return Functions object error flag
Attributes and Parameters
vfe_FunctionsSetFunction()- set callback function
Instance a Functions object using
Once a Functions is instanced, set function callbacks using
vfe_FunctionsSetFunction(). Finally, register the instance of Functions
to the ProSolve object:
vfe_Functions* functions = vfe_FunctionsBegin(); vfe_FunctionsSetFunction(functions, VFE_FUN_STIFF, (Vfunc*)CustomSolid3DStiff, NULL); vfe_FunctionsSetFunction(functions, VFE_FUN_DISTLOAD, (Vfunc*)CustomSolid3DDistLoad, NULL); vfx_ProSolveSetObject(prosolve_test, VFE_SOLID3D_FUNCTIONS, functions);
where functions CustomSolid3DStiff and CustomSolid3DDistLoad will replace the ones used internally by default in ProSolve (i.e vfe_Solid3DStiff and vfe_Shell3DDistLoad) during structural analysis with distributed loads.
13.1. Function Descriptions
The currently available Functions functions are described in detail in this section.
create an instance of a Functions object
Create an instance of a Functions object. Memory is allocated for the object private data and the pointer to the object is returned. By default all of the analysis functions and object functions are set to null.
Destroy an instance of a Functions object using
void vfe_FunctionsEnd (vfe_Functions *Functions )
Return the current value of a Functions object error flag using
Vint vfe_FunctionsError (vfe_Functions *Functions )
The function returns a pointer to the newly created Functions object. If the object creation fails, NULL is returned.
void vfe_FunctionsEnd(vfe_Functions *p)
destroy an instance of a Functions object
Vint vfe_FunctionsError(vfe_Functions *p)
return the current value of a Functions object error flag
void vfe_FunctionsSetFunction(vfe_Functions *p, Vint funtype, Vfunc *function, Vobject *object)
set callback functions
Set callback functions. By default the display callback is NULL. A callback is not invoked if it is NULL. Each function will be called with its own set of parameters. For all functions the four first parameters correspond to the element (Vobject *), the function object (Vobject *) the connect object (vis_Connect *) and the elementindex (Vint) of the aforementioned element. The element object should be casted to what the user is expecting, for instance, if the user is setting functions for the vfe_Solid3D element module, element can be casted to a vfe_Solid3D * type. The connect object and the element index are passed as a mean to obtain element connectivities of adjacent nodes/elements, or any other topologic information the user needs to perform computations at the element level.
Functions registered with VFE_FUN_STIFF will be called with 5 parameters:
void userStiffness (Vobject *element, Vobject *functionobject, vis_Connect *connect, Vint elementindex, Vdouble *stiffness)
Where stiffness (Vdouble *) is the stiffness matrix that will be assembled to the global matrix.
Functions registered with VFE_FUN_ELEMLOAD will be called with 6 parameters:
void userElemLoad (Vobject *element, Vobject *functionobject, vis_Connect *connect, Vint elementindex, Vdouble accelerations, Vdouble *loads)
Where accelerations (Vdouble) array of node accelerations used to compute the consistent degree of freedom body loads loads (Vdouble *). loads, should contain loads for all degrees of freedom in the element once the function returns. See
vfe_Solid3DElemLoadfor more information.
Functions registered with VFE_FUN_DISTLOAD will be called with 9 parameters:where entitytype is the entity type on which the load is applied (e.g. SYS_EDGE or SYS_FACE), entityindex is the index of the entity within the element, loadtype is the distributed load type (e.g. VFE_DISTLOAD_TRAC, VFE_DISTLOAD_PRES…) inputloads is the vector of distributed load values, and distloads is the output degree of freedom vector of consistent distributed loads. See
void userDistLoad (Vobject *element, Vobject *functionobject, vis_Connect *connect, Vint elementindex, Vint entitytype, Vint entityindex, Vint loadtype, Vdouble *inputloads, Vdouble *distloads)
vfe_Solid3DDistLoadfor more information.
p – Pointer to Functions object.
funtype – Type of callback function to set
x=VFE_FUN_STIFF Stiffness matrix callback x=VFE_FUN_ELEMLOAD Body load callback x=VFE_FUN_DISTLOAD Distributed load callback
function – Pointer to callback function
object – Pointer to the object to be returned as function argument