33static char const *
grid_names[2] = {
"src_grid",
"tgt_grid"};
66 double coordinates_x[2][4] = {{0.0,1.0,2.0,3.0}, {0.5,1.5,2.5}};
68 size_t const num_cells[2][2] = {{3,2}, {2,2}};
69 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
70 size_t local_count[2][2][2] = {{{2,2},{2,2}}, {{2,2}}};
78 utest_generate_basic_grid_data_reg2d(
92 .coordinates_idx = SIZE_MAX,
93 .masks_idx = SIZE_MAX}};
94 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
97 .coordinates_idx = SIZE_MAX,
98 .masks_idx = SIZE_MAX};
120 double * tgt_field_buf = NULL;
125 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
126 tgt_field_buf[j] = -42.0;
130 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
131 src_field[j] = -666.0;
137 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
138 if (memcmp(&tgt_field_buf[j], &
fixed_value,
sizeof(
double)) != 0)
139 PUT_ERR_F(
"wrong fixed interpolation result (expected %g, got %g)",
159 MPI_Init(NULL, NULL);
161 xt_initialize(MPI_COMM_WORLD);
163 int comm_rank, comm_size;
164 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
165 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
166 MPI_Barrier(MPI_COMM_WORLD);
169 if (comm_size != 3) {
170 PUT_ERR(
"ERROR: wrong number of processes");
178 MPI_COMM_WORLD, comm_rank < 2, 0, &
split_comm);
187 utest_fixed_value(-1.0);
191 utest_fixed_value(0.0);
195 utest_fixed_value(NAN);
217 double coordinates_x[2][4] = {{0.0,1.0,2.0,3.0}, {0.5,1.5,2.5}};
219 size_t const num_cells[2][2] = {{3,2}, {2,2}};
220 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
221 size_t local_count[2][2][2] = {{{2,2},{2,2}}, {{2,2}}};
223 int global_src_mask[12] = {1, 1, 1, 0,
233 utest_generate_basic_grid_data_reg2d(
245 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
246 src_mask[i] = global_src_mask[
grid_data.vertex_ids[i]];
255 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
257 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
281 double * tgt_field_buf = NULL;
290 double ref_global_tgt_field[9] =
298 for(
size_t j = 0; j<
grid_data.num_vertices; ++j)
299 tgt_field_buf[j] = -42;
300 double * ref_tgt_field =
302 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
303 ref_tgt_field[j] = ref_global_tgt_field[
grid_data.vertex_ids[j]];
307 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
308 if (fabs(ref_tgt_field[j] - tgt_field_buf[j]) > 1e-9)
309 PUT_ERR(
"Test 4: wrong interpolation result (avg+fixed fallback)");
315 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
316 src_field[j] = (
double)(
grid_data.vertex_ids[j]);
339 double coordinates_x[2][4] = {{0.0,1.0,2.0,3.0}, {0.5,1.5,2.5}};
341 size_t const num_cells[2][2] = {{3,2}, {2,2}};
342 size_t local_start[2][2][2] = {{{0,0},{1,0}}, {{0,0}}};
343 size_t local_count[2][2][2] = {{{2,2},{2,2}}, {{2,2}}};
352 utest_generate_basic_grid_data_reg2d(
366 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
368 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
390 double *** src_data =
398 src_data[
c] =
xmalloc(1 *
sizeof(**src_data));
399 src_data[
c][0] = NULL;
407 for(
size_t j = 0; j<
grid_data.num_vertices; ++j)
408 tgt_data[c][j] = -42;
414 for(
size_t j = 0; j<
grid_data.num_vertices; ++j)
415 src_data[c][0][j] = -666;
422 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
423 if (tgt_data[c][j] != 42.0)
424 PUT_ERR(
"Test 5: wrong fixed interpolation result "
425 "(expected 42.0 in all collections)");
428 free(src_data[c][0]);
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
size_t yac_basic_grid_add_mask_nocpy(struct yac_basic_grid *grid, enum yac_location location, int const *mask, char const *mask_name)
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)
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_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 double const fixed_value
static MPI_Comm split_comm
static char const * grid_names[2]
enum yac_interp_weights_reorder_type reorder_types[]
#define PUT_ERR_F(fmt,...)