Skip to main content

grad

Description

The grad function object computes the gradient of an input field.

The operation is limited to scalar and vector volume or surface fields, and the output is a volume vector or tensor field.

Operands

OperandTypeLocation
input{vol,surface}{Scalar,Vector}Field$FOAM_CASE/<time>/<inpField>
output file--
output fieldvol{Vector,Tensor}Field$FOAM_CASE/<time>/<outField>

Usage

Example of the grad function object by using functions sub-dictionary in system/controlDict file:

grad1
{
// Mandatory entries (unmodifiable)
type grad;
libs (fieldFunctionObjects);

// Mandatory (inherited) entries (runtime modifiable)
field <field>;

// Optional (inherited) entries
result <fieldResult>;
region region0;
enabled true;
log true;
timeStart 0;
timeEnd 1000;
executeControl timeStep;
executeInterval 1;
writeControl timeStep;
writeInterval 1;
}

where the entries mean:

PropertyDescriptionTypeRequiredDefault
typeType name: gradwordyes-
libsLibrary name: fieldFunctionObjectswordyes-
fieldName of the operand fieldwordyes-

The inherited entries are elaborated in:

Example by using the postProcess utility:

postProcess -func "grad(<field>)"

Further information

Tutorial:

Source code:

API:

History: Introduced in version v1606+