16#include <grass/N_solute_transport.h>
25 int col,
int row,
int depth)
28 double dx, dy, dz, Az;
29 double diff_x, diff_y, diff_z;
35 double C,
W, E,
N, S, T, B, V;
38 double Dw = 0,
De = 0,
Dn = 0, Ds = 0,
Dt = 0,
Db = 0;
39 double rw = 0.5, re = 0.5,
rn = 0.5,
rs = 0.5,
rt = 0.5,
rb = 0.5;
105 W = -1 * (
Dw)*dy * dz -
vw * (1 -
rw) * dy * dz;
107 E = -1 * (
De)*dy * dz +
ve * (1 - re) * dy * dz;
109 S = -1 * (Ds)*dx * dz -
vs * (1 -
rs) * dx * dz;
111 N = -1 * (
Dn)*dx * dz +
vn * (1 -
rn) * dx * dz;
113 B = -1 * (
Db)*Az -
vb * (1 -
rb) * Az;
115 T = -1 * (
Dt)*Az +
vt * (1 -
rt) * Az;
129 C = ((
Dw -
vw) * dy * dz + (
De +
ve) * dy * dz + (Ds -
vs) * dx * dz +
131 Az * dz * R / data->
dt - q / nf);
134 V = (cs +
cg_start * Az * dz * R / data->
dt - q / nf * cin);
148 G_debug(6,
"N_callback_solute_transport_3d: called [%i][%i][%i]", row,
col,
183 double diff_x, diff_y;
195 double vw = 0,
ve = 0,
vn = 0,
vs = 0;
197 double Dw = 0,
De = 0,
Dn = 0, Ds = 0;
198 double rw = 0.5, re = 0.5,
rn = 0.5,
rs = 0.5;
315 E = -1 * (
De)*dy *
z_e +
ve * (1 - re) * dy *
z_e;
317 S = -1 * (Ds)*dx *
z_s +
vs * (1 -
rs) * dx *
z_s;
340 Az * z * R / data->
dt - q / nf;
343 V = (cs +
cg_start * Az * z * R / data->
dt + q / nf * cin);
358 G_debug(6,
"N_callback_solute_transport_2d: called [%i][%i]", row,
col);
570 G_debug(2,
"N_calc_solute_transport_transmission_2d: calculating "
571 "transmission boundary");
573 for (
j = 0;
j < rows;
j++) {
574 for (i = 0; i < cols; i++) {
610 if (c > 0 || c == 0 || c < 0)
639 double disp_xx, disp_yy, disp_xy;
645 G_debug(2,
"N_calc_solute_transport_disptensor_2d: calculating the "
646 "dispersivity tensor");
648 for (
j = 0;
j < rows;
j++) {
649 for (i = 0; i < cols; i++) {
657 vx = (grad.
WC + grad.
EC) / 2;
658 vy = (grad.
NC + grad.
SC) / 2;
664 disp_xy = (data->
al - data->
at) *
vx *
vy /
vv;
668 "N_calc_solute_transport_disptensor_2d: [%i][%i] disp_xx "
669 "%g disp_yy %g disp_xy %g",
670 i,
j, disp_xx, disp_yy, disp_xy);
698 int cols, rows, depths;
700 double disp_xx, disp_yy, disp_zz, disp_xy, disp_xz, disp_yz;
707 G_debug(2,
"N_calc_solute_transport_disptensor_3d: calculating the "
708 "dispersivity tensor");
710 for (k = 0; k < depths; k++) {
711 for (
j = 0;
j < rows;
j++) {
712 for (i = 0; i < cols; i++) {
722 vx = (grad.
WC + grad.
EC) / 2;
723 vy = (grad.
NC + grad.
SC) / 2;
724 vz = (grad.
BC + grad.
TC) / 2;
734 disp_xy = (data->
al - data->
at) *
vx *
vy /
vv;
735 disp_xz = (data->
al - data->
at) *
vx *
vz /
vv;
736 disp_yz = (data->
al - data->
at) *
vy *
vz /
vv;
740 "N_calc_solute_transport_disptensor_3d: [%i][%i][%i] "
741 "disp_xx %g disp_yy %g disp_zz %g disp_xy %g disp_xz "
743 i,
j, k, disp_xx, disp_yy, disp_zz, disp_xy, disp_xz,
#define N_CELL_TRANSMISSION
double N_exp_upwinding(double sprod, double distance, double D)
exponential upwinding stabilization algorithm
double N_calc_geom_mean(double a, double b)
Calculate the geometrical mean of values a and b.
double N_full_upwinding(double sprod, double distance, double D)
full upwinding stabilization algorithm
double N_calc_harmonic_mean(double a, double b)
Calculate the harmonical mean of values a and b.
void G_free(void *)
Free allocated memory.
int G_debug(int, const char *,...) __attribute__((format(printf
N_array_3d * N_alloc_array_3d(int cols, int rows, int depths, int offset, int type)
Allocate memory for a N_array_3d data structure.
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
DCELL N_get_array_2d_d_value(N_array_2d *data, int col, int row)
Returns the value of type DCELL at position col, row.
int N_is_array_2d_value_null(N_array_2d *data, int col, int row)
Returns 1 if the value of N_array_2d struct at position col, row is of type null, otherwise 0.
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
void N_put_array_3d_d_value(N_array_3d *data, int col, int row, int depth, double value)
Writes a double value to the N_array_3d struct at position col, row, depth.
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
double N_get_array_3d_d_value(N_array_3d *data, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
void N_put_array_2d_d_value(N_array_2d *data, int col, int row, DCELL value)
Writes a DCELL value to the N_array_2d struct at position col, row.
double N_get_geom_data_area_of_cell(N_geom_data *geom, int row)
Get the areay size in square meter of one cell (x*y) at row.
N_gradient_field_2d * N_alloc_gradient_field_2d(int cols, int rows)
Allocate a N_gradient_field_2d.
N_gradient_field_3d * N_alloc_gradient_field_3d(int cols, int rows, int depths)
Allocate a N_gradient_field_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].
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][co...
N_data_star * N_create_9star(double C, double W, double E, double N, double S, double NW, double SW, double NE, double SE, double V)
allocate and initialize a 9 point star data structure
N_data_star * N_create_7star(double C, double W, double E, double N, double S, double T, double B, double V)
allocate and initialize a 7 point star data structure
N_solute_transport_data2d * N_alloc_solute_transport_data2d(int cols, int rows)
Allocate memory for the solute transport data structure in two dimensions.
void N_calc_solute_transport_disptensor_2d(N_solute_transport_data2d *data)
Compute the dispersivity tensor based on the solute transport data in 2d.
void N_free_solute_transport_data2d(N_solute_transport_data2d *data)
Release the memory of the solute transport data structure in two dimensions.
N_solute_transport_data3d * N_alloc_solute_transport_data3d(int cols, int rows, int depths)
Allocate memory for the solute transport data structure in three dimensions.
void N_free_solute_transport_data3d(N_solute_transport_data3d *data)
Release the memory of the solute transport data structure in three dimensions.
N_data_star * N_callback_solute_transport_2d(void *solutedata, N_geom_data *geom, int col, int row)
This callback function creates the mass balance of a 5 point star.
N_data_star * N_callback_solute_transport_3d(void *solutedata, N_geom_data *geom, int col, int row, int depth)
This is just a placeholder.
void N_calc_solute_transport_transmission_2d(N_solute_transport_data2d *data)
Compute the transmission boundary condition in 2d.
void N_calc_solute_transport_disptensor_3d(N_solute_transport_data3d *data)
Compute the dispersivity tensor based on the solute transport data in 3d.
Matrix entries for a mass balance 5/7/9 star system.
Geometric information about the structured grid.
Gradient between the cells in X and Y direction.
Gradient between the cells in X, Y and Z direction.
N_gradient_field_2d * grad
N_gradient_field_3d * grad