19#include <grass/N_solute_transport.h>
28 int col,
int row,
int depth)
31 double dx, dy, dz, Az;
32 double diff_x, diff_y, diff_z;
38 double C,
W, E,
N, S, T, B, V;
41 double Dw = 0,
De = 0,
Dn = 0, Ds = 0,
Dt = 0,
Db = 0;
42 double rw = 0.5, re = 0.5,
rn = 0.5,
rs = 0.5,
rt = 0.5,
rb = 0.5;
108 W = -1 * (
Dw)*dy * dz -
vw * (1 -
rw) * dy * dz;
110 E = -1 * (
De)*dy * dz +
ve * (1 - re) * dy * dz;
112 S = -1 * (Ds)*dx * dz -
vs * (1 -
rs) * dx * dz;
114 N = -1 * (
Dn)*dx * dz +
vn * (1 -
rn) * dx * dz;
116 B = -1 * (
Db)*Az -
vb * (1 -
rb) * Az;
118 T = -1 * (
Dt)*Az +
vt * (1 -
rt) * Az;
132 C = ((
Dw -
vw) * dy * dz + (
De +
ve) * dy * dz + (Ds -
vs) * dx * dz +
134 Az * dz * R / data->
dt - q / nf);
137 V = (cs +
cg_start * Az * dz * R / data->
dt - q / nf * cin);
151 G_debug(6,
"N_callback_solute_transport_3d: called [%i][%i][%i]", row,
col,
186 double diff_x, diff_y;
198 double vw = 0,
ve = 0,
vn = 0,
vs = 0;
200 double Dw = 0,
De = 0,
Dn = 0, Ds = 0;
201 double rw = 0.5, re = 0.5,
rn = 0.5,
rs = 0.5;
318 E = -1 * (
De)*dy *
z_e +
ve * (1 - re) * dy *
z_e;
320 S = -1 * (Ds)*dx *
z_s +
vs * (1 -
rs) * dx *
z_s;
343 Az * z * R / data->
dt - q / nf;
346 V = (cs +
cg_start * Az * z * R / data->
dt + q / nf * cin);
361 G_debug(6,
"N_callback_solute_transport_2d: called [%i][%i]", row,
col);
573 G_debug(2,
"N_calc_solute_transport_transmission_2d: calculating "
574 "transmission boundary");
576 for (
j = 0;
j < rows;
j++) {
577 for (i = 0; i < cols; i++) {
613 if (c > 0 || c == 0 || c < 0)
642 double disp_xx, disp_yy, disp_xy;
648 G_debug(2,
"N_calc_solute_transport_disptensor_2d: calculating the "
649 "dispersivity tensor");
651 for (
j = 0;
j < rows;
j++) {
652 for (i = 0; i < cols; i++) {
660 vx = (grad.
WC + grad.
EC) / 2;
661 vy = (grad.
NC + grad.
SC) / 2;
667 disp_xy = (data->
al - data->
at) *
vx *
vy /
vv;
671 "N_calc_solute_transport_disptensor_2d: [%i][%i] disp_xx "
672 "%g disp_yy %g disp_xy %g",
673 i,
j, disp_xx, disp_yy, disp_xy);
701 int cols, rows, depths;
703 double disp_xx, disp_yy, disp_zz, disp_xy, disp_xz, disp_yz;
710 G_debug(2,
"N_calc_solute_transport_disptensor_3d: calculating the "
711 "dispersivity tensor");
713 for (k = 0; k < depths; k++) {
714 for (
j = 0;
j < rows;
j++) {
715 for (i = 0; i < cols; i++) {
725 vx = (grad.
WC + grad.
EC) / 2;
726 vy = (grad.
NC + grad.
SC) / 2;
727 vz = (grad.
BC + grad.
TC) / 2;
737 disp_xy = (data->
al - data->
at) *
vx *
vy /
vv;
738 disp_xz = (data->
al - data->
at) *
vx *
vz /
vv;
739 disp_yz = (data->
al - data->
at) *
vy *
vz /
vv;
743 "N_calc_solute_transport_disptensor_3d: [%i][%i][%i] "
744 "disp_xx %g disp_yy %g disp_zz %g disp_xy %g disp_xz "
746 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