29static void utest_test_grid_data__1x1(
32 double ref_coords_x[4] = {0.5,1.5,0.5,1.5};
33 double ref_coords_y[4] = {0.5,0.5,1.5,1.5};
34 double vertex_coordinates[4][3];
35 for (
size_t i = 0;
i < 4; ++
i)
36 LLtoXYZ_deg(ref_coords_x[i], ref_coords_y[i], vertex_coordinates[i]);
43 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
53 .core_cell_mask = NULL,
54 .core_vertex_mask = NULL,
55 .core_edge_mask = NULL,
56 .num_vertices_per_cell = (
int[]){4},
57 .num_cells_per_vertex = (
int[]){1,1,1,1},
58 .cell_to_vertex = (
size_t[]){0,1,3,2},
59 .cell_to_vertex_offsets = (
size_t[]){0},
60 .cell_to_edge = (
size_t[]){0,2,3,1},
61 .cell_to_edge_offsets = (
size_t[]){0},
62 .vertex_to_cell = (
size_t[]){0,0,0,0},
63 .vertex_to_cell_offsets = (
size_t[]){0,1,2,3},
64 .edge_to_vertex = (
size_t[][2]){{0,1},{0,2},{1,3},{2,3}},
65 .edge_type = ref_edge_type,
67 .num_total_vertices = 4,
68 .num_total_edges = 4};
73static void utest_test_grid_data__2x2(
76 double ref_coords_x[9] = {0,1,2,0,1,2,0,1,2};
77 double ref_coords_y[9] = {0,0,0,1,1,1,2,2,2};
79 for (
size_t i = 0;
i < 9; ++
i)
91 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
101 .core_cell_mask = NULL,
102 .core_vertex_mask = NULL,
103 .core_edge_mask = NULL,
104 .num_vertices_per_cell = (
int[]){4,4,4,4},
105 .num_cells_per_vertex = (
int[]){1,2,1, 2,4,2, 1,2,1},
106 .cell_to_vertex = (
size_t[]){0,1,4,3, 1,2,5,4, 3,4,7,6, 4,5,8,7},
107 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12},
108 .cell_to_edge = (
size_t[]){0,3,5,1, 2,4,7,3, 5,8,10,6, 7,9,11,8},
109 .cell_to_edge_offsets = (
size_t[]){0,4,8,12},
110 .vertex_to_cell = (
size_t[]){0, 0,1, 1, 0,2, 0,1,2,3, 1,3, 2, 2,3, 3},
111 .vertex_to_cell_offsets = (
size_t[]){0, 1, 3, 4, 6, 10, 12, 13, 15, 16},
112 .edge_to_vertex = (
size_t[][2]){{0,1},{0,3},{1,2},{1,4},{2,5},
113 {3,4},{3,6},{4,5},{4,7},{5,8},
115 .edge_type = ref_edge_type,
116 .num_total_cells = 4,
117 .num_total_vertices = 9,
118 .num_total_edges = 12};
120 double ref_cell_areas[4];
122 double cell_coords_x[2][4] = {{0,1,1,0},{1,2,2,1}};
123 double cell_coords_y[2][4] = {{0,0,1,1},{1,1,2,2}};
129 for (
size_t i = 0, k = 0;
i < 2; ++
i) {
130 for (
size_t j = 0; j < 2; ++j, ++k) {
133 cell_coords_x[j], cell_coords_y[i], edge_types[
type ==
REG2D], 4);
140 double cell_areas[4];
143 for (
size_t i = 0;
i < 4; ++
i)
144 if (fabs(ref_cell_areas[i] - cell_areas[i]) >
YAC_AREA_TOL)
145 PUT_ERR(
"ERROR in yac_basic_grid_data_compute_cell_areas");
150static void utest_test_grid_data__2x3(
153 double ref_coords_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
154 double ref_coords_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
155 double vertex_coordinates[12][3];
156 for (
size_t i = 0;
i < 12; ++
i)
157 LLtoXYZ_deg(ref_coords_x[i], ref_coords_y[i], vertex_coordinates[i]);
172 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
182 .core_cell_mask = NULL,
183 .core_vertex_mask = NULL,
184 .core_edge_mask = NULL,
185 .num_vertices_per_cell = (
int[]){4,4,4,4,4,4},
186 .num_cells_per_vertex = (
int[]){1,2,1, 2,4,2, 2,4,2, 1,2,1},
187 .cell_to_vertex = (
size_t[]){0,1,4,3, 1,2,5,4, 3,4,7,6, 4,5,8,7,
188 6,7,10,9, 7,8,11,10},
189 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12,16,20},
190 .cell_to_edge = (
size_t[]){0,3,5,1, 2,4,7,3, 5,8,10,6,
191 7,9,12,8, 10,13,15,11, 12,14,16,13},
192 .cell_to_edge_offsets = (
size_t[]){0,4,8,12,16,20},
193 .vertex_to_cell = (
size_t[]){0, 0,1, 1, 0,2, 0,1,2,3, 1,3,
194 2,4, 2,3,4,5, 3,5, 4, 4,5, 5},
195 .vertex_to_cell_offsets = (
size_t[]){0,1,3,4,6,10,12,14,18,20,21,23,24},
196 .edge_to_vertex = (
size_t[][2]){{0,1},{0,3},{1,2},{1,4},{2,5},
197 {3,4},{3,6},{4,5},{4,7},{5,8},
198 {6,7},{6,9},{7,8},{7,10},{8,11},
200 .edge_type = ref_edge_type,
201 .num_total_cells = 6,
202 .num_total_vertices = 12,
203 .num_total_edges = 17};
208static void utest_test_grid_data__3x3(
211 double ref_coords_x[16] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
212 double ref_coords_y[16] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
214 for (
size_t i = 0;
i < 16; ++
i)
232 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
242 .core_cell_mask = NULL,
243 .core_vertex_mask = NULL,
244 .core_edge_mask = NULL,
245 .num_vertices_per_cell = (
int[]){4,4,4,4,4,4,4,4,4},
246 .num_cells_per_vertex = (
int[]){1,2,2,1, 2,4,4,2, 2,4,4,2, 1,2,2,1},
247 .cell_to_vertex = (
size_t[]){0,1,5,4, 1,2,6,5, 2,3,7,6,
248 4,5,9,8, 5,6,10,9, 6,7,11,10,
249 8,9,13,12, 9,10,14,13, 10,11,15,14},
250 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12,16,20,24,28,32},
251 .cell_to_edge = (
size_t[]){0,3,7,1, 2,5,9,3, 4,6,11,5,
252 7,10,14,8, 9,12,16,10, 11,13,18,12,
253 14,17,21,15, 16,19,22,17, 18,20,23,19},
254 .cell_to_edge_offsets = (
size_t[]){0,4,8, 12,16,20, 24,28,32},
255 .vertex_to_cell = (
size_t[]){0, 0,1, 1,2, 2,
256 0,3, 0,1,3,4, 1,2,4,5, 2,5,
257 3,6, 3,4,6,7, 4,5,7,8, 5,8,
259 .vertex_to_cell_offsets = (
size_t[]){0,1,3,5,
263 .edge_to_vertex = (
size_t[][2]){{0,1},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},
264 {4,5},{4,8},{5,6},{5,9},{6,7},{6,10},{7,11},
265 {8,9},{8,12},{9,10},{9,13},{10,11},{10,14},{11,15},
266 {12,13},{13,14},{14,15}},
267 .edge_type = ref_edge_type,
268 .num_total_cells = 9,
269 .num_total_vertices = 16,
270 .num_total_edges = 24};
275static void utest_test_grid_data__3x3_cloud(
278 double ref_coords_x[16] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
279 double ref_coords_y[16] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
281 for (
size_t i = 0;
i < 16; ++
i)
292 .core_cell_mask = NULL,
293 .core_vertex_mask = NULL,
294 .core_edge_mask = NULL,
295 .num_vertices_per_cell = NULL,
296 .num_cells_per_vertex = (
int[]){0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0},
297 .cell_to_vertex = NULL,
298 .cell_to_vertex_offsets = NULL,
299 .cell_to_edge = NULL,
300 .cell_to_edge_offsets = NULL,
301 .vertex_to_cell = NULL,
302 .vertex_to_cell_offsets = (
size_t[]){0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0},
303 .edge_to_vertex = NULL,
305 .num_total_cells = 0,
306 .num_total_vertices = 16,
307 .num_total_edges = 0};
312static void utest_test_grid_data__3x3_reg2d_rot(
316 double ref_coords_x[16] = {-1.5,-0.5,0.5,1.5,
320 double ref_coords_y[16] = {-1.5,-1.5,-1.5,-1.5,
325 for (
size_t i = 0;
i < 16; ++
i) {
327 LLtoXYZ_deg(ref_coords_x[i], ref_coords_y[i], temp);
347 .core_cell_mask = NULL,
348 .core_vertex_mask = NULL,
349 .core_edge_mask = NULL,
350 .num_vertices_per_cell = (
int[]){4,4,4,4,4,4,4,4,4},
351 .num_cells_per_vertex = (
int[]){1,2,2,1, 2,4,4,2, 2,4,4,2, 1,2,2,1},
352 .cell_to_vertex = (
size_t[]){0,1,5,4, 1,2,6,5, 2,3,7,6,
353 4,5,9,8, 5,6,10,9, 6,7,11,10,
354 8,9,13,12, 9,10,14,13, 10,11,15,14},
355 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12,16,20,24,28,32},
356 .cell_to_edge = (
size_t[]){0,3,7,1, 2,5,9,3, 4,6,11,5,
357 7,10,14,8, 9,12,16,10, 11,13,18,12,
358 14,17,21,15, 16,19,22,17, 18,20,23,19},
359 .cell_to_edge_offsets = (
size_t[]){0,4,8, 12,16,20, 24,28,32},
360 .vertex_to_cell = (
size_t[]){0, 0,1, 1,2, 2,
361 0,3, 0,1,3,4, 1,2,4,5, 2,5,
362 3,6, 3,4,6,7, 4,5,7,8, 5,8,
364 .vertex_to_cell_offsets = (
size_t[]){0,1,3,5,
368 .edge_to_vertex = (
size_t[][2]){{0,1},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},
369 {4,5},{4,8},{5,6},{5,9},{6,7},{6,10},{7,11},
370 {8,9},{8,12},{9,10},{9,13},{10,11},{10,14},{11,15},
371 {12,13},{13,14},{14,15}},
372 .edge_type = unstruct_edge_type,
373 .num_total_cells = 9,
374 .num_total_vertices = 16,
375 .num_total_edges = 24};
380static void utest_test_grid_data__3x2(
383 double ref_coords_x[12] = {0,1,2,3,0,1,2,3,0,1,2,3};
384 double ref_coords_y[12] = {0,0,0,0,1,1,1,1,2,2,2,2};
386 for (
size_t i = 0;
i < 12; ++
i)
402 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
412 .core_cell_mask = NULL,
413 .core_vertex_mask = NULL,
414 .core_edge_mask = NULL,
415 .num_vertices_per_cell = (
int[]){4,4,4,4,4,4},
416 .num_cells_per_vertex = (
int[]){1,2,2,1, 2,4,4,2, 1,2,2,1},
417 .cell_to_vertex = (
size_t[]){0,1,5,4, 1,2,6,5, 2,3,7,6,
418 4,5,9,8, 5,6,10,9, 6,7,11,10},
419 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12,16,20},
420 .cell_to_edge = (
size_t[]){0,3,7,1, 2,5,9,3, 4,6,11,5,
421 7,10,14,8, 9,12,15,10, 11,13,16,12},
422 .cell_to_edge_offsets = (
size_t[]){0,4,8, 12,16,20},
423 .vertex_to_cell = (
size_t[]){0, 0,1, 1,2, 2,
424 0,3, 0,1,3,4, 1,2,4,5, 2,5,
426 .vertex_to_cell_offsets = (
size_t[]){0,1,3,5,
429 .edge_to_vertex = (
size_t[][2]){{0,1},{0,4},{1,2},{1,5},{2,3},{2,6},{3,7},
430 {4,5},{4,8},{5,6},{5,9},{6,7},{6,10},{7,11},
431 {8,9},{9,10},{10,11}},
432 .edge_type = ref_edge_type,
433 .num_total_cells = 6,
434 .num_total_vertices = 12,
435 .num_total_edges = 17};
440static void utest_test_grid_data__1x4(
443 double ref_coords_x[10] = {0,1,0,1,0,1,0,1,0,1};
444 double ref_coords_y[10] = {0,0,1,1,2,2,3,3,4,4};
446 for (
size_t i = 0;
i < 10; ++
i)
462 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
472 .core_cell_mask = NULL,
473 .core_vertex_mask = NULL,
474 .core_edge_mask = NULL,
475 .num_vertices_per_cell = (
int[]){4,4,4,4},
476 .num_cells_per_vertex = (
int[]){1,1, 2,2, 2,2, 2,2, 1,1},
477 .cell_to_vertex = (
size_t[]){0,1,3,2, 2,3,5,4, 4,5,7,6, 6,7,9,8},
478 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12},
479 .cell_to_edge = (
size_t[]){0,2,3,1, 3,5,6,4, 6,8,9,7, 9,11,12,10},
480 .cell_to_edge_offsets = (
size_t[]){0,4,8,12},
481 .vertex_to_cell = (
size_t[]){0, 0, 0,1, 0,1, 1,2, 1,2, 2,3, 2,3, 3, 3},
482 .vertex_to_cell_offsets = (
size_t[]){0,1,2,4,6,8,10,12,14,15},
483 .edge_to_vertex = (
size_t[][2]){{0,1},{0,2},{1,3},
488 .edge_type = ref_edge_type,
489 .num_total_cells = 4,
490 .num_total_vertices = 10,
491 .num_total_edges = 13};
496static void utest_test_grid_data__4x1(
499 double ref_coords_x[10] = {0,1,2,3,4,0,1,2,3,4};
500 double ref_coords_y[10] = {0,0,0,0,0,1,1,1,1,1};
502 for (
size_t i = 0;
i < 10; ++
i)
516 (
type ==
REG2D)?reg2d_edge_type:unstruct_edge_type;
526 .core_cell_mask = NULL,
527 .core_vertex_mask = NULL,
528 .core_edge_mask = NULL,
529 .num_vertices_per_cell = (
int[]){4,4,4,4},
530 .num_cells_per_vertex = (
int[]){1,2,2,2,1, 1,2,2,2,1},
531 .cell_to_vertex = (
size_t[]){0,1,6,5, 1,2,7,6, 2,3,8,7, 3,4,9,8},
532 .cell_to_vertex_offsets = (
size_t[]){0,4,8,12},
533 .cell_to_edge = (
size_t[]){0,3,9,1, 2,5,10,3, 4,7,11,5, 6,8,12,7},
534 .cell_to_edge_offsets = (
size_t[]){0,4,8,12},
535 .vertex_to_cell = (
size_t[]){0, 0,1, 1,2, 2,3, 3,
536 0, 0,1, 1,2, 2,3, 3},
537 .vertex_to_cell_offsets = (
size_t[]){0,1,3,5,7, 8,9,11,13,15},
538 .edge_to_vertex = (
size_t[][2]){{0,1},{0,5},{1,2},{1,6},{2,3},{2,7},{3,4},{3,8},{4,9},
539 {5,6},{6,7},{7,8},{8,9}},
540 .edge_type = ref_edge_type,
541 .num_total_cells = 4,
542 .num_total_vertices = 10,
543 .num_total_edges = 13};
548static void utest_test_grid_data__6x4_cyclic(
551 double ref_coords_x[6] = {0,60,120,180,240,300};
552 double ref_coords_y[5] = {-89,-45,0,45,89};
554 for (
size_t i = 0, k = 0;
i < 5; ++
i)
555 for (
size_t j = 0; j < 6; ++j, ++k)
588 .core_cell_mask = NULL,
589 .core_vertex_mask = NULL,
590 .core_edge_mask = NULL,
591 .num_vertices_per_cell = (
int[]){4,4,4,4,4,4,
595 .num_cells_per_vertex = (
int[]){2,2,2,2,2,2,
600 .cell_to_vertex = (
size_t[]){0,1,7,6, 1,2,8,7, 2,3,9,8, 3,4,10,9, 4,5,11,10, 5,0,6,11,
601 6,7,13,12, 7,8,14,13, 8,9,15,14, 9,10,16,15, 10,11,17,16, 11,6,12,17,
602 12,13,19,18, 13,14,20,19, 14,15,21,20, 15,16,22,21, 16,17,23,22, 17,12,18,23,
603 18,19,25,24, 19,20,26,25, 20,21,27,26, 21,22,28,27, 22,23,29,28, 23,18,24,29},
605 .cell_to_edge = (
size_t[]){0,4,12,2, 3,6,15,4, 5,8,17,6, 7,10,19,8, 9,11,21,10, 1,2,13,11,
606 12,16,24,14, 15,18,27,16, 17,20,29,18, 19,22,31,20, 21,23,33,22, 13,14,25,23,
607 24,28,36,26, 27,30,39,28, 29,32,41,30, 31,34,43,32, 33,35,45,34, 25,26,37,35,
608 36,40,48,38, 39,42,50,40, 41,44,51,42, 43,46,52,44, 45,47,53,46, 37,38,49,47},
610 .vertex_to_cell = (
size_t[]){0,5, 0,1, 1,2, 2,3, 3,4, 4,5,
611 0,6,11,5, 0,1,7,6, 1,2,8,7, 2,3,9,8, 3,4,10,9, 4,5,11,10,
612 6,12,17,11, 6,7,13,12, 7,8,14,13, 8,9,15,14, 9,10,16,15, 10,11,17,16,
613 12,18,23,17, 12,13,19,18, 13,14,20,19, 14,15,21,20, 15,16,22,21, 16,17,23,22,
614 18,23, 18,19, 19,20, 20,21, 21,22, 22,23},
616 .edge_to_vertex = (
size_t[][2]){{0,1},{0,5},{0,6},{1,2},{1,7},{2,3},{2,8},{3,4},{3,9},{4,5},{4,10},{5,11},
617 {6,7},{6,11},{6,12},{7,8},{7,13},{8,9},{8,14},{9,10},{9,15},{10,11},{10,16},{11,17},
618 {12,13},{12,17},{12,18},{13,14},{13,19},{14,15},{14,20},{15,16},{15,21},{16,17},{16,22},{17,23},
619 {18,19},{18,23},{18,24},{19,20},{19,25},{20,21},{20,26},{21,22},{21,27},{22,23},{22,28},{23,29},
620 {24,25},{24,29},{25,26},{26,27},{27,28},{28,29}},
621 .edge_type = ref_edge_type,
622 .num_total_cells = 24,
623 .num_total_vertices = 30,
624 .num_total_edges = 54};
633 double tmp_coordinates_xyz[num_corners][3];
634 for (
size_t i = 0; i < num_corners; ++i)
650 .edge_type = tmp_edge_type,
656 for (
int order = -1; order < 2; order += 2) {
666 corner_indices[k] = (size_t)idx;
678 for (
size_t m = 0; m < 3; ++m)
682 PUT_ERR(
"error in yac_triangulate_cell_indices");
684 double total_area = 0.0;
690 PUT_ERR(
"wrong number of corners in triangle\n");
695 if (fabs(total_area - cell_area) > 1e-9)
696 PUT_ERR(
"error in cell triangulation\n");
710 double coord_x[2] = {0.5,1.5};
711 double coord_y[2] = {0.5,1.5};
713 size_t num_vertices[2] = {2,2};
720 utest_test_grid_data__1x1(reg_grid,
"regular 2d grid",
REG2D);
729 double coord_x[4] = {0.5,1.5,0.5,1.5};
730 double coord_y[4] = {0.5,0.5,1.5,1.5};
739 utest_test_grid_data__1x1(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
746 double coord_x[4] = {0.5,1.5,0.5,1.5};
747 double coord_y[4] = {0.5,0.5,1.5,1.5};
756 utest_test_grid_data__1x1(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
765 double coord_x[4] = {0.5,1.5,0.5,1.5};
766 double coord_y[4] = {0.5,0.5,1.5,1.5};
775 utest_test_grid_data__1x1(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
786 double coord_x[4] = {0.5,1.5,0.5,1.5};
787 double coord_y[4] = {0.5,0.5,1.5,1.5};
788 int num_edges_per_cell[] = {4};
797 utest_test_grid_data__1x1(
798 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
809 double coord_x[4] = {0.5,1.5,0.5,1.5};
810 double coord_y[4] = {0.5,0.5,1.5,1.5};
811 int num_edges_per_cell[] = {4};
820 utest_test_grid_data__1x1(
821 unstruct_edge_grid,
"unstructured edge 2d grid",
REG2D);
828 double coord_x[3] = {0,1,2};
829 double coord_y[3] = {0,1,2};
838 utest_test_grid_data__2x2(reg_grid,
"regular 2d grid",
REG2D);
847 double coord_x[9] = {0,1,2,0,1,2,0,1,2};
848 double coord_y[9] = {0,0,0,1,1,1,2,2,2};
850 int cell_to_vertex[16] = {0,1,4,3, 1,2,5,4, 3,4,7,6, 4,5,8,7};
857 utest_test_grid_data__2x2(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
864 double coord_x[9] = {0,1,2,0,1,2,0,1,2};
865 double coord_y[9] = {0,0,0,1,1,1,2,2,2};
874 utest_test_grid_data__2x2(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
883 double coord_x[9] = {0,1,2,0,1,2,0,1,2};
884 double coord_y[9] = {0,0,0,1,1,1,2,2,2};
886 int cell_to_vertex[16] = {0,1,4,3, 1,2,5,4, 3,4,7,6, 4,5,8,7};
893 utest_test_grid_data__2x2(
894 unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
905 double coord_x[9] = {0,1,2,0,1,2,0,1,2};
906 double coord_y[9] = {0,0,0,1,1,1,2,2,2};
907 int num_edges_per_cell[4] = {4,4,4,4};
908 int cell_to_edge[] = {0,3,5,1, 2,4,7,3, 5,8,10,6, 7,9,11,8};
909 int edge_to_vertex[] = {0,1, 0,3, 1,2, 1,4, 2,5,
910 3,4, 3,6, 4,5, 4,7, 5,8,
918 utest_test_grid_data__2x2(
919 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
930 double coord_x[9] = {0,1,2,0,1,2,0,1,2};
931 double coord_y[9] = {0,0,0,1,1,1,2,2,2};
932 int num_edges_per_cell[4] = {4,4,4,4};
933 int cell_to_edge[] = {0,3,5,1, 2,4,7,3, 5,8,10,6, 7,9,11,8};
934 int edge_to_vertex[] = {0,1, 0,3, 1,2, 1,4, 2,5,
935 3,4, 3,6, 4,5, 4,7, 5,8,
943 utest_test_grid_data__2x2(
944 unstruct_edge_grid,
"unstructured edge lonlat 2d grid",
REG2D);
951 double coord_x[3] = {0,1,2};
952 double coord_y[4] = {0,1,2,3};
961 utest_test_grid_data__2x3(reg_grid,
"regular 2d grid",
REG2D);
970 double coord_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
971 double coord_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
975 6,7,10,9, 7,8,11,10};
982 utest_test_grid_data__2x3(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
989 double coord_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
990 double coord_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
999 utest_test_grid_data__2x3(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
1008 double coord_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
1009 double coord_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
1013 6,7,10,9, 7,8,11,10};
1020 utest_test_grid_data__2x3(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
1031 double coord_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
1032 double coord_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
1033 int num_edges_per_cell[6] = {4,4,4,4,4,4};
1036 10,13,15,11, 12,14,16,13};
1037 int edge_to_vertex[] = {0,1, 0,3, 1,2, 1,4, 2,5,
1038 3,4, 3,6, 4,5, 4,7, 5,8,
1039 6,7, 6,9, 7,8, 7,10, 8,11,
1047 utest_test_grid_data__2x3(
1048 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
1059 double coord_x[12] = {0,1,2,0,1,2,0,1,2,0,1,2};
1060 double coord_y[12] = {0,0,0,1,1,1,2,2,2,3,3,3};
1061 int num_edges_per_cell[6] = {4,4,4,4,4,4};
1064 10,13,15,11, 12,14,16,13};
1065 int edge_to_vertex[] = {0,1, 0,3, 1,2, 1,4, 2,5,
1066 3,4, 3,6, 4,5, 4,7, 5,8,
1067 6,7, 6,9, 7,8, 7,10, 8,11,
1075 utest_test_grid_data__2x3(
1076 unstruct_edge_grid,
"unstructured edge lonlat 2d grid",
REG2D);
1083 double coord_x[] = {0,1,2,3};
1084 double coord_y[] = {0,1,2,3};
1093 utest_test_grid_data__3x3(reg_grid,
"regular 2d grid",
REG2D);
1102 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1103 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1105 int cell_to_vertex[] = {0,1,5,4, 1,2,6,5, 2,3,7,6,
1106 4,5,9,8, 5,6,10,9, 6,7,11,10,
1107 8,9,13,12, 9,10,14,13, 10,11,15,14};
1114 utest_test_grid_data__3x3(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
1121 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1122 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1131 utest_test_grid_data__3x3(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
1140 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1141 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1143 int cell_to_vertex[] = {0,1,5,4, 1,2,6,5, 2,3,7,6,
1144 4,5,9,8, 5,6,10,9, 6,7,11,10,
1145 8,9,13,12, 9,10,14,13, 10,11,15,14};
1152 utest_test_grid_data__3x3(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
1163 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1164 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1165 int num_edges_per_cell[] = {4,4,4, 4,4,4, 4,4,4};
1166 int cell_to_edge[] = {0,3,7,1, 2,5,9,3, 4,6,11,5,
1167 7,10,14,8, 9,12,16,10, 11,13,18,12,
1168 14,17,21,15, 16,19,22,17, 18,20,23,19};
1169 int edge_to_vertex[] = {0,1, 0,4, 1,2, 1,5, 2,3, 2,6, 3,7,
1170 4,5, 4,8, 5,6, 5,9, 6,7, 6,10, 7,11,
1171 8,9, 8,12, 9,10, 9,13, 10,11, 10,14, 11,15,
1172 12,13, 13,14, 14,15};
1179 utest_test_grid_data__3x3(
1180 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
1191 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1192 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1193 int num_edges_per_cell[] = {4,4,4, 4,4,4, 4,4,4};
1194 int cell_to_edge[] = {0,3,7,1, 2,5,9,3, 4,6,11,5,
1195 7,10,14,8, 9,12,16,10, 11,13,18,12,
1196 14,17,21,15, 16,19,22,17, 18,20,23,19};
1197 int edge_to_vertex[] = {0,1, 0,4, 1,2, 1,5, 2,3, 2,6, 3,7,
1198 4,5, 4,8, 5,6, 5,9, 6,7, 6,10, 7,11,
1199 8,9, 8,12, 9,10, 9,13, 10,11, 10,14, 11,15,
1200 12,13, 13,14, 14,15};
1207 utest_test_grid_data__3x3(
1208 unstruct_edge_grid,
"unstructured edge lonlat 2d grid",
REG2D);
1215 double coord_x[] = {0,1,2,3};
1216 double coord_y[] = {0,1,2};
1225 utest_test_grid_data__3x2(reg_grid,
"regular 2d grid",
REG2D);
1234 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3};
1235 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2};
1237 int cell_to_vertex[] = {0,1,5,4, 1,2,6,5, 2,3,7,6,
1238 4,5,9,8, 5,6,10,9, 6,7,11,10};
1245 utest_test_grid_data__3x2(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
1252 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3};
1253 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2};
1262 utest_test_grid_data__3x2(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
1271 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3};
1272 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2};
1274 int cell_to_vertex[] = {0,1,5,4, 1,2,6,5, 2,3,7,6,
1275 4,5,9,8, 5,6,10,9, 6,7,11,10};
1282 utest_test_grid_data__3x2(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
1293 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3};
1294 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2};
1295 int num_edges_per_cell[] = {4,4,4, 4,4,4};
1296 int cell_to_edge[] = {0,3,7,1, 2,5,9,3, 4,6,11,5,
1297 7,10,14,8, 9,12,15,10, 11,13,16,12};
1298 int edge_to_vertex[] = {0,1, 0,4, 1,2, 1,5, 2,3, 2,6, 3,7,
1299 4,5, 4,8, 5,6, 5,9, 6,7, 6,10, 7,11,
1307 utest_test_grid_data__3x2(
1308 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
1319 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3};
1320 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2};
1321 int num_edges_per_cell[] = {4,4,4, 4,4,4};
1322 int cell_to_edge[] = {0,3,7,1, 2,5,9,3, 4,6,11,5,
1323 7,10,14,8, 9,12,15,10, 11,13,16,12};
1324 int edge_to_vertex[] = {0,1, 0,4, 1,2, 1,5, 2,3, 2,6, 3,7,
1325 4,5, 4,8, 5,6, 5,9, 6,7, 6,10, 7,11,
1333 utest_test_grid_data__3x2(
1334 unstruct_edge_grid,
"unstructured edge lonlat 2d grid",
REG2D);
1341 double coord_x[] = {0,1};
1342 double coord_y[] = {0,1,2,3,4};
1351 utest_test_grid_data__1x4(reg_grid,
"regular 2d grid",
REG2D);
1360 double coord_x[] = {0,1,0,1,0,1,0,1,0,1};
1361 double coord_y[] = {0,0,1,1,2,2,3,3,4,4};
1363 int cell_to_vertex[] = {0,1,3,2, 2,3,5,4, 4,5,7,6, 6,7,9,8};
1370 utest_test_grid_data__1x4(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
1377 double coord_x[] = {0,1,0,1,0,1,0,1,0,1};
1378 double coord_y[] = {0,0,1,1,2,2,3,3,4,4};
1387 utest_test_grid_data__1x4(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
1396 double coord_x[] = {0,1,0,1,0,1,0,1,0,1};
1397 double coord_y[] = {0,0,1,1,2,2,3,3,4,4};
1399 int cell_to_vertex[] = {0,1,3,2, 2,3,5,4, 4,5,7,6, 6,7,9,8};
1406 utest_test_grid_data__1x4(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
1417 double coord_x[] = {0,1,0,1,0,1,0,1,0,1};
1418 double coord_y[] = {0,0,1,1,2,2,3,3,4,4};
1419 int num_edges_per_cell[] = {4,4,4,4};
1420 int cell_to_edge[] = {0,2,3,1, 3,5,6,4, 6,8,9,7, 9,11,12,10};
1421 int edge_to_vertex[] = {0,1, 0,2, 1,3, 2,3, 2,4, 3,5, 4,5,
1422 4,6, 5,7, 6,7, 6,8, 7,9, 8,9};
1429 utest_test_grid_data__1x4(
1430 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
1441 double coord_x[] = {0,1,0,1,0,1,0,1,0,1};
1442 double coord_y[] = {0,0,1,1,2,2,3,3,4,4};
1443 int num_edges_per_cell[] = {4,4,4,4};
1444 int cell_to_edge[] = {0,2,3,1, 3,5,6,4, 6,8,9,7, 9,11,12,10};
1445 int edge_to_vertex[] = {0,1, 0,2, 1,3, 2,3, 2,4, 3,5, 4,5,
1446 4,6, 5,7, 6,7, 6,8, 7,9, 8,9};
1453 utest_test_grid_data__1x4(
1454 unstruct_edge_grid,
"unstructured edge 2d grid",
REG2D);
1461 double coord_x[] = {0,1,2,3,4};
1462 double coord_y[] = {0,1};
1471 utest_test_grid_data__4x1(reg_grid,
"regular 2d grid",
REG2D);
1478 double coord_x[] = {0,60,120,180,240,300};
1479 double coord_y[] = {-89,-45,0,45,89};
1488 utest_test_grid_data__6x4_cyclic(reg_grid,
"regular 2d grid");
1497 double coord_x[] = {0,1,2,3,4, 0,1,2,3,4};
1498 double coord_y[] = {0,0,0,0,0, 1,1,1,1,1};
1500 int cell_to_vertex[] = {0,1,6,5, 1,2,7,6, 2,3,8,7, 3,4,9,8};
1507 utest_test_grid_data__4x1(unstruct_grid,
"unstructured 2d grid",
UNSTRUCT);
1514 double coord_x[] = {0,1,2,3,4, 0,1,2,3,4};
1515 double coord_y[] = {0,0,0,0,0, 1,1,1,1,1};
1524 utest_test_grid_data__4x1(curvi_grid,
"curvilinear 2d grid",
CURVE2D);
1533 double coord_x[] = {0,1,2,3,4, 0,1,2,3,4};
1534 double coord_y[] = {0,0,0,0,0, 1,1,1,1,1};
1536 int cell_to_vertex[] = {0,1,6,5, 1,2,7,6, 2,3,8,7, 3,4,9,8};
1543 utest_test_grid_data__4x1(unstruct_grid,
"unstructured lonlat 2d grid",
REG2D);
1554 double coord_x[] = {0,1,2,3,4, 0,1,2,3,4};
1555 double coord_y[] = {0,0,0,0,0, 1,1,1,1,1};
1556 int num_edges_per_cell[] = {4,4,4,4};
1557 int cell_to_edge[] = {0,3,9,1, 2,5,10,3, 4,7,11,5, 6,8,12,7};
1558 int edge_to_vertex [] = {0,1, 0,5, 1,2, 1,6, 2,3, 2,7, 3,4, 3,8, 4,9,
1559 5,6, 6,7, 7,8, 8,9};
1566 utest_test_grid_data__4x1(
1567 unstruct_edge_grid,
"unstructured edge 2d grid",
UNSTRUCT);
1578 double coord_x[] = {0,1,2,3,4, 0,1,2,3,4};
1579 double coord_y[] = {0,0,0,0,0, 1,1,1,1,1};
1580 int num_edges_per_cell[] = {4,4,4,4};
1581 int cell_to_edge[] = {0,3,9,1, 2,5,10,3, 4,7,11,5, 6,8,12,7};
1582 int edge_to_vertex [] = {0,1, 0,5, 1,2, 1,6, 2,3, 2,7, 3,4, 3,8, 4,9,
1583 5,6, 6,7, 7,8, 8,9};
1590 utest_test_grid_data__4x1(
1591 unstruct_edge_grid,
"unstructured edge lonlat 2d grid",
REG2D);
1600 double coord_x[9] = {0,1,2, 0+360,1-360,2+2*360, 0,1,2};
1601 double coord_y[9] = { 0,0,0, 1,1,1, 2,2,2};
1603 int cell_to_vertex[16] = {0,1,4,3, 1,2,5,4, 3,4,7,6, 4,5,8,7};
1610 utest_test_grid_data__2x2(
1611 unstruct_grid,
"periodic unstructured lonlat 2d grid",
REG2D);
1621 (
double[]){0,1,1,0.5,0}, (
double[]){0,0,1,1.5,1}, 5);
1623 (
double[]){0,0.5,1,1,0.5,0}, (
double[]){0,-0.5,0,1,1.5,1}, 6);
1625 (
double[]){-0.25,0, 0.5,1,1.25,1,0},
1626 (
double[]){ 0.5 ,0,-0.5,0,0.5 ,1,1}, 7);
1628 (
double[]){-0.25,0, 0.5,1,1.25,1,0.5,0},
1629 (
double[]){ 0.5 ,0,-0.5,0,0.5 ,1,1.5,1}, 8);
1636 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1637 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1646 utest_test_grid_data__3x3_cloud(unstruct_grid,
"unstructured 2d grid cloud");
1653 size_t num_coords = 16;
1654 double coord_x[] = {0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3};
1655 double coord_y[] = {0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3};
1660 utest_test_grid_data__3x3_cloud(cloud_grid,
"cloud 2d grid");
1667 double coord_x[] = {-1.5,-0.5,0.5,1.5};
1668 double coord_y[] = {-1.5,-0.5,0.5,1.5};
1669 double north_pole[] = {180.0, 45.0};
1677 north_pole[0], north_pole[1]);
1679 double rot_axis[] = {0.0, -1.0, 0.0};
1682 utest_test_grid_data__3x3_reg2d_rot(
1683 reg_rot_grid,
"reg rot 2d grid", rot_axis, rot_angle);
1688#ifdef NOT_YET_SUPPORTED
1691 double coord_x[] = {0,60,120,180,240};
1692 double coord_y[] = {-90,45,0,45,90};
1694 size_t num_vertices[2] = {5,4};
double yac_huiliers_area(struct yac_grid_cell cell)
Area calculation on a unit sphere taken from ESMF based on L'Huilier's Theorem.
Structs and interfaces for area calculations.
void yac_basic_grid_data_compute_cell_areas(struct yac_basic_grid_data grid, double *cell_areas)
void yac_basic_grid_data_free(struct yac_basic_grid_data 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_unstruct_edge_deg(size_t nbr_vertices, size_t nbr_cells, size_t nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex)
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d_rot_deg(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices, double north_pole_lon, double north_pole_lat)
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct_edge_ll_deg(size_t nbr_vertices, size_t nbr_cells, size_t nbr_edges, int *num_edges_per_cell, double *x_vertices, double *y_vertices, int *cell_to_edge, int *edge_to_vertex)
struct yac_basic_grid_data yac_generate_basic_grid_data_cloud_deg(size_t nbr_points, double *x_points, double *y_points)
struct yac_basic_grid_data yac_generate_basic_grid_data_curve_2d_deg(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d_deg(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
struct yac_basic_grid_data yac_generate_basic_grid_data_unstruct_ll_deg(size_t nbr_vertices, size_t nbr_cells, int *num_vertices_per_cell, double *x_vertices, double *y_vertices, int *cell_to_vertex)
void yac_triangulate_cell_indices(size_t const *corner_indices, size_t num_corners, size_t start_corner, size_t(*triangle_indices)[3])
static void rotate_vector2(double axis[], struct sin_cos_angle angle, double v_in[], double v_out[])
void yac_triangulate_cell(struct yac_grid_cell cell, size_t start_corner, struct yac_grid_cell *triangles)
static void LLtoXYZ_deg(double lon, double lat, double p_out[])
void yac_init_grid_cell(struct yac_grid_cell *cell)
void yac_free_grid_cell(struct yac_grid_cell *cell)
@ YAC_GREAT_CIRCLE_EDGE
great circle
@ YAC_LAT_CIRCLE_EDGE
latitude circle
@ YAC_LON_CIRCLE_EDGE
longitude circle
yac_coordinate_pointer vertex_coordinates
size_t * vertex_to_cell_offsets
yac_size_t_2_pointer edge_to_vertex
size_t * cell_to_vertex_offsets
int * num_vertices_per_cell
double(* coordinates_xyz)[3]
static void check_cell_triangulation(double *coordinates_x, double *coordinates_y, size_t num_corners)
struct yac_grid_cell generate_cell_deg(double *lon, double *lat, enum yac_edge_type *edge_type, size_t num_corners)
void check_basic_grid_data(struct yac_basic_grid_data grid_a, struct yac_basic_grid_data grid_b, char const *grid_name)