29static void utest_compute_field_data_XYZ(
30 double (*vertices)[3],
size_t num_vertices,
double * f_v);
31static char const *
grid_names[2] = {
"src_grid",
"tgt_grid"};
37 xt_initialize(MPI_COMM_WORLD);
39 int comm_rank, comm_size;
40 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
41 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
42 MPI_Barrier(MPI_COMM_WORLD);
45 PUT_ERR(
"ERROR: wrong number of processes");
52 MPI_Comm_split(MPI_COMM_WORLD, comm_rank < 1, 0, &
split_comm);
133 enum {NUM_SRC_DECOMP = 2};
137 for (
int case_idx = 0; case_idx < NUM_SRC_DECOMP; ++case_idx) {
140 {{{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}},
141 {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}}};
143 {{{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}},
144 {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}}};
145 size_t const num_cells[2][2] = {{7,7}, {9,9}};
146 size_t local_start[NUM_SRC_DECOMP][2][5][2] =
147 {{{{0,0},{0,2},{0,3},{4,2},{0,5}}, {{0,0}}},
148 {{{0,0},{1,0},{3,0},{3,3},{5,0}}, {{0,0}}}};
149 size_t local_count[NUM_SRC_DECOMP][2][5][2] =
150 {{{{7,2},{4,1},{4,2},{3,3},{7,2}}, {{9,9}}},
151 {{{2,7},{2,7},{2,3},{2,4},{2,7}}, {{9,9}}}};
153 for (
size_t i = 0;
i < 10; ++
i) {
163 utest_generate_basic_grid_data_reg2d(
177 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
179 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
204 double * ref_tgt_field = NULL;
210 utest_compute_field_data_XYZ(
211 grid_data.vertex_coordinates, 100, ref_tgt_field);
212 for (
size_t i = 0;
i < 100; ++
i) tgt_field[i] = -1;
213 num_points[case_idx][
i] =
grid_data.num_vertices;
217 utest_compute_field_data_XYZ(
224 for (
size_t i = 0;
i < 100; ++
i)
225 if (fabs(1.0 - ref_tgt_field[i] / tgt_field[i]) > 1e-2)
226 PUT_ERR(
"wrong interpolation result");
244 for (
int case_idx = 0; case_idx < NUM_SRC_DECOMP; ++case_idx) {
248 if (num_points[0][0] != num_points[case_idx][reorder_type])
249 PUT_ERR(
"error in test setup");
250 for (
size_t i = 0;
i < num_points[0][0]; ++
i)
251 if (tgt_fields[0][0][i] != tgt_fields[case_idx][reorder_type][i])
252 PUT_ERR(
"interpolation results are not "
253 "decomposition-independant");
256 for (
int case_idx = 0; case_idx < NUM_SRC_DECOMP; ++case_idx)
258 ++reorder_type) free(tgt_fields[case_idx][reorder_type]);
318 double coordinates_x[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
319 double coordinates_y[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
320 size_t const num_cells[2][2] = {{7,7}, {9,9}};
321 size_t local_start[2][5][2] = {{{0,0},{0,2},{0,3},{4,2},{0,5}}, {{0,0}}};
322 size_t local_count[2][5][2] = {{{7,2},{4,1},{4,2},{3,3},{7,2}}, {{9,9}}};
324 for (
size_t i = 0;
i < 10; ++
i) {
334 utest_generate_basic_grid_data_reg2d(
347 {{.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX}};
348 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
350 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
375 double * ref_tgt_field = NULL;
381 utest_compute_field_data_XYZ(
382 grid_data.vertex_coordinates, 100, ref_tgt_field);
383 for (
size_t i = 0;
i < 100; ++
i) tgt_field[i] = -1;
386 utest_compute_field_data_XYZ(
393 for (
size_t i = 0;
i < 100; ++
i)
394 if (fabs(1.0 - ref_tgt_field[i] / tgt_field[i]) > 1e-2)
395 PUT_ERR(
"wrong interpolation result");
470 double coordinates_x[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
471 double coordinates_y[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
472 size_t const num_cells[2][2] = {{7,7}, {9,9}};
473 size_t local_start[2][5][2] = {{{0,0},{0,2},{0,3},{4,2},{0,5}}, {{0,0}}};
474 size_t local_count[2][5][2] = {{{7,2},{4,1},{4,2},{3,3},{7,2}}, {{9,9}}};
476 for (
size_t i = 0;
i < 10; ++
i) {
486 utest_generate_basic_grid_data_reg2d(
493 src_point_coordinates =
496 double * middle_point = src_point_coordinates[
i];
497 for (
size_t k = 0; k < 3; ++k) middle_point[k] = 0.0;
498 size_t * curr_vertices =
501 for (
size_t j = 0; j < curr_num_vertices; ++j) {
502 double * curr_vertex_coord =
503 grid_data.vertex_coordinates[curr_vertices[j]];
504 for (
size_t k = 0; k < 3; ++k)
505 middle_point[k] += curr_vertex_coord[k];
521 {{.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = SIZE_MAX}};
522 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
524 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
549 double * ref_tgt_field = NULL;
555 utest_compute_field_data_XYZ(
556 grid_data.vertex_coordinates, 100, ref_tgt_field);
557 for (
size_t i = 0;
i < 100; ++
i) tgt_field[i] = -1;
560 utest_compute_field_data_XYZ(
561 src_point_coordinates,
grid_data.num_cells, src_field);
567 for (
size_t i = 0;
i < 100; ++
i)
568 if (fabs(1.0 - ref_tgt_field[i] / tgt_field[i]) > 1e-2)
569 PUT_ERR(
"wrong interpolation result");
645 double coordinates_x[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
646 double coordinates_y[2][10] = {{0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0},{-1.0}};
647 size_t const num_cells[2][2] = {{7,7}, {9,9}};
648 size_t local_start[2][5][2] = {{{0,0},{0,2},{0,3},{4,2},{0,5}}, {{0,0}}};
649 size_t local_count[2][5][2] = {{{7,2},{4,1},{4,2},{3,3},{7,2}}, {{9,9}}};
651 for (
size_t i = 0;
i < 10; ++
i) {
661 utest_generate_basic_grid_data_reg2d(
668 src_point_coordinates =
671 double * middle_point = src_point_coordinates[
i];
672 for (
size_t k = 0; k < 3; ++k) middle_point[k] = 0.0;
673 size_t * curr_vertices =
676 for (
size_t j = 0; j < curr_num_vertices; ++j) {
677 double * curr_vertex_coord =
678 grid_data.vertex_coordinates[curr_vertices[j]];
679 for (
size_t k = 0; k < 3; ++k)
680 middle_point[k] += curr_vertex_coord[k];
696 {{.location =
YAC_LOC_CELL, .coordinates_idx = 0, .masks_idx = SIZE_MAX}};
697 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
699 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
724 double * ref_tgt_field = NULL;
727 int is_outside_src_grid[] = {
728 0,0,0,0,0,0,1,1,1,1,
729 0,0,0,0,0,0,1,1,1,1,
730 0,0,0,0,0,0,1,1,1,1,
731 0,0,0,0,0,0,1,1,1,1,
732 0,0,0,0,0,0,1,1,1,1,
733 0,0,0,0,0,0,1,1,1,1,
734 1,1,1,1,1,1,1,1,1,1,
735 1,1,1,1,1,1,1,1,1,1,
736 1,1,1,1,1,1,1,1,1,1,
737 1,1,1,1,1,1,1,1,1,1};
741 utest_compute_field_data_XYZ(
742 grid_data.vertex_coordinates, 100, ref_tgt_field);
743 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i)
744 if (is_outside_src_grid[
grid_data.vertex_ids[i]])
745 ref_tgt_field[
i] = -1.0;
746 for (
size_t i = 0;
i < 100; ++
i) tgt_field[i] = -2.0;
749 utest_compute_field_data_XYZ(
750 src_point_coordinates,
grid_data.num_cells, src_field);
756 for (
size_t i = 0;
i < 100; ++
i)
757 if (fabs(1.0 - ref_tgt_field[i] / tgt_field[i]) > 1e-2)
758 PUT_ERR(
"wrong interpolation result");
834 {{72.00,72.25,72.50,72.75,73.00,73.25,73.5,73.75},{-1.0}};
836 {{90.0,89.75,89.50,89.25,89.00,88.75,88.50,88.25},{-1.0}};
837 size_t const num_cells[2][2] = {{7,7}, {9,9}};
838 size_t local_start[2][5][2] = {{{0,0},{0,2},{0,3},{4,2},{0,5}}, {{0,0}}};
839 size_t local_count[2][5][2] = {{{7,2},{4,1},{4,2},{3,3},{7,2}}, {{9,9}}};
841 for (
size_t i = 0;
i < 10; ++
i) {
851 utest_generate_basic_grid_data_reg2d(
865 vertex_coordinates,
grid_data.vertex_coordinates,
866 grid_data.num_vertices *
sizeof(*vertex_coordinates));
869 for (
size_t i = 0;
i <
grid_data.num_vertices; ++
i) {
870 if (fabs(1.0 - fabs(vertex_coordinates[i][2])) < 1e-9) {
871 vertex_coordinates[
i][0] = 0.0;
872 vertex_coordinates[
i][1] = 0.0;
883 {{.location =
YAC_LOC_CORNER, .coordinates_idx = 0, .masks_idx = SIZE_MAX}};
884 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
886 {.location =
YAC_LOC_CORNER, .coordinates_idx = SIZE_MAX, .masks_idx = SIZE_MAX};
911 double * ref_tgt_field = NULL;
917 utest_compute_field_data_XYZ(
918 grid_data.vertex_coordinates, 100, ref_tgt_field);
919 for (
size_t i = 0;
i < 100; ++
i) tgt_field[i] = -1;
922 utest_compute_field_data_XYZ(
929 for (
size_t i = 0;
i < 100; ++
i)
930 if (fabs(1.0 - ref_tgt_field[i] / tgt_field[i]) > 1e-2)
931 PUT_ERR(
"wrong interpolation result");
963 {13.0, 8.5, 8.4999999999999982, 10.6, 9.3000000000000007, 10.9,
966 {20.0, 22.598076211353316, 17.401923788646684, 19.399999999999999,
967 20.800000000000001, 20.899999999999999, 20.160148507481018};
970 enum {NUM_SRC_CELLS = 9};
971 int src_num_vertices_per_cell[NUM_SRC_CELLS] =
972 {3, 3, 3, 3, 3, 3, 3, 3, 3};
973 int src_cell_to_vertex[NUM_SRC_CELLS * 3] =
974 {0,3,2, 1,5,0, 6,3,0, 5,6,0, 6,5,3, 4,5,1, 5,4,3, 4,1,2, 3,4,2};
979 {10.903688, 10.266667, 11.603688, 9.466667};
981 {20.153383, 20.366667, 19.853383, 19.200641};
991 src_coordinates_x, src_coordinates_y, src_cell_to_vertex);
1002 .masks_idx = SIZE_MAX}};
1003 size_t num_src_fields =
sizeof(src_fields) /
sizeof(src_fields[0]);
1006 .masks_idx = SIZE_MAX};
1035 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
1039 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
1046 for (
size_t j = 0; j <
grid_data.num_vertices; ++j)
1048 PUT_ERR(
"wrong interpolation result");
1073#if defined __INTEL_COMPILER
1074#pragma intel optimization_level 0
1078static void utest_compute_field_data_XYZ(
1079 double (*vertices)[3],
size_t num_vertices,
double * f_v) {
1081 for (
size_t i = 0;
i < num_vertices; ++
i) {
1083 double x = vertices[
i][0];
1084 double y = vertices[
i][1];
1085 double z = vertices[
i][2];
1088 f_v[
i] = 1.0 + pow(x, 8.0);
1089 f_v[
i] += exp(2.0*y*y*y);
1090 f_v[
i] += exp(2.0*x*x) + 10.0*
x*
y*z;
struct yac_basic_grid * yac_basic_grid_new(char const *name, struct yac_basic_grid_data grid_data)
size_t yac_basic_grid_add_coordinates_nocpy(struct yac_basic_grid *grid, enum yac_location location, yac_coordinate_pointer coordinates)
struct yac_basic_grid * yac_basic_grid_empty_new(char const *name)
void yac_basic_grid_delete(struct yac_basic_grid *grid)
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct_deg(size_t nbr_vertices, size_t nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex)
struct yac_basic_grid_data yac_generate_basic_grid_data_cloud_deg(size_t nbr_points, double *x_points, double *y_points)
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 normalise_vector(double v[])
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_fixed_new(double value)
struct interp_method * yac_interp_method_hcsbb_new()
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
int * num_vertices_per_cell
enum yac_location location
struct yac_interp_field tgt_field
struct yac_dist_grid_pair * grid_pair
struct yac_interp_field src_fields[]
static MPI_Comm split_comm
static char const * grid_names[2]
enum yac_interp_weights_reorder_type reorder_types[]
static double tgt_field_data[MAX_COLLECTION_SIZE][NUM_TGT_POINTS]
double(* yac_coordinate_pointer)[3]