GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
n_gradient.c File Reference
#include <grass/N_pde.h>
Include dependency graph for n_gradient.c:

Go to the source code of this file.

Functions

N_gradient_2dN_alloc_gradient_2d (void)
 Allocate a N_gradient_2d structure. More...
 
void N_free_gradient_2d (N_gradient_2d *grad)
 Free's a N_gradient_2d structure. More...
 
N_gradient_2dN_create_gradient_2d (double NC, double SC, double WC, double EC)
 allocate and initialize a N_gradient_2d structure More...
 
int N_copy_gradient_2d (N_gradient_2d *source, N_gradient_2d *target)
 copy a N_gradient_2d structure More...
 
N_gradient_2dN_get_gradient_2d (N_gradient_field_2d *field, N_gradient_2d *gradient, int col, int row)
 Return a N_gradient_2d structure calculated from the input gradient field at position [row][col]. More...
 
N_gradient_3dN_alloc_gradient_3d (void)
 Allocate a N_gradient_3d structure. More...
 
void N_free_gradient_3d (N_gradient_3d *grad)
 Free's a N_gradient_3d structure. More...
 
N_gradient_3dN_create_gradient_3d (double NC, double SC, double WC, double EC, double TC, double BC)
 allocate and initialize a N_gradient_3d structure More...
 
int N_copy_gradient_3d (N_gradient_3d *source, N_gradient_3d *target)
 copy a N_gradient_3d structure More...
 
N_gradient_3dN_get_gradient_3d (N_gradient_field_3d *field, N_gradient_3d *gradient, int col, int row, int depth)
 Return a N_gradient_3d structure calculated from the input gradient field at position [depth][row][col]. More...
 
N_gradient_neighbours_xN_alloc_gradient_neighbours_x (void)
 Allocate a N_gradient_neighbours_x structure. More...
 
void N_free_gradient_neighbours_x (N_gradient_neighbours_x *grad)
 Free's a N_gradient_neighbours_x structure. More...
 
N_gradient_neighbours_xN_create_gradient_neighbours_x (double NWN, double NEN, double WC, double EC, double SWS, double SES)
 Allocate and initialize a N_gradient_neighbours_x structure. More...
 
int N_copy_gradient_neighbours_x (N_gradient_neighbours_x *source, N_gradient_neighbours_x *target)
 copy a N_gradient_neighbours_x structure More...
 
N_gradient_neighbours_yN_alloc_gradient_neighbours_y (void)
 Allocate a N_gradient_neighbours_y structure. More...
 
void N_free_gradient_neighbours_y (N_gradient_neighbours_y *grad)
 Free's a N_gradient_neighbours_y structure. More...
 
N_gradient_neighbours_yN_create_gradient_neighbours_y (double NWW, double NEE, double NC, double SC, double SWW, double SEE)
 Allocate and initialize a N_gradient_neighbours_y structure. More...
 
int N_copy_gradient_neighbours_y (N_gradient_neighbours_y *source, N_gradient_neighbours_y *target)
 copy a N_gradient_neighbours_y structure More...
 
N_gradient_neighbours_zN_alloc_gradient_neighbours_z (void)
 Allocate a N_gradient_neighbours_z structure. More...
 
void N_free_gradient_neighbours_z (N_gradient_neighbours_z *grad)
 Free's a N_gradient_neighbours_z structure. More...
 
N_gradient_neighbours_zN_create_gradient_neighbours_z (double NWZ, double NZ, double NEZ, double WZ, double CZ, double EZ, double SWZ, double SZ, double SEZ)
 Allocate and initialize a N_gradient_neighbours_z structure. More...
 
int N_copy_gradient_neighbours_z (N_gradient_neighbours_z *source, N_gradient_neighbours_z *target)
 copy a N_gradient_neighbours_z structure More...
 
N_gradient_neighbours_2dN_alloc_gradient_neighbours_2d (void)
 Allocate a N_gradient_neighbours_2d structure. More...
 
void N_free_gradient_neighbours_2d (N_gradient_neighbours_2d *grad)
 Free's a N_gradient_neighbours_2d structure. More...
 
N_gradient_neighbours_2dN_create_gradient_neighbours_2d (N_gradient_neighbours_x *x, N_gradient_neighbours_y *y)
 Allocate and initialize a N_gradient_neighbours_2d structure. More...
 
int N_copy_gradient_neighbours_2d (N_gradient_neighbours_2d *source, N_gradient_neighbours_2d *target)
 copy a N_gradient_neighbours_2d structure More...
 
N_gradient_neighbours_2dN_get_gradient_neighbours_2d (N_gradient_field_2d *field, N_gradient_neighbours_2d *gradient, int col, int row)
 Return a N_gradient_neighbours_2d structure calculated from the input gradient field at position [row][col]. More...
 
N_gradient_neighbours_3dN_alloc_gradient_neighbours_3d (void)
 Allocate a N_gradient_neighbours_3d structure. More...
 
void N_free_gradient_neighbours_3d (N_gradient_neighbours_3d *grad)
 Free's a N_gradient_neighbours_3d structure. More...
 
N_gradient_neighbours_3dN_create_gradient_neighbours_3d (N_gradient_neighbours_x *xt, N_gradient_neighbours_x *xc, N_gradient_neighbours_x *xb, N_gradient_neighbours_y *yt, N_gradient_neighbours_y *yc, N_gradient_neighbours_y *yb, N_gradient_neighbours_z *zt, N_gradient_neighbours_z *zb)
 Allocate and initialize a N_gradient_neighbours_3d structure. More...
 
int N_copy_gradient_neighbours_3d (N_gradient_neighbours_3d *source, N_gradient_neighbours_3d *target)
 copy a N_gradient_neighbours_3d structure More...
 
N_gradient_field_2dN_alloc_gradient_field_2d (int cols, int rows)
 Allocate a N_gradient_field_2d. More...
 
void N_free_gradient_field_2d (N_gradient_field_2d *field)
 Free's a N_gradient_neighbours_2d structure. More...
 
int N_copy_gradient_field_2d (N_gradient_field_2d *source, N_gradient_field_2d *target)
 Copy N_gradient_field_2d structure from source to target. More...
 
void N_print_gradient_field_2d_info (N_gradient_field_2d *field)
 Print gradient field information to stdout. More...
 
N_gradient_field_3dN_alloc_gradient_field_3d (int cols, int rows, int depths)
 Allocate a N_gradient_field_3d. More...
 
void N_free_gradient_field_3d (N_gradient_field_3d *field)
 Free's a N_gradient_neighbours_3d structure. More...
 
int N_copy_gradient_field_3d (N_gradient_field_3d *source, N_gradient_field_3d *target)
 Copy N_gradient_field_3d structure from source to target. More...
 
void N_print_gradient_field_3d_info (N_gradient_field_3d *field)
 Print gradient field information to stdout. More...
 

Function Documentation

N_gradient_2d* N_alloc_gradient_2d ( void  )

Allocate a N_gradient_2d structure.

Returns
N_gradient_2d *

Definition at line 27 of file n_gradient.c.

Referenced by N_create_gradient_2d().

N_gradient_3d* N_alloc_gradient_3d ( void  )

Allocate a N_gradient_3d structure.

Returns
N_gradient_3d *

Definition at line 151 of file n_gradient.c.

Referenced by N_create_gradient_3d().

N_gradient_field_2d* N_alloc_gradient_field_2d ( int  cols,
int  rows 
)

Allocate a N_gradient_field_2d.

The field arrays are of type DCELL.

Parameters
rows- number of rows of the 2d array from which the gradient should be calculated
cols- number of cols of the 2d array from which the gradient should be calculated
Returns
N_gradient_field_2d *

Definition at line 920 of file n_gradient.c.

References Cell_head::cols, N_gradient_field_2d::cols, DCELL_TYPE, G_debug(), N_alloc_array_2d(), Cell_head::rows, N_gradient_field_2d::rows, N_gradient_field_2d::x_array, and N_gradient_field_2d::y_array.

Referenced by N_alloc_solute_transport_data2d(), and N_compute_gradient_field_2d().

N_gradient_field_3d* N_alloc_gradient_field_3d ( int  cols,
int  rows,
int  depths 
)

Allocate a N_gradient_field_3d.

The field arrays are always of type DCELL_TYPE.

Parameters
cols- number of cols of the 3d array from which the gradient should be calculated
rows- number of rows of the 3d array from which the gradient should be calculated
depths- number of depths of the 3d array from which the gradient should be calculated
Returns
N_gradient_field_3d *

Definition at line 1018 of file n_gradient.c.

References Cell_head::cols, N_gradient_field_3d::cols, DCELL_TYPE, Cell_head::depths, N_gradient_field_3d::depths, G_debug(), N_alloc_array_3d(), Cell_head::rows, N_gradient_field_3d::rows, N_gradient_field_3d::x_array, N_gradient_field_3d::y_array, and N_gradient_field_3d::z_array.

Referenced by N_alloc_solute_transport_data3d(), and N_compute_gradient_field_3d().

N_gradient_neighbours_2d* N_alloc_gradient_neighbours_2d ( void  )

Allocate a N_gradient_neighbours_2d structure.

This structure contains all neighbour gradients in all directions of one cell in a 2d raster layer

Returns
N_gradient_neighbours_2d *

Definition at line 587 of file n_gradient.c.

References N_alloc_gradient_neighbours_x(), N_alloc_gradient_neighbours_y(), N_gradient_neighbours_2d::x, and N_gradient_neighbours_2d::y.

Referenced by N_create_gradient_neighbours_2d().

N_gradient_neighbours_x* N_alloc_gradient_neighbours_x ( void  )

Allocate a N_gradient_neighbours_x structure.

This structure contains all neighbour gradients in x direction of one cell

Returns
N_gradient_neighbours_x *

Definition at line 290 of file n_gradient.c.

Referenced by N_alloc_gradient_neighbours_2d(), N_alloc_gradient_neighbours_3d(), and N_create_gradient_neighbours_x().

N_gradient_neighbours_y* N_alloc_gradient_neighbours_y ( void  )

Allocate a N_gradient_neighbours_y structure.

This structure contains all neighbour gradients in y direction of one cell

Returns
N_gradient_neighbours_y *

Definition at line 386 of file n_gradient.c.

Referenced by N_alloc_gradient_neighbours_2d(), N_alloc_gradient_neighbours_3d(), and N_create_gradient_neighbours_y().

N_gradient_neighbours_z* N_alloc_gradient_neighbours_z ( void  )

Allocate a N_gradient_neighbours_z structure.

This structure contains all neighbour gradients in z direction of one cell

Returns
N_gradient_neighbours_z *

Definition at line 481 of file n_gradient.c.

Referenced by N_alloc_gradient_neighbours_3d(), and N_create_gradient_neighbours_z().

int N_copy_gradient_2d ( N_gradient_2d source,
N_gradient_2d target 
)

copy a N_gradient_2d structure

Parameters
source- the source N_gradient_2d struct
target- the target N_gradient_2d struct
Returns
int - 1 success, 0 failure while copying

Definition at line 85 of file n_gradient.c.

References N_gradient_2d::EC, G_debug(), N_gradient_2d::NC, N_gradient_2d::SC, and N_gradient_2d::WC.

int N_copy_gradient_3d ( N_gradient_3d source,
N_gradient_3d target 
)

copy a N_gradient_3d structure

Parameters
source- the source N_gradient_3d struct
target- the target N_gradient_3d struct
Returns
int - 1 success, 0 failure while copying

Definition at line 214 of file n_gradient.c.

References N_gradient_3d::BC, N_gradient_3d::EC, G_debug(), N_gradient_3d::NC, N_gradient_3d::SC, N_gradient_3d::TC, and N_gradient_3d::WC.

int N_copy_gradient_field_2d ( N_gradient_field_2d source,
N_gradient_field_2d target 
)

Copy N_gradient_field_2d structure from source to target.

Parameters
source- the source N_gradient_field_2d struct
target- the target N_gradient_field_2d struct
Returns
int - 1 success, 0 failure while copying

Definition at line 966 of file n_gradient.c.

References G_debug(), N_copy_array_2d(), N_gradient_field_2d::x_array, and N_gradient_field_2d::y_array.

int N_copy_gradient_field_3d ( N_gradient_field_3d source,
N_gradient_field_3d target 
)

Copy N_gradient_field_3d structure from source to target.

Parameters
source- the source N_gradient_field_3d struct
target- the target N_gradient_field_3d struct
Returns
int - 1 success, 0 failure while copying

Definition at line 1069 of file n_gradient.c.

References G_debug(), N_copy_array_3d(), N_gradient_field_3d::x_array, N_gradient_field_3d::y_array, and N_gradient_field_3d::z_array.

int N_copy_gradient_neighbours_2d ( N_gradient_neighbours_2d source,
N_gradient_neighbours_2d target 
)

copy a N_gradient_neighbours_2d structure

Parameters
source- the source N_gradient_neighbours_2d struct
target- the target N_gradient_neighbours_2d struct
Returns
int - 1 success, 0 failure while copying

Definition at line 663 of file n_gradient.c.

References G_debug(), N_copy_gradient_neighbours_x(), N_copy_gradient_neighbours_y(), N_gradient_neighbours_2d::x, and N_gradient_neighbours_2d::y.

Referenced by N_get_gradient_neighbours_2d().

N_gradient_2d* N_create_gradient_2d ( double  NC,
double  SC,
double  WC,
double  EC 
)

allocate and initialize a N_gradient_2d structure

Parameters
NCdouble - the gradient between northern and center cell
SCdouble - the gradient between southern and center cell
WCdouble - the gradient between western and center cell
ECdouble - the gradient between eastern and center cell
Returns
N_gradient_2d *

Definition at line 60 of file n_gradient.c.

References N_gradient_2d::EC, G_debug(), N_alloc_gradient_2d(), N_gradient_2d::NC, N_gradient_2d::SC, and N_gradient_2d::WC.

Referenced by N_get_gradient_2d().

N_gradient_3d* N_create_gradient_3d ( double  NC,
double  SC,
double  WC,
double  EC,
double  TC,
double  BC 
)

allocate and initialize a N_gradient_3d structure

Parameters
NCdouble - the gradient between northern and center cell
SCdouble - the gradient between southern and center cell
WCdouble - the gradient between western and center cell
ECdouble - the gradient between eastern and center cell
TCdouble - the gradient between top and center cell
BCdouble - the gradient between bottom and center cell
Returns
N_gradient_3d *

Definition at line 187 of file n_gradient.c.

References N_gradient_3d::BC, N_gradient_3d::EC, G_debug(), N_alloc_gradient_3d(), N_gradient_3d::NC, N_gradient_3d::SC, N_gradient_3d::TC, and N_gradient_3d::WC.

Referenced by N_get_gradient_3d().

N_gradient_neighbours_2d* N_create_gradient_neighbours_2d ( N_gradient_neighbours_x x,
N_gradient_neighbours_y y 
)

Allocate and initialize a N_gradient_neighbours_2d structure.

The parameter N_gradient_neighbours x and y are copied into the new allocated structure and can be deleted after the initializing

Returns
N_gradient_neighbours_2d * – if failure NULL is returned

Definition at line 630 of file n_gradient.c.

References G_debug(), N_alloc_gradient_neighbours_2d(), N_copy_gradient_neighbours_x(), N_copy_gradient_neighbours_y(), N_free_gradient_neighbours_2d(), NULL, N_gradient_neighbours_2d::x, and N_gradient_neighbours_2d::y.

Referenced by N_get_gradient_neighbours_2d().

N_gradient_neighbours_x* N_create_gradient_neighbours_x ( double  NWN,
double  NEN,
double  WC,
double  EC,
double  SWS,
double  SES 
)

Allocate and initialize a N_gradient_neighbours_x structure.

Parameters
NWNdouble - the gradient between north-west and northern cell
NENdouble - the gradient between north-east and northern cell
WCdouble - the gradient between western and center cell
ECdouble - the gradient between eastern and center cell
SWSdouble - the gradient between south-west and southern cell
SESdouble - the gradient between south-east and southern cell
Returns
N_gradient_neighbours_x *

Definition at line 329 of file n_gradient.c.

References N_gradient_neighbours_x::EC, G_debug(), N_alloc_gradient_neighbours_x(), N_gradient_neighbours_x::NEN, N_gradient_neighbours_x::NWN, N_gradient_neighbours_x::SES, N_gradient_neighbours_x::SWS, and N_gradient_neighbours_x::WC.

Referenced by N_get_gradient_neighbours_2d().

N_gradient_neighbours_y* N_create_gradient_neighbours_y ( double  NWW,
double  NEE,
double  NC,
double  SC,
double  SWW,
double  SEE 
)

Allocate and initialize a N_gradient_neighbours_y structure.

Parameters
NWWdouble - the gradient between north-west and western cell
NEEdouble - the gradient between north-east and eastern cell
NCdouble - the gradient between northern and center cell
SCdouble - the gradient between southern and center cell
SWWdouble - the gradient between south-west and western cell
SEEdouble - the gradient between south-east and eastern cell
Returns
N_gradient_neighbours_y *

Definition at line 424 of file n_gradient.c.

References G_debug(), N_alloc_gradient_neighbours_y(), N_gradient_neighbours_y::NC, N_gradient_neighbours_y::NEE, N_gradient_neighbours_y::NWW, N_gradient_neighbours_y::SC, N_gradient_neighbours_y::SEE, and N_gradient_neighbours_y::SWW.

Referenced by N_get_gradient_neighbours_2d().

N_gradient_neighbours_z* N_create_gradient_neighbours_z ( double  NWZ,
double  NZ,
double  NEZ,
double  WZ,
double  CZ,
double  EZ,
double  SWZ,
double  SZ,
double  SEZ 
)

Allocate and initialize a N_gradient_neighbours_z structure.

Parameters
NWZdouble - the gradient between upper and lower north-western cells
NZdouble - the gradient between upper and lower northern cells
NEZdouble - the gradient between upper and lower north-eastern cells
WZdouble - the gradient between upper and lower western cells
CZdouble - the gradient between upper and lower center cells
EZdouble - the gradient between upper and lower eastern cells
SWZdouble - the gradient between upper and lower south-western cells
SZdouble - the gradient between upper and lower southern cells
SEZdouble - the gradient between upper and lower south-eastern cells
Returns
N_gradient_neighbours_z *

Definition at line 522 of file n_gradient.c.

References N_gradient_neighbours_z::CZ, N_gradient_neighbours_z::EZ, G_debug(), N_alloc_gradient_neighbours_z(), N_gradient_neighbours_z::NEZ, N_gradient_neighbours_z::NWZ, N_gradient_neighbours_z::NZ, N_gradient_neighbours_z::SEZ, N_gradient_neighbours_z::SWZ, N_gradient_neighbours_z::SZ, and N_gradient_neighbours_z::WZ.

void N_free_gradient_2d ( N_gradient_2d grad)

Free's a N_gradient_2d structure.

Returns
void

Definition at line 42 of file n_gradient.c.

References G_free(), and NULL.

void N_free_gradient_3d ( N_gradient_3d grad)

Free's a N_gradient_3d structure.

Returns
void

Definition at line 166 of file n_gradient.c.

References G_free(), and NULL.

void N_free_gradient_field_2d ( N_gradient_field_2d field)

Free's a N_gradient_neighbours_2d structure.

Returns
void

Definition at line 944 of file n_gradient.c.

References G_free(), N_free_array_2d(), NULL, N_gradient_field_2d::x_array, and N_gradient_field_2d::y_array.

void N_free_gradient_field_3d ( N_gradient_field_3d field)
void N_free_gradient_neighbours_x ( N_gradient_neighbours_x grad)

Free's a N_gradient_neighbours_x structure.

Returns
void

Definition at line 307 of file n_gradient.c.

References G_free(), and NULL.

Referenced by N_free_gradient_neighbours_2d(), N_free_gradient_neighbours_3d(), and N_get_gradient_neighbours_2d().

void N_free_gradient_neighbours_y ( N_gradient_neighbours_y grad)

Free's a N_gradient_neighbours_y structure.

Returns
void

Definition at line 403 of file n_gradient.c.

References G_free(), and NULL.

Referenced by N_free_gradient_neighbours_2d(), N_free_gradient_neighbours_3d(), and N_get_gradient_neighbours_2d().

void N_free_gradient_neighbours_z ( N_gradient_neighbours_z grad)

Free's a N_gradient_neighbours_z structure.

Returns
void

Definition at line 498 of file n_gradient.c.

References G_free(), and NULL.

Referenced by N_free_gradient_neighbours_3d().

N_gradient_2d* N_get_gradient_2d ( N_gradient_field_2d field,
N_gradient_2d gradient,
int  col,
int  row 
)

Return a N_gradient_2d structure calculated from the input gradient field at position [row][col].

This function returns the gradient of a cell at position [row][col] from the input gradient field. Returend is a new structure of type N_gradient_2d.

Parameters
fieldN_gradient_field_2d * - A two dimensional gradient field
gradientN_gradient_2d * - the gradient structure which should be filled with data, if a NULL pointer is given, a new structure will be created
colint
rowint
Returns
N_gradient_2d * - the new or filled gradient structure

Definition at line 115 of file n_gradient.c.

References N_gradient_2d::EC, G_debug(), N_create_gradient_2d(), N_get_array_2d_d_value(), N_gradient_2d::NC, N_gradient_2d::SC, N_gradient_2d::WC, N_gradient_field_2d::x_array, and N_gradient_field_2d::y_array.

Referenced by N_calc_solute_transport_disptensor_2d(), N_calc_solute_transport_transmission_2d(), N_callback_solute_transport_2d(), and N_compute_gradient_field_components_2d().

N_gradient_3d* N_get_gradient_3d ( N_gradient_field_3d field,
N_gradient_3d gradient,
int  col,
int  row,
int  depth 
)

Return a N_gradient_3d structure calculated from the input gradient field at position [depth][row][col].

This function returns the gradient of a 3d cell at position [depth][row][col] from the input gradient field. Returned is a new structure of type N_gradient_3d.

Parameters
fieldN_gradient_field_3d * - A three dimensional gradient field
gradientN_gradient_3d * - an existing gradient structure or a NULL pointer, if a NULL pointer is providet a new structure will be returned
colint
rowint
depthint
Returns
N_gradient_3d *

Definition at line 248 of file n_gradient.c.

References N_gradient_3d::BC, N_gradient_3d::EC, G_debug(), N_create_gradient_3d(), N_get_array_3d_d_value(), N_gradient_3d::NC, N_gradient_3d::SC, N_gradient_3d::TC, N_gradient_3d::WC, N_gradient_field_3d::x_array, N_gradient_field_3d::y_array, and N_gradient_field_3d::z_array.

Referenced by N_calc_solute_transport_disptensor_3d(), N_callback_solute_transport_3d(), and N_compute_gradient_field_components_3d().

N_gradient_neighbours_2d* N_get_gradient_neighbours_2d ( N_gradient_field_2d field,
N_gradient_neighbours_2d gradient,
int  col,
int  row 
)

Return a N_gradient_neighbours_2d structure calculated from the input gradient field at position [row][col].

This function returns the gradient neighbours in x and y dierection of a cell at position [row][col] from the input gradient field. Returend is a pointer to a structure of type N_gradient_neighbours_2d.

Parameters
fieldN_gradient_field_2d * - A two dimensional gradient field
gradientN_gradient_neighbours_2d * - the gradient structure which should be filled with data, if a NULL pointer is given, a new structure will be created
colint
rowint
Returns
N_gradient_neighbours_2d * - the new or filled gradient structure

Definition at line 702 of file n_gradient.c.

References G_debug(), N_copy_gradient_neighbours_2d(), N_create_gradient_neighbours_2d(), N_create_gradient_neighbours_x(), N_create_gradient_neighbours_y(), N_free_gradient_neighbours_2d(), N_free_gradient_neighbours_x(), N_free_gradient_neighbours_y(), N_get_array_2d_d_value(), NULL, N_gradient_field_2d::x_array, and N_gradient_field_2d::y_array.

void N_print_gradient_field_2d_info ( N_gradient_field_2d field)