# udfGetElmJac()

Return the array storage for the element Jacobian at the quadrature point.

## Syntax

jac = udfGetElmJac( 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 independent variable of the Jacobian.
- UDF_ELM_JAC_VELOCITY
- Velocity.
- UDF_ELM_JAC_PRESSURE
- Pressure.
- UDF_ELM_JAC_TEMPERATURE
- Temperature.
- UDF_ELM_JAC_SPECIES
- Species.
- UDF_ELM_JAC_STRAIN_INVARIANT_2
- Second invariant of strain rate tensor.

## Return Value

- jac (Real*)
- Pointer to multi-dimensional real array of the element Jacobian. The first (fastest) dimension of the array is the number of elements, nItems, the second dimension is one or three for the components of the UDF type, and the third (slowest) dimension is one or three for the components of the given independent variable.

## Description

This routine returns the array storage for the element Jacobian at the quadrature point. The Jacobian is defined here as the derivative of the UDF type with respect to the independent variable given by dataName. This Jacobian becomes part of the left-hand side of the solution strategy only. Therefore, it does not affect the final solution itself, but it may be very important to achieving a robust strategy to obtain the solution.

If the specified combination of type and independent variable is not supported, then a NULL is returned. If the combination is supported but the particular problem does not contain the appropriate physics, then the array storage is returned but not used. This feature is convenient for certain types of restart problems. For instance, if the type is gravity and dataName is UDF_ELM_JAC_TEMPERATURE, then storage for a two dimensional array (nItems, 3) is returned for you to fill with the appropriate data. But this data will not be used if there is no temperature equation specified in the problem. However, if such an equation is specified on restart, then the data is used by the solver.

The returned array is three dimensional in general. The first (fastest) dimension of the array is the number of elements, nItems. The second dimension is three for a UDF type of gravity and one for all other types. The third (slowest) dimension is three for a dataName of UDF_ELM_JAC_VELOCITY and one for all others. If either the second or third dimension is one then the array may be treated as two dimensional. If both are one, then the array is one-dimensional.

```
Void usrGrav( UdfHd udfHd,
Real* outVec,
Integer nItems,
Integer vecDim )
{
Real grav0 ; /* expansivity */
Integer i ; /* a running index */
Real* usrVals ; /* user supplied values */
Real* temp ; /* temperature */
Real* gravJacTemp ; /* partial grav / partial temp */
Real* xJacTemp ; /* x-gravJacTemp */
Real* yJacTemp ; /* y-gravJacTemp */
Real* zJacTemp ; /* z-gravJacTemp */
Real* xGrav ; /* x-gravity */
Real* yGrav ; /* y-gravity */
Real* zGrav ; /* z-gravity */
/*---------------------------------------------------------------------------
* Get the parameters
*---------------------------------------------------------------------------
*/
udfCheckNumUsrVals( udfHd, 1 ) ;
usrVals = udfGetUsrVals( udfHd ) ;
grav0 = usrVals[0] ;
temp = udfGetElmData( udfHd, UDF_ELM_TEMPERATURE ) ;
gravJacTemp = udfGetElmJac( udfHd, UDF_ELM_JAC_TEMPERATURE ) ;
if ( gravJacTemp == Nil(Real*) ) {
udfSetError( udfHd, "Invalid dataName" ) ;
}
xGrav = &outVec[0*nItems] ;
yGrav = &outVec[1*nItems] ;
zGrav = &outVec[2*nItems] ;
xJacTemp = &gravJacTemp[0*nItems] ;
yJacTemp = &gravJacTemp[1*nItems] ;
zJacTemp = &gravJacTemp[2*nItems] ;
/*---------------------------------------------------------------------------
* Compute the gravity and its Jacobian with respect to temperature
*---------------------------------------------------------------------------
*/
for ( i = 0 ; i < nItems ; i++ ) {
xGrav[i] = 0 ;
yGrav[i] = -grav0 + temp[i] ;
zGrav[i] = 0 ;
xJacTemp[i] = 0 ;
yJacTemp[i] = 1 ;
zJacTemp[i] = 0 ;
}
} /*
```

## 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.