19 double n_x[3] = {1, 0, 0};
20 double n_y[3] = {0, 1, 0};
23 double * n = (angle_x > angle_y)?n_x:n_y;
25 double temp_vector[3];
26 double start_vector[3];
60 size_t const num_points_per_great_circle = 71;
67 xmalloc((num_grid_corners + num_points_per_great_circle) *
sizeof(*
points));
73 num_points_per_great_circle, &(
points[num_grid_corners][0]));
80 unsigned * num_points_per_cell =
84 for (
size_t i = 0; i < grid->
num_cells; ++i)
88 num_points_per_cell[grid->
num_cells] = (unsigned)num_points_per_great_circle;
91 size_t total_num_cell_points = 0;
92 for (
size_t i = 0; i < grid->
num_cells; ++i)
93 total_num_cell_points += num_points_per_cell[i];
95 unsigned * cell_data =
96 xmalloc((total_num_cell_points + num_points_per_great_circle) *
100 for (
size_t i = 0; i < total_num_cell_points; ++i)
104 for (
size_t i = 0; i < num_points_per_great_circle; ++i)
105 cell_data[i + total_num_cell_points] = (
unsigned)(num_grid_corners + i);
111 unsigned * cell_type =
xmalloc((num_grid_cells + 1) *
sizeof(*cell_type));
112 int * core_cell_mask =
xmalloc((num_grid_cells + 1) *
sizeof(*core_cell_mask));
114 for (
size_t i = 0; i < num_grid_cells; ++i) cell_type[i] = 0;
115 cell_type[num_grid_cells] = 1;
119 num_grid_cells *
sizeof(*core_cell_mask));
121 for (
size_t i = 0; i < num_grid_cells; ++i) core_cell_mask[i] = 1;
123 core_cell_mask[num_grid_cells] = 0;
129 char * filename =
xcalloc((strlen(name) + 5),
sizeof(*filename));
130 strcpy(filename, name);
131 strcat(filename,
".vtk");
140 file, &(
points[0][0]), num_grid_corners + num_points_per_great_circle);
152 free(core_cell_mask);
155 free(num_points_per_cell);
161 size_t * points_array_size,
size_t *
num_points,
size_t num_points_per_edge) {
184 double a_lon, b_lon, lat;
188 double d_lon_angle =
get_angle(b_lon, a_lon) / (double)num_points_per_edge;
190 for (
size_t i = 0, offset = *
num_points; i < num_points_per_edge;
192 LLtoXYZ(a_lon + d_lon_angle * (
double)i, lat, (*points)[offset]);
196 double rotation_axis[3];
200 double d_angle = edge_length / (double)num_points_per_edge;
202 for (
size_t i = 0, offset = *
num_points; i < num_points_per_edge;
204 rotate_vector(rotation_axis, d_angle * (
double)i, a, (*points)[offset]);
212 size_t num_points_per_edge) {
214 if (num_cells == 0)
return;
216 num_points_per_edge =
MAX(num_points_per_edge, 3);
218 unsigned * num_points_per_cell =
219 xmalloc(num_cells *
sizeof(*num_points_per_cell));
225 double (*
points)[3] = NULL;
226 size_t points_array_size = 0;
229 for (
size_t i = 0; i < num_cells; ++i) {
237 for (
size_t j = 0; j < num_edges; ++j)
244 num_points_per_cell[i] =
num_points - prev_num_points;
254 for (
size_t i = 0; i <
num_points; ++i) cell_data[i] = (
unsigned)i;
260 char * filename =
xcalloc((strlen(name) + 5),
sizeof(*filename));
261 strcpy(filename, name);
262 strcat(filename,
".vtk");
279 free(num_points_per_cell);
struct yac_basic_grid_data * yac_basic_grid_get_data(struct yac_basic_grid *grid)
#define ENSURE_ARRAY_SIZE(arrayp, curr_array_size, req_size)
static void crossproduct_d(const double a[], const double b[], double cross[])
static void rotate_vector(double axis[], double angle, double v_in[], double v_out[])
static const struct sin_cos_angle SIN_COS_M_PI_2
static void rotate_vector2(double axis[], struct sin_cos_angle angle, double v_in[], double v_out[])
static void normalise_vector(double v[])
static double get_angle(double a_lon, double b_lon)
static void LLtoXYZ(double lon, double lat, double p_out[])
static double get_vector_angle(double const a[3], double const b[3])
static void XYZtoLL(double const p_in[], double *lon, double *lat)
static void get_equator_point_data(size_t num_points, double *points)
static void get_bounding_circle_point_data(struct bounding_circle bnd_circle, size_t num_points, double *points)
static void get_edge_points(double *a, double *b, enum yac_edge_type edge_type, double(**points)[3], size_t *points_array_size, size_t *num_points, size_t num_points_per_edge)
void yac_write_basic_grid_data_to_file(struct yac_basic_grid_data *grid, char const *name)
void yac_write_basic_grid_to_file(struct yac_basic_grid *grid, char const *name)
void yac_write_grid_cells_to_file(struct yac_grid_cell *cells, size_t num_cells, char *name, size_t num_points_per_edge)
@ YAC_LAT_CIRCLE_EDGE
latitude circle
#define xcalloc(nmemb, size)
struct sin_cos_angle inc_angle
angle between the middle point and the boundary of the spherical cap
yac_coordinate_pointer vertex_coordinates
int * num_vertices_per_cell
enum yac_edge_type * edge_type
double(* coordinates_xyz)[3]
void yac_vtk_write_cell_scalars_uint(YAC_VTK_FILE *vtk_file, unsigned *scalars, unsigned num_cells, char *name)
void yac_vtk_write_cell_scalars_int(YAC_VTK_FILE *vtk_file, int *scalars, unsigned num_cells, char *name)
void yac_vtk_write_point_data(YAC_VTK_FILE *vtk_file, double *point_data, unsigned num_points)
void yac_vtk_close(YAC_VTK_FILE *vtk_file)
void yac_vtk_write_cell_data(YAC_VTK_FILE *vtk_file, unsigned *cell_corners, unsigned *num_points_per_cell, unsigned num_cells)
YAC_VTK_FILE * yac_vtk_open(const char *filename, const char *title)
general routines for writing vtk files
static struct user_input_data_points ** points
double(* yac_coordinate_pointer)[3]