YetAnotherCoupler 3.5.2
Loading...
Searching...
No Matches
grid_reg2d.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#include "basic_grid_data.h"
6#include "grid_reg2d_common.h"
7#include "geometry.h"
8#include "utils_common.h"
9
11 size_t nbr_vertices[2], int cyclic[2],
12 double *lon_vertices, double *lat_vertices,
13 void (*LLtoXYZ_ptr)(double, double, double[])) {
14
16 !cyclic[1],
17 "ERROR(yac_generate_basic_grid_data_reg_2d): "
18 "cyclic[1] != 0 not yet supported")
19
20 size_t num_cells_2d[2] =
21 {nbr_vertices[0] - (cyclic[0]?0:1), nbr_vertices[1] - (cyclic[1]?0:1)};
22 size_t num_vertices_2d[2] = {num_cells_2d[0] + (cyclic[0]?0:1), num_cells_2d[1] + 1};
23 size_t num_vertices = num_vertices_2d[0] * num_vertices_2d[1];
24 size_t num_edges =
25 (num_cells_2d[0] + (cyclic[0]?0:1)) * num_cells_2d[1] +
26 num_cells_2d[0] * (num_cells_2d[1] + 1);
27
30 for (size_t i = 0, k = 0; i < num_vertices_2d[1]; ++i) {
31 for (size_t j = 0; j < num_vertices_2d[0]; ++j, ++k) {
32 LLtoXYZ_ptr(lon_vertices[j], lat_vertices[i],
33 &(vertex_coordinates[k][0]));
34 }
35 }
36
38 if (!cyclic[0]) {
39 for (size_t i = 0, k = 0; i < num_cells_2d[1]; ++i) {
40 for (size_t j = 0; j < num_vertices_2d[0]; ++j, k += 2) {
43 }
44 --k;
46 }
47 } else {
48 for (size_t i = 1; i < num_edges; ++i)
50 for (size_t i = 0; i < num_cells_2d[1]; ++i) {
51 edge_type[2*i*num_cells_2d[0]] = YAC_LAT_CIRCLE_EDGE;
52 edge_type[2*(i+1)*num_cells_2d[0]-1] = YAC_LON_CIRCLE_EDGE;
53 }
54 }
55 for (size_t i = num_edges - num_cells_2d[0]; i < num_edges; ++i)
57
58 struct yac_basic_grid_data grid =
61 grid.edge_type = edge_type;
62 return grid;
63}
64
66 size_t nbr_vertices[2], int cyclic[2],
67 double *lon_vertices, double *lat_vertices) {
68
69 return
71 nbr_vertices, cyclic, lon_vertices, lat_vertices, LLtoXYZ);
72}
73
75 size_t nbr_vertices[2], int cyclic[2],
76 double *lon_vertices, double *lat_vertices) {
77
78 return
80 nbr_vertices, cyclic, lon_vertices, lat_vertices, LLtoXYZ_deg);
81}
static void LLtoXYZ_deg(double lon, double lat, double p_out[])
Definition geometry.h:304
static void LLtoXYZ(double lon, double lat, double p_out[])
Definition geometry.h:287
yac_edge_type
Definition grid_cell.h:12
@ YAC_LAT_CIRCLE_EDGE
latitude circle
Definition grid_cell.h:14
@ YAC_LON_CIRCLE_EDGE
longitude circle
Definition grid_cell.h:15
struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices)
Definition grid_reg2d.c:65
static struct yac_basic_grid_data yac_generate_basic_grid_data_reg_2d_(size_t nbr_vertices[2], int cyclic[2], double *lon_vertices, double *lat_vertices, void(*LLtoXYZ_ptr)(double, double, double[]))
Definition grid_reg2d.c:10
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)
Definition grid_reg2d.c:74
struct yac_basic_grid_data yac_generate_basic_grid_data_reg2d_common(size_t nbr_vertices[2], int cyclic[2])
#define xmalloc(size)
Definition ppm_xfuncs.h:66
yac_coordinate_pointer vertex_coordinates
enum yac_edge_type * edge_type
#define YAC_ASSERT(exp, msg)
Definition yac_assert.h:16
double(* yac_coordinate_pointer)[3]
Definition yac_types.h:19