GRASS Programmer's Manual  6.5.svn(2014)-r66266
`#include <grass/N_pde.h>`

Go to the source code of this file.

## Functions

Calculate basic statistics of a gradient field. More...

This function computes the gradient based on the input N_array_2d pot (potential), a weighting factor N_array_2d named weight and the distance between two cells saved in the N_geom_data struct. More...

Calculate the x and y vector components from a gradient field for each cell and stores them in the provided N_array_2d structures. More...

Calculate basic statistics of a gradient field. More...

This function computes the gradient based on the input N_array_3d pot (that means potential), a weighting factor N_array_3d named weight and the distance between two cells saved in the N_geom_data struct. More...

Calculate the x, y and z vector components from a gradient field for each cell and store them in the provided N_array_3d structures. More...

## Function Documentation

Calculate basic statistics of a gradient field.

The statistic is stored in the gradient field struct

Parameters
Returns
void

Definition at line 29 of file N_gradient_calc.c.

Calculate basic statistics of a gradient field.

The statistic is stored in the gradient field struct

Parameters
Returns
void

Definition at line 311 of file N_gradient_calc.c.

This function computes the gradient based on the input N_array_2d pot (potential), a weighting factor N_array_2d named weight and the distance between two cells saved in the N_geom_data struct.

The gradient is calculated between cells for each cell and direction. An existing gradient field can be filled with new data or, if a NULL pointer is given, a new gradient field will be allocated with the appropriate size.

```______________
|    |    |    |
|    |    |    |
|----|-NC-|----|
|    |    |    |
|   WC    EC   |
|    |    |    |
|----|-SC-|----|
|    |    |    |
|____|____|____|

x - direction:

r = 2 * weight[row][col]*weight[row][col + 1] / (weight[row][col]*weight[row][col + 1])
EC = r * (pot[row][col] - pot[row][col + 1])/dx

y - direction:

r = 2 * weight[row][col]*weight[row + 1][col] / (weight[row][col]*weight[row + 1][col])
SC = r * (pot[row][col] - pot[row + 1][col])/dy

the values SC and EC are the values of the next row/col```
Parameters
 pot N_array_2d * - the potential N_array_2d weight_x N_array_2d * - the weighting factor N_array_2d used to modify the gradient in x-direction weight_y N_array_2d * - the weighting factor N_array_2d used to modify the gradient in y-direction geom N_geom_data * - geometry data structure gradfield N_gradient_field_2d * - a gradient field of the correct size, if a NULL pointer is provided this gradient field will be new allocated
Returns

Definition at line 108 of file N_gradient_calc.c.

This function computes the gradient based on the input N_array_3d pot (that means potential), a weighting factor N_array_3d named weight and the distance between two cells saved in the N_geom_data struct.

The gradient is calculated between cells for each cell and direction. An existing gradient field can be filled with new data or, if a NULL pointer is given, a new gradient field will be allocated with the appropriate size.

```|  /
TC NC
|/
--WC-----EC--
/|
SC BC
/  |

x - direction:

r = 2 * weight_x[depth][row][col]*weight_x[depth][row][col + 1] / (weight_X[depth][row][col]*weight_x[depth][row][col + 1])
EC = r * (pot[depth][row][col] - pot[depth][row][col + 1])/dx

y - direction:

r = 2 * weight_y[depth][row][col]*weight_y[depth][row + 1][col] / (weight_y[depth][row][col]*weight_y[depth][row + 1][col])
SC = r * (pot[depth][row][col] - pot[depth][row + 1][col])/dy

z - direction:

r = 2 * weight_z[depth][row][col]*weight_z[depth + 1][row][col] / (weight_z[depth][row][col]*weight_z[depth + 1][row][col])
TC = r * (pot[depth][row][col] - pot[depth + 1][row][col])/dy

the values BC, NC, WC are the values of the next depth/row/col```
Parameters
 pot N_array_3d * - the potential N_array_2d weight_x N_array_3d * - the weighting factor N_array_3d used to modify the gradient in x-direction weight_y N_array_3d * - the weighting factor N_array_3d used to modify the gradient in y-direction weight_z N_array_3d * - the weighting factor N_array_3d used to modify the gradient in z-direction geom N_geom_data * - geometry data structure gradfield N_gradient_field_3d * - a gradient field of the correct size, if a NULL pointer is provided this gradient field will be new allocated
Returns

Definition at line 400 of file N_gradient_calc.c.

 void N_compute_gradient_field_components_2d ( N_gradient_field_2d * field, N_array_2d * x_comp, N_array_2d * y_comp )

Calculate the x and y vector components from a gradient field for each cell and stores them in the provided N_array_2d structures.

The arrays must have the same size as the gradient field.

```Based on this storages scheme the gradient vector for each cell is
calculated and stored in the provided  N_array_2d structures

______________
|    |    |    |
|    |    |    |
|----|-NC-|----|
|    |    |    |
|   WC    EC   |
|    |    |    |
|----|-SC-|----|
|    |    |    |
|____|____|____|

x vector component:

x = (WC + EC) / 2

y vector component:

y = (NC + SC) / 2```
Parameters
 field N_gradient_field_2d * x_comp N_array_2d * - the array in which the x component will be written y_comp N_array_2d * - the array in which the y component will be written
Returns
void

Definition at line 249 of file N_gradient_calc.c.

 void N_compute_gradient_field_components_3d ( N_gradient_field_3d * field, N_array_3d * x_comp, N_array_3d * y_comp, N_array_3d * z_comp )

Calculate the x, y and z vector components from a gradient field for each cell and store them in the provided N_array_3d structures.

The arrays must have the same size as the gradient field.

```Based on this storages scheme the gradient vector for each cell is
calculated and stored in the provided  N_array_3d structures

|  /
TC NC
|/
--WC-----EC--
/|
SC BC
/  |

x vector component:

x = (WC + EC) / 2

y vector component:

y = (NC + SC) / 2

z vector component:

z = (TC + BC) / 2```
Parameters
 field N_gradient_field_3d * x_comp N_array_3d * - the array in which the x component will be written y_comp N_array_3d * - the array in which the y component will be written z_comp N_array_3d * - the array in which the z component will be written
Returns
void

Definition at line 596 of file N_gradient_calc.c.