GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
N_pde.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * MODULE: Grass PDE Numerical Library
4 * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
5 * soerengebbert <at> gmx <dot> de
6 *
7 * PURPOSE: This file contains definitions of variables and data types
8 *
9 * SPDX-FileCopyrightText: 2000 GRASS Development Team
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 *****************************************************************************/
13
14#include <grass/gis.h>
15#include <grass/raster3d.h>
16#include <grass/glocale.h>
17#include <grass/gmath.h>
18
19#ifndef _N_PDE_H_
20#define _N_PDE_H_
21
22#define N_NORMAL_LES 0
23#define N_SPARSE_LES 1
24/*!
25 * Boundary conditions for cells
26 */
27#define N_CELL_INACTIVE 0
28#define N_CELL_ACTIVE 1
29#define N_CELL_DIRICHLET 2
30#define N_CELL_TRANSMISSION 3
31/*!
32 * \brief the maximum number of available cell states (eg: boundary condition,
33 * inactiven active)
34 * */
35#define N_MAX_CELL_STATE 20
36
37#define N_5_POINT_STAR 0
38#define N_7_POINT_STAR 1
39#define N_9_POINT_STAR 2
40#define N_27_POINT_STAR 3
41
42#define N_MAXIMUM_NORM 0
43#define N_EUKLID_NORM 1
44
45#define N_ARRAY_SUM 0 /* summ two arrays */
46#define N_ARRAY_DIF 1 /* calc the difference between two arrays */
47#define N_ARRAY_MUL 2 /* multiply two arrays */
48#define N_ARRAY_DIV \
49 3 /* array division, if div with 0 the NULL value is set \
50 */
52#define N_UPWIND_FULL 0 /*full upwinding stabilization */
53#define N_UPWIND_EXP 1 /*exponential upwinding stabilization */
54#define N_UPWIND_WEIGHT 2 /*weighted upwinding stabilization */
55
56/* *************************************************************** */
57/* *************** LINEARE EQUATION SYSTEM PART ****************** */
58/* *************************************************************** */
59
60/*!
61 * \brief The linear equation system (les) structure
62 *
63 * This structure manages the Ax = b system.
64 * It manages regular quadratic matrices or
65 * sparse matrices. The vector b and x are normal one dimensional
66 * memory structures of type double. Also the number of rows
67 * and the matrix type are stored in this structure.
68 * */
69typedef struct {
70 double *x; /*the value vector */
71 double *b; /*the right side of Ax = b */
72 double **A; /*the normal quadratic matrix */
73 G_math_spvector **Asp; /*the sparse matrix */
74 int rows; /*number of rows */
75 int cols; /*number of cols */
76 int quad; /*is the matrix quadratic (1-quadratic, 0 not) */
77 int type; /*the type of the les, normal == 0, sparse == 1 */
78} N_les;
79
80extern N_les *N_alloc_les_param(int cols, int rows, int type, int param);
81extern N_les *N_alloc_les(int rows, int type);
82extern N_les *N_alloc_les_A(int rows, int type);
83extern N_les *N_alloc_les_Ax(int rows, int type);
84extern N_les *N_alloc_les_Ax_b(int rows, int type);
85extern N_les *N_alloc_nquad_les(int cols, int rows, int type);
86extern N_les *N_alloc_nquad_les_A(int cols, int rows, int type);
87extern N_les *N_alloc_nquad_les_Ax(int cols, int rows, int type);
88extern N_les *N_alloc_nquad_les_Ax_b(int cols, int rows, int type);
89extern void N_print_les(N_les *les);
90extern void N_free_les(N_les *les);
91
92/* *************************************************************** */
93/* *************** GEOMETRY INFORMATION ************************** */
94/* *************************************************************** */
95
96/*!
97 * \brief Geometric information about the structured grid
98 * */
99typedef struct {
100 int planimetric; /*If the projection is not planimetric (0), the array
101 calculation is different for each row */
102 double *area; /* the vector of area values for non-planimetric projection
103 for each row */
104 int dim; /* 2 or 3 */
106 double dx;
107 double dy;
108 double dz;
110 double Az;
112 int depths;
113 int rows;
114 int cols;
115
117
118extern N_geom_data *N_alloc_geom_data(void);
122extern N_geom_data *N_init_geom_data_2d(struct Cell_head *region,
124extern double N_get_geom_data_area_of_cell(N_geom_data *geom, int row);
125
126/* *************************************************************** */
127/* *************** READING RASTER AND VOLUME DATA **************** */
128/* *************************************************************** */
130typedef struct {
131 int type; /* which raster type CELL_TYPE, FCELL_TYPE, DCELL_TYPE */
132 int rows, cols;
133 int rows_intern, cols_intern;
134 int offset; /*number of cols/rows offset at each boundary */
135 CELL *cell_array; /*The data is stored in an one dimensional array
136 internally */
137 FCELL *fcell_array; /*The data is stored in an one dimensional array
138 internally */
139 DCELL *dcell_array; /*The data is stored in an one dimensional array
140 internally */
141} N_array_2d;
142
143extern N_array_2d *N_alloc_array_2d(int cols, int rows, int offset, int type);
146extern void N_get_array_2d_value(N_array_2d *array2d, int col, int row,
147 void *value);
148extern CELL N_get_array_2d_c_value(N_array_2d *array2d, int col, int row);
149extern FCELL N_get_array_2d_f_value(N_array_2d *array2d, int col, int row);
150extern DCELL N_get_array_2d_d_value(N_array_2d *array2d, int col, int row);
151extern void N_put_array_2d_value(N_array_2d *array2d, int col, int row,
152 char *value);
153extern void N_put_array_2d_c_value(N_array_2d *array2d, int col, int row,
154 CELL value);
155extern void N_put_array_2d_f_value(N_array_2d *array2d, int col, int row,
156 FCELL value);
157extern void N_put_array_2d_d_value(N_array_2d *array2d, int col, int row,
158 DCELL value);
159extern int N_is_array_2d_value_null(N_array_2d *array2d, int col, int row);
160extern void N_put_array_2d_value_null(N_array_2d *array2d, int col, int row);
161extern void N_print_array_2d(N_array_2d *data);
162extern void N_print_array_2d_info(N_array_2d *data);
163extern void N_copy_array_2d(N_array_2d *source, N_array_2d *target);
164extern double N_norm_array_2d(N_array_2d *array1, N_array_2d *array2, int type);
166 N_array_2d *result, int type);
169extern void N_write_array_2d_to_rast(N_array_2d *array, char *name);
170extern void N_calc_array_2d_stats(N_array_2d *a, double *min, double *max,
171 double *sum, int *nonzero, int withoffset);
173typedef struct {
174 int type; /* which raster type FCELL_TYPE, DCELL_TYPE */
175 int rows, cols, depths;
176 int rows_intern, cols_intern, depths_intern;
177 int offset; /*number of cols/rows/depths offset at each boundary */
178 float *fcell_array; /*The data is stored in an one dimensional array
179 internally */
180 double *dcell_array; /*The data is stored in an one dimensional array
181 internally */
182} N_array_3d;
183
184extern N_array_3d *N_alloc_array_3d(int cols, int rows, int depths, int offset,
185 int type);
188extern void N_get_array_3d_value(N_array_3d *array3d, int col, int row,
189 int depth, void *value);
190extern float N_get_array_3d_f_value(N_array_3d *array3d, int col, int row,
191 int depth);
192extern double N_get_array_3d_d_value(N_array_3d *array3d, int col, int row,
193 int depth);
194extern void N_put_array_3d_value(N_array_3d *array3d, int col, int row,
195 int depth, char *value);
196extern void N_put_array_3d_f_value(N_array_3d *array3d, int col, int row,
197 int depth, float value);
198extern void N_put_array_3d_d_value(N_array_3d *array3d, int col, int row,
199 int depth, double value);
200extern int N_is_array_3d_value_null(N_array_3d *array3d, int col, int row,
201 int depth);
202extern void N_put_array_3d_value_null(N_array_3d *array3d, int col, int row,
203 int depth);
204extern void N_print_array_3d(N_array_3d *data);
205extern void N_print_array_3d_info(N_array_3d *data);
206extern void N_copy_array_3d(N_array_3d *source, N_array_3d *target);
207extern double N_norm_array_3d(N_array_3d *array1, N_array_3d *array2, int type);
209 N_array_3d *result, int type);
212 int mask);
213extern void N_write_array_3d_to_rast3d(N_array_3d *array, char *name, int mask);
214extern void N_calc_array_3d_stats(N_array_3d *a, double *min, double *max,
215 double *sum, int *nonzero, int withoffset);
216
217/* *************************************************************** */
218/* *************** MATRIX ASSEMBLING METHODS ********************* */
219/* *************************************************************** */
220/*!
221 * \brief Matrix entries for a mass balance 5/7/9 star system
222 *
223 * Matrix entries for the mass balance of a 5 star system
224 *
225 * The entries are center, east, west, north, south and the
226 * right side vector b of Ax = b. This system is typically used in 2d.
227
228 \verbatim
229 N
230 |
231 W-- C --E
232 |
233 S
234 \endverbatim
235
236 * Matrix entries for the mass balance of a 7 star system
237 *
238 * The entries are center, east, west, north, south, top, bottom and the
239 * right side vector b of Ax = b. This system is typically used in 3d.
240
241 \verbatim
242 T N
243 |/
244 W-- C --E
245 /|
246 S B
247 \endverbatim
248
249 * Matrix entries for the mass balance of a 9 star system
250 *
251 * The entries are center, east, west, north, south, north-east, south-east,
252 * north-wast, south-west and the
253 * right side vector b of Ax = b. This system is typically used in 2d.
254
255 \verbatim
256 NW N NE
257 \ | /
258 W-- C --E
259 / | \
260 SW S SE
261 \endverbatim
262
263 * Matrix entries for the mass balance of a 27 star system
264 *
265 * The entries are center, east, west, north, south, north-east, south-east,
266 * north-wast, south-west, same for top and bottom and the
267 * right side vector b of Ax = b. This system is typically used in 2d.
268
269 \verbatim
270 top:
271 NW_T N_Z NE_T
272 \ | /
273 W_T-- T --E_T
274 / | \
275 SW_T S_T SE_T
276
277 center:
278 NW N NE
279 \ | /
280 W-- C --E
281 / | \
282 SW S SE
283
284 bottom:
285 NW_B N_B NE_B
286 \ | /
287 W_B-- B --E_B
288 / | \
289 SW_B S_B SE_B
290 \endverbatim
291
292 */
293typedef struct {
294 int type;
295 int count;
296 double C, W, E, N, S, NE, NW, SE, SW, V;
297 /*top part */
298 double T, W_T, E_T, N_T, S_T, NE_T, NW_T, SE_T, SW_T;
299 /*bottom part */
300 double B, W_B, E_B, N_B, S_B, NE_B, NW_B, SE_B, SW_B;
302
303/*!
304 * \brief callback structure for 3d matrix assembling
305 * */
306typedef struct {
307 N_data_star *(*callback)(void *, N_geom_data *, int, int, int);
309
310/*!
311 * \brief callback structure for 2d matrix assembling
312 * */
313typedef struct {
314 N_data_star *(*callback)(void *, N_geom_data *, int, int);
316
318 N_les_callback_3d *data,
319 N_data_star *(*callback_func_3d)(void *, N_geom_data *, int, int, int));
321 N_les_callback_2d *data,
322 N_data_star *(*callback_func_2d)(void *, N_geom_data *, int, int));
325extern N_data_star *N_alloc_5star(void);
326extern N_data_star *N_alloc_7star(void);
327extern N_data_star *N_alloc_9star(void);
328extern N_data_star *N_alloc_27star(void);
329extern N_data_star *N_create_5star(double C, double W, double E, double N,
330 double S, double V);
331extern N_data_star *N_create_7star(double C, double W, double E, double N,
332 double S, double T, double B, double V);
333extern N_data_star *N_create_9star(double C, double W, double E, double N,
334 double S, double NW, double SW, double NE,
335 double SE, double V);
336extern N_data_star *
337N_create_27star(double C, double W, double E, double N, double S, double NW,
338 double SW, double NE, double SE, double T, double W_T,
339 double E_T, double N_T, double S_T, double NW_T, double SW_T,
340 double NE_T, double SE_T, double B, double W_B, double E_B,
341 double N_B, double S_B, double NW_B, double SW_B, double NE_B,
342 double SE_B, double V);
344 int col, int row, int depth);
346 int col, int row);
349 void *data, N_les_callback_3d *callback);
351 N_array_3d *status,
352 N_array_3d *start_val, void *data,
353 N_les_callback_3d *callback);
355 N_array_3d *status,
356 N_array_3d *start_val, void *data,
357 N_les_callback_3d *callback);
360 void *data, N_les_callback_3d *callback,
361 int cell_type);
364 void *data, N_les_callback_2d *callback);
366 N_array_2d *status,
367 N_array_2d *start_val, void *data,
368 N_les_callback_2d *callback);
370 N_array_2d *status,
371 N_array_2d *start_val, void *data,
372 N_les_callback_2d *callback);
375 void *data, N_les_callback_2d *callback,
377extern int N_les_pivot_create(N_les *les);
382
383/* *************************************************************** */
384/* *************** GPDE STANDARD OPTIONS ************************* */
385/* *************************************************************** */
386
387/*! \brief Standard options of the gpde library
388 * */
389typedef enum {
390 N_OPT_SOLVER_SYMM, /*! solver for symmetric, positive definite linear
391 equation systems */
392 N_OPT_SOLVER_UNSYMM, /*! solver for unsymmetric linear equation systems */
393 N_OPT_MAX_ITERATIONS, /*! Maximum number of iteration used to solver the
394 linear equation system */
395 N_OPT_ITERATION_ERROR, /*! Error break criteria for the iterative solver
396 (jacobi, sor, cg or bicgstab) */
397 N_OPT_SOR_VALUE, /*! The relaxation parameter used by the jacobi and sor
398 solver for speedup or stabilizing */
399 N_OPT_CALC_TIME /*! The calculation time in seconds */
400} N_STD_OPT;
401
402extern struct Option *N_define_standard_option(int opt);
403
404/* *************************************************************** */
405/* *************** GPDE MATHEMATICAL TOOLS *********************** */
406/* *************************************************************** */
407
408extern double N_calc_arith_mean(double a, double b);
409extern double N_calc_arith_mean_n(double *a, int size);
410extern double N_calc_geom_mean(double a, double b);
411extern double N_calc_geom_mean_n(double *a, int size);
412extern double N_calc_harmonic_mean(double a, double b);
413extern double N_calc_harmonic_mean_n(double *a, int size);
414extern double N_calc_quad_mean(double a, double b);
415extern double N_calc_quad_mean_n(double *a, int size);
416
417/* *************************************************************** */
418/* *************** UPWIND STABILIZATION ALGORITHMS *************** */
419/* *************************************************************** */
420
421extern double N_full_upwinding(double sprod, double distance, double D);
422extern double N_exp_upwinding(double sprod, double distance, double D);
423
424/* *************************************************************** */
425/* *************** METHODS FOR GRADIENT CALCULATION ************** */
426/* *************************************************************** */
427/*!
428 \verbatim
429
430 ______________
431 | | | |
432 | | | |
433 |----|-NC-|----|
434 | | | |
435 | WC EC |
436 | | | |
437 |----|-SC-|----|
438 | | | |
439 |____|____|____|
440
441
442 | /
443 TC NC
444 |/
445 --WC-----EC--
446 /|
447 SC BC
448 / |
449
450 \endverbatim
451
452 */
453
454/*! \brief Gradient between the cells in X and Y direction */
455typedef struct {
457 double NC, SC, WC, EC;
458
460
461/*! \brief Gradient between the cells in X, Y and Z direction */
462typedef struct {
464 double NC, SC, WC, EC, TC, BC;
465
467
468/*!
469 \verbatim
470
471 Gradient in X direction between the cell neighbours
472 ____ ____ ____
473 | | | |
474 | NWN NEN |
475 |____|____|____|
476 | | | |
477 | WN EN |
478 |____|____|____|
479 | | | |
480 | SWS SES |
481 |____|____|____|
482
483 Gradient in Y direction between the cell neighbours
484 ______________
485 | | | |
486 | | | |
487 |NWW-|-NC-|-NEE|
488 | | | |
489 | | | |
490 |SWW-|-SC-|-SEE|
491 | | | |
492 |____|____|____|
493
494 Gradient in Z direction between the cell neighbours
495 /______________/
496 /| | | |
497 | NWZ| NZ | NEZ|
498 |____|____|____|
499 /| | | |
500 | WZ | CZ | EZ |
501 |____|____|____|
502 /| | | |
503 | SWZ| SZ | SEZ|
504 |____|____|____|
505 /____/____/____/
506
507
508 \endverbatim
509 */
510
511/*! \brief Gradient between the cell neighbours in X direction */
512typedef struct {
514 double NWN, NEN, WC, EC, SWS, SES;
515
517
518/*! \brief Gradient between the cell neighbours in Y direction */
519typedef struct {
521 double NWW, NEE, NC, SC, SWW, SEE;
522
524
525/*! \brief Gradient between the cell neighbours in Z direction */
526typedef struct {
528 double NWZ, NZ, NEZ, WZ, CZ, EZ, SWZ, SZ, SEZ;
529
531
532/*! \brief Gradient between the cell neighbours in X and Y direction */
533typedef struct {
537
539
540/*! \brief Gradient between the cell neighbours in X, Y and Z direction */
541typedef struct {
543 N_gradient_neighbours_x *xt; /*top values */
544 N_gradient_neighbours_x *xc; /*center values */
545 N_gradient_neighbours_x *xb; /*bottom values */
547 N_gradient_neighbours_y *yt; /*top values */
548 N_gradient_neighbours_y *yc; /*center values */
549 N_gradient_neighbours_y *yb; /*bottom values */
551 N_gradient_neighbours_z *zt; /*top-center values */
552 N_gradient_neighbours_z *zb; /*bottom-center values */
553
555
556/*! Two dimensional gradient field */
557typedef struct {
559 N_array_2d *x_array;
560 N_array_2d *y_array;
561 int cols, rows;
562 double min, max, mean, sum;
563 int nonull;
564
566
567/*! Three dimensional gradient field */
568typedef struct {
570 N_array_3d *x_array;
571 N_array_3d *y_array;
572 N_array_3d *z_array;
573 int cols, rows, depths;
574 double min, max, mean, sum;
575 int nonull;
576
578
580extern void N_free_gradient_2d(N_gradient_2d *grad);
581extern N_gradient_2d *N_create_gradient_2d(double NC, double SC, double WC,
582 double EC);
586 int row);
588extern void N_free_gradient_3d(N_gradient_3d *grad);
589extern N_gradient_3d *N_create_gradient_3d(double NC, double SC, double WC,
590 double EC, double TC, double BC);
594 int row, int depth);
598N_create_gradient_neighbours_x(double NWN, double NEN, double WC, double EC,
599 double SWS, double SES);
605N_create_gradient_neighbours_y(double NWW, double NEE, double NC, double SC,
606 double SWW, double SEE);
612N_create_gradient_neighbours_z(double NWZ, double NZ, double NEZ, double WZ,
613 double CZ, double EZ, double SWZ, double SZ,
614 double SEZ);
627 int row);
639extern N_gradient_field_2d *N_alloc_gradient_field_2d(int cols, int rows);
642 N_gradient_field_2d *target);
643extern N_gradient_field_2d *
652extern N_gradient_field_3d *N_alloc_gradient_field_3d(int cols, int rows,
653 int depths);
656 N_gradient_field_3d *target);
657extern N_gradient_field_3d *
665
666#endif
N_gradient_3d * N_alloc_gradient_3d(void)
Allocate a N_gradient_3d structure.
Definition n_gradient.c:146
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
Definition n_gradient.c:181
N_data_star * N_alloc_27star(void)
allocate a 27 point star data structure
N_les * N_assemble_les_2d(int les_type, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val, void *data, N_les_callback_2d *callback)
Assemble a linear equation system (les) based on 2d location data (raster) and active cells.
N_gradient_field_2d * N_compute_gradient_field_2d(N_array_2d *pot, N_array_2d *weight_x, N_array_2d *weight_y, N_geom_data *geom, N_gradient_field_2d *gradfield)
This function computes the gradient based on the input N_array_2d pot (potential),...
N_gradient_2d * N_alloc_gradient_2d(void)
Allocate a N_gradient_2d structure.
Definition n_gradient.c:23
N_gradient_neighbours_y * N_alloc_gradient_neighbours_y(void)
Allocate a N_gradient_neighbours_y structure.
Definition n_gradient.c:378
double N_norm_array_2d(N_array_2d *array1, N_array_2d *array2, int type)
Calculate the norm of the two input arrays.
void N_print_les(N_les *les)
prints the linear equation system to stdout
Definition n_les.c:254
N_data_star * N_callback_template_3d(void *data, N_geom_data *geom, int col, int row, int depth)
A callback template creates a 7 point star structure.
int N_copy_gradient_neighbours_2d(N_gradient_neighbours_2d *source, N_gradient_neighbours_2d *target)
copy a N_gradient_neighbours_2d structure
Definition n_gradient.c:647
N_les * N_assemble_les_3d(int les_type, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val, void *data, N_les_callback_3d *callback)
Assemble a linear equation system (les) based on 3d location data (g3d) active cells.
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 ...
void N_put_array_3d_f_value(N_array_3d *array3d, int col, int row, int depth, float value)
This function writes a float value to the N_array_3d data at position col, row, depth.
Definition n_arrays.c:1118
CELL N_get_array_2d_c_value(N_array_2d *array2d, int col, int row)
Returns the value of type CELL at position col, row.
Definition n_arrays.c:311
int N_copy_gradient_3d(N_gradient_3d *source, N_gradient_3d *target)
copy a N_gradient_3d structure
Definition n_gradient.c:208
N_geom_data * N_alloc_geom_data(void)
Allocate the pde geometry data structure and return a pointer to the new allocated structure.
Definition n_geom.c:26
void N_print_array_3d_info(N_array_3d *data)
Write the info of the array to stdout.
Definition n_arrays.c:1167
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.
Definition n_geom.c:193
DCELL N_get_array_2d_d_value(N_array_2d *array2d, int col, int row)
Returns the value of type DCELL at position col, row.
Definition n_arrays.c:377
N_gradient_neighbours_z * N_alloc_gradient_neighbours_z(void)
Allocate a N_gradient_neighbours_z structure.
Definition n_gradient.c:470
void N_put_array_3d_value_null(N_array_3d *array3d, int col, int row, int depth)
This function writes a null value to the N_array_3d data at position col, row, depth.
Definition n_arrays.c:1057
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.
Definition n_gradient.c:510
N_STD_OPT
Standard options of the gpde library.
Definition N_pde.h:388
@ N_OPT_MAX_ITERATIONS
Definition N_pde.h:392
@ N_OPT_SOLVER_UNSYMM
Definition N_pde.h:391
@ N_OPT_SOLVER_SYMM
Definition N_pde.h:389
@ N_OPT_ITERATION_ERROR
Definition N_pde.h:394
@ N_OPT_CALC_TIME
Definition N_pde.h:398
@ N_OPT_SOR_VALUE
Definition N_pde.h:396
N_geom_data * N_init_geom_data_3d(RASTER3D_Region *region3d, N_geom_data *geodata)
Initiate a pde geometry data structure with a 3d region.
Definition n_geom.c:70
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.
Definition n_arrays.c:716
void N_put_array_3d_d_value(N_array_3d *array3d, int col, int row, int depth, double value)
Writes a double value to the N_array_3d struct at position col, row, depth.
Definition n_arrays.c:1145
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 pr...
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
void N_calc_gradient_field_2d_stats(N_gradient_field_2d *field)
Calculate basic statistics of a gradient field.
void N_put_array_3d_value(N_array_3d *array3d, int col, int row, int depth, char *value)
This function writes a value to the N_array_3d data at position col, row, depth.
Definition n_arrays.c:1007
N_data_star * N_create_27star(double C, double W, double E, double N, double S, double NW, double SW, double NE, double SE, double T, double W_T, double E_T, double N_T, double S_T, double NW_T, double SW_T, double NE_T, double SE_T, double B, double W_B, double E_B, double N_B, double S_B, double NW_B, double SW_B, double NE_B, double SE_B, double V)
allocate and initialize a 27 point star data structure
void N_free_gradient_field_3d(N_gradient_field_3d *field)
Free's a N_gradient_neighbours_3d structure.
void N_write_array_3d_to_rast3d(N_array_3d *array, char *name, int mask)
Write a N_array_3d struct to a volume map.
N_les * N_alloc_les_Ax(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A and vector x.
Definition n_les.c:114
int N_convert_array_3d_null_to_zero(N_array_3d *a)
Convert all null values to zero values.
double N_norm_array_3d(N_array_3d *array1, N_array_3d *array2, int type)
Calculate the norm of the two input arrays.
N_data_star * N_alloc_7star(void)
allocate a 7 point star data structure
double N_exp_upwinding(double sprod, double distance, double D)
exponential upwinding stabilization algorithm
Definition n_upwind.c:60
int N_convert_array_2d_null_to_zero(N_array_2d *a)
Convert all null values to zero values.
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.
N_les * N_alloc_nquad_les_Ax(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A and vector x...
Definition n_les.c:48
int N_copy_gradient_neighbours_x(N_gradient_neighbours_x *source, N_gradient_neighbours_x *target)
copy a N_gradient_neighbours_x structure
Definition n_gradient.c:352
N_data_star * N_alloc_9star(void)
allocate a 9 point star data structure
N_gradient_field_2d * N_alloc_gradient_field_2d(int cols, int rows)
Allocate a N_gradient_field_2d.
Definition n_gradient.c:893
int N_les_integrate_dirichlet_3d(N_les *les, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val)
Integrate Dirichlet or Transmission boundary conditions into the les (3d)
int N_get_array_3d_type(N_array_3d *array3d)
Return the data type of the N_array_3d.
Definition n_arrays.c:800
FCELL N_get_array_2d_f_value(N_array_2d *array2d, int col, int row)
Returns the value of type FCELL at position col, row.
Definition n_arrays.c:344
N_gradient_neighbours_3d * N_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.
Definition n_gradient.c:803
N_les * N_alloc_nquad_les(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A,...
Definition n_les.c:31
void N_free_gradient_neighbours_2d(N_gradient_neighbours_2d *grad)
Free's a N_gradient_neighbours_2d structure.
Definition n_gradient.c:593
void N_print_gradient_field_2d_info(N_gradient_field_2d *field)
Print gradient field information to stdout.
Definition n_gradient.c:958
N_array_2d * N_read_rast_to_array_2d(char *name, N_array_2d *array)
Read a raster map into a N_array_2d structure.
Definition n_arrays_io.c:41
double N_calc_geom_mean_n(double *a, int size)
Calculate the geometrical mean of the values in vector a of size n.
Definition n_tools.c:90
N_les * N_assemble_les_3d_param(int les_type, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val, void *data, N_les_callback_3d *callback, int cell_type)
Assemble a linear equation system (les) based on 3d location data (g3d)
int N_is_array_2d_value_null(N_array_2d *array2d, int col, int row)
Returns 1 if the value of N_array_2d struct at position col, row is of type null, otherwise 0.
Definition n_arrays.c:228
N_gradient_neighbours_x * N_alloc_gradient_neighbours_x(void)
Allocate a N_gradient_neighbours_x structure.
Definition n_gradient.c:286
double N_calc_harmonic_mean_n(double *a, int size)
Calculate the harmonical mean of the values in vector a of size n.
Definition n_tools.c:133
void N_print_gradient_field_3d_info(N_gradient_field_3d *field)
Print gradient field information to stdout.
void N_free_gradient_neighbours_z(N_gradient_neighbours_z *grad)
Free's a N_gradient_neighbours_z structure.
Definition n_gradient.c:486
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...
Definition n_gradient.c:686
struct Option * N_define_standard_option(int opt)
Create standardised Option structure related to the gpde library.
int N_copy_gradient_neighbours_z(N_gradient_neighbours_z *source, N_gradient_neighbours_z *target)
copy a N_gradient_neighbours_z structure
Definition n_gradient.c:544
void N_free_array_3d(N_array_3d *data_array)
Release the memory of a N_array_3d.
Definition n_arrays.c:771
int N_les_integrate_dirichlet_2d(N_les *les, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val)
Integrate Dirichlet or Transmission boundary conditions into the les (2s)
N_gradient_field_3d * N_alloc_gradient_field_3d(int cols, int rows, int depths)
Allocate a N_gradient_field_3d.
Definition n_gradient.c:990
void N_calc_array_3d_stats(N_array_3d *a, double *min, double *max, double *sum, int *nonzero, int withoffset)
Calculate basic statistics of the N_array_3d struct.
void N_print_array_2d(N_array_2d *data)
Write info and content of the N_array_2d struct to stdout.
Definition n_arrays.c:625
int N_copy_gradient_neighbours_3d(N_gradient_neighbours_3d *source, N_gradient_neighbours_3d *target)
copy a N_gradient_neighbours_3d structure
Definition n_gradient.c:849
N_gradient_neighbours_2d * N_alloc_gradient_neighbours_2d(void)
Allocate a N_gradient_neighbours_2d structure.
Definition n_gradient.c:574
void N_free_geom_data(N_geom_data *geodata)
Release memory of a pde geometry data structure.
Definition n_geom.c:46
double N_calc_quad_mean_n(double *a, int size)
Calculate the quadratic mean of the values in vector a of size n.
Definition n_tools.c:181
void N_get_array_2d_value(N_array_2d *array2d, int col, int row, void *value)
Write the value of the N_array_2d struct at position col, row to value.
Definition n_arrays.c:179
N_les * N_assemble_les_3d_dirichlet(int les_type, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val, void *data, N_les_callback_3d *callback)
Assemble a linear equation system (les) based on 3d location data (g3d) active and dirichlet cells.
N_les * N_alloc_les_A(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A.
Definition n_les.c:130
double N_calc_geom_mean(double a, double b)
Calculate the geometrical mean of values a and b.
Definition n_tools.c:70
N_les * N_alloc_nquad_les_A(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A.
Definition n_les.c:65
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
double N_calc_arith_mean_n(double *a, int size)
Calculate the arithmetic mean of the values in vector a of size n.
Definition n_tools.c:48
void N_copy_array_3d(N_array_3d *source, N_array_3d *target)
Copy the source N_array_3d struct to the target N_array_3d struct.
void N_print_array_2d_info(N_array_2d *data)
This function writes the data info of the array data to stdout.
Definition n_arrays.c:600
N_les * N_assemble_les_2d_dirichlet(int les_type, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val, void *data, N_les_callback_2d *callback)
Assemble a linear equation system (les) based on 2d location data (raster) and active and dirichlet c...
N_les * N_alloc_nquad_les_Ax_b(int cols, int rows, int type)
Allocate memory for a (not) quadratic linear equation system which includes the Matrix A,...
Definition n_les.c:82
double N_calc_arith_mean(double a, double b)
Calculate the arithmetic mean of values a and b.
Definition n_tools.c:28
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.
Definition n_gradient.c:323
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.
Definition n_gradient.c:615
void N_copy_array_2d(N_array_2d *source, N_array_2d *target)
Copy the source N_array_2d struct to the target N_array_2d struct.
N_gradient_neighbours_3d * N_alloc_gradient_neighbours_3d(void)
Allocate a N_gradient_neighbours_3d structure.
Definition n_gradient.c:749
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.
Definition n_gradient.c:415
N_data_star * N_callback_template_2d(void *data, N_geom_data *geom, int col, int row)
A callback template creates a 9 point star 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_array_3d * N_read_rast3d_to_array_3d(char *name, N_array_3d *array, int mask)
Read a volume map into a N_array_3d structure.
N_data_star * N_alloc_5star(void)
allocate a 5 point star data structure
N_les * N_alloc_les_Ax_b(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A,...
Definition n_les.c:146
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].
Definition n_gradient.c:111
int N_les_pivot_create(N_les *les)
double N_full_upwinding(double sprod, double distance, double D)
full upwinding stabilization algorithm
Definition n_upwind.c:29
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...
Definition n_gradient.c:243
N_array_2d * N_alloc_array_2d(int cols, int rows, int offset, int type)
Allocate memory for a N_array_2d data structure.
Definition n_arrays.c:72
void N_free_gradient_2d(N_gradient_2d *grad)
Free's a N_gradient_2d structure.
Definition n_gradient.c:38
int N_copy_gradient_neighbours_y(N_gradient_neighbours_y *source, N_gradient_neighbours_y *target)
copy a N_gradient_neighbours_y structure
Definition n_gradient.c:444
N_gradient_field_3d * N_compute_gradient_field_3d(N_array_3d *pot, N_array_3d *weight_x, N_array_3d *weight_y, N_array_3d *weight_z, N_geom_data *geom, N_gradient_field_3d *gradfield)
This function computes the gradient based on the input N_array_3d pot (that means potential),...
void N_free_les(N_les *les)
Release the memory of the linear equation system.
Definition n_les.c:304
N_les * N_alloc_les_param(int cols, int rows, int type, int param)
Allocate memory for a quadratic or not quadratic linear equation system.
Definition n_les.c:179
int N_is_array_3d_value_null(N_array_3d *array3d, int col, int row, int depth)
This function returns 1 if value of N_array_3d data at position col, row, depth is of type null,...
Definition n_arrays.c:870
N_les * N_alloc_les(int rows, int type)
Allocate memory for a quadratic linear equation system which includes the Matrix A,...
Definition n_les.c:98
void N_put_array_2d_d_value(N_array_2d *array2d, int col, int row, DCELL value)
Writes a DCELL value to the N_array_2d struct at position col, row.
Definition n_arrays.c:573
int N_copy_gradient_2d(N_gradient_2d *source, N_gradient_2d *target)
copy a N_gradient_2d structure
Definition n_gradient.c:80
int N_get_array_2d_type(N_array_2d *array2d)
Return the data type of the N_array_2d struct.
Definition n_arrays.c:161
void N_free_gradient_3d(N_gradient_3d *grad)
Free's a N_gradient_3d structure.
Definition n_gradient.c:161
N_les * N_assemble_les_2d_active(int les_type, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val, void *data, N_les_callback_2d *callback)
Assemble a linear equation system (les) based on 2d location data (raster) and active cells.
void N_write_array_2d_to_rast(N_array_2d *array, char *name)
Write a N_array_2d struct to a raster map.
void N_put_array_2d_value_null(N_array_2d *array2d, int col, int row)
Writes the null value to the N_array_2d struct at position col, row.
Definition n_arrays.c:456
N_les_callback_2d * N_alloc_les_callback_2d(void)
Allocate the structure holding the callback function.
N_les * N_assemble_les_3d_active(int les_type, N_geom_data *geom, N_array_3d *status, N_array_3d *start_val, void *data, N_les_callback_3d *callback)
Assemble a linear equation system (les) based on 3d location data (g3d) active cells.
void N_calc_array_2d_stats(N_array_2d *a, double *min, double *max, double *sum, int *nonzero, int withoffset)
Calculate basic statistics of the N_array_2d struct.
void N_free_gradient_neighbours_y(N_gradient_neighbours_y *grad)
Free's a N_gradient_neighbours_y structure.
Definition n_gradient.c:394
N_geom_data * N_init_geom_data_2d(struct Cell_head *region, N_geom_data *geodata)
Initiate a pde geometry data structure with a 2d region.
Definition n_geom.c:114
void N_get_array_3d_value(N_array_3d *array3d, int col, int row, int depth, void *value)
This function writes the value of N_array_3d data at position col, row, depth to the variable value.
Definition n_arrays.c:819
N_array_3d * N_math_array_3d(N_array_3d *array1, N_array_3d *array2, N_array_3d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.
void N_calc_gradient_field_3d_stats(N_gradient_field_3d *field)
Calculate basic statistics of a gradient field.
N_les * N_assemble_les_2d_param(int les_type, N_geom_data *geom, N_array_2d *status, N_array_2d *start_val, void *data, N_les_callback_2d *callback, int cell_Type)
Assemble a linear equation system (les) based on 2d location data (raster)
double N_calc_quad_mean(double a, double b)
Calculate the quadratic mean of values a and b.
Definition n_tools.c:161
void N_put_array_2d_f_value(N_array_2d *array2d, int col, int row, FCELL value)
Writes a FCELL value to the N_array_2d struct at position col, row.
Definition n_arrays.c:543
float N_get_array_3d_f_value(N_array_3d *array3d, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
Definition n_arrays.c:945
N_les_callback_3d * N_alloc_les_callback_3d(void)
Allocate the structure holding the callback function.
double N_calc_harmonic_mean(double a, double b)
Calculate the harmonical mean of values a and b.
Definition n_tools.c:112
double N_get_array_3d_d_value(N_array_3d *array3d, int col, int row, int depth)
This function returns the value of type float at position col, row, depth.
Definition n_arrays.c:976
void N_free_array_2d(N_array_2d *data_array)
Release the memory of a N_array_2d structure.
Definition n_arrays.c:129
void N_set_les_callback_3d_func(N_les_callback_3d *data, N_data_star *(*callback_func_3d)(void *, N_geom_data *, int, int, int))
Set the callback function which is called while assembling the les in 3d.
void N_put_array_2d_c_value(N_array_2d *array2d, int col, int row, CELL value)
Writes a CELL value to the N_array_2d struct at position col, row.
Definition n_arrays.c:513
void N_print_array_3d(N_array_3d *data)
Write info and content of the array data to stdout.
Definition n_arrays.c:1193
void N_set_les_callback_2d_func(N_les_callback_2d *data, N_data_star *(*callback_func_2d)(void *, N_geom_data *, int, int))
Set the callback function which is called while assembling the les in 2d.
void N_free_gradient_field_2d(N_gradient_field_2d *field)
Free's a N_gradient_neighbours_2d structure.
Definition n_gradient.c:917
void N_free_gradient_neighbours_x(N_gradient_neighbours_x *grad)
Free's a N_gradient_neighbours_x structure.
Definition n_gradient.c:302
N_array_2d * N_math_array_2d(N_array_2d *array1, N_array_2d *array2, N_array_2d *result, int type)
Perform calculations with two input arrays, the result is written to a third array.
N_gradient_2d * N_create_gradient_2d(double NC, double SC, double WC, double EC)
allocate and initialize a N_gradient_2d structure
Definition n_gradient.c:56
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.
Definition n_gradient.c:938
void N_free_gradient_neighbours_3d(N_gradient_neighbours_3d *grad)
Free's a N_gradient_neighbours_3d structure.
Definition n_gradient.c:774
void N_put_array_2d_value(N_array_2d *array2d, int col, int row, char *value)
Writes a value to the N_array_2d struct at position col, row.
Definition n_arrays.c:409
#define SE
Definition dataquad.h:27
#define SW
Definition dataquad.h:26
#define NE
Definition dataquad.h:25
#define NW
Definition dataquad.h:24
#define min(x, y)
Definition draw2.c:29
#define max(x, y)
Definition draw2.c:30
#define N
#define D
float FCELL
Definition gis.h:633
double DCELL
Definition gis.h:632
int CELL
Definition gis.h:631
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
int count
const char * name
Definition named_colr.c:6
#define W
Definition ogsf.h:144
double b
Definition r_raster.c:37
2D/3D raster map header (used also for region)
Definition gis.h:443
The row vector of the sparse matrix.
Definition gmath.h:54
Matrix entries for a mass balance 5/7/9 star system.
Definition N_pde.h:292
Geometric information about the structured grid.
Definition N_pde.h:98
Gradient between the cells in X and Y direction.
Definition N_pde.h:454
Gradient between the cells in X, Y and Z direction.
Definition N_pde.h:461
Gradient between the cell neighbours in X and Y direction.
Definition N_pde.h:532
Gradient between the cell neighbours in X, Y and Z direction.
Definition N_pde.h:540
Gradient between the cell neighbours in X direction.
Definition N_pde.h:511
Gradient between the cell neighbours in Y direction.
Definition N_pde.h:518
Gradient between the cell neighbours in Z direction.
Definition N_pde.h:525
callback structure for 2d matrix assembling
Definition N_pde.h:312
callback structure for 3d matrix assembling
Definition N_pde.h:305
The linear equation system (les) structure.
Definition N_pde.h:68
Structure that stores option information.
Definition gis.h:560
#define x