11#include "../include/var_struc.h"
12#include "../include/file_io.h"
37#define PRINT_NC(v, v_array) \
39 dataset_id = H5Dcreate(group_id, #v, H5T_NATIVE_FLOAT, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); \
40 status = H5Dwrite(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, v_array); \
41 status = H5Dclose(dataset_id); \
55 double * X[],
const double * cpu_time,
const char * problem,
double time_plot[])
57 char add_out[FILENAME_MAX+40];
61 char file_data[FILENAME_MAX+40];
62 strcpy(file_data, add_out);
63 strcat(file_data,
"FLU_VAR.h5");
65 double *XX = (
double*)malloc(m *
sizeof(
double));
68 printf(
"NOT enough memory! plot X\n");
72 hid_t file_id, group_id, attr_id, dataspace_id, dataspaceA_id, dataset_id;
74 const unsigned rank = 1;
75 const hsize_t dims[1] = {(hsize_t)m}, dimsA[1] = {1};
83 file_id = H5Fcreate(file_data, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
91 dataspace_id = H5Screate_simple(rank, dims, NULL);
92 dataspaceA_id = H5Screate_simple(rank, dimsA, NULL);
95 for(
int k = 0; k < N; k++)
97 sprintf(group_name,
"/T%d", k);
102 group_id = H5Gcreate(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
107 attr_id = H5Acreate(group_id,
"time_plot", H5T_NATIVE_FLOAT, dataspaceA_id, H5P_DEFAULT, H5P_DEFAULT);
108 status = H5Awrite(attr_id, H5T_NATIVE_DOUBLE, time_plot+k);
109 status = H5Aclose(attr_id);
118 for(
int j = 0; j < m; ++j)
119 XX[j] = 0.5 * (X[k][j] + X[k][j+1]);
123 status = H5Gclose(group_id);
126 status = H5Sclose(dataspaceA_id);
127 status = H5Sclose(dataspace_id);
128 status = H5Fclose(file_id);
163 double ** X,
double ** Y,
const double * cpu_time,
const char * problem,
double time_plot[])
165 char add_out[FILENAME_MAX+40];
169 char file_data[FILENAME_MAX+40];
170 strcpy(file_data, add_out);
171 strcat(file_data,
"FLU_VAR.h5");
174 XX = (
double **)malloc(n_x *
sizeof(
double *));
175 YY = (
double **)malloc(n_x *
sizeof(
double *));
176 if(XX == NULL || YY == NULL)
178 printf(
"NOT enough memory! plot X or Y\n");
181 for(
int j = 0; j < n_x; ++j)
183 XX[j] = (
double *)malloc(n_y *
sizeof(
double));
184 YY[j] = (
double *)malloc(n_y *
sizeof(
double));
185 if(XX[j] == NULL || YY[j] == NULL)
187 printf(
"NOT enough memory! plot X[%d] or Y[%d]\n", j, j);
192 hid_t file_id, group_id, attr_id, dataspace_id, dataspaceA_id, dataset_id;
194 const unsigned rank = 2;
195 const hsize_t dims[2] = {(hsize_t)n_y, (hsize_t)n_x}, dimsA[1] = {1};
197 file_id = H5Fcreate(file_data, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
198 dataspace_id = H5Screate_simple(rank, dims, NULL);
199 dataspaceA_id = H5Screate_simple(rank, dimsA, NULL);
202 for(
int k = 0; k < N; k++)
204 sprintf(group_name,
"/T%d", k);
205 group_id = H5Gcreate(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
207 attr_id = H5Acreate(group_id,
"time_plot", H5T_NATIVE_FLOAT, dataspaceA_id, H5P_DEFAULT, H5P_DEFAULT);
208 status = H5Awrite(attr_id, H5T_NATIVE_DOUBLE, time_plot+k);
209 status = H5Aclose(attr_id);
216 for(
int i = 0; i < n_y; ++i)
217 for(
int j = 0; j < n_x; ++j)
219 XX[j][i] = 0.25*(X[j][i] + X[j][i+1] + X[j+1][i] + X[j+1][i+1]);
220 YY[j][i] = 0.25*(Y[j][i] + Y[j][i+1] + Y[j+1][i] + Y[j+1][i+1]);
225 status = H5Gclose(group_id);
228 status = H5Sclose(dataspaceA_id);
229 status = H5Sclose(dataspace_id);
230 status = H5Fclose(file_id);
232 for(
int j = 0; j < n_x; ++j)
void file_1D_write_HDF5(const int m, const int N, const struct cell_var_stru CV, double *X[], const double *cpu_time, const char *problem, double time_plot[])
This function write the 1-D solution into HDF5 output '.h5' files.
void file_2D_write_HDF5(const int n_x, const int n_y, const int N, const struct cell_var_stru CV[], double **X, double **Y, const double *cpu_time, const char *problem, double time_plot[])
This function write the 2-D solution into HDF5 output '.h5' files.
#define PRINT_NC(v, v_array)
Print out fluid variable 'v' with data array 'v_array'.
void example_io(const char *example, char *add_mkdir, const int i_or_o)
This function produces folder path for data input or output.
pointer structure of VARiables on STRUctural computational grid CELLs.
double ** E
specific total energy.
double ** P
density, velocity components in direction x and y, pressure.