YetAnotherCoupler 3.5.2
Loading...
Searching...
No Matches
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#ifdef HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <math.h>
10#include <string.h>
11
12#include "geometry.h"
13#include "yac_mpi_internal.h"
14#include "interp_stack_config.h"
15
17 struct {
20 struct {
25 struct {
30 struct {
32 int order;
34 int partial_coverage;
37 struct {
44 struct {
47 struct {
51 struct {
53 double value;
55 struct {
60 struct {
64 struct {
68 struct {
73};
74
79
102
104 struct yac_interp_stack_config * interp_stack) {
105
106 struct yac_interp_stack_config * interp_stack_copy =
107 xmalloc(1 * sizeof(*interp_stack_copy));
108 interp_stack_copy->size = interp_stack->size;
109 interp_stack_copy->config =
110 xmalloc(interp_stack_copy->size * sizeof(*(interp_stack_copy->config)));
111 for (size_t i = 0; i < interp_stack_copy->size; ++i)
113 interp_stack_copy->config + i, interp_stack->config + i);
114 return interp_stack_copy;
115}
116
117static inline void check_interpolation_type(
118 enum yac_interpolation_list type, char const * routine) {
119
121 (type == YAC_AVERAGE) ||
124 (type == YAC_CONSERVATIVE) ||
126 (type == YAC_FIXED_VALUE) ||
128 (type == YAC_USER_FILE) ||
129 (type == YAC_CHECK) ||
130 (type == YAC_CREEP) ||
131 (type == YAC_USER_CALLBACK) ||
133 (type == YAC_UNDEFINED),
134 "ERROR(%s): invalid interpolation type", routine)
135}
136
138 struct yac_spmap_cell_area_config a, struct yac_spmap_cell_area_config b) {
139
140 int ret;
141 if ((ret = ((int)(a.cell_area_provider) > (int)(b.cell_area_provider)) -
142 ((int)(a.cell_area_provider) < (int)(b.cell_area_provider))))
143 return ret;
144
145 switch (a.cell_area_provider) {
146 default:
148 return
149 ((int)(a.sphere_radius) > (int)(b.sphere_radius)) -
150 ((int)(a.sphere_radius) < (int)(b.sphere_radius));
151 }
153 if ((ret = strcmp(a.file_config.filename, b.file_config.filename)))
154 return ret;
155 if ((ret = strcmp(a.file_config.varname, b.file_config.varname)))
156 return ret;
157 return
158 ((int)(a.file_config.min_global_id) >
159 (int)(b.file_config.min_global_id)) -
160 ((int)(a.file_config.min_global_id) <
161 (int)(b.file_config.min_global_id));
162 }
163 }
164}
165
168
169 int ret;
170 if ((ret = ((int)(a.type) > (int)(b.type)) - ((int)(a.type) < (int)(b.type))))
171 return ret;
172 if ((ret = yac_spmap_cell_area_config_compare(a.src, b.src))) return ret;
173 if ((ret = yac_spmap_cell_area_config_compare(a.tgt, b.tgt))) return ret;
174 return 0;
175}
176
178 void const * a_, void const * b_) {
179
180 union yac_interp_stack_config_entry const * a =
181 (union yac_interp_stack_config_entry const *)a_;
182 union yac_interp_stack_config_entry const * b =
183 (union yac_interp_stack_config_entry const *)b_;
184
186 a->general.type, "yac_interp_stack_config_entry_compare");
188 b->general.type, "yac_interp_stack_config_entry_compare");
191 "ERROR(yac_interp_stack_config_entry_compare): "
192 "interpolation type is undefined");
193
194 if (a->general.type != b->general.type)
195 return (a->general.type > b->general.type) -
196 (a->general.type < b->general.type);
197
198 switch(a->general.type) {
199 default:
201 return 0;
202 case (YAC_AVERAGE): {
208 }
210 case (YAC_N_NEAREST_NEIGHBOR): {
211 if (a->n_nearest_neighbor.config.n !=
213 return (a->n_nearest_neighbor.config.n >
225 return (a->n_nearest_neighbor.config.type >
229 switch (a->n_nearest_neighbor.config.type) {
235 case (YAC_INTERP_NNN_RBF):
240 default:
241 return 0;
242 };
243 }
244 case (YAC_CONSERVATIVE): {
245 if (a->conservative.order !=
247 return (a->conservative.order >
248 b->conservative.order) -
249 (a->conservative.order <
253 return (a->conservative.enforced_conserv >
259 return (a->conservative.partial_coverage >
263 return (a->conservative.normalisation >
267 }
269 if (fabs(a->spmap.spread_distance -
271 return (a->spmap.spread_distance >
275 if (fabs(a->spmap.max_search_distance -
277 return (a->spmap.max_search_distance >
281 if (a->spmap.weight_type != b->spmap.weight_type)
282 return (a->spmap.weight_type >
283 b->spmap.weight_type) -
284 (a->spmap.weight_type <
285 b->spmap.weight_type);
286 return
289 }
290 case (YAC_FIXED_VALUE): {
291 return (a->fixed.value >
292 b->fixed.value) -
293 (a->fixed.value <
294 b->fixed.value);
295 }
296 case (YAC_USER_FILE): {
297 return strcmp(a->user_file.filename, b->user_file.filename);
298 }
299 case (YAC_CHECK): {
300 int ret;
301 if ((ret = strncmp(a->check.constructor_key, b->check.constructor_key,
302 sizeof(a->check.constructor_key)))) return ret;
303 return
304 strncmp(
306 sizeof(a->check.do_search_key));
307 };
308 case (YAC_CREEP): {
309 return
312 }
313 case (YAC_USER_CALLBACK): {
316 }
328 }
329 };
330}
331
332int yac_interp_stack_config_compare(void const * a_, void const * b_) {
333
334 struct yac_interp_stack_config const * a =
335 (struct yac_interp_stack_config const *)a_;
336 struct yac_interp_stack_config const * b =
337 (struct yac_interp_stack_config const *)b_;
338
339 int ret;
340 if ((ret = (a->size > b->size) - (a->size < b->size))) return ret;
341
342 size_t stack_size = a->size;
343 for (size_t method_idx = 0; method_idx < stack_size; ++method_idx)
344 if ((ret =
346 &(a->config[method_idx]), &(b->config[method_idx]))))
347 return ret;
348 return 0;
349}
350
352 struct yac_interp_stack_config * interp_stack) {
353
354 size_t interp_stack_size = interp_stack->size;
355 struct interp_method ** method_stack =
356 xmalloc((interp_stack_size + 1) * sizeof(*method_stack));
357 method_stack[interp_stack_size] = NULL;
358
359 for (size_t i = 0; i < interp_stack_size; ++i) {
360
362 interp_stack->config[i].general.type, "yac_interp_stack_config_generate");
364 interp_stack->config[i].general.type != YAC_UNDEFINED,
365 "ERROR(yac_interp_stack_config_generate): "
366 "unsupported interpolation method")
367 switch((int)(interp_stack->config[i].general.type)) {
368 default:
369 case(YAC_AVERAGE): {
371 interp_stack->config[i].average.reduction_type;
372 int partial_coverage =
373 (int)interp_stack->config[i].average.partial_coverage;
374 method_stack[i] =
375 yac_interp_method_avg_new(weight_type, partial_coverage);
376 break;
377 }
378 case(YAC_CONSERVATIVE): {
379 int order =
380 interp_stack->config[i].conservative.order;
381 int enforced_conserv =
382 interp_stack->config[i].conservative.enforced_conserv;
383 int partial_coverage =
384 interp_stack->config[i].conservative.partial_coverage;
385 enum yac_interp_method_conserv_normalisation normalisation =
386 interp_stack->config[i].conservative.normalisation;
387
388 method_stack[i] =
390 order, enforced_conserv, partial_coverage, normalisation);
391 break;
392 }
393 case(YAC_FIXED_VALUE): {
394 double fixed_value =
395 interp_stack->config[i].fixed.value;
396 method_stack[i] = yac_interp_method_fixed_new(fixed_value);
397 break;
398 }
399 case(YAC_USER_FILE): {
400 char const * weight_file_name =
401 interp_stack->config[i].user_file.filename;
402 method_stack[i] =
403 yac_interp_method_file_new(weight_file_name);
404 break;
405 }
406 case(YAC_CHECK): {
407 func_constructor constructor_callback;
408 void * constructor_user_data;
410 void * do_search_user_data;
411
413 interp_stack->config[i].check.constructor_key,
414 &constructor_callback, &constructor_user_data);
416 interp_stack->config[i].check.do_search_key,
417 &do_search_callback, &do_search_user_data);
418
419 method_stack[i] =
421 constructor_callback, constructor_user_data,
422 do_search_callback, do_search_user_data);
423 break;
424 }
425 case (YAC_N_NEAREST_NEIGHBOR): {
426 method_stack[i] =
428 interp_stack->config[i].
429 n_nearest_neighbor.config);
430 break;
431 }
432 case (YAC_BERNSTEIN_BEZIER): {
433 method_stack[i] =
435 break;
436 }
438 method_stack[i] =
440 interp_stack->config[i].
441 radial_basis_function.config);
442 break;
443 }
445 method_stack[i] =
447 interp_stack->config[i].spmap.spread_distance,
448 interp_stack->config[i].spmap.max_search_distance,
449 interp_stack->config[i].spmap.weight_type,
450 interp_stack->config[i].spmap.scale_config);
451 break;
452 }
453 case (YAC_CREEP): {
454 method_stack[i] =
456 interp_stack->config[i].creep.creep_distance);
457 break;
458 }
459 case(YAC_USER_CALLBACK): {
460 yac_func_compute_weights compute_weights_callback;
461 void * user_data;
464 &compute_weights_callback, &user_data);
465
466 method_stack[i] =
467 yac_interp_method_callback_new(compute_weights_callback, user_data);
468 break;
469 }
471 method_stack[i] =
473 interp_stack->config[i].nearest_corner_cells.weight_type,
475 break;
476 }
477 };
478 }
479
480 return method_stack;
481}
482
484 char const * string, MPI_Comm comm) {
485
486 int strlen_pack_size, string_pack_size;
487 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &strlen_pack_size), comm);
488
490 string != NULL, "ERROR(yac_interp_stack_config_get_string_pack_size): "
491 "string is NULL");
492
494 MPI_Pack_size(
495 (int)(strlen(string)), MPI_CHAR, comm, &string_pack_size), comm);
496
497 return (size_t)strlen_pack_size + (size_t)string_pack_size;
498}
499
501 struct yac_spmap_cell_area_config cell_area_config, MPI_Comm comm) {
502
503 int int_pack_size, dbl_pack_size;
504 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
505 yac_mpi_call(MPI_Pack_size(1, MPI_DOUBLE, comm, &dbl_pack_size), comm);
506
507 size_t pack_size = (size_t)int_pack_size; // cell_area_provider
508
509 switch (cell_area_config.cell_area_provider) {
510 default:
512 pack_size += (size_t)dbl_pack_size; // sphere_radius
513 break;
514 }
516 pack_size +=
518 cell_area_config.file_config.filename, comm) + // filename
520 cell_area_config.file_config.varname, comm) + // varname
521 int_pack_size; // min_global_id
522 break;
523 }
524 }
525
526 return pack_size;
527}
528
530 union yac_interp_stack_config_entry * entry, MPI_Comm comm) {
531
532 int int_pack_size, dbl_pack_size;
533 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &int_pack_size), comm);
534 yac_mpi_call(MPI_Pack_size(1, MPI_DOUBLE, comm, &dbl_pack_size), comm);
535
537 entry->general.type,
538 "yac_interp_stack_config_get_entry_pack_size");
540 entry->general.type != YAC_UNDEFINED,
541 "ERROR(yac_interp_stack_config_get_entry_pack_size): "
542 "invalid interpolation type")
543 switch (entry->general.type) {
544 default:
545 case (YAC_AVERAGE):
546 return (size_t)int_pack_size + // type
547 (size_t)int_pack_size + // reduction_type
548 (size_t)int_pack_size; // partial_coverage
551 return (size_t)int_pack_size + // type
552 (size_t)int_pack_size + // weight_type
553 (size_t)int_pack_size + // n
554 (size_t)dbl_pack_size + // max_search_distance
555 (size_t)dbl_pack_size; // scale
556 case (YAC_CONSERVATIVE):
557 return (size_t)int_pack_size + // type
558 (size_t)int_pack_size + // order
559 (size_t)int_pack_size + // enforced_conserv
560 (size_t)int_pack_size + // partial_coverage
561 (size_t)int_pack_size; // normalisation
563 return (size_t)int_pack_size + // type
564 (size_t)dbl_pack_size + // spread_distance
565 (size_t)dbl_pack_size + // max_search_distance
566 (size_t)int_pack_size + // weight_type
567 (size_t)int_pack_size + // scale_type
569 entry->spmap.scale_config.src, comm) +
571 entry->spmap.scale_config.tgt, comm);
572 case (YAC_FIXED_VALUE):
573 return (size_t)int_pack_size + // type
574 (size_t)dbl_pack_size; // value
576 return (size_t)int_pack_size; // type
577 case (YAC_USER_FILE):
578 return (size_t)int_pack_size + // type
580 entry->user_file.filename, comm);
581 case (YAC_CHECK):
582 return (size_t)int_pack_size + // type
584 entry->check.constructor_key, comm) + // constructor_key
586 entry->check.do_search_key, comm); // do_search_key
587 case (YAC_CREEP):
588 return (size_t)int_pack_size + // type
589 (size_t)int_pack_size; // creep_distance
590 case (YAC_USER_CALLBACK):
591 return (size_t)int_pack_size + // type
594 // func_compute_weights_key
596 return (size_t)int_pack_size + // type
597 (size_t)int_pack_size + // weight_type
598 (size_t)int_pack_size; // partial_coverage
599 }
600}
601
603 struct yac_interp_stack_config * interp_stack, MPI_Comm comm) {
604
605 int size_pack_size;
606 yac_mpi_call(MPI_Pack_size(1, MPI_INT, comm, &size_pack_size), comm);
607
608 size_t config_pack_size = 0;
609
610 for (size_t i = 0; i < interp_stack->size; ++i)
611 config_pack_size +=
613 interp_stack->config + i, comm);
614
615 return (size_t)size_pack_size + config_pack_size;
616}
617
619 char const * string, void * buffer, int buffer_size, int * position,
620 MPI_Comm comm) {
621
622 size_t len = (string == NULL)?0:strlen(string);
623
625 len <= INT_MAX, "ERROR(yac_interp_stack_config_pack_string): string too long")
626
627 int len_int = (int)len;
628
630 MPI_Pack(
631 &len_int, 1, MPI_INT, buffer, buffer_size, position, comm), comm);
632
633 if (len > 0)
635 MPI_Pack(
636 string, len_int, MPI_CHAR, buffer, buffer_size, position, comm),
637 comm);
638}
639
641 struct yac_spmap_cell_area_config cell_area_config,
642 void * buffer, int buffer_size, int * position, MPI_Comm comm) {
643
644 int cell_area_provider = (int)(cell_area_config.cell_area_provider);
646 MPI_Pack(
647 &cell_area_provider, 1, MPI_INT, buffer, buffer_size, position, comm), comm);
648
649 switch (cell_area_config.cell_area_provider) {
650 default:
653 MPI_Pack(
654 &(cell_area_config.sphere_radius), 1, MPI_DOUBLE,
655 buffer, buffer_size, position, comm), comm);
656 break;
657 }
660 cell_area_config.file_config.filename,
661 buffer, buffer_size, position, comm);
663 cell_area_config.file_config.varname,
664 buffer, buffer_size, position, comm);
666 (cell_area_config.file_config.min_global_id >= -INT_MAX) &&
667 (cell_area_config.file_config.min_global_id <= INT_MAX),
668 "ERRROR(yac_spmap_cell_area_config_pack): invalid minimum global id");
669 int min_global_id = (int)(cell_area_config.file_config.min_global_id);
671 MPI_Pack(
672 &min_global_id, 1, MPI_INT, buffer, buffer_size, position, comm),
673 comm);
674 break;
675 }
676 }
677}
678
680 union yac_interp_stack_config_entry * entry,
681 void * buffer, int buffer_size, int * position, MPI_Comm comm) {
682
683 int type = (int)(entry->general.type);
685 MPI_Pack(&type, 1, MPI_INT, buffer, buffer_size, position, comm), comm);
686
688 entry->general.type,
689 "yac_interp_stack_config_pack_entry");
691 entry->general.type != YAC_UNDEFINED,
692 "ERROR(yac_interp_stack_config_pack_entry): "
693 "invalid interpolation type")
694 switch (entry->general.type) {
695 default:
696 case (YAC_AVERAGE): {
697 int reduction_type = (int)(entry->average.reduction_type);
699 MPI_Pack(
700 &reduction_type, 1, MPI_INT, buffer, buffer_size, position, comm),
701 comm);
703 MPI_Pack(
704 &(entry->average.partial_coverage), 1, MPI_INT,
705 buffer, buffer_size, position, comm), comm);
706 break;
707 }
709 case (YAC_N_NEAREST_NEIGHBOR): {
711 entry->n_nearest_neighbor.config.n <= INT_MAX,
712 "ERROR(yac_interp_stack_config_pack_entry): "
713 "n_nearest_neighbor.config.n bigger than INT_MAX")
714 int type = (int)(entry->n_nearest_neighbor.config.type);
716 MPI_Pack(
717 &type, 1, MPI_INT, buffer, buffer_size, position, comm), comm);
718 int n = (int)(entry->n_nearest_neighbor.config.n);
720 MPI_Pack(
721 &n, 1, MPI_INT, buffer, buffer_size, position, comm), comm);
723 MPI_Pack(
725 MPI_DOUBLE, buffer, buffer_size, position, comm), comm);
727 MPI_Pack(
728 &(entry->n_nearest_neighbor.config.data.rbf_scale), 1, MPI_DOUBLE,
729 buffer, buffer_size, position, comm), comm);
730 break;
731 }
732 case (YAC_CONSERVATIVE): {
734 MPI_Pack(
735 &(entry->conservative.order), 1, MPI_INT,
736 buffer, buffer_size, position, comm), comm);
738 MPI_Pack(
739 &(entry->conservative.enforced_conserv), 1, MPI_INT,
740 buffer, buffer_size, position, comm), comm);
742 MPI_Pack(
743 &(entry->conservative.partial_coverage), 1, MPI_INT,
744 buffer, buffer_size, position, comm), comm);
745 int normalisation = (int)(entry->conservative.normalisation);
747 MPI_Pack(
748 &normalisation, 1, MPI_INT, buffer, buffer_size, position, comm),
749 comm);
750 break;
751 }
754 MPI_Pack(
755 &(entry->spmap.spread_distance), 1, MPI_DOUBLE,
756 buffer, buffer_size, position, comm), comm);
758 MPI_Pack(
759 &(entry->spmap.max_search_distance), 1, MPI_DOUBLE,
760 buffer, buffer_size, position, comm), comm);
761 int weight_type = (int)(entry->spmap.weight_type);
763 MPI_Pack(
764 &weight_type, 1, MPI_INT, buffer, buffer_size, position, comm),
765 comm);
766 int scale_type = (int)(entry->spmap.scale_config.type);
768 MPI_Pack(
769 &scale_type, 1, MPI_INT, buffer, buffer_size, position, comm),
770 comm);
772 entry->spmap.scale_config.src, buffer, buffer_size, position, comm);
774 entry->spmap.scale_config.tgt, buffer, buffer_size, position, comm);
775 break;
776 }
777 case (YAC_FIXED_VALUE): {
779 MPI_Pack(
780 &(entry->fixed.value), 1, MPI_DOUBLE,
781 buffer, buffer_size, position, comm), comm);
782 break;
783 }
785 break;
786 case (YAC_USER_FILE): {
788 entry->user_file.filename, buffer, buffer_size, position, comm);
789 break;
790 }
791 case (YAC_CHECK): {
793 entry->check.constructor_key, buffer, buffer_size, position, comm);
795 entry->check.do_search_key, buffer, buffer_size, position, comm);
796 break;
797 }
798 case (YAC_CREEP): {
800 MPI_Pack(
801 &(entry->creep.creep_distance), 1, MPI_INT,
802 buffer, buffer_size, position, comm), comm);
803 break;
804 }
805 case (YAC_USER_CALLBACK): {
808 buffer, buffer_size, position, comm);
809 break;
810 }
812 int weight_type = (int)(entry->nearest_corner_cells.weight_type);
814 MPI_Pack(
815 &weight_type, 1, MPI_INT, buffer, buffer_size, position, comm),
816 comm);
818 MPI_Pack(
819 &(entry->nearest_corner_cells.partial_coverage), 1, MPI_INT,
820 buffer, buffer_size, position, comm), comm);
821 break;
822 }
823 }
824}
825
827 struct yac_interp_stack_config * interp_stack,
828 void * buffer, int buffer_size, int * position, MPI_Comm comm) {
829
830 int stack_size = (int)(interp_stack->size);
832 MPI_Pack(
833 &stack_size, 1, MPI_INT,
834 buffer, buffer_size, position, comm), comm);
835
836 for (size_t i = 0; i < interp_stack->size; ++i)
838 interp_stack->config + i, buffer, buffer_size, position, comm);
839}
840
842 void * buffer, int buffer_size, int * position,
843 char * string, int max_string_len, MPI_Comm comm) {
844
845 int string_len;
847 MPI_Unpack(
848 buffer, buffer_size, position, &string_len, 1, MPI_INT, comm), comm);
849
851 string_len >= 0,
852 "ERROR(yac_interp_stack_config_unpack_n_string): invalid string length")
853
855 string_len < max_string_len,
856 "ERROR(yac_interp_stack_config_unpack_n_string): string length to long")
857
858 if (string_len > 0)
860 MPI_Unpack(
861 buffer, buffer_size, position, string, string_len, MPI_CHAR, comm),
862 comm);
863 string[string_len] = '\0';
864}
865
867 void * buffer, int buffer_size, int * position, MPI_Comm comm) {
868
869 int string_len;
871 MPI_Unpack(
872 buffer, buffer_size, position, &string_len, 1, MPI_INT, comm), comm);
873
875 string_len >= 0,
876 "ERROR(yac_interp_stack_config_unpack_string): invalid string length")
877
878 char * string = NULL;
879 if (string_len > 0) {
880 string = xmalloc((size_t)(string_len + 1) * sizeof(*string));
882 MPI_Unpack(
883 buffer, buffer_size, position, string, string_len, MPI_CHAR, comm),
884 comm);
885 string[string_len] = '\0';
886 }
887 return string;
888}
889
891 void * buffer, int buffer_size, int * position,
892 struct yac_spmap_cell_area_config * cell_area_config, MPI_Comm comm) {
893
894 int cell_area_provider;
896 MPI_Unpack(
897 buffer, buffer_size, position, &cell_area_provider, 1, MPI_INT, comm),
898 comm);
899 cell_area_config->cell_area_provider =
900 (enum yac_interp_spmap_cell_area_provider)cell_area_provider;
901
902 switch (cell_area_config->cell_area_provider) {
903 default:
906 MPI_Unpack(
907 buffer, buffer_size, position,
908 &(cell_area_config->sphere_radius), 1, MPI_DOUBLE, comm), comm);
909 cell_area_config->file_config.filename = NULL;
910 cell_area_config->file_config.varname = NULL;
911 cell_area_config->file_config.min_global_id = 0;
912 break;
913 }
915 cell_area_config->sphere_radius = 0.0;
916 cell_area_config->file_config.filename =
918 buffer, buffer_size, position, comm);
919 cell_area_config->file_config.varname =
921 buffer, buffer_size, position, comm);
922 int min_global_id;
924 MPI_Unpack(
925 buffer, buffer_size, position, &min_global_id, 1, MPI_INT, comm),
926 comm);
927 cell_area_config->file_config.min_global_id = (size_t)min_global_id;
928 }
929 }
930}
931
933 void * buffer, int buffer_size, int * position,
934 union yac_interp_stack_config_entry * entry, MPI_Comm comm) {
935
936 int type;
938 MPI_Unpack(
939 buffer, buffer_size, position, &type, 1, MPI_INT, comm), comm);
940
942
944 entry->general.type,
945 "yac_interp_stack_config_unpack_entry");
947 entry->general.type != YAC_UNDEFINED,
948 "ERROR(yac_interp_stack_config_unpack_entry): "
949 "invalid interpolation type")
950 switch (type) {
951 default:
952 case (YAC_AVERAGE): {
953 int reduction_type;
955 MPI_Unpack(
956 buffer, buffer_size, position, &reduction_type, 1, MPI_INT, comm),
957 comm);
958 entry->average.reduction_type =
959 (enum yac_interp_avg_weight_type)reduction_type;
961 MPI_Unpack(
962 buffer, buffer_size, position, &(entry->average.partial_coverage),
963 1, MPI_INT, comm), comm);
964 break;
965 }
967 case (YAC_N_NEAREST_NEIGHBOR): {
968 int type;
970 MPI_Unpack(
971 buffer, buffer_size, position, &type, 1, MPI_INT, comm), comm);
974 int n;
976 MPI_Unpack(
977 buffer, buffer_size, position, &n, 1, MPI_INT, comm), comm);
979 n >= 0,
980 "ERROR(yac_interp_stack_config_unpack_entry): "
981 "invalid n_nearest_neighbor.config.n")
982 entry->n_nearest_neighbor.config.n = (size_t)n;
984 MPI_Unpack(
985 buffer, buffer_size, position,
987 1, MPI_DOUBLE, comm), comm);
989 MPI_Unpack(
990 buffer, buffer_size, position,
992 1, MPI_DOUBLE, comm), comm);
993 break;
994 }
995 case (YAC_CONSERVATIVE): {
997 MPI_Unpack(
998 buffer, buffer_size, position,
999 &(entry->conservative.order), 1, MPI_INT, comm), comm);
1001 MPI_Unpack(
1002 buffer, buffer_size, position,
1003 &(entry->conservative.enforced_conserv), 1, MPI_INT, comm), comm);
1005 MPI_Unpack(
1006 buffer, buffer_size, position,
1007 &(entry->conservative.partial_coverage), 1, MPI_INT, comm), comm);
1008 int normalisation;
1010 MPI_Unpack(
1011 buffer, buffer_size, position, &normalisation, 1, MPI_INT, comm),
1012 comm);
1014 (enum yac_interp_method_conserv_normalisation)normalisation;
1015 break;
1016 }
1017 case (YAC_SOURCE_TO_TARGET_MAP): {
1019 MPI_Unpack(
1020 buffer, buffer_size, position,
1021 &(entry->spmap.spread_distance), 1, MPI_DOUBLE, comm), comm);
1023 MPI_Unpack(
1024 buffer, buffer_size, position,
1025 &(entry->spmap.max_search_distance), 1, MPI_DOUBLE, comm), comm);
1026 int weight_type;
1028 MPI_Unpack(
1029 buffer, buffer_size, position, &weight_type, 1, MPI_INT, comm),
1030 comm);
1031 entry->spmap.weight_type =
1033 int scale_type;
1035 MPI_Unpack(
1036 buffer, buffer_size, position, &scale_type, 1, MPI_INT, comm),
1037 comm);
1038 entry->spmap.scale_config.type =
1039 (enum yac_interp_spmap_scale_type)scale_type;
1041 buffer, buffer_size, position, &(entry->spmap.scale_config.src), comm);
1043 buffer, buffer_size, position, &(entry->spmap.scale_config.tgt), comm);
1044 break;
1045 }
1046 case (YAC_FIXED_VALUE): {
1048 MPI_Unpack(
1049 buffer, buffer_size, position,
1050 &(entry->fixed.value), 1, MPI_DOUBLE, comm), comm);
1051 break;
1052 }
1053 case (YAC_BERNSTEIN_BEZIER):
1054 break;
1055 case (YAC_USER_FILE): {
1057 buffer, buffer_size, position,
1059 break;
1060 }
1061 case (YAC_CHECK): {
1063 buffer, buffer_size, position,
1066 buffer, buffer_size, position,
1068 break;
1069 }
1070 case (YAC_CREEP): {
1072 MPI_Unpack(
1073 buffer, buffer_size, position,
1074 &(entry->creep.creep_distance), 1, MPI_INT, comm), comm);
1075 break;
1076 }
1077 case (YAC_USER_CALLBACK): {
1079 buffer, buffer_size, position,
1082 break;
1083 }
1084 case (YAC_NEAREST_CORNER_CELLS): {
1085 int weight_type;
1087 MPI_Unpack(
1088 buffer, buffer_size, position, &weight_type, 1, MPI_INT, comm),
1089 comm);
1093 MPI_Unpack(
1094 buffer, buffer_size, position,
1096 1, MPI_INT, comm), comm);
1097 break;
1098 }
1099 }
1100}
1101
1103 void * buffer, int buffer_size, int * position, MPI_Comm comm) {
1104
1105 int stack_size;
1107 MPI_Unpack(
1108 buffer, buffer_size, position, &stack_size, 1, MPI_INT, comm), comm);
1109
1110 YAC_ASSERT(
1111 stack_size >= 0,
1112 "ERROR(yac_interp_stack_config_unpack_interp_stack): invalid stack size")
1113
1114 struct yac_interp_stack_config * interp_stack =
1116
1117 interp_stack->size = (size_t)stack_size;
1118 interp_stack->config =
1119 xmalloc((size_t)stack_size * sizeof(*interp_stack->config));
1120
1121 for (int i = 0; i < stack_size; ++i)
1123 buffer, buffer_size, position, interp_stack->config + (size_t)i, comm);
1124
1125 return interp_stack;
1126}
1127
1129
1130 struct yac_interp_stack_config * interp_stack_config =
1131 xmalloc(1 * sizeof(*interp_stack_config));
1132 interp_stack_config->config = NULL;
1133 interp_stack_config->size = 0;
1134
1135 return interp_stack_config;
1136}
1137
1139 union yac_interp_stack_config_entry * entry) {
1140
1141 if (entry->general.type == YAC_SOURCE_TO_TARGET_MAP) {
1142 free((void*)entry->spmap.scale_config.src.file_config.filename);
1143 free((void*)entry->spmap.scale_config.src.file_config.varname);
1144 free((void*)entry->spmap.scale_config.tgt.file_config.filename);
1145 free((void*)entry->spmap.scale_config.tgt.file_config.varname);
1146 }
1147}
1148
1150 struct yac_interp_stack_config * interp_stack_config) {
1151 for (size_t i = 0; i < interp_stack_config->size; ++i)
1152 yac_interp_stack_config_entry_free(interp_stack_config->config + i);
1153 free(interp_stack_config->config);
1154 free(interp_stack_config);
1155}
1156
1157static union yac_interp_stack_config_entry *
1159 struct yac_interp_stack_config * interp_stack_config) {
1160
1161 interp_stack_config->size++;
1162 interp_stack_config->config =
1163 xrealloc(
1164 interp_stack_config->config,
1165 interp_stack_config->size * sizeof(*(interp_stack_config->config)));
1166
1167 return interp_stack_config->config + (interp_stack_config->size - 1);
1168}
1169
1181
1183 struct yac_interp_stack_config * interp_stack_config,
1185
1186 YAC_ASSERT(
1190 "ERROR(yac_interp_stack_config_add_average_f2c): "
1191 "reduction_type must be one of "
1192 "YAC_INTERP_AVG_ARITHMETIC/YAC_INTERP_AVG_DIST/YAC_INTERP_AVG_BARY");
1193
1195 interp_stack_config, (enum yac_interp_avg_weight_type)reduction_type,
1197}
1198
1210
1212 struct yac_interp_stack_config * interp_stack_config,
1213 int weight_type, int partial_coverage) {
1214
1215 YAC_ASSERT(
1218 "ERROR(yac_interp_stack_config_add_ncc_f2c): "
1219 "weight_type must be one of "
1220 "YAC_INTERP_NCC_AVG/YAC_INTERP_NCC_DIST");
1221
1223 interp_stack_config, (enum yac_interp_ncc_weight_type)weight_type,
1225}
1226
1228 struct yac_interp_stack_config * interp_stack_config,
1229 enum yac_interp_nnn_weight_type type, size_t n,
1230 double max_search_distance, double scale) {
1231
1232 union yac_interp_stack_config_entry * entry =
1233 yac_interp_stack_config_add_entry(interp_stack_config);
1234
1235 if (type == YAC_INTERP_NNN_RBF) {
1238 (struct yac_nnn_config){
1239 .type = YAC_INTERP_NNN_RBF, .n = n,
1240 .max_search_distance = max_search_distance,
1241 .data.rbf_scale = scale};
1242 } else {
1244 entry->n_nearest_neighbor.config =
1245 (struct yac_nnn_config){
1246 .type = type, .n = n, .max_search_distance = max_search_distance,
1247 .data.rbf_scale = scale};
1248 }
1249}
1250
1252 struct yac_interp_stack_config * interp_stack_config,
1253 int type, size_t n, double max_search_distance, double scale) {
1254
1255 YAC_ASSERT(
1256 (type == YAC_INTERP_NNN_AVG) ||
1259 (type == YAC_INTERP_NNN_RBF) ||
1261 "ERROR(yac_interp_stack_config_add_nnn_f2c): "
1262 "type must be one of YAC_INTERP_NNN_AVG/YAC_INTERP_NNN_DIST/"
1263 "YAC_INTERP_NNN_GAUSS/YAC_INTERP_NNN_RBF/YAC_INTERP_NNN_ZERO.")
1264
1266 interp_stack_config, (enum yac_interp_nnn_weight_type)type, n,
1267 max_search_distance, scale);
1268}
1269
1271 struct yac_interp_stack_config * interp_stack_config,
1272 int order, int enforced_conserv, int partial_coverage,
1273 enum yac_interp_method_conserv_normalisation normalisation) {
1274
1275 union yac_interp_stack_config_entry * entry =
1276 yac_interp_stack_config_add_entry(interp_stack_config);
1277
1279 entry->conservative.order = order;
1283}
1284
1286 struct yac_interp_stack_config * interp_stack_config,
1288 int normalisation) {
1289
1290 YAC_ASSERT(
1293 "ERROR(yac_interp_stack_config_add_conservative_f2c): "
1294 "type must be one of "
1295 "YAC_INTERP_CONSERV_DESTAREA/YAC_INTERP_CONSERV_FRACAREA.")
1296
1298 interp_stack_config, order, enforced_conserv, partial_coverage,
1300}
1301
1302static struct yac_spmap_cell_area_config yac_spmap_cell_area_config_set(
1303 double sphere_radius, char const * filename,
1304 char const * varname, int min_global_id, char const * type) {
1305
1307 (sphere_radius == 0.0) ||
1308 ((sphere_radius != 0.0) &&
1309 ((filename == NULL) && (varname == NULL))),
1310 "ERROR(yac_spmap_cell_area_config_set): "
1311 "%s sphere_radius != 0.0, but filename and varname are not NULL", type);
1313 (sphere_radius != 0.0) ||
1314 ((sphere_radius == 0.0) &&
1315 ((filename != NULL) && (strlen(filename) > 0) && (filename[0] != '\0') &&
1316 (varname != NULL) && (strlen(varname) > 0) && (varname[0] != '\0'))),
1317 "ERROR(yac_spmap_cell_area_config_set): "
1318 "%s sphere_radius == 0.0, but filename and/or varname are invalid", type);
1319
1320 struct yac_spmap_cell_area_config cell_area_config;
1321 if (sphere_radius != 0.0)
1322 cell_area_config.cell_area_provider = YAC_INTERP_SPMAP_CELL_AREA_YAC;
1323 else
1324 cell_area_config.cell_area_provider = YAC_INTERP_SPMAP_CELL_AREA_FILE;
1325
1326 switch (cell_area_config.cell_area_provider) {
1327 default:
1329
1331 sphere_radius > 0.0,
1332 "ERROR(yac_spmap_cell_area_config_set): "
1333 "invalid %s sphere_radius (%.6lf)", type, sphere_radius)
1334 cell_area_config.sphere_radius = sphere_radius;
1335 cell_area_config.file_config.filename = NULL;
1336 cell_area_config.file_config.varname = NULL;
1337 cell_area_config.file_config.min_global_id = 0;
1338 break;
1339 }
1341
1342 cell_area_config.sphere_radius = 0.0;
1343 cell_area_config.file_config.filename = strdup(filename);
1344 cell_area_config.file_config.varname = strdup(varname);
1345 cell_area_config.file_config.min_global_id = (yac_int)min_global_id;
1346 break;
1347 }
1348 }
1349 return cell_area_config;
1350}
1351
1353 struct yac_interp_stack_config * interp_stack_config,
1354 double spread_distance, double max_search_distance,
1356 enum yac_interp_spmap_scale_type scale_type,
1357 double src_sphere_radius, char const * src_filename,
1358 char const * src_varname, int src_min_global_id,
1359 double tgt_sphere_radius, char const * tgt_filename,
1360 char const * tgt_varname, int tgt_min_global_id) {
1361
1362 union yac_interp_stack_config_entry * entry =
1363 yac_interp_stack_config_add_entry(interp_stack_config);
1364
1368 entry->spmap.weight_type = weight_type;
1369 entry->spmap.scale_config.type = scale_type;
1370 entry->spmap.scale_config.src =
1372 src_sphere_radius, src_filename,
1373 src_varname, src_min_global_id, "source");
1374 entry->spmap.scale_config.tgt =
1376 tgt_sphere_radius, tgt_filename,
1377 tgt_varname, tgt_min_global_id, "target");
1378}
1379
1381 struct yac_interp_stack_config * interp_stack_config,
1382 double spread_distance, double max_search_distance,
1383 int weight_type, int scale_type,
1384 double src_sphere_radius, char const * src_filename,
1385 char const * src_varname, int src_min_global_id,
1386 double tgt_sphere_radius, char const * tgt_filename,
1387 char const * tgt_varname, int tgt_min_global_id) {
1388
1389 YAC_ASSERT(
1392 "ERROR(yac_interp_stack_config_add_spmap_f2c): "
1393 "weight_type must be one of "
1394 "YAC_INTERP_SPMAP_AVG/YAC_INTERP_SPMAP_DIST.")
1395
1396 YAC_ASSERT(
1397 (scale_type == YAC_INTERP_SPMAP_NONE) ||
1398 (scale_type == YAC_INTERP_SPMAP_SRCAREA) ||
1399 (scale_type == YAC_INTERP_SPMAP_INVTGTAREA) ||
1400 (scale_type == YAC_INTERP_SPMAP_FRACAREA),
1401 "ERROR(yac_interp_stack_config_add_spmap_f2c): "
1402 "scale_type must be one of "
1403 "YAC_INTERP_SPMAP_NONE/YAC_INTERP_SPMAP_SRCAREA/"
1404 "YAC_INTERP_SPMAP_INVTGTAREA/YAC_INTERP_SPMAP_FRACAREA.")
1405
1406 if (src_filename && (src_filename[0] == '\0')) src_filename = NULL;
1407 if (src_varname && (src_varname[0] == '\0')) src_varname = NULL;
1408 if (tgt_filename && (tgt_filename[0] == '\0')) tgt_filename = NULL;
1409 if (tgt_varname && (tgt_varname[0] == '\0')) tgt_varname = NULL;
1410
1412 interp_stack_config, spread_distance, max_search_distance,
1414 (enum yac_interp_spmap_scale_type)scale_type,
1415 src_sphere_radius, src_filename, src_varname, src_min_global_id,
1416 tgt_sphere_radius, tgt_filename, tgt_varname, tgt_min_global_id);
1417}
1418
1420 struct yac_interp_stack_config * interp_stack_config) {
1421
1422 union yac_interp_stack_config_entry * entry =
1423 yac_interp_stack_config_add_entry(interp_stack_config);
1424
1426}
1427
1428static void check_string(
1429 char const * string, char const * file, int line, char const * routine,
1430 char const * variable) {
1431
1433 string != NULL, "ERROR(%s:%d:%s): %s is NULL",
1434 file, line, routine, variable)
1436 strlen(string) < YAC_MAX_FILE_NAME_LENGTH,
1437 "ERROR(%s:%d:%s): %s is too long", file, line, routine, variable)
1438}
1439
1441 struct yac_interp_stack_config * interp_stack_config,
1442 char const * filename) {
1443
1445 filename, __FILE__, __LINE__,
1446 "yac_interp_stack_config_add_user_file", "filename");
1447
1448 union yac_interp_stack_config_entry * entry =
1449 yac_interp_stack_config_add_entry(interp_stack_config);
1450
1451 entry->user_file.type = YAC_USER_FILE;
1452 strcpy(entry->user_file.filename, filename);
1453}
1454
1456 struct yac_interp_stack_config * interp_stack_config, double value) {
1457
1458 union yac_interp_stack_config_entry * entry =
1459 yac_interp_stack_config_add_entry(interp_stack_config);
1460
1461 entry->fixed.type = YAC_FIXED_VALUE;
1462 entry->fixed.value = value;
1463}
1464
1466 struct yac_interp_stack_config * interp_stack_config,
1467 char const * constructor_key, char const * do_search_key) {
1468
1471 "ERROR(yac_interp_stack_config_add_check): "
1472 "constructor_key name \"%s\" is too long "
1473 "(has to be smaller than %d)", constructor_key, YAC_MAX_ROUTINE_NAME_LENGTH);
1476 "ERROR(yac_interp_stack_config_add_check): "
1477 "do_search_key name \"%s\" is too long "
1478 "(has to be smaller than %d)", do_search_key, YAC_MAX_ROUTINE_NAME_LENGTH);
1479
1480 union yac_interp_stack_config_entry * entry =
1481 yac_interp_stack_config_add_entry(interp_stack_config);
1482
1483 entry->check.type = YAC_CHECK;
1484 if (constructor_key) {
1485 strcpy(entry->check.constructor_key, constructor_key);
1486 } else {
1487 memset(entry->check.constructor_key, '\0',
1488 sizeof(entry->check.constructor_key));
1489 }
1490 if (do_search_key) {
1491 strcpy(entry->check.do_search_key, do_search_key);
1492 } else {
1493 memset(entry->check.do_search_key, '\0',
1494 sizeof(entry->check.do_search_key));
1495 }
1496}
1497
1499 struct yac_interp_stack_config * interp_stack_config, int creep_distance) {
1500
1501 union yac_interp_stack_config_entry * entry =
1502 yac_interp_stack_config_add_entry(interp_stack_config);
1503
1504 entry->creep.type = YAC_CREEP;
1506}
1507
1509 struct yac_interp_stack_config * interp_stack_config,
1510 char const * func_compute_weights_key) {
1511
1513 func_compute_weights_key, __FILE__, __LINE__,
1514 "yac_interp_stack_config_add_user_callback",
1515 "func_compute_weights_key");
1516
1517 union yac_interp_stack_config_entry * entry =
1518 yac_interp_stack_config_add_entry(interp_stack_config);
1519
1521 strcpy(
1523}
1524
1526 struct yac_interp_stack_config * interp_stack) {
1527
1528 return interp_stack->size;
1529}
1530
1533 struct yac_interp_stack_config * interp_stack,
1534 size_t interp_stack_idx) {
1535
1536 YAC_ASSERT(
1537 interp_stack_idx < interp_stack->size,
1538 "ERROR(yac_interp_stack_config_get_entry): "
1539 "invalid interpolation stack index");
1540
1541 return interp_stack->config + interp_stack_idx;
1542}
1543
1544
1546 union yac_interp_stack_config_entry const * interp_stack_entry) {
1547
1548 return interp_stack_entry->general.type;
1549}
1550
1552 union yac_interp_stack_config_entry const * interp_stack_entry,
1554 int * partial_coverage) {
1555
1556 YAC_ASSERT(
1557 interp_stack_entry->general.type == YAC_AVERAGE,
1558 "ERROR(yac_interp_stack_config_entry_get_average): "
1559 "wrong interpolation stack entry type");
1560
1561 *reduction_type = interp_stack_entry->average.reduction_type;
1562 *partial_coverage = interp_stack_entry->average.partial_coverage;
1563}
1564
1566 union yac_interp_stack_config_entry const * interp_stack_entry,
1568
1569 YAC_ASSERT(
1570 (interp_stack_entry->general.type == YAC_NEAREST_CORNER_CELLS),
1571 "ERROR(yac_interp_stack_config_entry_get_ncc): "
1572 "wrong interpolation stack entry type");
1573
1574 *type = interp_stack_entry->nearest_corner_cells.weight_type;
1576 interp_stack_entry->nearest_corner_cells.partial_coverage;
1577}
1578
1580 union yac_interp_stack_config_entry const * interp_stack_entry,
1581 enum yac_interp_nnn_weight_type * type, size_t * n,
1582 double * max_search_distance, double * scale) {
1583
1584 YAC_ASSERT(
1585 (interp_stack_entry->general.type == YAC_N_NEAREST_NEIGHBOR) ||
1586 (interp_stack_entry->general.type == YAC_RADIAL_BASIS_FUNCTION),
1587 "ERROR(yac_interp_stack_config_entry_get_nnn): "
1588 "wrong interpolation stack entry type");
1589
1590 *type = interp_stack_entry->n_nearest_neighbor.config.type;
1591 *n = interp_stack_entry->n_nearest_neighbor.config.n;
1593 interp_stack_entry->n_nearest_neighbor.config.max_search_distance;
1594 *scale = interp_stack_entry->n_nearest_neighbor.config.data.rbf_scale;
1595}
1596
1598 union yac_interp_stack_config_entry const * interp_stack_entry,
1599 int * order, int * enforced_conserv, int * partial_coverage,
1601
1602 YAC_ASSERT(
1603 interp_stack_entry->general.type == YAC_CONSERVATIVE,
1604 "ERROR(yac_interp_stack_config_entry_get_conservative): "
1605 "wrong interpolation stack entry type");
1606
1607 *order = interp_stack_entry->conservative.order;
1608 *enforced_conserv = interp_stack_entry->conservative.enforced_conserv;
1609 *partial_coverage = interp_stack_entry->conservative.partial_coverage;
1610 *normalisation = interp_stack_entry->conservative.normalisation;
1611}
1612
1614 union yac_interp_stack_config_entry const * interp_stack_entry,
1615 double * spread_distance, double * max_search_distance,
1617 enum yac_interp_spmap_scale_type * scale_type,
1618 double * src_sphere_radius, char const ** src_filename,
1619 char const ** src_varname, int * src_min_global_id,
1620 double * tgt_sphere_radius, char const ** tgt_filename,
1621 char const ** tgt_varname, int * tgt_min_global_id) {
1622
1623 YAC_ASSERT(
1624 interp_stack_entry->general.type == YAC_SOURCE_TO_TARGET_MAP,
1625 "ERROR(yac_interp_stack_config_entry_get_spmap): "
1626 "wrong interpolation stack entry type");
1627
1628 *spread_distance = interp_stack_entry->spmap.spread_distance;
1629 *max_search_distance = interp_stack_entry->spmap.max_search_distance;
1630 *weight_type = interp_stack_entry->spmap.weight_type;
1631 *scale_type = interp_stack_entry->spmap.scale_config.type;
1632 *src_sphere_radius = interp_stack_entry->spmap.scale_config.src.sphere_radius;
1633 *src_filename =
1634 interp_stack_entry->spmap.scale_config.src.file_config.filename;
1635 *src_varname =
1636 interp_stack_entry->spmap.scale_config.src.file_config.varname;
1637 *src_min_global_id =
1638 interp_stack_entry->spmap.scale_config.src.file_config.min_global_id;
1639 *tgt_sphere_radius = interp_stack_entry->spmap.scale_config.tgt.sphere_radius;
1640 *tgt_filename =
1641 interp_stack_entry->spmap.scale_config.tgt.file_config.filename;
1642 *tgt_varname =
1643 interp_stack_entry->spmap.scale_config.tgt.file_config.varname;
1644 *tgt_min_global_id =
1645 interp_stack_entry->spmap.scale_config.tgt.file_config.min_global_id;
1646}
1647
1649 union yac_interp_stack_config_entry const * interp_stack_entry,
1650 char const ** filename) {
1651
1652 YAC_ASSERT(
1653 interp_stack_entry->general.type == YAC_USER_FILE,
1654 "ERROR(yac_interp_stack_config_entry_get_user_file): "
1655 "wrong interpolation stack entry type");
1656
1657 *filename = interp_stack_entry->user_file.filename;
1658}
1659
1661 union yac_interp_stack_config_entry const * interp_stack_entry,
1662 double * value) {
1663
1664 YAC_ASSERT(
1665 interp_stack_entry->general.type == YAC_FIXED_VALUE,
1666 "ERROR(yac_interp_stack_config_entry_get_fixed): "
1667 "wrong interpolation stack entry type");
1668
1669 *value = interp_stack_entry->fixed.value;
1670}
1671
1673 union yac_interp_stack_config_entry const * interp_stack_entry,
1674 char const ** constructor_key, char const ** do_search_key) {
1675
1676 YAC_ASSERT(
1677 interp_stack_entry->general.type == YAC_CHECK,
1678 "ERROR(yac_interp_stack_config_entry_get_check): "
1679 "wrong interpolation stack entry type");
1680
1681 *constructor_key = interp_stack_entry->check.constructor_key;
1682 *do_search_key = interp_stack_entry->check.do_search_key;
1683}
1684
1686 union yac_interp_stack_config_entry const * interp_stack_entry,
1687 int * creep_distance) {
1688
1689 YAC_ASSERT(
1690 interp_stack_entry->general.type == YAC_CREEP,
1691 "ERROR(yac_interp_stack_config_entry_get_creep): "
1692 "wrong interpolation stack entry type");
1693
1694 *creep_distance = interp_stack_entry->creep.creep_distance;
1695}
1696
1698 union yac_interp_stack_config_entry const * interp_stack_entry,
1699 char const ** func_compute_weights_key) {
1700
1701 YAC_ASSERT(
1702 interp_stack_entry->general.type == YAC_USER_CALLBACK,
1703 "ERROR(yac_interp_stack_config_entry_get_user_callback): "
1704 "wrong interpolation stack entry type");
1705
1707 interp_stack_entry->user_callback.func_compute_weights_key;
1708}
enum yac_interp_ncc_weight_type weight_type
#define yac_angle_tol
Definition geometry.h:34
struct interp_method * yac_interp_method_avg_new(enum yac_interp_avg_weight_type weight_type, int partial_coverage)
yac_interp_avg_weight_type
@ YAC_INTERP_AVG_DIST
@ YAC_INTERP_AVG_ARITHMETIC
@ YAC_INTERP_AVG_BARY
void * user_data
void yac_interp_method_callback_get_compute_weights_callback(char const *key, yac_func_compute_weights *compute_weights_callback, void **user_data)
static size_t do_search_callback(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights)
struct interp_method * yac_interp_method_callback_new(yac_func_compute_weights compute_weights_callback, void *user_data)
void(* yac_func_compute_weights)(double const tgt_coords[3], int src_cell_id, size_t src_cell_idx, int const **global_results_points, double **result_weights, size_t *result_count, void *user_data)
void yac_interp_method_check_get_do_search_callback(char const *key, func_do_search *do_search_callback, void **user_data)
void yac_interp_method_check_get_constructor_callback(char const *key, func_constructor *constructor_callback, void **user_data)
struct @7::@8 value
enum callback_type type
struct interp_method * yac_interp_method_check_new(func_constructor constructor_callback, void *constructor_user_data, func_do_search do_search_callback, void *do_search_user_data)
void(* func_do_search)(yac_int const *global_ids, double const (*coordinates_xyz)[3], size_t count, void *user_data)
void(* func_constructor)(void *user_data)
struct interp_method * yac_interp_method_conserv_new(int order, int enforced_conserv, int partial_coverage, enum yac_interp_method_conserv_normalisation normalisation)
yac_interp_method_conserv_normalisation
@ YAC_INTERP_CONSERV_DESTAREA
@ YAC_INTERP_CONSERV_FRACAREA
struct interp_method * yac_interp_method_creep_new(int creep_distance)
struct interp_method * yac_interp_method_file_new(char const *weight_file_name)
struct interp_method * yac_interp_method_fixed_new(double value)
struct interp_method * yac_interp_method_hcsbb_new()
struct interp_method * yac_interp_method_ncc_new(enum yac_interp_ncc_weight_type weight_type, int partial_coverage)
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
struct interp_method * yac_interp_method_nnn_new(struct yac_nnn_config config)
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
struct interp_method * yac_interp_method_spmap_new(double spread_distance, double max_search_distance, enum yac_interp_spmap_weight_type weight_type, struct yac_spmap_scale_config scale_config)
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
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
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)
int yac_interp_stack_config_compare(void const *a_, void const *b_)
static union yac_interp_stack_config_entry * yac_interp_stack_config_add_entry(struct yac_interp_stack_config *interp_stack_config)
static void yac_spmap_cell_area_config_unpack(void *buffer, int buffer_size, int *position, struct yac_spmap_cell_area_config *cell_area_config, MPI_Comm comm)
static void yac_spmap_cell_area_config_pack(struct yac_spmap_cell_area_config cell_area_config, void *buffer, int buffer_size, int *position, MPI_Comm comm)
static struct yac_spmap_cell_area_config yac_spmap_cell_area_config_set(double sphere_radius, char const *filename, char const *varname, int min_global_id, char const *type)
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)
static void yac_interp_stack_config_pack_string(char const *string, void *buffer, int buffer_size, int *position, MPI_Comm comm)
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_hcsbb(struct yac_interp_stack_config *interp_stack_config)
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)
static void yac_interp_stack_config_pack_entry(union yac_interp_stack_config_entry *entry, void *buffer, int buffer_size, int *position, MPI_Comm comm)
void yac_interp_stack_config_entry_get_user_file(union yac_interp_stack_config_entry const *interp_stack_entry, char const **filename)
void yac_interp_stack_config_add_creep(struct yac_interp_stack_config *interp_stack_config, int creep_distance)
void yac_interp_stack_config_add_user_file(struct yac_interp_stack_config *interp_stack_config, char const *filename)
static size_t yac_interp_stack_config_get_string_pack_size(char const *string, MPI_Comm comm)
static int yac_spmap_cell_area_config_compare(struct yac_spmap_cell_area_config a, struct yac_spmap_cell_area_config b)
static size_t yac_spmap_cell_area_config_get_pack_size(struct yac_spmap_cell_area_config cell_area_config, MPI_Comm comm)
static int yac_spmap_scale_config_compare(struct yac_spmap_scale_config a, struct yac_spmap_scale_config b)
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_add_spmap_f2c(struct yac_interp_stack_config *interp_stack_config, double spread_distance, double max_search_distance, int weight_type, int 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_entry_get_ncc(union yac_interp_stack_config_entry const *interp_stack_entry, enum yac_interp_ncc_weight_type *type, int *partial_coverage)
void yac_interp_stack_config_add_conservative_f2c(struct yac_interp_stack_config *interp_stack_config, int order, int enforced_conserv, int partial_coverage, int normalisation)
static void yac_interp_stack_config_unpack_entry(void *buffer, int buffer_size, int *position, union yac_interp_stack_config_entry *entry, MPI_Comm comm)
struct yac_interp_stack_config * yac_interp_stack_config_unpack(void *buffer, int buffer_size, int *position, MPI_Comm comm)
void yac_interp_stack_config_add_ncc_f2c(struct yac_interp_stack_config *interp_stack_config, int weight_type, int partial_coverage)
static void check_interpolation_type(enum yac_interpolation_list type, char const *routine)
void yac_interp_stack_config_delete(struct yac_interp_stack_config *interp_stack_config)
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)
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)
static int yac_interp_stack_config_entry_compare(void const *a_, void const *b_)
struct interp_method ** yac_interp_stack_config_generate(struct yac_interp_stack_config *interp_stack)
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)
static char * yac_interp_stack_config_unpack_string(void *buffer, int buffer_size, int *position, MPI_Comm comm)
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)
void yac_interp_stack_config_add_average_f2c(struct yac_interp_stack_config *interp_stack_config, int reduction_type, int partial_coverage)
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_nnn_f2c(struct yac_interp_stack_config *interp_stack_config, int type, size_t n, double max_search_distance, double scale)
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_add_user_callback(struct yac_interp_stack_config *interp_stack_config, char const *func_compute_weights_key)
static void yac_interp_stack_config_unpack_n_string(void *buffer, int buffer_size, int *position, char *string, int max_string_len, MPI_Comm comm)
struct yac_interp_stack_config * yac_interp_stack_config_new()
static void yac_interp_stack_config_entry_free(union yac_interp_stack_config_entry *entry)
void yac_interp_stack_config_pack(struct yac_interp_stack_config *interp_stack, void *buffer, int buffer_size, int *position, MPI_Comm comm)
static void check_string(char const *string, char const *file, int line, char const *routine, char const *variable)
static void yac_interp_stack_config_entry_copy(union yac_interp_stack_config_entry *to, union yac_interp_stack_config_entry *from)
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)
static size_t yac_interp_stack_config_get_entry_pack_size(union yac_interp_stack_config_entry *entry, MPI_Comm comm)
yac_interpolation_list
@ YAC_N_NEAREST_NEIGHBOR
@ YAC_CREEP
@ YAC_USER_FILE
@ YAC_USER_CALLBACK
@ YAC_SOURCE_TO_TARGET_MAP
@ YAC_CONSERVATIVE
@ YAC_FIXED_VALUE
@ YAC_UNDEFINED
@ YAC_CHECK
@ YAC_BERNSTEIN_BEZIER
@ YAC_NEAREST_CORNER_CELLS
@ YAC_RADIAL_BASIS_FUNCTION
@ YAC_AVERAGE
#define YAC_MAX_ROUTINE_NAME_LENGTH
#define YAC_MAX_FILE_NAME_LENGTH
#define xrealloc(ptr, size)
Definition ppm_xfuncs.h:67
#define xmalloc(size)
Definition ppm_xfuncs.h:66
union yac_interp_stack_config_entry * config
union yac_nnn_config::@21 data
enum yac_interp_nnn_weight_type type
struct yac_spmap_scale_config::yac_spmap_cell_area_config::yac_spmap_cell_area_file_config file_config
struct yac_spmap_scale_config::yac_spmap_cell_area_config src
struct yac_spmap_scale_config::yac_spmap_cell_area_config tgt
enum yac_interp_spmap_scale_type type
struct yac_interp_stack_config_entry::@33 nearest_corner_cells
struct yac_interp_stack_config_entry::@29 fixed
enum yac_interp_ncc_weight_type weight_type
double value
char do_search_key[YAC_MAX_ROUTINE_NAME_LENGTH]
struct yac_interp_stack_config_entry::@23 average
double max_search_distance
enum yac_interpolation_list type
struct yac_interp_stack_config_entry::@25 conservative
int partial_coverage
struct yac_interp_stack_config_entry::@24 radial_basis_function
struct yac_nnn_config config
struct yac_interp_stack_config_entry::@31 creep
struct yac_interp_stack_config_entry::@32 user_callback
int creep_distance
int enforced_conserv
struct yac_interp_stack_config_entry::@26 spmap
int order
double spread_distance
char constructor_key[YAC_MAX_ROUTINE_NAME_LENGTH]
enum yac_interp_avg_weight_type reduction_type
struct yac_interp_stack_config_entry::@28 user_file
enum yac_interp_method_conserv_normalisation normalisation
struct yac_interp_stack_config_entry::@22 general
struct yac_interp_stack_config_entry::@27 hcsbb
char filename[YAC_MAX_FILE_NAME_LENGTH]
enum yac_interp_spmap_weight_type weight_type
struct yac_interp_stack_config_entry::@24 n_nearest_neighbor
struct yac_interp_stack_config_entry::@30 check
char func_compute_weights_key[YAC_MAX_ROUTINE_NAME_LENGTH]
struct yac_spmap_scale_config scale_config
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:19
#define YAC_ASSERT(exp, msg)
Definition yac_assert.h:16
#define yac_mpi_call(call, comm)
Xt_int yac_int
Definition yac_types.h:15