Test for vtk output utility functions.
#include <unistd.h>
#include <limits.h>
{
char const filename[] = "test_vtk_output_1.vtk";
enum {
NUM_POINTS = 13,
LON = 0,
LAT = 1,
};
double point_data[2][NUM_POINTS] = {{0,
45,165,285,
0,90,180,270,
180,252,324,396,468},
{90,
85,85,85,
80,80,80,80,
75,75,75,75,75}};
for (size_t i = 0; i < NUM_POINTS; ++i) {
}
unsigned cell_corners[NUM_POINTS] = {0,
1,2,3,
4,5,6,7,
8,9,10,11,12};
unsigned num_points_per_cell[] = {1,3,4,5};
unsigned num_cells = 4;
vtk_file, point_data[LON], point_data[LAT], NUM_POINTS);
vtk_file, cell_corners, num_points_per_cell, num_cells);
unsigned cell_scalars_uint[] = {0,1,2};
int cell_scalars_int[] = {0,1,2};
float cell_scalars_float[] = {0,1,2};
double cell_scalars_double[] = {0,1,2};
vtk_file, cell_scalars_uint, num_cells, "cell_scalars_uint");
vtk_file, cell_scalars_int, num_cells, "cell_scalars_int");
vtk_file, cell_scalars_float, num_cells, "cell_scalars_float");
vtk_file, cell_scalars_double, num_cells, "cell_scalars_double");
unsigned point_scalars_uint[NUM_POINTS] = {UINT_MAX, 0,1,2,3,4,5,6,7,8,9,10,11};
int point_scalars_int[NUM_POINTS] = {-1, 0,1,2,3,4,5,6,7,8,9,10,11};
float point_scalars_float[NUM_POINTS] = {-1, 0,1,2,3,4,5,6,7,8,9,10,11};
double point_scalars_double[NUM_POINTS];
for (size_t i = 0; i < NUM_POINTS; ++i)
point_scalars_double[i] =
vtk_file, point_scalars_uint, NUM_POINTS, "point_scalars_uint");
vtk_file, point_scalars_int, NUM_POINTS, "point_scalars_int");
vtk_file, point_scalars_float, NUM_POINTS, "point_scalars_float");
vtk_file, point_scalars_double, NUM_POINTS, "point_scalars_double");
unlink(filename);
}
{
unsigned n = 30;
unsigned num_cells;
unsigned num_vertices;
double * x_vertices;
double * y_vertices;
double * z_vertices;
unsigned * vertices_of_cell;
unsigned * face_id;
n, &num_cells, &num_vertices, &x_vertices, &y_vertices, &z_vertices,
&vertices_of_cell, &face_id);
struct {
char * func_name;
double (*func)(double, double);
} test_funcs[] = {
};
char const filename[] = "test_vtk_output_2.vtk";
double * point_data =
xmalloc(3 * num_vertices *
sizeof(*point_data));
for (unsigned i = 0; i < num_vertices; ++i) {
point_data[3 * i + 0] = x_vertices[i];
point_data[3 * i + 1] = y_vertices[i];
point_data[3 * i + 2] = z_vertices[i];
}
unsigned * num_points_per_cell =
xmalloc(num_cells *
sizeof(*num_points_per_cell));
for (unsigned i = 0; i < num_cells; ++i) num_points_per_cell[i] = 4;
vtk_file, vertices_of_cell, num_points_per_cell, num_cells);
double * field_data =
xmalloc(num_vertices *
sizeof(*field_data));
for (size_t i = 0; i < sizeof(test_funcs) / sizeof(test_funcs[0]); ++i) {
for (unsigned j = 0; j < num_vertices; ++j) {
double lon, lat;
XYZtoLL(point_data + 3 * j, &lon, &lat);
field_data[j] = test_funcs[i].func(lon, lat);
}
vtk_file, field_data, num_vertices, test_funcs[i].func_name);
}
free(field_data);
free(num_points_per_cell);
free(point_data);
unlink(filename);
free(x_vertices);
free(y_vertices);
free(z_vertices);
free(vertices_of_cell);
free(face_id);
}
return EXIT_SUCCESS;
}
int main(int argc, char **argv)
void yac_generate_cubed_sphere_grid_information(unsigned n, unsigned *num_cells, unsigned *num_vertices, double **x_vertices, double **y_vertices, double **z_vertices, unsigned **cell_to_vertex, unsigned **face_id)
static void XYZtoLL(double const p_in[], double *lon, double *lat)
double yac_test_one(double lon, double lat)
double yac_test_ana_fcos(double lon, double lat)
double yac_test_func_deg(double lon, double lat)
double yac_test_harmonic(double lon, double lat)
double yac_test_vortex(double lon, double lat)
double yac_test_func(double lon, double lat)
double yac_test_ana_fcossin(double lon, double lat)
double yac_test_gulfstream(double lon, double lat)
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_float(YAC_VTK_FILE *vtk_file, float *scalars, unsigned num_cells, char *name)
void yac_vtk_write_cell_scalars_double(YAC_VTK_FILE *vtk_file, double *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_scalars_uint(YAC_VTK_FILE *vtk_file, unsigned *scalars, unsigned num_points, char *name)
void yac_vtk_write_point_data_ll(YAC_VTK_FILE *vtk_file, double *point_data_lon, double *point_data_lat, unsigned num_points)
void yac_vtk_write_point_scalars_double(YAC_VTK_FILE *vtk_file, double *scalars, unsigned num_points, char *name)
void yac_vtk_write_point_data(YAC_VTK_FILE *vtk_file, double *point_data, unsigned num_points)
void yac_vtk_write_point_scalars_int(YAC_VTK_FILE *vtk_file, int *scalars, unsigned num_points, char *name)
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)
void yac_vtk_write_point_scalars_float(YAC_VTK_FILE *vtk_file, float *scalars, unsigned num_points, char *name)
general routines for writing vtk files