N_pde.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. * COPYRIGHT: (C) 2000 by the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General Public
  12. * License (>=v2). Read the file COPYING that comes with GRASS
  13. * for details.
  14. *
  15. *****************************************************************************/
  16. #include <grass/gis.h>
  17. #include <grass/raster3d.h>
  18. #include <grass/glocale.h>
  19. #include <grass/gmath.h>
  20. #ifndef _N_PDE_H_
  21. #define _N_PDE_H_
  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, inactiven active)
  33. * */
  34. #define N_MAX_CELL_STATE 20
  35. #define N_5_POINT_STAR 0
  36. #define N_7_POINT_STAR 1
  37. #define N_9_POINT_STAR 2
  38. #define N_27_POINT_STAR 3
  39. #define N_MAXIMUM_NORM 0
  40. #define N_EUKLID_NORM 1
  41. #define N_ARRAY_SUM 0 /* summ two arrays */
  42. #define N_ARRAY_DIF 1 /* calc the difference between two arrays */
  43. #define N_ARRAY_MUL 2 /* multiply two arrays */
  44. #define N_ARRAY_DIV 3 /* array division, if div with 0 the NULL value is set */
  45. #define N_UPWIND_FULL 0 /*full upwinding stabilization */
  46. #define N_UPWIND_EXP 1 /*exponential upwinding stabilization */
  47. #define N_UPWIND_WEIGHT 2 /*weighted upwinding stabilization */
  48. /* *************************************************************** */
  49. /* *************** LINEARE EQUATION SYSTEM PART ****************** */
  50. /* *************************************************************** */
  51. /*!
  52. * \brief The linear equation system (les) structure
  53. *
  54. * This structure manages the Ax = b system.
  55. * It manages regular quadratic matrices or
  56. * sparse matrices. The vector b and x are normal one dimensional
  57. * memory structures of type double. Also the number of rows
  58. * and the matrix type are stored in this structure.
  59. * */
  60. typedef struct
  61. {
  62. double *x; /*the value vector */
  63. double *b; /*the right side of Ax = b */
  64. double **A; /*the normal quadratic matrix */
  65. G_math_spvector **Asp; /*the sparse matrix */
  66. int rows; /*number of rows */
  67. int cols; /*number of cols */
  68. int quad; /*is the matrix quadratic (1-quadratic, 0 not) */
  69. int type; /*the type of the les, normal == 0, sparse == 1 */
  70. } N_les;
  71. extern N_les *N_alloc_les_param(int cols, int rows, int type, int param);
  72. extern N_les *N_alloc_les(int rows, int type);
  73. extern N_les *N_alloc_les_A(int rows, int type);
  74. extern N_les *N_alloc_les_Ax(int rows, int type);
  75. extern N_les *N_alloc_les_Ax_b(int rows, int type);
  76. extern N_les *N_alloc_nquad_les(int cols, int rows, int type);
  77. extern N_les *N_alloc_nquad_les_A(int cols, int rows, int type);
  78. extern N_les *N_alloc_nquad_les_Ax(int cols, int rows, int type);
  79. extern N_les *N_alloc_nquad_les_Ax_b(int cols, int rows, int type);
  80. extern void N_print_les(N_les * les);
  81. extern void N_free_les(N_les * les);
  82. /* *************************************************************** */
  83. /* *************** GEOMETRY INFORMATION ************************** */
  84. /* *************************************************************** */
  85. /*!
  86. * \brief Geometric information about the structured grid
  87. * */
  88. typedef struct
  89. {
  90. int planimetric; /*If the projection is not planimetric (0), the array calculation is different for each row */
  91. double *area; /* the vector of area values for non-planimetric projection for each row */
  92. int dim; /* 2 or 3 */
  93. double dx;
  94. double dy;
  95. double dz;
  96. double Az;
  97. int depths;
  98. int rows;
  99. int cols;
  100. } N_geom_data;
  101. extern N_geom_data *N_alloc_geom_data(void);
  102. extern void N_free_geom_data(N_geom_data * geodata);
  103. extern N_geom_data *N_init_geom_data_3d(RASTER3D_Region * region3d, N_geom_data * geodata);
  104. extern N_geom_data *N_init_geom_data_2d(struct Cell_head *region, N_geom_data * geodata);
  105. extern double N_get_geom_data_area_of_cell(N_geom_data * geom, int row);
  106. /* *************************************************************** */
  107. /* *************** READING RASTER AND VOLUME DATA **************** */
  108. /* *************************************************************** */
  109. typedef struct
  110. {
  111. int type; /* which raster type CELL_TYPE, FCELL_TYPE, DCELL_TYPE */
  112. int rows, cols;
  113. int rows_intern, cols_intern;
  114. int offset; /*number of cols/rows offset at each boundary */
  115. CELL *cell_array; /*The data is stored in an one dimensional array internally */
  116. FCELL *fcell_array; /*The data is stored in an one dimensional array internally */
  117. DCELL *dcell_array; /*The data is stored in an one dimensional array internally */
  118. } N_array_2d;
  119. extern N_array_2d *N_alloc_array_2d(int cols, int rows, int offset, int type);
  120. extern void N_free_array_2d(N_array_2d * data_array);
  121. extern int N_get_array_2d_type(N_array_2d * array2d);
  122. extern void N_get_array_2d_value(N_array_2d * array2d, int col, int row, void *value);
  123. extern CELL N_get_array_2d_c_value(N_array_2d * array2d, int col, int row);
  124. extern FCELL N_get_array_2d_f_value(N_array_2d * array2d, int col, int row);
  125. extern DCELL N_get_array_2d_d_value(N_array_2d * array2d, int col, int row);
  126. extern void N_put_array_2d_value(N_array_2d * array2d, int col, int row, char *value);
  127. extern void N_put_array_2d_c_value(N_array_2d * array2d, int col, int row, CELL value);
  128. extern void N_put_array_2d_f_value(N_array_2d * array2d, int col, int row, FCELL value);
  129. extern void N_put_array_2d_d_value(N_array_2d * array2d, int col, int row, DCELL value);
  130. extern int N_is_array_2d_value_null(N_array_2d * array2d, int col, int row);
  131. extern void N_put_array_2d_value_null(N_array_2d * array2d, int col, int row);
  132. extern void N_print_array_2d(N_array_2d * data);
  133. extern void N_print_array_2d_info(N_array_2d * data);
  134. extern void N_copy_array_2d(N_array_2d * source, N_array_2d * target);
  135. extern double N_norm_array_2d(N_array_2d * array1, N_array_2d * array2, int type);
  136. extern N_array_2d *N_math_array_2d(N_array_2d * array1, N_array_2d * array2, N_array_2d * result, int type);
  137. extern int N_convert_array_2d_null_to_zero(N_array_2d * a);
  138. extern N_array_2d *N_read_rast_to_array_2d(char *name, N_array_2d * array);
  139. extern void N_write_array_2d_to_rast(N_array_2d * array, char *name);
  140. extern void N_calc_array_2d_stats(N_array_2d * a, double *min, double *max, double *sum, int *nonzero, int withoffset);
  141. typedef struct
  142. {
  143. int type; /* which raster type FCELL_TYPE, DCELL_TYPE */
  144. int rows, cols, depths;
  145. int rows_intern, cols_intern, depths_intern;
  146. int offset; /*number of cols/rows/depths offset at each boundary */
  147. float *fcell_array; /*The data is stored in an one dimensional array internally */
  148. double *dcell_array; /*The data is stored in an one dimensional array internally */
  149. } N_array_3d;
  150. extern N_array_3d *N_alloc_array_3d(int cols, int rows, int depths, int offset, int type);
  151. extern void N_free_array_3d(N_array_3d * data_array);
  152. extern int N_get_array_3d_type(N_array_3d * array3d);
  153. extern void N_get_array_3d_value(N_array_3d * array3d, int col, int row, int depth, void *value);
  154. extern float N_get_array_3d_f_value(N_array_3d * array3d, int col, int row, int depth);
  155. extern double N_get_array_3d_d_value(N_array_3d * array3d, int col, int row, int depth);
  156. extern void N_put_array_3d_value(N_array_3d * array3d, int col, int row, int depth, char *value);
  157. extern void N_put_array_3d_f_value(N_array_3d * array3d, int col, int row, int depth, float value);
  158. extern void N_put_array_3d_d_value(N_array_3d * array3d, int col, int row, int depth, double value);
  159. extern int N_is_array_3d_value_null(N_array_3d * array3d, int col, int row, int depth);
  160. extern void N_put_array_3d_value_null(N_array_3d * array3d, int col, int row, int depth);
  161. extern void N_print_array_3d(N_array_3d * data);
  162. extern void N_print_array_3d_info(N_array_3d * data);
  163. extern void N_copy_array_3d(N_array_3d * source, N_array_3d * target);
  164. extern double N_norm_array_3d(N_array_3d * array1, N_array_3d * array2, int type);
  165. extern N_array_3d *N_math_array_3d(N_array_3d * array1, N_array_3d * array2, N_array_3d * result, int type);
  166. extern int N_convert_array_3d_null_to_zero(N_array_3d * a);
  167. extern N_array_3d *N_read_rast3d_to_array_3d(char *name, N_array_3d * array, int mask);
  168. extern void N_write_array_3d_to_rast3d(N_array_3d * array, char *name, int mask);
  169. extern void N_calc_array_3d_stats(N_array_3d * a, double *min, double *max, double *sum, int *nonzero, int withoffset);
  170. /* *************************************************************** */
  171. /* *************** MATRIX ASSEMBLING METHODS ********************* */
  172. /* *************************************************************** */
  173. /*!
  174. * \brief Matrix entries for a mass balance 5/7/9 star system
  175. *
  176. * Matrix entries for the mass balance of a 5 star system
  177. *
  178. * The entries are center, east, west, north, south and the
  179. * right side vector b of Ax = b. This system is typically used in 2d.
  180. \verbatim
  181. N
  182. |
  183. W-- C --E
  184. |
  185. S
  186. \endverbatim
  187. * Matrix entries for the mass balance of a 7 star system
  188. *
  189. * The entries are center, east, west, north, south, top, bottom and the
  190. * right side vector b of Ax = b. This system is typically used in 3d.
  191. \verbatim
  192. T N
  193. |/
  194. W-- C --E
  195. /|
  196. S B
  197. \endverbatim
  198. * Matrix entries for the mass balance of a 9 star system
  199. *
  200. * The entries are center, east, west, north, south, north-east, south-east,
  201. * north-wast, south-west and the
  202. * right side vector b of Ax = b. This system is typically used in 2d.
  203. \verbatim
  204. NW N NE
  205. \ | /
  206. W-- C --E
  207. / | \
  208. SW S SE
  209. \endverbatim
  210. * Matrix entries for the mass balance of a 27 star system
  211. *
  212. * The entries are center, east, west, north, south, north-east, south-east,
  213. * north-wast, south-west, same for top and bottom and the
  214. * right side vector b of Ax = b. This system is typically used in 2d.
  215. \verbatim
  216. top:
  217. NW_T N_Z NE_T
  218. \ | /
  219. W_T-- T --E_T
  220. / | \
  221. SW_T S_T SE_T
  222. center:
  223. NW N NE
  224. \ | /
  225. W-- C --E
  226. / | \
  227. SW S SE
  228. bottom:
  229. NW_B N_B NE_B
  230. \ | /
  231. W_B-- B --E_B
  232. / | \
  233. SW_B S_B SE_B
  234. \endverbatim
  235. */
  236. typedef struct
  237. {
  238. int type;
  239. int count;
  240. double C, W, E, N, S, NE, NW, SE, SW, V;
  241. /*top part */
  242. double T, W_T, E_T, N_T, S_T, NE_T, NW_T, SE_T, SW_T;
  243. /*bottom part */
  244. double B, W_B, E_B, N_B, S_B, NE_B, NW_B, SE_B, SW_B;
  245. } N_data_star;
  246. /*!
  247. * \brief callback structure for 3d matrix assembling
  248. * */
  249. typedef struct
  250. {
  251. N_data_star *(*callback) ();
  252. } N_les_callback_3d;
  253. /*!
  254. * \brief callback structure for 2d matrix assembling
  255. * */
  256. typedef struct
  257. {
  258. N_data_star *(*callback) ();
  259. } N_les_callback_2d;
  260. extern void N_set_les_callback_3d_func(N_les_callback_3d * data, N_data_star * (*callback_func_3d) ());
  261. extern void N_set_les_callback_2d_func(N_les_callback_2d * data, N_data_star * (*callback_func_2d) ());
  262. extern N_les_callback_3d *N_alloc_les_callback_3d(void);
  263. extern N_les_callback_2d *N_alloc_les_callback_2d(void);
  264. extern N_data_star *N_alloc_5star(void);
  265. extern N_data_star *N_alloc_7star(void);
  266. extern N_data_star *N_alloc_9star(void);
  267. extern N_data_star *N_alloc_27star(void);
  268. extern N_data_star *N_create_5star(double C, double W, double E, double N,
  269. double S, double V);
  270. extern N_data_star *N_create_7star(double C, double W, double E, double N,
  271. double S, double T, double B, double V);
  272. extern N_data_star *N_create_9star(double C, double W, double E, double N,
  273. double S, double NW, double SW, double NE,
  274. double SE, double V);
  275. extern N_data_star *N_create_27star(double C, double W, double E, double N,
  276. double S, double NW, double SW, double NE,
  277. double SE, double T, double W_T,
  278. double E_T, double N_T, double S_T,
  279. double NW_T, double SW_T, double NE_T,
  280. double SE_T, double B, double W_B,
  281. double E_B, double N_B, double S_B,
  282. double NW_B, double SW_B, double NE_B,
  283. double SE_B, double V);
  284. extern N_data_star *N_callback_template_3d(void *data, N_geom_data * geom, int col, int row, int depth);
  285. extern N_data_star *N_callback_template_2d(void *data, N_geom_data * geom, int col, int row);
  286. extern 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);
  287. extern 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);
  288. extern 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);
  289. extern 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);
  290. extern 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);
  291. extern 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);
  292. extern 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);
  293. extern 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);
  294. extern int N_les_pivot_create(N_les * les);
  295. int N_les_integrate_dirichlet_2d(N_les * les, N_geom_data * geom, N_array_2d * status, N_array_2d * start_val);
  296. int N_les_integrate_dirichlet_3d(N_les * les, N_geom_data * geom, N_array_3d * status, N_array_3d * start_val);
  297. /* *************************************************************** */
  298. /* *************** GPDE STANDARD OPTIONS ************************* */
  299. /* *************************************************************** */
  300. /*! \brief Standard options of the gpde library
  301. * */
  302. typedef enum
  303. {
  304. N_OPT_SOLVER_SYMM, /*! solver for symmetric, positive definite linear equation systems */
  305. N_OPT_SOLVER_UNSYMM, /*! solver for unsymmetric linear equation systems */
  306. N_OPT_MAX_ITERATIONS, /*! Maximum number of iteration used to solver the linear equation system */
  307. N_OPT_ITERATION_ERROR, /*! Error break criteria for the iterative solver (jacobi, sor, cg or bicgstab) */
  308. N_OPT_SOR_VALUE, /*! The relaxation parameter used by the jacobi and sor solver for speedup or stabilizing */
  309. N_OPT_CALC_TIME /*! The calculation time in seconds */
  310. } N_STD_OPT;
  311. extern struct Option *N_define_standard_option(int opt);
  312. /* *************************************************************** */
  313. /* *************** GPDE MATHEMATICAL TOOLS *********************** */
  314. /* *************************************************************** */
  315. extern double N_calc_arith_mean(double a, double b);
  316. extern double N_calc_arith_mean_n(double *a, int size);
  317. extern double N_calc_geom_mean(double a, double b);
  318. extern double N_calc_geom_mean_n(double *a, int size);
  319. extern double N_calc_harmonic_mean(double a, double b);
  320. extern double N_calc_harmonic_mean_n(double *a, int size);
  321. extern double N_calc_quad_mean(double a, double b);
  322. extern double N_calc_quad_mean_n(double *a, int size);
  323. /* *************************************************************** */
  324. /* *************** UPWIND STABILIZATION ALGORITHMS *************** */
  325. /* *************************************************************** */
  326. extern double N_full_upwinding(double sprod, double distance, double D);
  327. extern double N_exp_upwinding(double sprod, double distance, double D);
  328. /* *************************************************************** */
  329. /* *************** METHODS FOR GRADIENT CALCULATION ************** */
  330. /* *************************************************************** */
  331. /*!
  332. \verbatim
  333. ______________
  334. | | | |
  335. | | | |
  336. |----|-NC-|----|
  337. | | | |
  338. | WC EC |
  339. | | | |
  340. |----|-SC-|----|
  341. | | | |
  342. |____|____|____|
  343. | /
  344. TC NC
  345. |/
  346. --WC-----EC--
  347. /|
  348. SC BC
  349. / |
  350. \endverbatim
  351. */
  352. /*! \brief Gradient between the cells in X and Y direction */
  353. typedef struct
  354. {
  355. double NC, SC, WC, EC;
  356. } N_gradient_2d;
  357. /*! \brief Gradient between the cells in X, Y and Z direction */
  358. typedef struct
  359. {
  360. double NC, SC, WC, EC, TC, BC;
  361. } N_gradient_3d;
  362. /*!
  363. \verbatim
  364. Gradient in X direction between the cell neighbours
  365. ____ ____ ____
  366. | | | |
  367. | NWN NEN |
  368. |____|____|____|
  369. | | | |
  370. | WN EN |
  371. |____|____|____|
  372. | | | |
  373. | SWS SES |
  374. |____|____|____|
  375. Gradient in Y direction between the cell neighbours
  376. ______________
  377. | | | |
  378. | | | |
  379. |NWW-|-NC-|-NEE|
  380. | | | |
  381. | | | |
  382. |SWW-|-SC-|-SEE|
  383. | | | |
  384. |____|____|____|
  385. Gradient in Z direction between the cell neighbours
  386. /______________/
  387. /| | | |
  388. | NWZ| NZ | NEZ|
  389. |____|____|____|
  390. /| | | |
  391. | WZ | CZ | EZ |
  392. |____|____|____|
  393. /| | | |
  394. | SWZ| SZ | SEZ|
  395. |____|____|____|
  396. /____/____/____/
  397. \endverbatim
  398. */
  399. /*! \brief Gradient between the cell neighbours in X direction */
  400. typedef struct
  401. {
  402. double NWN, NEN, WC, EC, SWS, SES;
  403. } N_gradient_neighbours_x;
  404. /*! \brief Gradient between the cell neighbours in Y direction */
  405. typedef struct
  406. {
  407. double NWW, NEE, NC, SC, SWW, SEE;
  408. } N_gradient_neighbours_y;
  409. /*! \brief Gradient between the cell neighbours in Z direction */
  410. typedef struct
  411. {
  412. double NWZ, NZ, NEZ, WZ, CZ, EZ, SWZ, SZ, SEZ;
  413. } N_gradient_neighbours_z;
  414. /*! \brief Gradient between the cell neighbours in X and Y direction */
  415. typedef struct
  416. {
  417. N_gradient_neighbours_x *x;
  418. N_gradient_neighbours_y *y;
  419. } N_gradient_neighbours_2d;
  420. /*! \brief Gradient between the cell neighbours in X, Y and Z direction */
  421. typedef struct
  422. {
  423. N_gradient_neighbours_x *xt; /*top values */
  424. N_gradient_neighbours_x *xc; /*center values */
  425. N_gradient_neighbours_x *xb; /*bottom values */
  426. N_gradient_neighbours_y *yt; /*top values */
  427. N_gradient_neighbours_y *yc; /*center values */
  428. N_gradient_neighbours_y *yb; /*bottom values */
  429. N_gradient_neighbours_z *zt; /*top-center values */
  430. N_gradient_neighbours_z *zb; /*bottom-center values */
  431. } N_gradient_neighbours_3d;
  432. /*! Two dimensional gradient field */
  433. typedef struct
  434. {
  435. N_array_2d *x_array;
  436. N_array_2d *y_array;
  437. int cols, rows;
  438. double min, max, mean, sum;
  439. int nonull;
  440. } N_gradient_field_2d;
  441. /*! Three dimensional gradient field */
  442. typedef struct
  443. {
  444. N_array_3d *x_array;
  445. N_array_3d *y_array;
  446. N_array_3d *z_array;
  447. int cols, rows, depths;
  448. double min, max, mean, sum;
  449. int nonull;
  450. } N_gradient_field_3d;
  451. extern N_gradient_2d *N_alloc_gradient_2d(void);
  452. extern void N_free_gradient_2d(N_gradient_2d * grad);
  453. extern N_gradient_2d *N_create_gradient_2d(double NC, double SC, double WC, double EC);
  454. extern int N_copy_gradient_2d(N_gradient_2d * source, N_gradient_2d * target);
  455. extern N_gradient_2d *N_get_gradient_2d(N_gradient_field_2d * field, N_gradient_2d * gradient, int col, int row);
  456. extern N_gradient_3d *N_alloc_gradient_3d(void);
  457. extern void N_free_gradient_3d(N_gradient_3d * grad);
  458. extern N_gradient_3d *N_create_gradient_3d(double NC, double SC, double WC, double EC, double TC, double BC);
  459. extern int N_copy_gradient_3d(N_gradient_3d * source, N_gradient_3d * target);
  460. extern N_gradient_3d *N_get_gradient_3d(N_gradient_field_3d * field, N_gradient_3d * gradient, int col, int row, int depth);
  461. extern N_gradient_neighbours_x *N_alloc_gradient_neighbours_x(void);
  462. extern void N_free_gradient_neighbours_x(N_gradient_neighbours_x * grad);
  463. extern N_gradient_neighbours_x *N_create_gradient_neighbours_x(double NWN,
  464. double NEN,
  465. double WC,
  466. double EC,
  467. double SWS,
  468. double SES);
  469. extern int N_copy_gradient_neighbours_x(N_gradient_neighbours_x * source, N_gradient_neighbours_x * target);
  470. extern N_gradient_neighbours_y *N_alloc_gradient_neighbours_y(void);
  471. extern void N_free_gradient_neighbours_y(N_gradient_neighbours_y * grad);
  472. extern N_gradient_neighbours_y *N_create_gradient_neighbours_y(double NWW,
  473. double NEE,
  474. double NC,
  475. double SC,
  476. double SWW,
  477. double SEE);
  478. extern int N_copy_gradient_neighbours_y(N_gradient_neighbours_y * source, N_gradient_neighbours_y * target);
  479. extern N_gradient_neighbours_z *N_alloc_gradient_neighbours_z(void);
  480. extern void N_free_gradient_neighbours_z(N_gradient_neighbours_z * grad);
  481. extern N_gradient_neighbours_z *N_create_gradient_neighbours_z(double NWZ,
  482. double NZ,
  483. double NEZ,
  484. double WZ,
  485. double CZ,
  486. double EZ,
  487. double SWZ,
  488. double SZ,
  489. double SEZ);
  490. extern int N_copy_gradient_neighbours_z(N_gradient_neighbours_z * source, N_gradient_neighbours_z * target);
  491. extern N_gradient_neighbours_2d *N_alloc_gradient_neighbours_2d(void);
  492. extern void N_free_gradient_neighbours_2d(N_gradient_neighbours_2d * grad);
  493. extern N_gradient_neighbours_2d * N_create_gradient_neighbours_2d(N_gradient_neighbours_x * x, N_gradient_neighbours_y * y);
  494. extern int N_copy_gradient_neighbours_2d(N_gradient_neighbours_2d * source, N_gradient_neighbours_2d * target);
  495. extern N_gradient_neighbours_2d * N_get_gradient_neighbours_2d(N_gradient_field_2d * field, N_gradient_neighbours_2d * gradient, int col, int row);
  496. extern N_gradient_neighbours_3d *N_alloc_gradient_neighbours_3d(void);
  497. extern void N_free_gradient_neighbours_3d(N_gradient_neighbours_3d * grad);
  498. extern N_gradient_neighbours_3d
  499. * N_create_gradient_neighbours_3d(N_gradient_neighbours_x * xt,
  500. N_gradient_neighbours_x * xc,
  501. N_gradient_neighbours_x * xb,
  502. N_gradient_neighbours_y * yt,
  503. N_gradient_neighbours_y * yc,
  504. N_gradient_neighbours_y * yb,
  505. N_gradient_neighbours_z * zt,
  506. N_gradient_neighbours_z * zb);
  507. extern int N_copy_gradient_neighbours_3d(N_gradient_neighbours_3d * source, N_gradient_neighbours_3d * target);
  508. extern void N_print_gradient_field_2d_info(N_gradient_field_2d * field);
  509. extern void N_calc_gradient_field_2d_stats(N_gradient_field_2d * field);
  510. extern N_gradient_field_2d *N_alloc_gradient_field_2d(int cols, int rows);
  511. extern void N_free_gradient_field_2d(N_gradient_field_2d * field);
  512. extern int N_copy_gradient_field_2d(N_gradient_field_2d * source, N_gradient_field_2d * target);
  513. extern N_gradient_field_2d *N_compute_gradient_field_2d(N_array_2d * pot,
  514. N_array_2d * weight_x,
  515. N_array_2d * weight_y,
  516. N_geom_data * geom,
  517. N_gradient_field_2d *
  518. gradfield);
  519. extern void N_compute_gradient_field_components_2d(N_gradient_field_2d * field, N_array_2d * x_comp, N_array_2d * y_comp);
  520. extern void N_print_gradient_field_3d_info(N_gradient_field_3d * field);
  521. extern void N_calc_gradient_field_3d_stats(N_gradient_field_3d * field);
  522. extern N_gradient_field_3d *N_alloc_gradient_field_3d(int cols, int rows, int depths);
  523. extern void N_free_gradient_field_3d(N_gradient_field_3d * field);
  524. extern int N_copy_gradient_field_3d(N_gradient_field_3d * source, N_gradient_field_3d * target);
  525. extern N_gradient_field_3d *N_compute_gradient_field_3d(N_array_3d * pot,
  526. N_array_3d * weight_x,
  527. N_array_3d * weight_y,
  528. N_array_3d * weight_z,
  529. N_geom_data * geom,
  530. N_gradient_field_3d *
  531. gradfield);
  532. extern 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);
  533. #endif