YAC 3.13.0
Yet Another Coupler
Loading...
Searching...
No Matches
test_interp_stack_config.c
Go to the documentation of this file.
1// Copyright (c) 2024 The YAC Authors
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#include <stdio.h>
6#include <math.h>
7#include <mpi.h>
8#include <yaxt.h>
9#include "tests.h"
10#include "dist_grid_utils.h"
13#include "geometry.h"
14
20#define ARGS(...) __VA_ARGS__
21#define _GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N, ...) N
22#define EXPAND(x) x
23#define FOREACH(name, ...) \
24 { \
25 enum {NUM_ ## name = sizeof( name ) / sizeof( name [0])}; \
26 int name ## _idx[2]; \
27 for (name ## _idx[0] = 0; name ## _idx[0] < NUM_ ## name; \
28 ++ name ## _idx[0]) { \
29 for (name ## _idx[1] = 0; name ## _idx[1] < NUM_ ## name; \
30 ++ name ## _idx[1]) { \
31 configs_differ += (name ## _idx[0]) != (name ## _idx[1]); \
32 {__VA_ARGS__} \
33 configs_differ -= (name ## _idx[0]) != (name ## _idx[1]); \
34 } \
35 } \
36 }
37#define FOREACH_ENUM(name, values, ...) \
38 { \
39 enum yac_ ## name name [] = {values}; \
40 FOREACH(name, __VA_ARGS__) \
41 }
42#define FOREACH_TYPE(name, type, values, ...) \
43 { \
44 type name[] = {values}; \
45 FOREACH(name, __VA_ARGS__) \
46 }
47#define FOREACH_INT(name, values, ...) \
48 FOREACH_TYPE(name, int, ARGS(values), __VA_ARGS__)
49#define FOREACH_DBLE(name, values, ...) \
50 FOREACH_TYPE(name, double, ARGS(values), __VA_ARGS__)
51#define FOREACH_BOOL(name, ...) FOREACH_INT(name, ARGS(0, 1), __VA_ARGS__)
52#define FOREACH_STRING(name, values, ...) \
53 FOREACH_TYPE(name, ARGS(char const *), ARGS(values), __VA_ARGS__)
54#define FOREACH_STRUCT(name, struct_name, values, ...) \
55 FOREACH_TYPE(name, ARGS(struct struct_name), ARGS(values), __VA_ARGS__)
56#define _CHECK_STACKS(interp_name, config) \
57 { \
58 int config_idx; \
59 struct yac_interp_stack_config * a = yac_interp_stack_config_new(); \
60 struct yac_interp_stack_config * b = yac_interp_stack_config_new(); \
61 config_idx = 0, yac_interp_stack_config_add_ ## interp_name ( a, config ); \
62 config_idx = 1, yac_interp_stack_config_add_ ## interp_name ( b, config ); \
63 utest_check_compare_stacks(a, b, configs_differ); \
64 }
65#define _CONFIG_ARGS1(arg_name) arg_name[arg_name ## _idx[config_idx]]
66#define _CONFIG_ARGS2(arg_name, ...) \
67 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS1(__VA_ARGS__)
68#define _CONFIG_ARGS3(arg_name, ...) \
69 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS2(__VA_ARGS__)
70#define _CONFIG_ARGS4(arg_name, ...) \
71 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS3(__VA_ARGS__)
72#define _CONFIG_ARGS5(arg_name, ...) \
73 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS4(__VA_ARGS__)
74#define _CONFIG_ARGS6(arg_name, ...) \
75 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS5(__VA_ARGS__)
76#define _CONFIG_ARGS7(arg_name, ...) \
77 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS6(__VA_ARGS__)
78#define _CONFIG_ARGS8(arg_name, ...) \
79 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS7(__VA_ARGS__)
80#define _CONFIG_ARGS9(arg_name, ...) \
81 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS8(__VA_ARGS__)
82#define _CONFIG_ARGS10(arg_name, ...) \
83 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS9(__VA_ARGS__)
84#define _CONFIG_ARGS11(arg_name, ...) \
85 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS10(__VA_ARGS__)
86#define _CONFIG_ARGS12(arg_name, ...) \
87 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS11(__VA_ARGS__)
88#define CHECK_STACKS(interp_name, ... ) \
89 _CHECK_STACKS(interp_name, \
90 EXPAND(_GET_NTH_ARG(__VA_ARGS__, _CONFIG_ARGS12, \
91 _CONFIG_ARGS11, \
92 _CONFIG_ARGS10, \
93 _CONFIG_ARGS9, \
94 _CONFIG_ARGS8, \
95 _CONFIG_ARGS7, \
96 _CONFIG_ARGS6, \
97 _CONFIG_ARGS5, \
98 _CONFIG_ARGS4, \
99 _CONFIG_ARGS3, \
100 _CONFIG_ARGS2, \
101 _CONFIG_ARGS1)(__VA_ARGS__)))
102
103static void utest_check_compare_stacks(
105 int configs_differ);
106
108 struct yac_interp_stack_config * interp_stack_config,
109 double spread_distance, double max_search_distance,
111 enum yac_interp_spmap_scale_type scale_type,
112 struct yac_spmap_cell_area_config * src_cell_area_config,
113 struct yac_spmap_cell_area_config * tgt_cell_area_config);
114
116 struct yac_interp_stack_config * interp_stack_config,
117 struct yac_interp_spmap_config * default_config,
118 struct yac_spmap_overwrite_config ** overwrite_configs);
119
120int main (void) {
121
122 MPI_Init(NULL, NULL);
123 xt_initialize(MPI_COMM_WORLD);
124
125 int configs_differ = 0;
126
127 { // stack with different sizes
133 utest_check_compare_stacks(a, b, 1);
134 }
135
136 { // compare empty config
139 utest_check_compare_stacks(a, b, 0);
140 }
141
142 // compare average config
144 interp_avg_weight_type,
147 partial_coverage,
148 CHECK_STACKS(average, interp_avg_weight_type, partial_coverage)))
149
150 // compare ncc config
152 interp_ncc_weight_type,
155 partial_coverage,
156 CHECK_STACKS(ncc, interp_ncc_weight_type, partial_coverage)))
157
158 // compare nnn config
159 // for YAC_INTERP_NNN_AVG, YAC_INTERP_NNN_DIST, and YAC_INTERP_NNN_ZERO
160 // the scale parameter is being ignored
162 interp_nnn_weight_type,
165 counts, ARGS(1,3,9),
167 max_search_distance, ARGS(0.0, M_PI_2),
169 scales, -1.0,
171 nnn, interp_nnn_weight_type, counts,
172 max_search_distance, scales)))))
173
174 // compare nnn config
175 // for YAC_INTERP_NNN_GAUSS and YAC_INTERP_NNN_RBF the scale
176 // parameter is being interpreted
178 interp_nnn_weight_type,
181 counts, ARGS(1,3,9),
183 max_search_distance, ARGS(0.0, M_PI_2),
185 scales, ARGS(0.5, 1.0),
187 nnn, interp_nnn_weight_type, counts,
188 max_search_distance, scales)))))
189
190 // compare conservative config
192 order, ARGS(1,2),
194 enforced_conserv,
196 partial_coverage,
198 interp_method_conserv_normalisation,
200 CHECK_STACKS(conservative,
201 order, enforced_conserv, partial_coverage,
202 interp_method_conserv_normalisation)))))
203
204 // compare source point mapping
205 {
206 struct yac_spmap_cell_area_config * cell_area_configs[] = {
209 yac_spmap_cell_area_config_file_new("area.nc", "cell_area", 0),
210 yac_spmap_cell_area_config_file_new("area.nc_", "cell_area", 0),
211 yac_spmap_cell_area_config_file_new("area.nc", "cell_area_", 0),
212 yac_spmap_cell_area_config_file_new("area.nc", "cell_area", 1),
213 yac_spmap_cell_area_config_file_new("area.nc_", "cell_area_", 1),
214 };
215 enum {
216 NUM_CELL_AREA_CONFIGS =
217 sizeof(cell_area_configs) / sizeof(cell_area_configs[0])};
218
220 src_cell_area_config, ARGS(struct yac_spmap_cell_area_config *),
221 ARGS(
222 cell_area_configs[0], cell_area_configs[1], cell_area_configs[2],
223 cell_area_configs[3], cell_area_configs[4], cell_area_configs[5],
224 cell_area_configs[6]),
226 tgt_cell_area_config, ARGS(struct yac_spmap_cell_area_config *),
227 ARGS(
228 cell_area_configs[0], cell_area_configs[1], cell_area_configs[2],
229 cell_area_configs[3], cell_area_configs[4], cell_area_configs[5],
230 cell_area_configs[6]),
232 spread_distance, ARGS(0.0, 0.1),
234 max_search_distance, ARGS(0.0, 0.4),
236 interp_spmap_weight_type,
239 interp_spmap_scale_type,
240 ARGS(
243 CHECK_STACKS(spmap_,
244 spread_distance, max_search_distance,
245 interp_spmap_weight_type, interp_spmap_scale_type,
246 src_cell_area_config, tgt_cell_area_config)))))))
247
248 for (size_t i = 0; i < NUM_CELL_AREA_CONFIGS; ++i)
249 yac_spmap_cell_area_config_delete(cell_area_configs[i]);
250 }
251
252 // compare source point mapping extended
253 {
254 struct yac_spmap_scale_config * scale_config_custom =
256 struct yac_interp_spmap_config * default_configs[] = {
259 1.0,
265 1.0,
277 scale_config_custom),
278 };
279 enum {
280 NUM_DEFAULT_CONFIGS =
281 sizeof(default_configs)/sizeof(default_configs[0])};
282
283 struct yac_point_selection * bnd_point_selection_a =
285 struct yac_point_selection * bnd_point_selection_b =
287 struct yac_interp_spmap_config * spmap_config_custom =
289 1.0,
293
294 struct yac_spmap_overwrite_config *** overwrite_configs =
295 (struct yac_spmap_overwrite_config **[])
296 {NULL,
297 (struct yac_spmap_overwrite_config *[]) {
298 yac_spmap_overwrite_config_new(bnd_point_selection_a, NULL),
299 NULL},
300 (struct yac_spmap_overwrite_config *[]) {
301 yac_spmap_overwrite_config_new(bnd_point_selection_b, NULL),
302 NULL},
303 (struct yac_spmap_overwrite_config *[]) {
305 bnd_point_selection_b, spmap_config_custom),
306 NULL},
307 (struct yac_spmap_overwrite_config *[]) {
309 bnd_point_selection_a, NULL),
311 bnd_point_selection_b, NULL),
312 NULL},
313 (struct yac_spmap_overwrite_config *[]) {
314 yac_spmap_overwrite_config_new(bnd_point_selection_a, NULL),
316 bnd_point_selection_b, spmap_config_custom),
317 NULL}};
318 enum {NUM_OVERWRITE_CONFIGS = 6};
319
321 default_config, ARGS(struct yac_interp_spmap_config *),
322 ARGS(
323 default_configs[0], default_configs[1],
324 default_configs[2], default_configs[3]),
326 overwrite_config, ARGS(struct yac_spmap_overwrite_config **),
327 ARGS(
328 overwrite_configs[0], overwrite_configs[1], overwrite_configs[2],
329 overwrite_configs[3], overwrite_configs[4], overwrite_configs[5]),
330 CHECK_STACKS(spmap_ext_, default_config, overwrite_config)))
331
332 for (size_t i = 0; i < NUM_OVERWRITE_CONFIGS; ++i)
333 for (size_t j = 0;
334 (overwrite_configs[i] != NULL) && (overwrite_configs[i][j] != NULL);
335 ++j)
336 yac_spmap_overwrite_config_delete(overwrite_configs[i][j]);
337 yac_interp_spmap_config_delete(spmap_config_custom);
338 yac_point_selection_delete(bnd_point_selection_a);
339 yac_point_selection_delete(bnd_point_selection_b);
340 for (size_t i = 0; i < NUM_DEFAULT_CONFIGS; ++i)
341 yac_interp_spmap_config_delete(default_configs[i]);
342 yac_spmap_scale_config_delete(scale_config_custom);
343 }
344
345 // compare user file
347 filename, ARGS(
348 "test_interp_stack_config_file_a.nc",
349 "test_interp_stack_config_file_b.nc"),
351 interp_file_on_missing_file,
354 interp_file_on_success,
357 user_file, filename, interp_file_on_missing_file,
358 interp_file_on_success))))
359
360 // compare fixed
362 fixed_value, ARGS(-1.0, 0.0, 1.0, NAN),
363 CHECK_STACKS(fixed, fixed_value))
364
365 // compare check
367 constructor_key, ARGS(NULL, "constructor_a", "constructor_b"),
369 do_search_key, ARGS(NULL, "do_search_key_a", "do_search_key_b"),
370 CHECK_STACKS(check, constructor_key, do_search_key)))
371
372 // compare creep
374 creep_distance, ARGS(-1, 0, 1),
375 CHECK_STACKS(creep, creep_distance))
376
377 // compare user callback
379 compute_weights_key, ARGS("compute_weights_a", "compute_weights_b"),
380 CHECK_STACKS(user_callback, compute_weights_key))
381
382 { // testing spmap interpolation generated from an interp_stack
383
384 // trivial 2x2 grid
385 double * coords = (double[]){0.0,0.1,0.2};
388 coords, coords, (size_t[]){2,2},
389 (size_t[]){0,0}, (size_t[]){2,2}, 1),
391 coords, coords, (size_t[]){2,2},
392 (size_t[]){0,0}, (size_t[]){2,2}, 1)};
393 yac_coordinate_pointer cell_center_coords =
394 malloc(4 * sizeof(*cell_center_coords));
395 for (int i = 0, k = 0; i < 2; ++i)
396 for (int j = 0; j < 2; ++j, ++k)
397 LLtoXYZ(
398 (coords[j] + coords[j+1])*0.5, (coords[i] + coords[i+1])*0.5,
399 cell_center_coords[k]);
400
401 struct yac_basic_grid * grids[2] =
402 {yac_basic_grid_new("src_grid", grid_data[0]),
403 yac_basic_grid_new("tgt_grid", grid_data[1])};
404
405 size_t src_cell_coord_idx =
407 grids[0], YAC_LOC_CELL, cell_center_coords, 4);
408 size_t tgt_cell_coord_idx =
410 grids[1], YAC_LOC_CELL, cell_center_coords, 4);
411 free(cell_center_coords);
412
413 struct yac_dist_grid_pair * grid_pair =
414 yac_dist_grid_pair_new(grids[0], grids[1], MPI_COMM_WORLD);
415
416 struct yac_interp_field src_fields[] =
417 {{.location = YAC_LOC_CELL, .masks_idx = SIZE_MAX}};
418 size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
420 {.location = YAC_LOC_CELL, .masks_idx = SIZE_MAX};
421 src_fields[0].coordinates_idx = src_cell_coord_idx;
422 tgt_field.coordinates_idx = tgt_cell_coord_idx;
423
424 struct yac_interp_grid * interp_grid =
425 yac_interp_grid_new(grid_pair, "src_grid", "tgt_grid",
427
428 enum {OVERWRITE_CONFIG_COUNT = 1};
430 overwrite_configs[OVERWRITE_CONFIG_COUNT+1];
431 overwrite_configs[OVERWRITE_CONFIG_COUNT] = NULL;
432
433 {
434 struct yac_point_selection * src_point_selection =
435 yac_point_selection_bnd_circle_new(0.05, 0.05, 0.01);
436 struct yac_interp_spmap_config * spmap_config =
438 0.11,
442 overwrite_configs[0] =
443 yac_spmap_overwrite_config_new(src_point_selection, spmap_config);
444 yac_interp_spmap_config_delete(spmap_config);
445 yac_point_selection_delete(src_point_selection);
446 }
447
448 struct yac_interp_stack_config * interp_stack_config =
450
452 interp_stack_config, YAC_INTERP_SPMAP_DEFAULT_CONFIG, overwrite_configs);
453
454 struct interp_method ** method_stack =
455 yac_interp_stack_config_generate(interp_stack_config);
456
457 yac_interp_stack_config_delete(interp_stack_config);
458
459 struct yac_interp_weights * weights =
460 yac_interp_method_do_search(method_stack, interp_grid);
461
462 struct yac_interpolation * interpolation =
464 weights, YAC_MAPPING_ON_SRC, 1,
465 YAC_FRAC_MASK_NO_VALUE, 1.0, 0.0, NULL, 1, 1);
466
467 {
468 double * src_field = (double[]){1.0,2.0,3.0,4.0};
469 double ** src_fields = &src_field;
470 double * tgt_field = (double[]){0.0,0.0,0.0,0.0};
471 double const * ref_tgt_field =
472 (double[]){1.0/3.0, 2.0+1.0/3.0, 3.0+1.0/3.0, 4.0};
473
474 yac_interpolation_execute(interpolation, &src_fields, &tgt_field);
475
476 for (int i = 0; i < 4; ++i)
477 if (fabs(tgt_field[i] - ref_tgt_field[i]) > 1e-6)
478 PUT_ERR("ERROR in yac_interp_stack_config_add_spmap_ext");
479 }
480
481 yac_interpolation_delete(interpolation);
482
484 yac_interp_method_delete(method_stack);
485 for (size_t i = 0; i < OVERWRITE_CONFIG_COUNT; ++i)
486 yac_spmap_overwrite_config_delete(overwrite_configs[i]);
487 yac_interp_grid_delete(interp_grid);
488 yac_dist_grid_pair_delete(grid_pair);
491 }
492
493 xt_finalize();
494 MPI_Finalize();
495
496 return TEST_EXIT_CODE;
497}
498
499static void utest_check_compare_stacks_(
501 int configs_differ) {
502
503 configs_differ = configs_differ != 0;
504
506 PUT_ERR("error in yac_interp_stack_config_compare (a != a)")
509
510 int cmp_a = yac_interp_stack_config_compare(a, b);
511 int cmp_b = yac_interp_stack_config_compare(b, a);
512
513 if ((cmp_a != cmp_b) ^ configs_differ)
514 PUT_ERR("error in yac_interp_stack_config_compare ((a > b) == (a < b))")
515 if ((cmp_a != 0) ^ configs_differ)
517 if ((cmp_b != 0) ^ configs_differ)
519
522}
523
524static void utest_check_compare_stacks(
526 int configs_differ) {
527
528 utest_check_compare_stacks_(
530 yac_interp_stack_config_copy(b), configs_differ);
531 utest_check_compare_stacks_(a, b, configs_differ);
532}
533
535 struct yac_interp_stack_config * interp_stack_config,
536 double spread_distance, double max_search_distance,
538 enum yac_interp_spmap_scale_type scale_type,
539 struct yac_spmap_cell_area_config * src_cell_area_config,
540 struct yac_spmap_cell_area_config * tgt_cell_area_config) {
541
542 enum yac_interp_spmap_cell_area_provider src_cell_area_config_type =
543 yac_spmap_cell_area_config_get_type(src_cell_area_config);
544 double src_sphere_radius =
545 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_YAC)?
546 yac_spmap_cell_area_config_get_sphere_radius(src_cell_area_config):0.0;
547 char const * src_filename =
548 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
549 yac_spmap_cell_area_config_get_filename(src_cell_area_config):NULL;
550 char const * src_varname =
551 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
552 yac_spmap_cell_area_config_get_varname(src_cell_area_config):NULL;
553 yac_int src_min_global_id =
554 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
555 yac_spmap_cell_area_config_get_min_global_id(src_cell_area_config):0;
556
557 enum yac_interp_spmap_cell_area_provider tgt_cell_area_config_type =
558 yac_spmap_cell_area_config_get_type(tgt_cell_area_config);
559 double tgt_sphere_radius =
560 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_YAC)?
561 yac_spmap_cell_area_config_get_sphere_radius(tgt_cell_area_config):0.0;
562 char const * tgt_filename =
563 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
564 yac_spmap_cell_area_config_get_filename(tgt_cell_area_config):NULL;
565 char const * tgt_varname =
566 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
567 yac_spmap_cell_area_config_get_varname(tgt_cell_area_config):NULL;
568 yac_int tgt_min_global_id =
569 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
570 yac_spmap_cell_area_config_get_min_global_id(tgt_cell_area_config):0;
571
573 interp_stack_config,
574 spread_distance, max_search_distance, weight_type, scale_type,
575 src_sphere_radius,
576 src_filename,
577 src_varname,
578 src_min_global_id,
579 tgt_sphere_radius,
580 tgt_filename,
581 tgt_varname,
582 tgt_min_global_id);
583
584 // test yac_interp_stack_config_entry_get_spmap
585 union yac_interp_stack_config_entry const * interp_stack_entry =
587 interp_stack_config,
588 yac_interp_stack_config_get_size(interp_stack_config) - 1);
589 double spread_distance_;
590 double max_search_distance_;
591 enum yac_interp_spmap_weight_type weight_type_;
592 enum yac_interp_spmap_scale_type scale_type_;
593 double src_sphere_radius_;
594 char const * src_filename_;
595 char const * src_varname_;
596 int src_min_global_id_;
597 double tgt_sphere_radius_;
598 char const * tgt_filename_;
599 char const * tgt_varname_;
600 int tgt_min_global_id_;
602 interp_stack_entry,
603 &spread_distance_, &max_search_distance_, &weight_type_, &scale_type_,
604 &src_sphere_radius_, &src_filename_, &src_varname_, &src_min_global_id_,
605 &tgt_sphere_radius_, &tgt_filename_, &tgt_varname_, &tgt_min_global_id_);
606
607 if (spread_distance_ != spread_distance)
608 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
609 if (max_search_distance_ != max_search_distance)
610 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
611 if (weight_type_ != weight_type)
612 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
613 if (scale_type_ != scale_type)
614 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
615}
616
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
Definition basic_grid.c:53
size_t yac_basic_grid_add_coordinates(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates, size_t count)
Definition basic_grid.c:235
void yac_basic_grid_delete(struct yac_basic_grid *grid)
Definition basic_grid.c:73
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
Definition dist_grid.c:2315
struct yac_dist_grid_pair * yac_dist_grid_pair_new(struct yac_basic_grid *grid_a, struct yac_basic_grid *grid_b, MPI_Comm comm)
Definition dist_grid.c:2063
struct yac_basic_grid_data yac_generate_basic_grid_data_reg2d(double const *global_coords_x, double const *global_coords_y, size_t const num_global_cells_[2], size_t const local_start[2], size_t const local_count[2], int with_halo)
void yac_interp_grid_delete(struct yac_interp_grid *interp_grid)
struct yac_interp_grid * yac_interp_grid_new(struct yac_dist_grid_pair *grid_pair, char const *src_grid_name, char const *tgt_grid_name, size_t num_src_fields, struct yac_interp_field const *src_fields, struct yac_interp_field const tgt_field)
Definition interp_grid.c:30
void yac_interp_method_delete(struct interp_method **method)
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_AVG_BARY
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
@ YAC_INTERP_FILE_MISSING_CONT
continue on missing file
@ YAC_INTERP_FILE_MISSING_ERROR
abort on missing file
@ YAC_INTERP_FILE_SUCCESS_CONT
@ YAC_INTERP_FILE_SUCCESS_STOP
@ YAC_INTERP_NCC_DIST
distance weighted average of n source points
@ YAC_INTERP_NCC_AVG
average of n source points
@ YAC_INTERP_NNN_GAUSS
distance with Gauss weights of n source points
@ YAC_INTERP_NNN_RBF
radial basis functions
@ YAC_INTERP_NNN_AVG
average of n source points
@ YAC_INTERP_NNN_DIST
distance weighted average of n source points
@ YAC_INTERP_NNN_ZERO
all weights are set to zero
char const * yac_spmap_cell_area_config_get_filename(struct yac_spmap_cell_area_config const *cell_area_config)
double yac_spmap_cell_area_config_get_sphere_radius(struct yac_spmap_cell_area_config const *cell_area_config)
struct yac_spmap_cell_area_config * yac_spmap_cell_area_config_file_new(char const *filename, char const *varname, yac_int min_global_id)
struct yac_spmap_overwrite_config * yac_spmap_overwrite_config_new(struct yac_point_selection const *src_point_selection, struct yac_interp_spmap_config const *config)
yac_int yac_spmap_cell_area_config_get_min_global_id(struct yac_spmap_cell_area_config const *cell_area_config)
enum yac_interp_spmap_cell_area_provider yac_spmap_cell_area_config_get_type(struct yac_spmap_cell_area_config const *cell_area_config)
char const * yac_spmap_cell_area_config_get_varname(struct yac_spmap_cell_area_config const *cell_area_config)
struct yac_interp_spmap_config * yac_interp_spmap_config_new(double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, struct yac_spmap_scale_config const *scale_config)
void yac_spmap_scale_config_delete(struct yac_spmap_scale_config *scale_config)
void yac_interp_spmap_config_delete(struct yac_interp_spmap_config *config)
void yac_spmap_cell_area_config_delete(struct yac_spmap_cell_area_config *cell_area_config)
struct yac_spmap_cell_area_config * yac_spmap_cell_area_config_yac_new(double sphere_radius)
void yac_spmap_overwrite_config_delete(struct yac_spmap_overwrite_config *overwrite_config)
struct yac_spmap_scale_config * yac_spmap_scale_config_new(enum yac_interp_spmap_scale_type scale_type, struct yac_spmap_cell_area_config const *source_cell_area_config, struct yac_spmap_cell_area_config const *target_cell_area_config)
#define YAC_INTERP_SPMAP_MAX_SEARCH_DISTANCE_DEFAULT
yac_interp_spmap_scale_type
@ YAC_INTERP_SPMAP_NONE
weights are not scaled
@ YAC_INTERP_SPMAP_INVTGTAREA
@ YAC_INTERP_SPMAP_SRCAREA
@ YAC_INTERP_SPMAP_FRACAREA
#define YAC_INTERP_SPMAP_SCALE_CONFIG_DEFAULT
#define YAC_INTERP_SPMAP_WEIGHTED_DEFAULT
#define YAC_INTERP_SPMAP_SPREAD_DISTANCE_DEFAULT
yac_interp_spmap_cell_area_provider
@ YAC_INTERP_SPMAP_CELL_AREA_FILE
@ YAC_INTERP_SPMAP_CELL_AREA_YAC
yac_interp_spmap_weight_type
@ YAC_INTERP_SPMAP_AVG
@ YAC_INTERP_SPMAP_DIST
#define YAC_INTERP_SPMAP_DEFAULT_CONFIG
size_t yac_interp_stack_config_get_size(struct yac_interp_stack_config *interp_stack)
int yac_interp_stack_config_compare(void const *a_, void const *b_)
union yac_interp_stack_config_entry const * yac_interp_stack_config_get_entry(struct yac_interp_stack_config *interp_stack, size_t interp_stack_idx)
void yac_interp_stack_config_add_spmap(struct yac_interp_stack_config *interp_stack_config, double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, enum yac_interp_spmap_scale_type scale_type, double src_sphere_radius, char const *src_filename, char const *src_varname, int src_min_global_id, double tgt_sphere_radius, char const *tgt_filename, char const *tgt_varname, int tgt_min_global_id)
void yac_interp_stack_config_add_fixed(struct yac_interp_stack_config *interp_stack_config, double value)
void yac_interp_stack_config_add_average(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_avg_weight_type reduction_type, int partial_coverage)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
struct yac_interp_stack_config * yac_interp_stack_config_copy(struct yac_interp_stack_config *interp_stack)
struct interp_method ** yac_interp_stack_config_generate(struct yac_interp_stack_config *interp_stack)
struct yac_interp_stack_config * yac_interp_stack_config_new()
void yac_interp_stack_config_add_spmap_ext(struct yac_interp_stack_config *interp_stack_config, struct yac_interp_spmap_config *default_config, struct yac_spmap_overwrite_config **overwrite_configs)
void yac_interp_stack_config_entry_get_spmap(union yac_interp_stack_config_entry const *interp_stack_entry, double *spread_distance, double *max_search_distance, enum yac_interp_spmap_weight_type *weight_type, enum yac_interp_spmap_scale_type *scale_type, double *src_sphere_radius, char const **src_filename, char const **src_varname, int *src_min_global_id, double *tgt_sphere_radius, char const **tgt_filename, char const **tgt_varname, int *tgt_min_global_id)
struct yac_interpolation * yac_interp_weights_get_interpolation(struct yac_interp_weights *weights, enum yac_interp_weights_reorder_type reorder, size_t collection_size, double frac_mask_fallback_value, double scaling_factor, double scaling_summand, char const *yaxt_exchanger_name, int is_source, int is_target)
void yac_interp_weights_delete(struct yac_interp_weights *weights)
@ YAC_MAPPING_ON_SRC
weights will be applied at source processes
void yac_interpolation_execute(struct yac_interpolation *interp, double ***src_fields, double **tgt_field)
Execute interpolation synchronously and write results to the target field.
void yac_interpolation_delete(struct yac_interpolation *interp)
Free an interpolation object and release all resources.
double const YAC_FRAC_MASK_NO_VALUE
@ YAC_LOC_CELL
Definition location.h:14
struct yac_point_selection * yac_point_selection_bnd_circle_new(double center_lon, double center_lat, double inc_angle)
void yac_point_selection_delete(struct yac_point_selection *point_select)
enum yac_location location
Definition basic_grid.h:16
size_t coordinates_idx
Definition basic_grid.h:17
struct yac_interp_field tgt_field
Definition interp_grid.c:25
size_t num_src_fields
Definition interp_grid.c:26
struct yac_dist_grid_pair * grid_pair
Definition interp_grid.c:24
struct yac_interp_field src_fields[]
Definition interp_grid.c:27
@ error
Definition test_cxc.c:17
#define FOREACH_TYPE(name, type, values,...)
#define FOREACH_STRING(name, values,...)
static void yac_interp_stack_config_add_spmap_(struct yac_interp_stack_config *interp_stack_config, double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, enum yac_interp_spmap_scale_type scale_type, struct yac_spmap_cell_area_config *src_cell_area_config, struct yac_spmap_cell_area_config *tgt_cell_area_config)
static void yac_interp_stack_config_add_spmap_ext_(struct yac_interp_stack_config *interp_stack_config, struct yac_interp_spmap_config *default_config, struct yac_spmap_overwrite_config **overwrite_configs)
#define CHECK_STACKS(interp_name,...)
#define FOREACH_DBLE(name, values,...)
#define FOREACH_ENUM(name, values,...)
#define FOREACH_INT(name, values,...)
#define FOREACH_BOOL(name,...)
#define ARGS(...)
#define TEST_EXIT_CODE
Definition tests.h:14
#define PUT_ERR(string)
Definition tests.h:10
static void LLtoXYZ(double lon, double lat, double p_out[])
Definition toy_scrip.c:587
struct yac_spmap_overwrite_config ** overwrite_configs
struct yac_interp_spmap_config * default_config
struct yac_basic_grid ** grids
Definition yac.c:155
YAC_INT yac_int
Definition yac_types.h:15
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:21