YAC 3.21.0
Yet Another Coupler
Loading...
Searching...
No Matches
interp_method_nnn.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// Get the definition of the 'restrict' keyword.
7#include "config.h"
8#endif
9
10#include <limits.h>
11#include <string.h>
12
18#include "parameter/param_int.h"
22#include "instrument_internal.h"
23#include "yac_mpi_internal.h"
24#include "yac_mpi_common.h"
25
26static size_t do_search_nnn(struct interp_method * method,
27 struct yac_interp_grid * interp_grid,
28 size_t * tgt_points, size_t count,
29 struct yac_interp_weights * weights,
30 int * interpolation_complete);
31static size_t do_search_1nn(struct interp_method * method,
32 struct yac_interp_grid * interp_grid,
33 size_t * tgt_points, size_t count,
34 struct yac_interp_weights * weights,
35 int * interpolation_complete);
36static size_t do_search_zero(struct interp_method * method,
37 struct yac_interp_grid * interp_grid,
38 size_t * tgt_points, size_t count,
39 struct yac_interp_weights * weights,
40 int * interpolation_complete);
41static void delete_nnn(struct interp_method * method);
42
43static struct interp_method_vtable
53
63
65
68 struct yac_interp_weights * weights, struct remote_points * tgts,
69 struct remote_point * srcs);
71};
72
77
78static size_t do_search_nnn (struct interp_method * method,
79 struct yac_interp_grid * interp_grid,
80 size_t * tgt_points, size_t count,
81 struct yac_interp_weights * weights,
82 int * interpolation_complete) {
83
84 if (*interpolation_complete) return 0;
85
86 YAC_INSTRUMENT_START(YAC_INSTR_INTERP_SEARCH_NNN);
87
88 struct interp_method_nnn * method_nnn = (struct interp_method_nnn *)method;
89
91
92 // get coordinates of target points
93 yac_coordinate_pointer tgt_coords = xmalloc(count * sizeof(*tgt_coords));
95 interp_grid, tgt_points, count, tgt_coords);
96
97 size_t n = method_nnn->n;
98 size_t n_min = method_nnn->n_min;
99
100 size_t * size_t_buffer = xmalloc((2 * n + 1) * count * sizeof(*size_t_buffer));
101 size_t * src_points = size_t_buffer;
102 size_t * src_points_reorder = size_t_buffer + n * count;
103 size_t * reorder_idx = size_t_buffer + 2 * n * count;
104 int * fail_flag = xmalloc(count * sizeof(*fail_flag));
105 size_t * num_src_per_tgt = xmalloc(count * sizeof(*num_src_per_tgt));
106
107 // search for the n nearest source points
109 interp_grid, tgt_coords, count, n, src_points,
110 method_nnn->max_search_distance);
111
112 size_t result_count = 0;
113 size_t total_num_weights = 0;
114
115 // count the number of source points found for each target point
116 // (the search returns the found source points at the beginning of the
117 // result buffer of each target point and fills up the remaining entries
118 // with SIZE_MAX)
119 // the search is considered to be successful, if at least n_min source
120 // points were found
121 for (size_t i = 0, k = 0; i < count; ++i) {
122 size_t curr_num_src = 0;
123 for (size_t j = 0; j < n; ++j, ++k)
124 if (src_points[k] != SIZE_MAX) ++curr_num_src;
125 num_src_per_tgt[i] = curr_num_src;
126 int flag = curr_num_src < n_min;
127 fail_flag[i] = flag;
128 if (!flag) {
129 ++result_count;
130 total_num_weights += curr_num_src;
131 }
132 reorder_idx[i] = i;
133 }
134
135 // sort target points, for which the search was successful to the beginning of
136 // the array
137 yac_quicksort_index_int_size_t(fail_flag, count, reorder_idx);
138 free(fail_flag);
139
140 yac_interp_compute_weights_func compute_weights =
141 method_nnn->compute_weights;
142 double scale = method_nnn->scale;
143 double * w = xmalloc(total_num_weights * sizeof(*w));
144 size_t * num_weights_per_tgt =
145 xmalloc(result_count * sizeof(*num_weights_per_tgt));
146 yac_coordinate_pointer src_coord_buffer = xmalloc(n * sizeof(*src_coord_buffer));
147 yac_const_coordinate_pointer src_field_coordinates =
149
150 // compute the weights
151 for (size_t i = 0, weight_offset = 0; i < result_count; ++i) {
152 size_t curr_reorder_idx = reorder_idx[i];
153 size_t curr_num_src = num_src_per_tgt[curr_reorder_idx];
154 for (size_t j = 0; j < curr_num_src; ++j) {
155 size_t curr_src_point = src_points[curr_reorder_idx * n + j];
156 memcpy(src_coord_buffer[j], src_field_coordinates[curr_src_point],
157 3 * sizeof(double));
158 src_points_reorder[weight_offset + j] = curr_src_point;
159 }
160
162 tgt_coords[curr_reorder_idx],
163 (yac_const_coordinate_pointer)src_coord_buffer, curr_num_src,
164 w + weight_offset, scale);
165 num_weights_per_tgt[i] = curr_num_src;
166 weight_offset += curr_num_src;
167 }
168
169 free(num_src_per_tgt);
170
171 // move the non-interpolated target points to the end
172 for (size_t i = 0; i < count; ++i) src_points[reorder_idx[i]] = i;
173 yac_quicksort_index_size_t_size_t(src_points, count, tgt_points);
174
175 free(src_coord_buffer);
176 free(tgt_coords);
177
178 struct remote_point * srcs =
180 interp_grid, 0, src_points_reorder, total_num_weights);
181
182 struct remote_points tgts = {
183 .data =
185 interp_grid, tgt_points, result_count),
186 .count = result_count};
187
188 // store weights
190 weights, &tgts, num_weights_per_tgt, srcs, w);
191
192 free(size_t_buffer);
193 free(tgts.data);
194 free(srcs);
195 free(w);
196 free(num_weights_per_tgt);
197
198 YAC_INSTRUMENT_STOP(YAC_INSTR_INTERP_SEARCH_NNN);
199
200 return result_count;
201}
202
203static size_t do_search_1nn(struct interp_method * method,
204 struct yac_interp_grid * interp_grid,
205 size_t * tgt_points, size_t count,
206 struct yac_interp_weights * weights,
207 int * interpolation_complete) {
208
209 if (*interpolation_complete) return 0;
210
211 YAC_INSTRUMENT_START(YAC_INSTR_INTERP_SEARCH_1NN);
212
214
215 // get coordinates of target points
216 yac_coordinate_pointer tgt_coords = xmalloc(count * sizeof(*tgt_coords));
218 interp_grid, tgt_points, count, tgt_coords);
219
220 size_t * src_points = xmalloc(count * sizeof(*src_points));
221
222 // search for the nearest source points
224 interp_grid, tgt_coords, count, 1, src_points,
225 ((struct interp_method_1nn *)method)->max_search_distance);
226
227 // move the non-interpolated target points to the end
228 // (source points == SIZE_MAX if no source point was found)
229 yac_quicksort_index_size_t_size_t(src_points, count, tgt_points);
230 free(tgt_coords);
231
232 // count the number of target points for which we found a source point
233 size_t result_count = 0;
234 for (; (result_count < count) && (src_points[result_count] != SIZE_MAX);
235 ++result_count);
236
237 struct remote_point * srcs =
239 interp_grid, 0, src_points, result_count);
240
241 struct remote_points tgts = {
242 .data =
244 interp_grid, tgt_points, result_count),
245 .count = result_count};
246
247 // store weights
248 ((struct interp_method_1nn *)method)->interp_weights_add(
249 weights, &tgts, srcs);
250
251 free(src_points);
252 free(tgts.data);
253 free(srcs);
254
255 YAC_INSTRUMENT_STOP(YAC_INSTR_INTERP_SEARCH_1NN);
256
257 return result_count;
258}
259
261 struct yac_interp_weights * weights, struct remote_points * tgts,
262 struct remote_point src) {
263
264 size_t * num_src_per_tgt = xmalloc(tgts->count * sizeof(*num_src_per_tgt));
265 double * w = xmalloc(tgts->count * sizeof(*w));
266 struct remote_point * srcs = xmalloc(tgts->count * sizeof(*srcs));
267
268 for (size_t i = 0; i < tgts->count; ++i) {
269 num_src_per_tgt[i] = 1;
270 w[i] = 0.0;
271 srcs[i] = src;
272 }
273
274 yac_interp_weights_add_wsum(weights, tgts, num_src_per_tgt, srcs, w);
275
276 free(srcs);
277 free(w);
278 free(num_src_per_tgt);
279}
280
281static size_t do_search_zero(struct interp_method * method,
282 struct yac_interp_grid * interp_grid,
283 size_t * tgt_points, size_t count,
284 struct yac_interp_weights * weights,
285 int * interpolation_complete) {
286
287 if (*interpolation_complete) return 0;
288
289 YAC_INSTRUMENT_START(YAC_INSTR_INTERP_SEARCH_ZERO);
290
292
293 UNUSED(method);
294
295 // get global ids of all valid local source points
296 size_t * src_points, src_count;
297 yac_interp_grid_get_src_points(interp_grid, 0, &src_points, &src_count);
298 yac_int * src_global_ids = xmalloc(src_count * sizeof(*src_global_ids));
299 if (src_count > 0)
301 interp_grid, src_points, src_count, 0, src_global_ids);
302 free(src_points);
303
304 // determine smallest global id of all unmasked source points in the
305 // local data
306 yac_int min_src_global_id = YAC_INT_MAX;
307 for (size_t i = 0; i < src_count; ++i)
308 if (src_global_ids[i] < min_src_global_id)
309 min_src_global_id = src_global_ids[i];
310 free(src_global_ids);
311
312 // determine smallest global id of all unmasked source points in the
313 // global data
314 MPI_Comm comm = yac_interp_grid_get_MPI_Comm(interp_grid);
316 MPI_Allreduce(
317 MPI_IN_PLACE, &min_src_global_id, 1, yac_int_dt, MPI_MIN, comm), comm);
319 min_src_global_id != YAC_INT_MAX, "unable to find unmasked source points");
320
321 // get the local id of the source point with the smallest global ids
322 // (add it to the local data if it does not yet exist there)
323 size_t min_src_local_id;
325 interp_grid, 0, &min_src_global_id, 1, &min_src_local_id);
326
327 struct remote_point * src =
329 interp_grid, 0, &min_src_local_id, 1);
330
331 struct remote_points tgts = {
332 .data =
334 interp_grid, tgt_points, count),
335 .count = count};
336
337 // store weights
338 interp_weights_add_zero(weights, &tgts, *src);
339
340 free(tgts.data);
341 free(src);
342
343 YAC_INSTRUMENT_STOP(YAC_INSTR_INTERP_SEARCH_ZERO);
344
345 return count;
346}
347
348// resolves the configured minimum number of source points
349// (a value of 0 is interpreted as "use n")
350// (the validity of n_min is checked in yac_interp_method_nnn_new)
352
353 return (config.n_min <= 0)?config.n:config.n_min;
354}
355
358
360 (config.max_search_distance >= 0.0) &&
361 (config.max_search_distance <= M_PI),
362 "unsupported value for max_search_distance (%lf), has to be in [0.0,PI]",
363 config.max_search_distance)
364
366 config.n >= 1, "unsupported value for n (%d), has to be >= 1", config.n)
367
369 (config.n_min >= 0) && (config.n_min <= config.n),
370 "unsupported value for n_min (%d), has to be in [0,n] (n: %d)",
371 config.n_min, config.n)
372
373 if (config.type == YAC_INTERP_NNN_ZERO) {
374
376 config.n == 1, "n != 1 does not make sense for zero")
378 config.max_search_distance == 0.0,
379 "max_search_distance != 0.0 does not make sense for zero")
380
381 struct interp_method_zero * method = xmalloc(1 * sizeof(*method));
383 return (struct interp_method*)method;
384 }
385
386 double max_search_distance =
387 (config.max_search_distance == 0.0)?M_PI:config.max_search_distance;
388
389 if (config.n == 1) {
390
391 struct interp_method_1nn * method = xmalloc(1 * sizeof(*method));
395 return (struct interp_method*)method;
396 }
397
398 struct interp_method_nnn * method = xmalloc(1 * sizeof(*method));
399
401
403 method->n = (size_t)config.n;
404 method->n_min = (size_t)get_nnn_n_min(config);
405
406 switch (config.type) {
407 YAC_UNREACHABLE_DEFAULT("invalid n-nearest-neighbour weight type")
408 case(YAC_INTERP_NNN_AVG):
410 config.n >= 1, "n needs to be at least 1 for distance weighted average")
411 method->scale = 0.0;
413 break;
416 config.n >= 2, "n needs to be at least 2 for distance weighted average")
417 method->scale = 0.0;
419 break;
422 config.n >= 2, "n needs to be at least 2 for gauss")
423 method->scale = config.data.gauss_scale;
425 break;
426 case(YAC_INTERP_NNN_RBF):
428 config.n >= 2, "n needs to be at least 2 for RBF")
429 method->scale = config.data.rbf_scale;
431 break;
432 };
433
434 return (struct interp_method*)method;
435}
436
437static void delete_nnn(struct interp_method * method) {
438 free(method);
439}
440
441// --- Modular config struct and vtable for NNN method ---
442
460
463 free(config);
464}
465
467 const struct yac_interp_method_config *config) {
469 struct yac_interp_method_config_nnn *copy =
470 xmalloc(sizeof(*copy));
471 copy->base.vtable = config_nnn->base.vtable;
472 copy->base.root_param_cache = NULL;
473 copy->config = config_nnn->config;
474 copy->rbf_kernel = config_nnn->rbf_kernel;
475 return (struct yac_interp_method_config *)copy;
476}
477
479 void const *a_, void const *b_) {
481 // Compare number of neighbors
482 CHECK_INT(config.n);
483 // Compare minimum number of neighbors (n_min == 0 is equivalent to n_min == n)
484 {
485 int a_n_min = get_nnn_n_min(a->config);
486 int b_n_min = get_nnn_n_min(b->config);
487 if (a_n_min != b_n_min) return (a_n_min > b_n_min) - (a_n_min < b_n_min);
488 }
489 // Compare max_search_distance with tolerance
490 CHECK_ANGLE(config.max_search_distance);
491 // Compare weighting type
492 CHECK_ENUM(config.type);
493 // Compare type-specific scale parameter
494 switch (a->config.type) {
495 YAC_UNREACHABLE_DEFAULT("invalid n-nearest-neighbour weight type");
497 CHECK_DOUBLE(config.data.gauss_scale);
498 break;
500 CHECK_DOUBLE(config.data.rbf_scale);
502 break;
506 // For other types, no further parameter to compare
507 break;
508 }
509 return 0;
510}
511
512// Gets interpolation method
516
520
522 struct yac_interp_method_config const *config) {
523 const struct yac_interp_method_config_nnn *config_nnn =
524 (const struct yac_interp_method_config_nnn *)config;
525 return yac_interp_method_nnn_new(config_nnn->config);
526}
527
529 struct yac_interp_method_config_nnn *config_nnn, int n_default) {
530
531 enum {
532 N_HAS_DEFAULT = 1,
533 N_IS_DEFINED = 1,
534 };
535
536 int const n_min = 1;
537 int const n_max = INT_MAX;
538
539 return yac_param_int_new(
540 "n",
541 &config_nnn->config.n, n_default,
542 n_min, n_max, N_HAS_DEFAULT, N_IS_DEFINED);
543}
544
546 struct yac_interp_method_config_nnn *config_nnn, int n_min_default) {
547
548 enum {
549 N_MIN_HAS_DEFAULT = 1,
550 N_MIN_IS_DEFINED = 1,
551 };
552
553 // a value of 0 is interpreted as "use the value of n"
554 int const n_min_min = 0;
555 int const n_min_max = INT_MAX;
556
557 return yac_param_int_new(
558 "n_min",
559 &config_nnn->config.n_min, n_min_default,
560 n_min_min, n_min_max, N_MIN_HAS_DEFAULT, N_MIN_IS_DEFINED);
561}
562
564 struct yac_interp_method_config_nnn *config_nnn,
565 double max_search_distance_default) {
566
567 enum {
568 MAX_SEARCH_DISTANCE_HAS_DEFAULT = 1,
569 MAX_SEARCH_DISTANCE_IS_DEFINED = 1,
570 };
571
572 double const max_search_distance_min = 0.0;
573 double const max_search_distance_max = M_PI - 0.000001;
574
576 "max_search_distance",
577 &config_nnn->config.max_search_distance,
578 max_search_distance_default,
579 max_search_distance_min, max_search_distance_max,
580 MAX_SEARCH_DISTANCE_HAS_DEFAULT, MAX_SEARCH_DISTANCE_IS_DEFINED);
581}
582
584 char const *name, double *scale_value, double scale_default) {
585
586 enum {
587 SCALE_HAS_DEFAULT = 1,
588 SCALE_IS_DEFINED = 1,
589 };
590
591 double const scale_min = -DBL_MAX;
592 double const scale_max = DBL_MAX;
593 enum {
594 SCALE_ALLOW_NAN = 0,
595 SCALE_ALLOW_INF = 0,
596 };
597
598 return yac_param_dble_new(
599 name, scale_value, scale_default, scale_min, scale_max,
600 SCALE_ALLOW_NAN, SCALE_ALLOW_INF, SCALE_HAS_DEFAULT, SCALE_IS_DEFINED);
601}
602
604 struct yac_interp_method_config const *config) {
605 struct yac_interp_method_config_nnn *config_nnn =
607
608 enum {
609 WEIGHTED_HAS_DEFAULT = 1,
610 WEIGHTED_IS_DEFINED = 1,
611 };
612
614 weighted_enum_table,
615 DEF_NAME_TYPE_PAIR(distance_weighted, YAC_INTERP_NNN_DIST),
617 DEF_NAME_TYPE_PAIR(arithmetic_average, YAC_INTERP_NNN_AVG),
619
620 struct yac_param *weighted_param =
622 "weighted",
623 (int *)&config_nnn->config.type,
625 weighted_enum_table, weighted_enum_table_size,
626 WEIGHTED_HAS_DEFAULT, WEIGHTED_IS_DEFINED);
627
628 struct yac_param *n_param =
630
631 struct yac_param *n_min_param =
633
634 struct yac_param *max_search_distance_param =
637
638 struct yac_param *gauss_scale_param =
640 "gauss_scale",
642
643 struct yac_param *root_param_array[] = {
644 weighted_param,
645 n_param,
646 n_min_param,
647 max_search_distance_param,
648 gauss_scale_param
649 };
650 enum {
651 ROOT_PARAM_ARRAY_SIZE =
652 sizeof(root_param_array) / sizeof(root_param_array[0])
653 };
654
656 "nnn", root_param_array, ROOT_PARAM_ARRAY_SIZE);
657}
658
667
669 struct yac_interp_method_config const *config) {
670 struct yac_interp_method_config_nnn *config_nnn =
672
673 enum {
674 RBF_KERNEL_HAS_DEFAULT = 1,
675 RBF_KERNEL_IS_DEFINED = 1
676 };
677
679 rbf_kernel_enum_table,
680 DEF_NAME_TYPE_PAIR(gauss_kernel, 0),
681 DEF_NAME_TYPE_PAIR(gauss, 0))
682
683 struct yac_param *n_param =
685
686 struct yac_param *n_min_param =
688
689 struct yac_param *max_search_distance_param =
692
693 struct yac_param *rbf_scale_param =
695 "rbf_scale",
697
698 struct yac_param *rbf_kernel_param =
700 "rbf_kernel",
701 &config_nnn->rbf_kernel,
703 rbf_kernel_enum_table, rbf_kernel_enum_table_size,
704 RBF_KERNEL_HAS_DEFAULT, RBF_KERNEL_IS_DEFINED);
705
706 struct yac_param *root_param_array[] = {
707 n_param,
708 n_min_param,
709 max_search_distance_param,
710 rbf_scale_param,
711 rbf_kernel_param,
712 };
713 enum {
714 ROOT_PARAM_ARRAY_SIZE =
715 sizeof(root_param_array) / sizeof(root_param_array[0])
716 };
717
719 "rbf", root_param_array, ROOT_PARAM_ARRAY_SIZE);
720}
721
730
732 struct yac_interp_method_config_nnn *config_nnn = xmalloc(sizeof(*config_nnn));
734 config_nnn->base.root_param_cache = NULL;
736 config_nnn->config = (struct yac_interp_method_nnn_config){
740 .max_search_distance = YAC_INTERP_NNN_MAX_SEARCH_DISTANCE_DEFAULT,
741 .data = {.gauss_scale = YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT},
742 };
743 return (struct yac_interp_method_config *)config_nnn;
744}
745
747 struct yac_interp_method_config_nnn *config_nnn = xmalloc(sizeof(*config_nnn));
749 config_nnn->base.root_param_cache = NULL;
751 config_nnn->config = (struct yac_interp_method_nnn_config){
755 .max_search_distance = YAC_INTERP_RBF_MAX_SEARCH_DISTANCE_DEFAULT,
756 .data = {.rbf_scale = YAC_INTERP_RBF_SCALE_DEFAULT},
757 };
758 return (struct yac_interp_method_config *)config_nnn;
759}
#define YAC_ASSERT(exp, msg)
#define UNUSED(x)
Definition core.h:72
#define DEF_NAME_TYPE_PAIR(NAME, TYPE)
#define DEF_NAME_TYPE_PAIRS(NAME,...)
#define YAC_INSTRUMENT_START(ID)
Enter an instrumented region.
#define YAC_INSTRUMENT_STOP(ID)
Exit an instrumented region entered with YAC_INSTRUMENT_START(ID).
MPI_Comm yac_interp_grid_get_MPI_Comm(struct yac_interp_grid *interp_grid)
struct remote_point * yac_interp_grid_get_tgt_remote_points(struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count)
void yac_interp_grid_get_src_points(struct yac_interp_grid *interp_grid, size_t src_field_idx, size_t **src_indices, size_t *count)
Definition interp_grid.c:87
struct remote_point * yac_interp_grid_get_src_remote_points(struct yac_interp_grid *interp_grid, size_t src_field_idx, size_t *src_points, size_t count)
void yac_interp_grid_do_nnn_search_src(struct yac_interp_grid *interp_grid, yac_coordinate_pointer search_coords, size_t count, size_t n, size_t *src_points, double max_search_distance)
yac_const_coordinate_pointer yac_interp_grid_get_src_field_coords(struct yac_interp_grid *interp_grid, size_t src_field_idx)
void yac_interp_grid_get_tgt_coordinates(struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, yac_coordinate_pointer tgt_coordinates)
void yac_interp_grid_get_src_global_ids(struct yac_interp_grid *interp_grid, size_t *src_points, size_t count, size_t src_field_idx, yac_int *src_global_ids)
void yac_interp_grid_src_global_to_local(struct yac_interp_grid *interp_grid, size_t src_field_idx, yac_int *src_global_ids, size_t count, size_t *src_local_ids)
yac_interpolation_list
@ YAC_N_NEAREST_NEIGHBOR
N-nearest-neighbor interpolation.
@ YAC_RADIAL_BASIS_FUNCTION
Radial basis function interpolation.
#define DEF_INTERP_METHOD_CONFIG_COMPARE_TYPE(TYPE)
#define CHECK_DOUBLE
#define DEF_INTERP_METHOD_CONFIG_TYPE(TYPE)
#define CHECK_ANGLE(FIELD)
static void compute_weights(struct tgt_point_search_data *tgt_point_data, size_t num_tgt_points, struct edge_interp_data *edge_data, size_t num_edges, struct triangle_interp_data *triangle_data, size_t num_triangles, struct weight_vector_data **weights, size_t **num_weights_per_tgt, size_t *total_num_weights)
static void config_nnn_delete(struct yac_interp_method_config *config)
static struct yac_param * config_nnn_get_param(struct yac_interp_method_config const *config)
struct yac_interp_method_config * yac_interp_method_config_default_nnn_new(void)
Creates a nearest-neighbour interpolation method configuration with default parameters.
static struct yac_interp_method_config_vtable yac_interp_method_config_vtable_rbf
static struct yac_interp_method_config * config_nnn_copy(const struct yac_interp_method_config *config)
static enum yac_interpolation_list config_nnn_get_type()
static struct yac_param * config_nnn_get_scale_param(char const *name, double *scale_value, double scale_default)
static size_t do_search_nnn(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights, int *interpolation_complete)
static enum yac_interpolation_list config_rbf_get_type()
static struct yac_interp_method_config_vtable yac_interp_method_config_vtable_nnn
static void delete_nnn(struct interp_method *method)
static struct yac_param * config_nnn_get_max_search_distance_param(struct yac_interp_method_config_nnn *config_nnn, double max_search_distance_default)
static size_t do_search_1nn(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights, int *interpolation_complete)
static struct interp_method * config_nnn_generate(struct yac_interp_method_config const *config)
struct interp_method * yac_interp_method_nnn_new(struct yac_interp_method_nnn_config config)
static struct interp_method_vtable interp_method_1nn_vtable
static int config_nnn_compare(void const *a_, void const *b_)
struct yac_interp_method_config * yac_interp_method_config_default_rbf_new(void)
Creates a radial-basis-function interpolation method configuration with default parameters.
static int get_nnn_n_min(struct yac_interp_method_nnn_config config)
static void interp_weights_add_zero(struct yac_interp_weights *weights, struct remote_points *tgts, struct remote_point src)
static struct interp_method_vtable interp_method_zero_vtable
static struct yac_param * config_nnn_get_n_min_param(struct yac_interp_method_config_nnn *config_nnn, int n_min_default)
static size_t do_search_zero(struct interp_method *method, struct yac_interp_grid *interp_grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights, int *interpolation_complete)
static struct yac_param * config_rbf_get_param(struct yac_interp_method_config const *config)
static struct interp_method_vtable interp_method_nnn_vtable
static struct yac_param * config_nnn_get_n_param(struct yac_interp_method_config_nnn *config_nnn, int n_default)
#define YAC_INTERP_NNN_WEIGHTED_DEFAULT
@ 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
#define YAC_INTERP_RBF_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_RBF_N_DEFAULT
#define YAC_INTERP_NNN_MAX_SEARCH_DISTANCE_DEFAULT
#define YAC_INTERP_RBF_N_MIN_DEFAULT
a value of 0 is interpreted as "use the value of n"
#define YAC_INTERP_NNN_GAUSS_SCALE_DEFAULT
#define YAC_INTERP_RBF_SCALE_DEFAULT
#define YAC_INTERP_NNN_N_DEFAULT
#define YAC_INTERP_RBF_KERNEL_DEFAULT
#define YAC_INTERP_NNN_N_MIN_DEFAULT
a value of 0 is interpreted as "use the value of n"
void yac_interp_compute_weights_gauss(double tgt_coord[3], yac_const_coordinate_pointer src_coords, size_t const n, double *weights, double const gauss_scale)
void yac_interp_compute_weights_avg(double tgt_coord[3], yac_const_coordinate_pointer src_coords, size_t const n, double *weights, double const dummy)
void yac_interp_compute_weights_dist(double tgt_coord[3], yac_const_coordinate_pointer src_coords, size_t const n, double *weights, double const dummy)
void yac_interp_compute_weights_rbf(double tgt_coord[3], yac_const_coordinate_pointer src_coords, size_t const n, double *weights, double const rbf_scale)
#define CHECK_SRC_FIELD_COUNT_SINGLE(INTERP_GRID)
void(* yac_interp_compute_weights_func)(double tgt_coord[3], yac_const_coordinate_pointer src_coords, size_t const n, double *weights, double const scale)
void yac_interp_weights_add_wsum(struct yac_interp_weights *weights, struct remote_points *tgts, size_t *num_src_per_tgt, struct remote_point *srcs, double *w)
void yac_interp_weights_add_direct(struct yac_interp_weights *weights, struct remote_points *tgts, struct remote_point *srcs)
Definition __init__.py:1
struct yac_param * yac_param_dble_new(const char *name, double *value_ptr, double default_value, double value_min, double value_max, int allow_nan, int allow_inf, int has_default, int is_defined)
Create a double parameter.
Definition param_dble.c:166
struct yac_param * yac_param_distance_new(const char *name, double *value_ptr, double default_value, double value_min, double value_max, int has_default, int is_defined)
Create a distance parameter (stored in radians)
struct yac_param * yac_param_enum_new(const char *name, int *value_ptr, int default_value, struct yac_name_type_pair const *enum_table, size_t enum_table_size, int has_default, int is_defined)
Create a new enum parameter for configuration.
Definition param_enum.c:148
struct yac_param * yac_param_int_new(const char *name, int *value_ptr, int default_value, int value_min, int value_max, int has_default, int is_defined)
Create an int parameter.
Definition param_int.c:163
struct yac_param * yac_param_struct_new(const char *name, struct yac_param **subparams, size_t subparam_count)
Create a new struct parameter with a given name and subparameters.
#define xmalloc(size)
Definition ppm_xfuncs.h:66
void(* interp_weights_add)(struct yac_interp_weights *weights, struct remote_points *tgts, struct remote_point *srcs)
struct interp_method_vtable * vtable
struct interp_method_vtable * vtable
yac_interp_compute_weights_func compute_weights
size_t(* do_search)(struct interp_method *method, struct yac_interp_grid *grid, size_t *tgt_points, size_t count, struct yac_interp_weights *weights, int *interpolation_complete)
struct interp_method_vtable * vtable
information (global id and location) about a point that
structure containing the information (global id and location)
struct remote_point * data
Concrete implementation of yac_interp_method_config for the NNN method.
struct yac_interp_method_config base
‍base config object, must be first entry
struct yac_interp_method_nnn_config config
‍method-specific configuration
void(* delete)(struct yac_interp_method_config *config)
struct yac_interp_method_config_vtable const * vtable
union yac_interp_method_nnn_config::@39 data
enum yac_interp_nnn_weight_type type
static struct yac_interp_method_config * config
char const * name
Definition toy_scrip.c:114
void yac_quicksort_index_int_size_t(int *a, size_t n, size_t *idx)
void yac_quicksort_index_size_t_size_t(size_t *a, size_t n, size_t *idx)
#define YAC_ASSERT_F(exp, format,...)
Definition yac_assert.h:39
#define YAC_UNREACHABLE_DEFAULT(msg)
Definition yac_assert.h:56
#define yac_mpi_call(call, comm)
double const (* yac_const_coordinate_pointer)[3]
Definition yac_types.h:22
YAC_INT yac_int
Definition yac_types.h:15
#define yac_int_dt
Definition yac_types.h:18
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:21