# udfGetElmData()

Return the element data at the quadrature point.

## Syntax

data = udfGetElmData( udfHd, dataName ) ;

## Type

User Defined Element

## Parameters

- udfHd
- The opaque handle (pointer) which was passed to the user function.
- dataName (integer)
- Symbolic name of the requested data.
- UDF_ELM_VELOCITY
- Velocity.
- UDF_ELM_ACCELERATION
- Acceleration.
- UDF_ELM_PRESSURE
- Pressure.
- UDF_ELM_TEMPERATURE
- Temperature.
- UDF_ELM_DENSITY
- Density.
- UDF_ELM_SPECIES
- Species.
- UDF_ELM_VISCOSITY
- Viscosity.
- UDF_ELM_EDDY_VISCOSITY
- Turbulence eddy viscosity.
- UDF_ELM_KINETIC_ENERGY
- Turbulence kinetic energy.
- UDF_ELM_EDDY_FREQUENCY
- Turbulence eddy frequency.
- UDF_ELM_GRAD_VELOCITY
- Gradient of velocity.
- UDF_ELM_GRAD_PRESSURE
- Gradient of pressure.
- UDF_ELM_GRAD_TEMPERATURE
- Gradient of temperature.
- UDF_ELM_GRAD_SPECIES
- Gradient of species.
- UDF_ELM_MESH_DISPLACEMENT
- Mesh displacement.
- UDF_ELM_MESH_VELOCITY
- Mesh velocity.
- UDF_ELM_MESH_GRAD_DISPLACEMENT
- Gradient of mesh displacement.
- UDF_ELM_MESH_GRAD_VELOCITY
- Gradient of mesh velocity.
- UDF_ELM_TURBULENCE_Y
- Distance to nearest turbulence wall.
- UDF_ELM_TURBULENCE_YPLUS
- Turbulence y+ based on distance to nearest turbulence wall and shear at that wall.
- UDF_ELM_VISCOELASTIC
- Viscoelastic.

## Return Value

- data (Real*)
- Pointer to one, two, or three dimensional real array of the requested data. The dimensions of
the array depend on dataName as follows. If the third (slowest)
dimension of the array is equal to one, then the array may be treated as two
dimensional. If the second dimension is likewise one, then the array is one dimensional.
The x, y, z components of the gradient for gradient quantities are always contained in
the last nontrivial dimension.
Table 1. dataName First Dimension Second Dimension Third Dimension UDF_ELM_VELOCITY nItems 3 1 UDF_ELM_ACCLERATION nItems 3 1 UDF_ELM_PRESSURE nItems 1 1 UDF_ELM_TEMPERATURE nItems 1 1 UDF_ELM_DENSITY nItems 1 1 UDF_ELM_SPECIES nItems udfGetNumSpecs() 1 UDF_ELM_VISCOSITY nItems 1 1 UDF_ELM_EDDY_VISCOSITY nItems 1 1 UDF_ELM_KINETIC_ENERGY nItems 1 1 UDF_ELM_EDDY_FREQUENCY nItems 1 1 UDF_ELM_GRAD_VELOCITY nItems 3 3 UDF_ELM_GRAD_PRESSURE nItems 3 1 UDF_ELM_GRAD_TEMPERATURE nItems 3 1 UDF_ELM_GRAD_SPECIES nItems udfGetNumSpecs() 3 UDF_ELM_MESH_DISPLACEMENT nItems 3 1 UDF_ELM_MESH_VELOCITY nItems 3 1 UDF_ELM_MESH_GRAD_DISPLACEMENT nItems 3 3 UDF_ELM_MESH_GRAD_VELOCITY nItems 3 3 UDF_ELM_TURBULENCE_Y nItems 1 1 UDF_ELM_TURBULENCE_YPLUS nItems 1 1 UDF_ELM_VISCOELASTIC nItems 6 1

## Description

```
Real* data ;
Real* grad_x ;
Real* grad_y ;
Real* grad_z ;
Real* s_x ;
Real* s_y ;
Real* s_z ;
Real u, v, w ;
Real u_x, v_x, w_x, u_y, v_y, w_y, u_z, v_z, w_z ;
Real spec_x, spec_y, spec_z ;
Integer elem, nSpecs, specId ;
...
data = udfGetElmData( udfHd, UDF_ELM_VELOCITY ) ;
for ( elem = 0 ; elem < nItems ; elem++ ) {
u = data[0*nItems+elem] ;
v = data[1*nItems+elem] ;
w = data[2*nItems+elem] ;
...
}
...
data = udfGetElmData( udfHd, UDF_ELM_GRAD_VELOCITY ) ;
for ( elem = 0 ; elem < nItems ; elem++ ) {
u_x = data[0*nItems+elem] ;
v_x = data[1*nItems+elem] ;
w_x = data[2*nItems+elem] ;
u_y = data[3*nItems+elem] ;
v_y = data[4*nItems+elem] ;
w_y = data[5*nItems+elem] ;
u_z = data[6*nItems+elem] ;
v_z = data[7*nItems+elem] ;
w_z = data[8*nItems+elem] ;
...
}
...
data = udfGetElmData( udfHd, UDF_ELM_GRAD_SPECIES ) ;
nSpecs = udfGetNumSpecs( udfHd ) ;
for ( specId = 0 ; specId < nSpecs ; specId++ ) {
for ( elem = 0 ; elem < nItems ; elem++ ) {
/* 3 components of gradient of species */
spec_x = data[nItems*(0*nSpecs+specId)+elem] ;
spec_y = data[nItems*(1*nSpecs+specId)+elem] ;
spec_z = data[nItems*(2*nSpecs+specId)+elem] ;
...
}
}
/* Alternative coding of the above. */
/* grad_? are pointers to 2-D arrays, and */
/* s_? are pointers to 1-D arrays. */
data = udfGetElmData( udfHd, UDF_ELM_GRAD_SPECIES ) ;
nSpecs = udfGetNumSpecs( udfHd ) ;
grad_x = &data[0*nItems*nSpecs] ;
grad_y = &data[1*nItems*nSpecs] ;
grad_z = &data[2*nItems*nSpecs] ;
for ( specId = 0 ; specId < nSpecs ; specId++ ) {
s_x = &grad_x[nItems*specId] ;
s_y = &grad_y[nItems*specId] ;
s_z = &grad_z[nItems*specId] ;
for ( elem = 0 ; elem < nItems ; elem++ ) {
/* 3 components of gradient of species */
spec_x = s_x[elem] ;
spec_y = s_y[elem] ;
spec_z = s_z[elem] ;
...
}
}
```

The quantities UDF_ELM_TURBULENCE_Y and UDF_ELM_TURBULENCE_YPLUS are based on the distance to the nearest turbulence wall. These are defined by TURBULENCE_WALL and SIMPLE_BOUNDARY_CONDITION type=wall commands. UDF_ELM_TURBULENCE_YPLUS also uses the shear at these walls. The data for these two quantities are current (computed at the end of each stagger) while the other quantities are computed only at the end of each time step.

## Errors

- This routine expects a valid udfHd.
- This routine may only be called within a Body Force, Material Model or Component Model user function.
- dataName must be one of the values given above.
- The problem must contain the equation associated with the requested data.