19 #include "grass/N_gwflow.h"
266 double hc_e = 0, hc_w = 0, hc_n = 0, hc_s = 0, hc_t = 0, hc_b = 0;
268 double dx, dy, dz, Ax, Ay, Az;
270 double hc_x, hc_y, hc_z;
272 double hc_xw, hc_yn, hc_zt;
274 double hc_xe, hc_ys, hc_zb;
280 double C, W, E,
N, S, T, B, V;
293 Ay = geom->
dx * geom->
dz;
294 Ax = geom->
dz * geom->
dy;
325 W = -1 * Ax * hc_w / dx;
327 E = -1 * Ax * hc_e / dx;
329 N = -1 * Ay * hc_n / dy;
331 S = -1 * Ay * hc_s / dy;
333 T = -1 * Az * hc_t / dz;
335 B = -1 * Az * hc_b / dz;
341 C = -1 * (W + E + N + S + T + B - Ss / data->
dt * Az);
344 V = (q + hc_start * Ss / data->
dt * Az);
347 if (depth == geom->
depths - 2) {
352 G_debug(5,
"N_callback_gwflow_3d: called [%i][%i][%i]", depth, col, row);
382 double T_e = 0, T_w = 0, T_n = 0, T_s = 0;
384 double z_e = 0, z_w = 0, z_n = 0, z_s = 0;
404 double C, W, E,
N, S, V;
410 double river_vect = 0;
412 double river_mat = 0;
414 double drain_vect = 0;
416 double drain_mat = 0;
469 if (z_w > 0 || z_w < 0 || z_w == 0)
473 if (z_e > 0 || z_e < 0 || z_e == 0)
477 if (z_n > 0 || z_n < 0 || z_n == 0)
481 if (z_s > 0 || z_s < 0 || z_s == 0)
540 W = -1 * T_w * dy / dx;
542 E = -1 * T_e * dy / dx;
544 N = -1 * T_n * dx / dy;
546 S = -1 * T_s * dx / dy;
549 C = -1 * (W + E + N + S - Ss / data->
dt - river_mat * Az -
553 V = (q + hc_start * Ss / data->
dt) + r + river_vect * Az +
556 G_debug(5,
"N_callback_gwflow_2d: called [%i][%i]", row, col);
void N_free_array_2d(N_array_2d *data)
Release the memory of a N_array_2d structure.
void G_free(void *buf)
Free allocated memory.
Matrix entries for a mass balance 5/7/9 star system.
void N_free_array_3d(N_array_3d *data)
Release the memory of a N_array_3d.
This data structure contains all data needed to compute the groundwater mass balance in three dimensi...
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
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.
Geometric information about the structured grid.
N_gwflow_data3d * N_alloc_gwflow_data3d(int cols, int rows, int depths, int river, int drain)
Allocate memory for the groundwater calculation data structure in 3 dimensions.
N_data_star * N_callback_gwflow_3d(void *gwdata, N_geom_data *geom, int col, int row, int depth)
This callback function creates the mass balance of a 7 point star.
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
void N_free_gwflow_data3d(N_gwflow_data3d *data)
Release the memory of the groundwater flow data structure in three dimensions.
N_data_star * N_callback_gwflow_2d(void *gwdata, N_geom_data *geom, int col, int row)
This callback function creates the mass balance of a 5 point star.
N_data_star * N_create_5star(double C, double W, double E, double N, double S, double V)
allocate and initialize a 5 point star data structure
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.
double N_calc_arith_mean(double a, double b)
Calculate the arithmetic mean of values a and b.
N_gwflow_data2d * N_alloc_gwflow_data2d(int cols, int rows, int river, int drain)
Alllocate memory for the groundwater calculation data structure in 2 dimensions.
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.
This data structure contains all data needed to compute the groundwater mass balance in two dimension...
void N_free_gwflow_data2d(N_gwflow_data2d *data)
Release the memory of the groundwater flow data structure in two dimensions.
int G_debug(int level, const char *msg,...)
Print debugging message.
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.
double N_calc_harmonic_mean(double a, double b)
Calculate the harmonical mean of values a and b.