26static char const *
grid_names[2] = {
"src_grid",
"tgt_grid"};
32 xt_initialize(MPI_COMM_WORLD);
34 int comm_rank, comm_size;
35 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
36 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
37 MPI_Barrier(MPI_COMM_WORLD);
40 PUT_ERR(
"ERROR: wrong number of processes");
47 MPI_Comm_split(MPI_COMM_WORLD, comm_rank < 2, 0, &
split_comm);
74 double coordinates_y[] = {0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0};
75 double tgt_cell_coordinates_x[] = {0.5,1.5,2.5};
76 double tgt_cell_coordinates_y[] = {0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5};
77 double tgt_cell_coordinates[24][3];
78 int tgt_cell_mask[24] = {1, 1, 1,
86 size_t const num_cells[2][2] = {{3,2}, {3,8}};
87 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
88 size_t local_count[2][2][2] = {{{2,2},{2,2}}, {{3,8}}};
96 utest_generate_basic_grid_data_reg2d(
106 for (
size_t i = 0, k = 0;
i <
num_cells[is_tgt][1]; ++
i)
107 for (
size_t j = 0; j <
num_cells[is_tgt][0]; ++j, ++k)
109 tgt_cell_coordinates_x[j], tgt_cell_coordinates_y[i],
110 tgt_cell_coordinates[k]);
121 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
123 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = 0};
129 for (
int creep_distance = -1; creep_distance <= 7; ++creep_distance) {
142 for (
size_t i = 0;
i < 2; ++
i) {
146 weights, reorder_type[i], 1,
154 double * ref_tgt_field = NULL;
155 double ref_global_tgt_field[9][24] =
235 ref_global_tgt_field[creep_distance+1][
grid_data.cell_ids[
i]];
239 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
240 src_field[i] = (
double)(
grid_data.vertex_ids[
i]);
247 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
248 PUT_ERR(
"wrong interpolation result");
293 double tgt_cell_coordinates_x[] = {0.5,1.5,2.5};
294 double tgt_cell_coordinates_y[] = {0.5,1.5,2.5};
295 double tgt_cell_coordinates[9][3];
299 size_t const num_cells[2][2] = {{1,1}, {3,3}};
300 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
301 size_t local_count[2][2][2] = {{{1,1},{0,1}}, {{3,3}}};
309 utest_generate_basic_grid_data_reg2d(
319 for (
size_t j = 0, k = 0; j <
num_cells[is_tgt][1]; ++j)
320 for (
size_t l = 0; l <
num_cells[is_tgt][0]; ++l, ++k)
322 tgt_cell_coordinates_x[l], tgt_cell_coordinates_y[j],
323 tgt_cell_coordinates[k]);
326 int temp_cell_mask[9];
337 .masks_idx = SIZE_MAX}};
338 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
340 {.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = 0};
356 for (
size_t i = 0;
i < 2; ++
i) {
360 weights, reorder_type[i], 1,
368 double * ref_tgt_field = NULL;
369 double ref_global_tgt_field[9] =
377 for (
size_t j = 0; j <
grid_data.num_cells; ++j) {
379 ref_tgt_field[j] = ref_global_tgt_field[
grid_data.cell_ids[j]];
383 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
390 for (
size_t j = 0; j <
grid_data.num_cells; ++j)
391 if (fabs(ref_tgt_field[j] - tgt_field[j]) > 1e-9)
392 PUT_ERR(
"wrong interpolation result");
422 double coordinates_x[2][8] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},
423 {0.5,1.5,2.5,3.5,4.5,5.5,6.5}};
424 double coordinates_y[2][8] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},
425 {0.5,1.5,2.5,3.5,4.5,5.5,6.5}};
442 size_t const num_cells[2][2] = {{7,7}, {6,6}};
443 size_t local_start[2][2][2] = {{{0,0},{3,0}}, {{0,0}}};
444 size_t local_count[2][2][2] = {{{3,7},{4,7}}, {{6,6}}};
452 utest_generate_basic_grid_data_reg2d(
461 int temp_vertex_mask[8*8];
462 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
463 temp_vertex_mask[i] = vertex_mask[is_tgt][
grid_data.vertex_ids[i]];
470 {{.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = 0}};
471 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
473 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = 0};
479 for (
int creep_distance = -1; creep_distance <= 3; ++creep_distance) {
492 for (
size_t i = 0;
i < 2; ++
i) {
496 weights, reorder_type[i], 1,
504 double * ref_tgt_field = NULL;
505 double ref_global_tgt_field[5][7*7] =
506 {{ 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
507 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
508 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
509 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
510 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
511 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
512 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
513 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
514 12.5, -1.0, -1.0, -1.0, -1.0, -1.0, 18.5,
515 20.5, -1.0, -1.0, -2.0, -1.0, -1.0, 26.5,
516 28.5, -1.0, -2.0, -1.0, -2.0, -1.0, 34.5,
517 36.5, -1.0, -1.0, -2.0, -1.0, -1.0, 42.5,
518 44.5, -1.0, -1.0, -1.0, -1.0, -1.0, 50.5,
519 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
520 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
521 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
522 20.5, 20.5, -1.0, -2.0, -1.0, 26.5, 26.5,
523 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
524 36.5, 36.5, -1.0, -2.0, -1.0, 42.5, 42.5,
525 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
526 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
527 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
528 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
529 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
530 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
531 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
532 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
533 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5},
534 { 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
535 12.5, 9.0, 6.5, 7.5, 8.5, 14.0, 18.5,
536 20.5, 20.5, 13.5, -2.0, 17.5, 26.5, 26.5,
537 28.5, 28.5, -2.0, -1.0, -2.0, 34.5, 34.5,
538 36.5, 36.5, 45.5, -2.0, 49.5, 42.5, 42.5,
539 44.5, 49.0, 54.5, 55.5, 56.5, 54.0, 50.5,
540 52.5, 53.5, 54.5, 55.5, 56.5, 57.5, 58.5}};
545 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i) {
548 ref_global_tgt_field[creep_distance+1][
grid_data.vertex_ids[
i]];
552 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
553 src_field[i] = (
double)(
grid_data.vertex_ids[
i]);
559 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
560 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
561 PUT_ERR(
"wrong interpolation result");
599 size_t const num_cells[2][2] = {{5,1}, {5,3}};
600 size_t local_start[2][2][2] = {{{0,0},{3,0}}, {{0,0}}};
601 size_t local_count[2][2][2] = {{{3,1},{2,1}}, {{5,3}}};
609 utest_generate_basic_grid_data_reg2d(
618 int temp_cell_mask[5*3];
627 {{.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = 0}};
628 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
630 {.location =
YAC_LOC_CELL, .coordinates_idx = SIZE_MAX, .masks_idx = 0};
636 for (
int creep_distance = -1; creep_distance <= 5; ++creep_distance) {
649 for (
size_t i = 0;
i < 2; ++
i) {
653 weights, reorder_type[i], 1,
661 double * ref_tgt_field = NULL;
662 double ref_global_tgt_field[7][7*7] =
663 {{ 0.0, 1.0 , 2.0 , 3.0 , 4.0,
664 0.0, 0.5 , -2.0 , 3.5 , 4.0,
665 0.0, 0.25, 2.0 , 3.75, 4.0},
666 { 0.0, -1.0 , 2.0 , -1.0 , 4.0,
667 -1.0, -1.0 , -2.0 , -1.0 , -1.0,
668 -1.0, -1.0 , -1.0 , -1.0 , -1.0},
669 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
670 0.0, -1.0 , -2.0 , -1.0 , 4.0,
671 -1.0, -1.0 , -1.0 , -1.0 , -1.0},
672 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
673 0.0, 0.5 , -2.0 , 3.5 , 4.0,
674 0.0, -1.0 , -1.0 , -1.0 , 4.0},
675 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
676 0.0, 0.5 , -2.0 , 3.5 , 4.0,
677 0.0, 0.25, -1.0 , 3.75, 4.0},
678 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
679 0.0, 0.5 , -2.0 , 3.5 , 4.0,
680 0.0, 0.25, 2.0 , 3.75, 4.0},
681 { 0.0, 1.0 , 2.0 , 3.0 , 4.0,
682 0.0, 0.5 , -2.0 , 3.5 , 4.0,
683 0.0, 0.25, 2.0 , 3.75, 4.0}};
691 ref_global_tgt_field[creep_distance+1][
grid_data.cell_ids[
i]];
696 src_field[i] = (
double)(
grid_data.cell_ids[
i]);
703 if (fabs(ref_tgt_field[i] - tgt_field[i]) > 1e-9)
704 PUT_ERR(
"wrong interpolation result");
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
size_t yac_basic_grid_add_mask(struct yac_basic_grid *grid, enum yac_location location, int const *mask, size_t count, char const *mask_name)
size_t yac_basic_grid_add_coordinates(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates, size_t count)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
void yac_dist_grid_pair_delete(struct yac_dist_grid_pair *grid_pair)
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)
static void LLtoXYZ_deg(double lon, double lat, double p_out[])
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)
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.
Defines the interface of the interpolation method "base class" in YAC.
struct interp_method * yac_interp_method_avg_new(enum yac_interp_avg_weight_type weight_type, int partial_coverage)
@ YAC_INTERP_AVG_ARITHMETIC
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_CONSERV_DESTAREA
struct interp_method * yac_interp_method_creep_new(int creep_distance)
struct interp_method * yac_interp_method_fixed_new(double value)
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_interp_weights_reorder_type
@ YAC_MAPPING_ON_TGT
weights will be applied at target processes
@ 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
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
static char const * grid_names[2]
static MPI_Comm split_comm