YAC 3.21.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 <string.h>
8#include <mpi.h>
9#include <yaxt.h>
10#include "tests.h"
11#include "dist_grid_utils.h"
14#include "geometry.h"
15
21#define ARGS(...) __VA_ARGS__
22#define _GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, N, ...) N
23#define EXPAND(x) x
24#define FOREACH(name, ...) \
25 { \
26 enum {NUM_ ## name = sizeof( name ) / sizeof( name [0])}; \
27 int name ## _idx[2]; \
28 for (name ## _idx[0] = 0; name ## _idx[0] < NUM_ ## name; \
29 ++ name ## _idx[0]) { \
30 for (name ## _idx[1] = 0; name ## _idx[1] < NUM_ ## name; \
31 ++ name ## _idx[1]) { \
32 configs_differ += (name ## _idx[0]) != (name ## _idx[1]); \
33 {__VA_ARGS__} \
34 configs_differ -= (name ## _idx[0]) != (name ## _idx[1]); \
35 } \
36 } \
37 }
38#define FOREACH_ENUM(name, values, ...) \
39 { \
40 enum yac_ ## name name [] = {values}; \
41 FOREACH(name, __VA_ARGS__) \
42 }
43#define FOREACH_TYPE(name, type, values, ...) \
44 { \
45 type name[] = {values}; \
46 FOREACH(name, __VA_ARGS__) \
47 }
48#define FOREACH_INT(name, values, ...) \
49 FOREACH_TYPE(name, int, ARGS(values), __VA_ARGS__)
50#define FOREACH_DBLE(name, values, ...) \
51 FOREACH_TYPE(name, double, ARGS(values), __VA_ARGS__)
52#define FOREACH_BOOL(name, ...) FOREACH_INT(name, ARGS(0, 1), __VA_ARGS__)
53#define FOREACH_STRING(name, values, ...) \
54 FOREACH_TYPE(name, ARGS(char const *), ARGS(values), __VA_ARGS__)
55#define FOREACH_STRUCT(name, struct_name, values, ...) \
56 FOREACH_TYPE(name, ARGS(struct struct_name), ARGS(values), __VA_ARGS__)
57#define _CHECK_STACKS(interp_name, config) \
58 { \
59 int config_idx; \
60 struct yac_interp_stack_config * a = yac_interp_stack_config_new(); \
61 struct yac_interp_stack_config * b = yac_interp_stack_config_new(); \
62 config_idx = 0, yac_interp_stack_config_add_ ## interp_name ( a, config ); \
63 config_idx = 1, yac_interp_stack_config_add_ ## interp_name ( b, config ); \
64 utest_check_compare_stacks(a, b, configs_differ); \
65 }
66#define _CONFIG_ARGS1(arg_name) arg_name[arg_name ## _idx[config_idx]]
67#define _CONFIG_ARGS2(arg_name, ...) \
68 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS1(__VA_ARGS__)
69#define _CONFIG_ARGS3(arg_name, ...) \
70 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS2(__VA_ARGS__)
71#define _CONFIG_ARGS4(arg_name, ...) \
72 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS3(__VA_ARGS__)
73#define _CONFIG_ARGS5(arg_name, ...) \
74 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS4(__VA_ARGS__)
75#define _CONFIG_ARGS6(arg_name, ...) \
76 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS5(__VA_ARGS__)
77#define _CONFIG_ARGS7(arg_name, ...) \
78 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS6(__VA_ARGS__)
79#define _CONFIG_ARGS8(arg_name, ...) \
80 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS7(__VA_ARGS__)
81#define _CONFIG_ARGS9(arg_name, ...) \
82 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS8(__VA_ARGS__)
83#define _CONFIG_ARGS10(arg_name, ...) \
84 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS9(__VA_ARGS__)
85#define _CONFIG_ARGS11(arg_name, ...) \
86 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS10(__VA_ARGS__)
87#define _CONFIG_ARGS12(arg_name, ...) \
88 _CONFIG_ARGS1(arg_name), _CONFIG_ARGS11(__VA_ARGS__)
89#define CHECK_STACKS(interp_name, ... ) \
90 _CHECK_STACKS(interp_name, \
91 EXPAND(_GET_NTH_ARG(__VA_ARGS__, _CONFIG_ARGS12, \
92 _CONFIG_ARGS11, \
93 _CONFIG_ARGS10, \
94 _CONFIG_ARGS9, \
95 _CONFIG_ARGS8, \
96 _CONFIG_ARGS7, \
97 _CONFIG_ARGS6, \
98 _CONFIG_ARGS5, \
99 _CONFIG_ARGS4, \
100 _CONFIG_ARGS3, \
101 _CONFIG_ARGS2, \
102 _CONFIG_ARGS1)(__VA_ARGS__)))
103
104static void utest_check_compare_stacks(
106 int configs_differ);
107
108static void utest_interp_stack_config_add_spmap_(
109 struct yac_interp_stack_config * interp_stack_config,
110 double spread_distance, double max_search_distance,
112 enum yac_interp_spmap_scale_type scale_type,
113 struct yac_spmap_cell_area_config * src_cell_area_config,
114 struct yac_spmap_cell_area_config * tgt_cell_area_config);
115
116#define yac_interp_stack_config_add_spmap_ utest_interp_stack_config_add_spmap_
117
118int main (void) {
119
120 MPI_Init(NULL, NULL);
121 xt_initialize(MPI_COMM_WORLD);
122
123 int configs_differ = 0;
124
125 { // stack with different sizes
131 utest_check_compare_stacks(a, b, 1);
132 }
133
134 { // compare empty config
137 utest_check_compare_stacks(a, b, 0);
138 }
139
140 // compare average config
142 interp_avg_weight_type,
145 partial_coverage,
146 CHECK_STACKS(average, interp_avg_weight_type, partial_coverage)))
147
148 // compare ncc config
150 interp_ncc_weight_type,
153 partial_coverage,
154 CHECK_STACKS(ncc, interp_ncc_weight_type, partial_coverage)))
155
156 // compare nnn config
157 // for YAC_INTERP_NNN_AVG, YAC_INTERP_NNN_DIST, and YAC_INTERP_NNN_ZERO
158 // the scale parameter is being ignored
160 interp_nnn_weight_type,
163 counts, ARGS(1,3,9),
165 max_search_distance, ARGS(0.0, M_PI_2),
167 scales, -1.0,
169 nnn, interp_nnn_weight_type, counts,
170 max_search_distance, scales)))))
171
172 // compare nnn config
173 // for YAC_INTERP_NNN_GAUSS and YAC_INTERP_NNN_RBF the scale
174 // parameter is being interpreted
176 interp_nnn_weight_type,
179 counts, ARGS(1,3,9),
181 max_search_distance, ARGS(0.0, M_PI_2),
183 scales, ARGS(0.5, 1.0),
185 nnn, interp_nnn_weight_type, counts,
186 max_search_distance, scales)))))
187
188 // compare dnn config
189 // for YAC_INTERP_DNN_AVG and YAC_INTERP_DNN_DIST
190 // the scale parameter is being ignored
192 interp_dnn_weight_type,
195 interp_dnn_search_distance_type,
198 search_distances, ARGS(0.0, M_PI_2),
200 scales, -1.0,
202 dnn, interp_dnn_weight_type, interp_dnn_search_distance_type,
203 search_distances, scales)))))
204
205 // compare dnn config
206 // for YAC_INTERP_DNN_GAUSS and YAC_INTERP_DNN_RBF the scale
207 // parameter is being interpreted
209 interp_dnn_weight_type,
212 interp_dnn_search_distance_type,
215 search_distances, ARGS(0.0, M_PI_2),
217 scales, ARGS(0.5, 1.0),
219 dnn, interp_dnn_weight_type, interp_dnn_search_distance_type,
220 search_distances, scales)))))
221
222 // compare conservative config
224 order, ARGS(1,2),
226 enforced_conserv,
228 partial_coverage,
230 interp_method_conserv_normalisation,
232 CHECK_STACKS(conservative,
233 order, enforced_conserv, partial_coverage,
234 interp_method_conserv_normalisation)))))
235
236 // compare source point mapping
237 {
238 struct yac_spmap_cell_area_config * cell_area_configs[] = {
241 yac_spmap_cell_area_config_file_new("area.nc", "cell_area", 0),
242 yac_spmap_cell_area_config_file_new("area.nc_", "cell_area", 0),
243 yac_spmap_cell_area_config_file_new("area.nc", "cell_area_", 0),
244 yac_spmap_cell_area_config_file_new("area.nc", "cell_area", 1),
245 yac_spmap_cell_area_config_file_new("area.nc_", "cell_area_", 1),
246 };
247 enum {
248 NUM_CELL_AREA_CONFIGS =
249 sizeof(cell_area_configs) / sizeof(cell_area_configs[0])};
250
252 src_cell_area_config, ARGS(struct yac_spmap_cell_area_config *),
253 ARGS(
254 cell_area_configs[0], cell_area_configs[1], cell_area_configs[2],
255 cell_area_configs[3], cell_area_configs[4], cell_area_configs[5],
256 cell_area_configs[6]),
258 tgt_cell_area_config, ARGS(struct yac_spmap_cell_area_config *),
259 ARGS(
260 cell_area_configs[0], cell_area_configs[1], cell_area_configs[2],
261 cell_area_configs[3], cell_area_configs[4], cell_area_configs[5],
262 cell_area_configs[6]),
264 spread_distance, ARGS(0.0, 0.1),
266 max_search_distance, ARGS(0.0, 0.4),
268 interp_spmap_weight_type,
271 interp_spmap_scale_type,
272 ARGS(
275 CHECK_STACKS(spmap_,
276 spread_distance, max_search_distance,
277 interp_spmap_weight_type, interp_spmap_scale_type,
278 src_cell_area_config, tgt_cell_area_config)))))))
279
280 for (size_t i = 0; i < NUM_CELL_AREA_CONFIGS; ++i)
281 yac_spmap_cell_area_config_delete(cell_area_configs[i]);
282 }
283
284 // compare source point mapping extended
285 {
286 struct yac_spmap_scale_config * scale_config_custom =
288 struct yac_interp_spmap_config * default_configs[] = {
291 1.0,
297 1.0,
309 scale_config_custom),
310 };
311 enum {
312 NUM_DEFAULT_CONFIGS =
313 sizeof(default_configs)/sizeof(default_configs[0])};
314
315 struct yac_point_selection * bnd_point_selection_a =
317 struct yac_point_selection * bnd_point_selection_b =
319 struct yac_interp_spmap_config * spmap_config_custom =
321 1.0,
325
326 struct yac_spmap_overwrite_config *** overwrite_configs =
327 (struct yac_spmap_overwrite_config **[])
328 {NULL,
329 (struct yac_spmap_overwrite_config *[]) {
330 yac_spmap_overwrite_config_new(bnd_point_selection_a, NULL),
331 NULL},
332 (struct yac_spmap_overwrite_config *[]) {
333 yac_spmap_overwrite_config_new(bnd_point_selection_b, NULL),
334 NULL},
335 (struct yac_spmap_overwrite_config *[]) {
337 bnd_point_selection_b, spmap_config_custom),
338 NULL},
339 (struct yac_spmap_overwrite_config *[]) {
341 bnd_point_selection_a, NULL),
343 bnd_point_selection_b, NULL),
344 NULL},
345 (struct yac_spmap_overwrite_config *[]) {
346 yac_spmap_overwrite_config_new(bnd_point_selection_a, NULL),
348 bnd_point_selection_b, spmap_config_custom),
349 NULL}};
350 enum {NUM_OVERWRITE_CONFIGS = 6};
351
353 default_config, ARGS(struct yac_interp_spmap_config *),
354 ARGS(
355 default_configs[0], default_configs[1],
356 default_configs[2], default_configs[3]),
358 overwrite_config, ARGS(struct yac_spmap_overwrite_config **),
359 ARGS(
360 overwrite_configs[0], overwrite_configs[1], overwrite_configs[2],
361 overwrite_configs[3], overwrite_configs[4], overwrite_configs[5]),
362 CHECK_STACKS(spmap_ext, default_config, overwrite_config)))
363
364 for (size_t i = 0; i < NUM_OVERWRITE_CONFIGS; ++i)
365 for (size_t j = 0;
366 (overwrite_configs[i] != NULL) && (overwrite_configs[i][j] != NULL);
367 ++j)
368 yac_spmap_overwrite_config_delete(overwrite_configs[i][j]);
369 yac_interp_spmap_config_delete(spmap_config_custom);
370 yac_point_selection_delete(bnd_point_selection_a);
371 yac_point_selection_delete(bnd_point_selection_b);
372 for (size_t i = 0; i < NUM_DEFAULT_CONFIGS; ++i)
373 yac_interp_spmap_config_delete(default_configs[i]);
374 yac_spmap_scale_config_delete(scale_config_custom);
375 }
376
377 { // round-trip test for non-empty spmap overwrite list
378
379 struct yac_point_selection * point_sel_a =
381 struct yac_point_selection * point_sel_b =
383
384 struct yac_interp_spmap_config * overwrite_cfg_a =
387 struct yac_interp_spmap_config * overwrite_cfg_b =
390
391 struct yac_spmap_overwrite_config * overwrite_configs[] = {
392 yac_spmap_overwrite_config_new(point_sel_a, overwrite_cfg_a),
393 yac_spmap_overwrite_config_new(point_sel_b, overwrite_cfg_b),
394 NULL,
395 };
396
397 struct yac_interp_spmap_config * default_cfg =
400
403 send_stack, default_cfg, overwrite_configs);
404
405 // verify readback before packing
406 {
407 union yac_interp_stack_config_entry const * entry =
409 struct yac_interp_spmap_config const * default_cfg_read = NULL;
410 struct yac_spmap_overwrite_config const ** overwrite_cfgs_read = NULL;
412 entry, &default_cfg_read, &overwrite_cfgs_read);
413
414 if (yac_interp_spmap_config_compare(default_cfg_read, default_cfg) != 0)
415 PUT_ERR("ERROR: spmap default config readback mismatch");
416 if (overwrite_cfgs_read == NULL || overwrite_cfgs_read[0] == NULL ||
417 overwrite_cfgs_read[1] == NULL || overwrite_cfgs_read[2] != NULL)
418 PUT_ERR("ERROR: spmap overwrite list readback size mismatch");
420 overwrite_cfgs_read[0], overwrite_configs[0]) != 0)
421 PUT_ERR("ERROR: spmap overwrite[0] readback mismatch");
423 overwrite_cfgs_read[1], overwrite_configs[1]) != 0)
424 PUT_ERR("ERROR: spmap overwrite[1] readback mismatch");
425 }
426
427 // verify pack/unpack round-trip
428 size_t pack_size =
429 yac_interp_stack_config_get_pack_size(send_stack, MPI_COMM_SELF);
430 int mpi_pack_size = (int)pack_size;
431 void * sendbuf = malloc(mpi_pack_size);
432 void * recvbuf = malloc(mpi_pack_size);
433 int pos = 0;
435 send_stack, sendbuf, mpi_pack_size, &pos, MPI_COMM_SELF);
436 MPI_Sendrecv(
437 sendbuf, mpi_pack_size, MPI_PACKED, 0, 0,
438 recvbuf, mpi_pack_size, MPI_PACKED, 0, 0,
439 MPI_COMM_SELF, MPI_STATUS_IGNORE);
440 int rpos = 0;
441 struct yac_interp_stack_config * recv_stack =
443 recvbuf, mpi_pack_size, &rpos, MPI_COMM_SELF);
444
445 if (yac_interp_stack_config_compare(send_stack, recv_stack) != 0)
446 PUT_ERR("ERROR: spmap stack pack/unpack compare mismatch");
447
448 {
449 union yac_interp_stack_config_entry const * entry =
451 struct yac_interp_spmap_config const * default_cfg_read = NULL;
452 struct yac_spmap_overwrite_config const ** overwrite_cfgs_read = NULL;
454 entry, &default_cfg_read, &overwrite_cfgs_read);
455
456 if (yac_interp_spmap_config_compare(default_cfg_read, default_cfg) != 0)
457 PUT_ERR("ERROR: unpacked spmap default config mismatch");
458 if (overwrite_cfgs_read == NULL || overwrite_cfgs_read[0] == NULL ||
459 overwrite_cfgs_read[1] == NULL || overwrite_cfgs_read[2] != NULL)
460 PUT_ERR("ERROR: unpacked spmap overwrite list size mismatch");
462 overwrite_cfgs_read[0], overwrite_configs[0]) != 0)
463 PUT_ERR("ERROR: unpacked spmap overwrite[0] mismatch");
465 overwrite_cfgs_read[1], overwrite_configs[1]) != 0)
466 PUT_ERR("ERROR: unpacked spmap overwrite[1] mismatch");
467 }
468
469 free(sendbuf);
470 free(recvbuf);
474 yac_spmap_overwrite_config_delete(overwrite_configs[0]);
475 yac_spmap_overwrite_config_delete(overwrite_configs[1]);
476 yac_interp_spmap_config_delete(overwrite_cfg_a);
477 yac_interp_spmap_config_delete(overwrite_cfg_b);
478 yac_point_selection_delete(point_sel_a);
479 yac_point_selection_delete(point_sel_b);
480 }
481
482 // compare user file
484 filename, ARGS(
485 "test_interp_stack_config_file_a.nc",
486 "test_interp_stack_config_file_b.nc"),
488 interp_file_on_missing_file,
491 interp_file_on_success,
494 user_file, filename, interp_file_on_missing_file,
495 interp_file_on_success))))
496
497 // compare fixed
499 fixed_value, ARGS(-1.0, 0.0, 1.0, NAN),
501
502 // compare check
504 constructor_key, ARGS(NULL, "constructor_a", "constructor_b"),
506 do_search_key, ARGS(NULL, "do_search_key_a", "do_search_key_b"),
507 CHECK_STACKS(check, constructor_key, do_search_key)))
508
509 // compare creep
511 creep_distance, ARGS(-1, 0, 1),
512 CHECK_STACKS(creep, creep_distance))
513
514 // compare user callback
516 compute_weights_key, ARGS("compute_weights_a", "compute_weights_b"),
517 CHECK_STACKS(user_callback, compute_weights_key))
518
519 { // getter: average
522
523 if (yac_interp_stack_config_get_size(interp_stack) != 1)
524 PUT_ERR("ERROR: unexpected stack size in average getter test");
525
526 union yac_interp_stack_config_entry const * entry =
527 yac_interp_stack_config_get_entry(interp_stack, 0);
529 PUT_ERR("ERROR: invalid interpolation type in average getter test");
530
532 int partial_coverage = 0;
534 entry, &reduction_type, &partial_coverage);
535 if ((reduction_type != YAC_INTERP_AVG_BARY) || (partial_coverage != 1))
536 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_average");
537
538 yac_interp_stack_config_delete(interp_stack);
539 }
540
541 { // getter: ncc
544
545 if (yac_interp_stack_config_get_size(interp_stack) != 1)
546 PUT_ERR("ERROR: unexpected stack size in ncc getter test");
547
548 union yac_interp_stack_config_entry const * entry =
549 yac_interp_stack_config_get_entry(interp_stack, 0);
552 PUT_ERR("ERROR: invalid interpolation type in ncc getter test");
553
555 int partial_coverage = 1;
556 yac_interp_stack_config_entry_get_ncc(entry, &type, &partial_coverage);
557 if ((type != YAC_INTERP_NCC_DIST) || (partial_coverage != 0))
558 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_ncc");
559
560 yac_interp_stack_config_delete(interp_stack);
561 }
562
563 { // getter: dnn avg
566 interp_stack, YAC_INTERP_DNN_WEIGHT_AVG,
568
569 if (yac_interp_stack_config_get_size(interp_stack) != 1)
570 PUT_ERR("ERROR: unexpected stack size in dnn avg getter test");
571
572 union yac_interp_stack_config_entry const * entry =
573 yac_interp_stack_config_get_entry(interp_stack, 0);
576 PUT_ERR("ERROR: invalid interpolation type in dnn avg getter test");
577
579 enum yac_interp_dnn_search_distance_type search_distance_type =
581 double search_distance = -1.0;
582 double scale = -1.0;
584 entry, &type, &search_distance_type, &search_distance, &scale);
586 (search_distance_type != YAC_INTERP_DNN_SEARCH_DISTANCE_FIXED) ||
587 (fabs(search_distance - 0.11) > 1e-12) ||
588 (fabs(scale - YAC_INTERP_DNN_DUMMY_SCALE) > 1e-12))
589 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_dnn (avg)");
590
591 yac_interp_stack_config_delete(interp_stack);
592 }
593
594 { // getter: dnn dist
597 interp_stack, YAC_INTERP_DNN_WEIGHT_DIST,
599
600 if (yac_interp_stack_config_get_size(interp_stack) != 1)
601 PUT_ERR("ERROR: unexpected stack size in dnn dist getter test");
602
603 union yac_interp_stack_config_entry const * entry =
604 yac_interp_stack_config_get_entry(interp_stack, 0);
607 PUT_ERR("ERROR: invalid interpolation type in dnn dist getter test");
608
610 enum yac_interp_dnn_search_distance_type search_distance_type =
612 double search_distance = -1.0;
613 double scale = -1.0;
615 entry, &type, &search_distance_type, &search_distance, &scale);
617 (search_distance_type != YAC_INTERP_DNN_SEARCH_DISTANCE_CELL_AREA) ||
618 (fabs(search_distance - 0.12) > 1e-12) ||
619 (fabs(scale - YAC_INTERP_DNN_DUMMY_SCALE) > 1e-12))
620 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_dnn (dist)");
621
622 yac_interp_stack_config_delete(interp_stack);
623 }
624
625 { // getter: dnn rbf
628 interp_stack, YAC_INTERP_DNN_WEIGHT_RBF,
630
631 if (yac_interp_stack_config_get_size(interp_stack) != 1)
632 PUT_ERR("ERROR: unexpected stack size in dnn rbf getter test");
633
634 union yac_interp_stack_config_entry const * entry =
635 yac_interp_stack_config_get_entry(interp_stack, 0);
638 PUT_ERR("ERROR: invalid interpolation type in dnn rbf getter test");
639
641 enum yac_interp_dnn_search_distance_type search_distance_type =
643 double search_distance = -1.0;
644 double scale = -1.0;
646 entry, &type, &search_distance_type, &search_distance, &scale);
648 (search_distance_type != YAC_INTERP_DNN_SEARCH_DISTANCE_FIXED) ||
649 (fabs(search_distance - 0.13) > 1e-12) ||
650 (fabs(scale - 0.91) > 1e-12))
651 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_dnn (rbf)");
652
653 yac_interp_stack_config_delete(interp_stack);
654 }
655
656 { // getter: dnn gauss
659 interp_stack, YAC_INTERP_DNN_WEIGHT_GAUSS,
661
662 if (yac_interp_stack_config_get_size(interp_stack) != 1)
663 PUT_ERR("ERROR: unexpected stack size in dnn gauss getter test");
664
665 union yac_interp_stack_config_entry const * entry =
666 yac_interp_stack_config_get_entry(interp_stack, 0);
669 PUT_ERR("ERROR: invalid interpolation type in dnn gauss getter test");
670
672 enum yac_interp_dnn_search_distance_type search_distance_type =
674 double search_distance = -1.0;
675 double scale = -1.0;
677 entry, &type, &search_distance_type, &search_distance, &scale);
679 (search_distance_type != YAC_INTERP_DNN_SEARCH_DISTANCE_CELL_AREA) ||
680 (fabs(search_distance - 0.14) > 1e-12) ||
681 (fabs(scale - 0.92) > 1e-12))
682 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_dnn (gauss)");
683
684 yac_interp_stack_config_delete(interp_stack);
685 }
686
687 { // getter: nnn gauss
689 yac_interp_stack_config_add_nnn(interp_stack, YAC_INTERP_NNN_GAUSS, 5, 0.21, 1.31);
690
691 if (yac_interp_stack_config_get_size(interp_stack) != 1)
692 PUT_ERR("ERROR: unexpected stack size in nnn getter test");
693
694 union yac_interp_stack_config_entry const * entry =
695 yac_interp_stack_config_get_entry(interp_stack, 0);
697 PUT_ERR("ERROR: invalid interpolation type in nnn getter test");
698
700 size_t n = 0;
701 double max_search_distance = 0.0;
702 double scale = 0.0;
704 entry, &type, &n, &max_search_distance, &scale);
705 if ((type != YAC_INTERP_NNN_GAUSS) || (n != 5) ||
706 (fabs(max_search_distance - 0.21) > 1e-12) ||
707 (fabs(scale - 1.31) > 1e-12))
708 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_nnn");
709
710 yac_interp_stack_config_delete(interp_stack);
711 }
712
713 { // getter: rbf
715 yac_interp_stack_config_add_rbf(interp_stack, 6, 0.22, 1.32);
716
717 if (yac_interp_stack_config_get_size(interp_stack) != 1)
718 PUT_ERR("ERROR: unexpected stack size in rbf getter test");
719
720 union yac_interp_stack_config_entry const * entry =
721 yac_interp_stack_config_get_entry(interp_stack, 0);
724 PUT_ERR("ERROR: invalid interpolation type in rbf getter test");
725
727 size_t n = 0;
728 double max_search_distance = 0.0;
729 double scale = 0.0;
731 entry, &type, &n, &max_search_distance, &scale);
732 if ((type != YAC_INTERP_NNN_RBF) || (n != 6) ||
733 (fabs(max_search_distance - 0.22) > 1e-12) ||
734 (fabs(scale - 1.32) > 1e-12))
735 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_nnn (rbf)");
736
737 n = 0;
738 max_search_distance = 0.0;
739 scale = 0.0;
740 yac_interp_stack_config_entry_get_rbf(entry, &n, &max_search_distance, &scale);
741 if ((n != 6) || (fabs(max_search_distance - 0.22) > 1e-12) ||
742 (fabs(scale - 1.32) > 1e-12))
743 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_rbf");
744
745 yac_interp_stack_config_delete(interp_stack);
746 }
747
748 { // getter: conservative
751 interp_stack, 2, 1, 0, YAC_INTERP_CONSERV_FRACAREA);
752
753 if (yac_interp_stack_config_get_size(interp_stack) != 1)
754 PUT_ERR("ERROR: unexpected stack size in conservative getter test");
755
756 union yac_interp_stack_config_entry const * entry =
757 yac_interp_stack_config_get_entry(interp_stack, 0);
759 PUT_ERR("ERROR: invalid interpolation type in conservative getter test");
760
761 int order = -1;
762 int enforced_conserv = -1;
763 int partial_coverage = -1;
764 enum yac_interp_method_conserv_normalisation normalisation =
767 entry, &order, &enforced_conserv, &partial_coverage, &normalisation);
768 if ((order != 2) || (enforced_conserv != 1) || (partial_coverage != 0) ||
769 (normalisation != YAC_INTERP_CONSERV_FRACAREA))
770 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_conservative");
771
772 yac_interp_stack_config_delete(interp_stack);
773 }
774
775 { // getter: user file
778 interp_stack, "test_file.nc",
780
781 if (yac_interp_stack_config_get_size(interp_stack) != 1)
782 PUT_ERR("ERROR: unexpected stack size in user file getter test");
783
784 union yac_interp_stack_config_entry const * entry =
785 yac_interp_stack_config_get_entry(interp_stack, 0);
787 PUT_ERR("ERROR: invalid interpolation type in user file getter test");
788
789 char const * filename = NULL;
790 enum yac_interp_file_on_missing_file on_missing_file =
794 entry, &filename, &on_missing_file, &on_success);
795 if ((filename == NULL) || strcmp(filename, "test_file.nc") ||
796 (on_missing_file != YAC_INTERP_FILE_MISSING_CONT) ||
797 (on_success != YAC_INTERP_FILE_SUCCESS_STOP))
798 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_user_file");
799 free((void*)filename);
800
801 yac_interp_stack_config_delete(interp_stack);
802 }
803
804 { // getter: fixed
806 yac_interp_stack_config_add_fixed(interp_stack, 2.5);
807
808 if (yac_interp_stack_config_get_size(interp_stack) != 1)
809 PUT_ERR("ERROR: unexpected stack size in fixed getter test");
810
811 union yac_interp_stack_config_entry const * entry =
812 yac_interp_stack_config_get_entry(interp_stack, 0);
814 PUT_ERR("ERROR: invalid interpolation type in fixed getter test");
815
816 double value = -1.0;
818 if (fabs(value - 2.5) > 1e-12)
819 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_fixed");
820
821 yac_interp_stack_config_delete(interp_stack);
822 }
823
824 { // getter: check
826 yac_interp_stack_config_add_check(interp_stack, NULL, "do_search_key");
827
828 if (yac_interp_stack_config_get_size(interp_stack) != 1)
829 PUT_ERR("ERROR: unexpected stack size in check getter test");
830
831 union yac_interp_stack_config_entry const * entry =
832 yac_interp_stack_config_get_entry(interp_stack, 0);
834 PUT_ERR("ERROR: invalid interpolation type in check getter test");
835
836 char const * constructor_key = NULL;
837 char const * do_search_key = NULL;
838 yac_interp_stack_config_entry_get_check(entry, &constructor_key, &do_search_key);
839 if ((constructor_key == NULL) || strcmp(constructor_key, "") ||
840 (do_search_key == NULL) || strcmp(do_search_key, "do_search_key"))
841 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_check");
842 free((void*)constructor_key);
843 free((void*)do_search_key);
844
845 yac_interp_stack_config_delete(interp_stack);
846 }
847
848 { // getter: creep
850 yac_interp_stack_config_add_creep(interp_stack, 3);
851
852 if (yac_interp_stack_config_get_size(interp_stack) != 1)
853 PUT_ERR("ERROR: unexpected stack size in creep getter test");
854
855 union yac_interp_stack_config_entry const * entry =
856 yac_interp_stack_config_get_entry(interp_stack, 0);
858 PUT_ERR("ERROR: invalid interpolation type in creep getter test");
859
860 int creep_distance = -1;
861 yac_interp_stack_config_entry_get_creep(entry, &creep_distance);
862 if (creep_distance != 3)
863 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_creep");
864
865 yac_interp_stack_config_delete(interp_stack);
866 }
867
868 { // getter: user callback
870 yac_interp_stack_config_add_user_callback(interp_stack, "compute_weights");
871
872 if (yac_interp_stack_config_get_size(interp_stack) != 1)
873 PUT_ERR("ERROR: unexpected stack size in user callback getter test");
874
875 union yac_interp_stack_config_entry const * entry =
876 yac_interp_stack_config_get_entry(interp_stack, 0);
878 PUT_ERR("ERROR: invalid interpolation type in user callback getter test");
879
880 char const * func_compute_weights_key = NULL;
882 entry, &func_compute_weights_key);
883 if ((func_compute_weights_key == NULL) ||
884 strcmp(func_compute_weights_key, "compute_weights"))
885 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_user_callback");
886 free((void*)func_compute_weights_key);
887
888 yac_interp_stack_config_delete(interp_stack);
889 }
890
891 { // round-trip via spmap_ext getter with file-based cell area configs
892
895 interp_stack,
897 0.0, "src_area.nc", "src_cell_area", 7,
898 0.0, "tgt_area.nc", "tgt_cell_area", 9);
899
900 union yac_interp_stack_config_entry const * entry =
901 yac_interp_stack_config_get_entry(interp_stack, 0);
902 struct yac_interp_spmap_config const * default_cfg = NULL;
903 struct yac_spmap_overwrite_config const ** overwrite_cfgs = NULL;
905 entry, &default_cfg, &overwrite_cfgs);
906
907 struct yac_spmap_cell_area_config * src_cell_area_cfg =
908 yac_spmap_cell_area_config_file_new("src_area.nc", "src_cell_area", 7);
909 struct yac_spmap_cell_area_config * tgt_cell_area_cfg =
910 yac_spmap_cell_area_config_file_new("tgt_area.nc", "tgt_cell_area", 9);
911 struct yac_spmap_scale_config * ref_scale_cfg =
913 YAC_INTERP_SPMAP_FRACAREA, src_cell_area_cfg, tgt_cell_area_cfg);
914 struct yac_interp_spmap_config * ref_default_cfg =
915 yac_interp_spmap_config_new(0.15, 0.45, YAC_INTERP_SPMAP_DIST, ref_scale_cfg);
916
917 if (yac_interp_spmap_config_compare(default_cfg, ref_default_cfg) != 0)
918 PUT_ERR("ERROR: unexpected file-based default spmap config");
919 if (overwrite_cfgs != NULL)
920 PUT_ERR("ERROR: unexpected overwrite configs for file-based spmap test");
921
922 yac_interp_spmap_config_delete(ref_default_cfg);
923 yac_spmap_scale_config_delete(ref_scale_cfg);
924 yac_spmap_cell_area_config_delete(src_cell_area_cfg);
925 yac_spmap_cell_area_config_delete(tgt_cell_area_cfg);
926 yac_interp_stack_config_delete(interp_stack);
927 }
928
929 { // testing spmap interpolation generated from an interp_stack
930
931 // trivial 2x2 grid
932 double * coords = (double[]){0.0,0.1,0.2};
934 {utest_generate_basic_grid_data_reg2d(
935 coords, coords, (size_t[]){2,2},
936 (size_t[]){0,0}, (size_t[]){2,2}, 1),
937 utest_generate_basic_grid_data_reg2d(
938 coords, coords, (size_t[]){2,2},
939 (size_t[]){0,0}, (size_t[]){2,2}, 1)};
940 yac_coordinate_pointer cell_center_coords =
941 malloc(4 * sizeof(*cell_center_coords));
942 for (int i = 0, k = 0; i < 2; ++i)
943 for (int j = 0; j < 2; ++j, ++k)
944 LLtoXYZ(
945 (coords[j] + coords[j+1])*0.5, (coords[i] + coords[i+1])*0.5,
946 cell_center_coords[k]);
947
948 struct yac_basic_grid * grids[2] =
949 {yac_basic_grid_new("src_grid", grid_data[0]),
950 yac_basic_grid_new("tgt_grid", grid_data[1])};
951
952 size_t src_cell_coord_idx =
954 grids[0], YAC_LOC_CELL, cell_center_coords, 4);
955 size_t tgt_cell_coord_idx =
957 grids[1], YAC_LOC_CELL, cell_center_coords, 4);
958 free(cell_center_coords);
959
960 struct yac_dist_grid_pair * grid_pair =
961 yac_dist_grid_pair_new(grids[0], grids[1], MPI_COMM_WORLD);
962
963 struct yac_interp_field src_fields[] =
964 {{.location = YAC_LOC_CELL, .masks_idx = SIZE_MAX}};
965 size_t num_src_fields = sizeof(src_fields) / sizeof(src_fields[0]);
966 struct yac_interp_field tgt_field =
967 {.location = YAC_LOC_CELL, .masks_idx = SIZE_MAX};
968 src_fields[0].coordinates_idx = src_cell_coord_idx;
969 tgt_field.coordinates_idx = tgt_cell_coord_idx;
970
971 struct yac_interp_grid * interp_grid =
972 yac_interp_grid_new(grid_pair, "src_grid", "tgt_grid",
974
975 enum {OVERWRITE_CONFIG_COUNT = 1};
977 overwrite_configs[OVERWRITE_CONFIG_COUNT+1];
978 overwrite_configs[OVERWRITE_CONFIG_COUNT] = NULL;
979
980 {
981 struct yac_point_selection * src_point_selection =
982 yac_point_selection_bnd_circle_new(0.05, 0.05, 0.01);
983 struct yac_interp_spmap_config * spmap_config =
985 0.11,
989 overwrite_configs[0] =
990 yac_spmap_overwrite_config_new(src_point_selection, spmap_config);
991 yac_interp_spmap_config_delete(spmap_config);
992 yac_point_selection_delete(src_point_selection);
993 }
994
995 struct yac_interp_stack_config * interp_stack_config =
997
999 interp_stack_config, YAC_INTERP_SPMAP_DEFAULT_CONFIG, overwrite_configs);
1000
1001 struct interp_method ** method_stack =
1002 yac_interp_stack_config_generate(interp_stack_config);
1003
1004 yac_interp_stack_config_delete(interp_stack_config);
1005
1006 struct yac_interp_weights * weights =
1007 yac_interp_method_do_search(method_stack, interp_grid);
1008
1009 struct yac_interpolation * interpolation =
1011 weights, YAC_MAPPING_ON_SRC, 1,
1012 YAC_FRAC_MASK_NO_VALUE, 1.0, 0.0, NULL, 1, 1);
1013
1014 {
1015 double * src_field = (double[]){1.0,2.0,3.0,4.0};
1016 double ** src_fields = &src_field;
1017 double * tgt_field = (double[]){0.0,0.0,0.0,0.0};
1018 double const * ref_tgt_field =
1019 (double[]){1.0/3.0, 2.0+1.0/3.0, 3.0+1.0/3.0, 4.0};
1020
1021 yac_interpolation_execute(interpolation, &src_fields, &tgt_field);
1022
1023 for (int i = 0; i < 4; ++i)
1024 if (fabs(tgt_field[i] - ref_tgt_field[i]) > 1e-6)
1025 PUT_ERR("ERROR in yac_interp_stack_config_add_spmap_ext");
1026 }
1027
1028 yac_interpolation_delete(interpolation);
1029
1031 yac_interp_method_delete(method_stack);
1032 free(method_stack);
1033 for (size_t i = 0; i < OVERWRITE_CONFIG_COUNT; ++i)
1034 yac_spmap_overwrite_config_delete(overwrite_configs[i]);
1035 yac_interp_grid_delete(interp_grid);
1036 yac_dist_grid_pair_delete(grid_pair);
1037 yac_basic_grid_delete(grids[1]);
1038 yac_basic_grid_delete(grids[0]);
1039 }
1040
1041 xt_finalize();
1042 MPI_Finalize();
1043
1044 return TEST_EXIT_CODE;
1045}
1046
1047static void utest_check_compare_stacks_(
1048 struct yac_interp_stack_config * a, struct yac_interp_stack_config * b,
1049 int configs_differ) {
1050
1051 configs_differ = configs_differ != 0;
1052
1054 PUT_ERR("error in yac_interp_stack_config_compare (a != a)")
1057
1058 int cmp_a = yac_interp_stack_config_compare(a, b);
1059 int cmp_b = yac_interp_stack_config_compare(b, a);
1060
1061 if ((cmp_a != cmp_b) ^ configs_differ) {
1062 PUT_ERR("error in yac_interp_stack_config_compare ((a > b) == (a < b))")
1063 }
1064 if ((cmp_a != 0) ^ configs_differ) {
1065 PUT_ERR("error in yac_interp_stack_config_compare ((a > b) == 0)")
1066 }
1067 if ((cmp_b != 0) ^ configs_differ) {
1068 PUT_ERR("error in yac_interp_stack_config_compare ((a > b) == 0)")
1069 }
1070
1073}
1074
1075static void utest_check_compare_stacks(
1076 struct yac_interp_stack_config * a, struct yac_interp_stack_config * b,
1077 int configs_differ) {
1078
1079 utest_check_compare_stacks_(
1081 yac_interp_stack_config_copy(b), configs_differ);
1082 utest_check_compare_stacks_(a, b, configs_differ);
1083}
1084
1085static void utest_interp_stack_config_add_spmap_(
1086 struct yac_interp_stack_config * interp_stack_config,
1087 double spread_distance, double max_search_distance,
1089 enum yac_interp_spmap_scale_type scale_type,
1090 struct yac_spmap_cell_area_config * src_cell_area_config,
1091 struct yac_spmap_cell_area_config * tgt_cell_area_config) {
1092
1093 enum yac_interp_spmap_cell_area_provider src_cell_area_config_type =
1094 yac_spmap_cell_area_config_get_type(src_cell_area_config);
1095 double src_sphere_radius =
1096 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_YAC)?
1097 yac_spmap_cell_area_config_get_sphere_radius(src_cell_area_config):0.0;
1098 char const * src_filename =
1099 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1100 yac_spmap_cell_area_config_get_filename(src_cell_area_config):NULL;
1101 char const * src_varname =
1102 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1103 yac_spmap_cell_area_config_get_varname(src_cell_area_config):NULL;
1104 yac_int src_min_global_id =
1105 (src_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1106 yac_spmap_cell_area_config_get_min_global_id(src_cell_area_config):0;
1107
1108 enum yac_interp_spmap_cell_area_provider tgt_cell_area_config_type =
1109 yac_spmap_cell_area_config_get_type(tgt_cell_area_config);
1110 double tgt_sphere_radius =
1111 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_YAC)?
1112 yac_spmap_cell_area_config_get_sphere_radius(tgt_cell_area_config):0.0;
1113 char const * tgt_filename =
1114 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1115 yac_spmap_cell_area_config_get_filename(tgt_cell_area_config):NULL;
1116 char const * tgt_varname =
1117 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1118 yac_spmap_cell_area_config_get_varname(tgt_cell_area_config):NULL;
1119 yac_int tgt_min_global_id =
1120 (tgt_cell_area_config_type == YAC_INTERP_SPMAP_CELL_AREA_FILE)?
1121 yac_spmap_cell_area_config_get_min_global_id(tgt_cell_area_config):0;
1122
1124 interp_stack_config,
1125 spread_distance, max_search_distance, weight_type, scale_type,
1126 src_sphere_radius,
1127 src_filename,
1128 src_varname,
1129 src_min_global_id,
1130 tgt_sphere_radius,
1131 tgt_filename,
1132 tgt_varname,
1133 tgt_min_global_id);
1134
1135 // test yac_interp_stack_config_entry_get_spmap
1136 union yac_interp_stack_config_entry const * interp_stack_entry =
1138 interp_stack_config,
1139 yac_interp_stack_config_get_size(interp_stack_config) - 1);
1140 double spread_distance_;
1141 double max_search_distance_;
1142 enum yac_interp_spmap_weight_type weight_type_;
1143 enum yac_interp_spmap_scale_type scale_type_;
1144 double src_sphere_radius_;
1145 char const * src_filename_;
1146 char const * src_varname_;
1147 int src_min_global_id_;
1148 double tgt_sphere_radius_;
1149 char const * tgt_filename_;
1150 char const * tgt_varname_;
1151 int tgt_min_global_id_;
1153 interp_stack_entry,
1154 &spread_distance_, &max_search_distance_, &weight_type_, &scale_type_,
1155 &src_sphere_radius_, &src_filename_, &src_varname_, &src_min_global_id_,
1156 &tgt_sphere_radius_, &tgt_filename_, &tgt_varname_, &tgt_min_global_id_);
1157
1158 if (spread_distance_ != spread_distance)
1159 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
1160 if (max_search_distance_ != max_search_distance)
1161 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
1162 if (weight_type_ != weight_type)
1163 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
1164 if (scale_type_ != scale_type)
1165 PUT_ERR("ERROR in yac_interp_stack_config_entry_get_spmap");
1166}
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
Definition basic_grid.c:57
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:222
void yac_basic_grid_delete(struct yac_basic_grid *grid)
Definition basic_grid.c:77
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
Definition dist_grid.c:2377
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:2089
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:31
void yac_interp_method_delete(struct interp_method **method)
Delete an interpolation stack and free its resources (but not the pointer array).
struct yac_interp_weights * yac_interp_method_do_search(struct interp_method **method, struct yac_interp_grid *interp_grid)
Perform weight computation using given interpolation stack and grid.
@ YAC_N_NEAREST_NEIGHBOR
N-nearest-neighbor interpolation.
@ YAC_CREEP
Creep-fill interpolation.
@ YAC_USER_FILE
User-supplied weights from file.
@ YAC_USER_CALLBACK
@ YAC_CONSERVATIVE
Conservative remapping (area/flux conserving)
@ YAC_FIXED_VALUE
Assigns a fixed value to all targets.
@ YAC_CHECK
Diagnostic check method (for testing)
@ YAC_DISTANCE_NEAREST_NEIGHBOR
Distance-nearest-neighbor interpolation.
@ YAC_NEAREST_CORNER_CELLS
Nearest-corner-cell interpolation.
@ YAC_RADIAL_BASIS_FUNCTION
Radial basis function interpolation.
@ YAC_AVERAGE
Simple averaging (or linear) interpolation.
yac_interp_avg_weight_type
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_AVG_BARY
enum callback_type type
struct @23::@24 value
yac_interp_method_conserv_normalisation
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
yac_interp_dnn_weight_type
@ YAC_INTERP_DNN_WEIGHT_AVG
average of source points within search distance
@ YAC_INTERP_DNN_WEIGHT_DIST
distance weighted average of source points
@ YAC_INTERP_DNN_WEIGHT_GAUSS
Gauss weighted average of source points.
@ YAC_INTERP_DNN_WEIGHT_RBF
radial basis function weighted average
#define YAC_INTERP_DNN_DUMMY_SCALE
yac_interp_dnn_search_distance_type
@ YAC_INTERP_DNN_SEARCH_DISTANCE_FIXED
use a fixed search distance (in radians)
@ YAC_INTERP_DNN_SEARCH_DISTANCE_CELL_AREA
yac_interp_file_on_missing_file
@ YAC_INTERP_FILE_MISSING_CONT
continue on missing file
@ YAC_INTERP_FILE_MISSING_ERROR
abort on missing file
yac_interp_file_on_success
@ YAC_INTERP_FILE_SUCCESS_CONT
@ YAC_INTERP_FILE_SUCCESS_STOP
yac_interp_ncc_weight_type
@ YAC_INTERP_NCC_DIST
distance weighted average of n source points
@ YAC_INTERP_NCC_AVG
average of n source points
yac_interp_nnn_weight_type
@ 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)
int yac_interp_spmap_config_compare(struct yac_interp_spmap_config const *a, struct yac_interp_spmap_config const *b)
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)
int yac_spmap_overwrite_config_compare(struct yac_spmap_overwrite_config const *a, struct yac_spmap_overwrite_config const *b)
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
void yac_interp_stack_config_entry_get_creep(union yac_interp_stack_config_entry const *interp_stack_entry, int *creep_distance)
void yac_interp_stack_config_add_check(struct yac_interp_stack_config *interp_stack_config, char const *constructor_key, char const *do_search_key)
size_t yac_interp_stack_config_get_size(struct yac_interp_stack_config *interp_stack)
Get the number of interpolation methods in the stack.
int yac_interp_stack_config_compare(void const *a_, void const *b_)
Compare two interpolation stack configurations.
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)
enum yac_interpolation_list yac_interp_stack_config_entry_get_type(union yac_interp_stack_config_entry const *interp_stack_entry)
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_rbf(struct yac_interp_stack_config *interp_stack_config, size_t n, double max_search_distance, double scale)
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_add_creep(struct yac_interp_stack_config *interp_stack_config, int creep_distance)
void yac_interp_stack_config_entry_get_rbf(union yac_interp_stack_config_entry const *interp_stack_entry, size_t *n, double *max_search_distance, double *scale)
void yac_interp_stack_config_entry_get_user_file(union yac_interp_stack_config_entry const *interp_stack_entry, char const **filename, enum yac_interp_file_on_missing_file *on_missing_file, enum yac_interp_file_on_success *on_success)
void yac_interp_stack_config_add_nnn(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_nnn_weight_type type, size_t n, double max_search_distance, double scale)
void yac_interp_stack_config_entry_get_dnn(union yac_interp_stack_config_entry const *interp_stack_entry, enum yac_interp_dnn_weight_type *type, enum yac_interp_dnn_search_distance_type *search_distance_type, double *search_distance, double *scale)
void yac_interp_stack_config_entry_get_ncc(union yac_interp_stack_config_entry const *interp_stack_entry, enum yac_interp_ncc_weight_type *type, int *partial_coverage)
struct yac_interp_stack_config * yac_interp_stack_config_unpack(void *buffer, int buffer_size, int *position, MPI_Comm comm)
Unpack a stack configuration from a buffer (MPI communication).
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
Free an interpolation stack configuration object.
void yac_interp_stack_config_entry_get_user_callback(union yac_interp_stack_config_entry const *interp_stack_entry, char const **func_compute_weights_key)
struct yac_interp_stack_config * yac_interp_stack_config_copy(struct yac_interp_stack_config *interp_stack)
Create a deep copy of an interpolation stack configuration.
void yac_interp_stack_config_add_conservative(struct yac_interp_stack_config *interp_stack_config, int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
void yac_interp_stack_config_entry_get_check(union yac_interp_stack_config_entry const *interp_stack_entry, char const **constructor_key, char const **do_search_key)
struct interp_method ** yac_interp_stack_config_generate(struct yac_interp_stack_config *interp_stack)
Generate a NULL-terminated array of interpolation methods from the stack configuration.
void yac_interp_stack_config_entry_get_conservative(union yac_interp_stack_config_entry const *interp_stack_entry, int *order, int *enforced_conserv, int *partial_coverage, enum yac_interp_method_conserv_normalisation *normalisation)
void yac_interp_stack_config_add_dnn(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_dnn_weight_type type, enum yac_interp_dnn_search_distance_type search_distance_type, double search_distance, double scale)
void yac_interp_stack_config_entry_get_average(union yac_interp_stack_config_entry const *interp_stack_entry, enum yac_interp_avg_weight_type *reduction_type, int *partial_coverage)
size_t yac_interp_stack_config_get_pack_size(struct yac_interp_stack_config *interp_stack, MPI_Comm comm)
Get the size required to pack the stack configuration for MPI.
void yac_interp_stack_config_add_ncc(struct yac_interp_stack_config *interp_stack_config, enum yac_interp_ncc_weight_type weight_type, int partial_coverage)
void yac_interp_stack_config_add_user_file(struct yac_interp_stack_config *interp_stack_config, char const *filename, enum yac_interp_file_on_missing_file on_missing_file, enum yac_interp_file_on_success on_success)
void yac_interp_stack_config_entry_get_nnn(union yac_interp_stack_config_entry const *interp_stack_entry, enum yac_interp_nnn_weight_type *type, size_t *n, double *max_search_distance, double *scale)
void yac_interp_stack_config_entry_get_spmap_ext(union yac_interp_stack_config_entry const *interp_stack_entry, struct yac_interp_spmap_config const **default_config, struct yac_spmap_overwrite_config const ***overwrite_configs)
void yac_interp_stack_config_add_user_callback(struct yac_interp_stack_config *interp_stack_config, char const *func_compute_weights_key)
struct yac_interp_stack_config * yac_interp_stack_config_new()
Allocate a new empty interpolation stack configuration object.
void yac_interp_stack_config_pack(struct yac_interp_stack_config *interp_stack, void *buffer, int buffer_size, int *position, MPI_Comm comm)
Pack the stack configuration into a buffer for MPI communication.
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_fixed(union yac_interp_stack_config_entry const *interp_stack_entry, double *value)
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:26
size_t num_src_fields
Definition interp_grid.c:27
struct yac_dist_grid_pair * grid_pair
Definition interp_grid.c:25
struct yac_interp_field src_fields[]
Definition interp_grid.c:28
@ error
Definition test_cxc.c:17
static double const fixed_value
#define FOREACH_TYPE(name, type, values,...)
#define FOREACH_STRING(name, values,...)
#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:15
#define PUT_ERR(string)
Definition tests.h:10
static void LLtoXYZ(double lon, double lat, double p_out[])
Definition toy_scrip.c:587
YAC_INT yac_int
Definition yac_types.h:15
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:21