TYCHO  1.3.0
 All Data Structures Files Functions Variables Enumerations Enumerator
Functions
/home/kapf/tycho_docu/prototypes.h File Reference

Go to the source code of this file.

Functions

int callocate_arrays_global (int x, int y, int z, int max_array_length)
int callocate_arrays_sweeps (int max_array_length)
int callocate_arrays_ppm (int max_array_length)
int free_sweep (void)
int free_ppm (void)
int initiate_grid (int x, double xmin, double xmax, int y, double ymin, double ymax, int z, double zmin, double zmax)
int initiate_domain (int x, int y, int z)
int initiate_domain_dom (int x, int y, int z)
int initiate_domain_marker (int x, int y, int z)
int hydro_sweeps (int x, int y, int z, int direction)
int init_ppm (double **rho_1D, double **pre_1D, double **eng_1D, double **vx_1D, double **vy_1D, double **vz_1D, double **marker_1D, double **dx0, double **xa0, double **xa, double **dx, double **a_coef, double **ai_coef, double **b_coef, double **bi_coef, double **c_coef, double **ci_coef, double **d_x, double **da, double **ar, double **dp, double **dr, double **du, double **pl, double **p6, double **rl, double **r6, double **ul, double **u6, double **vl, double **v6, double **wl, double **w6, double **el, double **e6, double **ql, double **q6, double **deltaa, double **dv, double **dw, double **dq, double **de, double **scratch1, double **scratch2, double **scratch3, double **diffa, double **plft, double **prgh, double **ulft, double **urgh, double **rlft, double **rrgh, double **Cdtdx, double **fCdtdx, double **clft, double **crgh, double **plfti, double **prghi, double **pmid, double **pmold, double **wlft, double **wrgh, double **zlft, double **zrgh, double **umidl, double **umidr, double **umid, double **dm, double **dtbdm, double **upmid, double **xa1, double **xa2, double **xa3, double **vx_1D_old, double **e_int_1D, double **dvol, double **dvol0, double **dvol1, double **delta, double **fluxr, double **fluxu, double **fluxv, double **fluxw, double **fluxe, double **fluxq, double **dm0, double **steep, double **flat, double ***para, double **pressure_solid_1D, double **rhodown, double **rhoup, double **rhofront, double **rhoback, double **vxdown, double **vxup, double **vxfront, double **vxback, double **vydown, double **vyup, double **vyfront, double **vyback, double **vzdown, double **vzup, double **vzfront, double **vzback, int dimension)
int ppm_free (double **rho_1D, double **pre_1D, double **eng_1D, double **vx_1D, double **vy_1D, double **vz_1D, double **marker_1D, double **pressure_solid_1D, double **dx0, double **xa0, double **xa, double **dx, double **a_coef, double **ai_coef, double **b_coef, double **bi_coef, double **c_coef, double **ci_coef, double **d_x, double **da, double **ar, double **dp, double **dr, double **du, double **pl, double **p6, double **rl, double **r6, double **ul, double **u6, double **vl, double **v6, double **wl, double **w6, double **el, double **e6, double **ql, double **q6, double **deltaa, double **dv, double **dw, double **dq, double **de, double **scratch1, double **scratch2, double **scratch3, double **diffa, double **plft, double **prgh, double **ulft, double **urgh, double **rlft, double **rrgh, double **Cdtdx, double **fCdtdx, double **clft, double **crgh, double **plfti, double **prghi, double **pmid, double **pmold, double **wlft, double **wrgh, double **zlft, double **zrgh, double **umidl, double **umidr, double **umid, double **dm, double **dtbdm, double **upmid, double **xa1, double **xa2, double **xa3, double **vx_1D_old, double **e_int_1D, double **dvol, double **dvol0, double **dvol1, double **delta, double **fluxr, double **fluxu, double **fluxv, double **fluxw, double **fluxe, double **fluxq, double **dm0, double **steep, double **flat, double ***para, double **rhodown, double **rhoup, double **rhofront, double **rhoback, double **vxdown, double **vxup, double **vxfront, double **vxback, double **vydown, double **vyup, double **vyfront, double **vyback, double **vzdown, double **vzup, double **vzfront, double **vzback, int dimension)
int init_diffusion (double **temperature_1D, double **temperature_1D_future, double **mass, int **dom_1D)
int make_ic (int x, int y, int z)
int make_sod_ic (int x, int y, int z)
int make_kh_instabilities (int x, int y, int z)
int read_ic (int x, int y, int z)
int read_restart (int x, int y, int z)
int read_dom (int x, int y, int z)
int read_marker_file (int x, int y, int z)
int start_file_reader (char filename[])
int calculate_pressure (int x, int y, int z, double temperature)
long long int ntohll (const long long int data)
int write_ic_tyc (int x, int y, int z)
int write_ic_vtk (int x, int y, int z)
int write_ic_amira (int x, int y, int z)
int write_ic_ifrit (int x, int y, int z)
int write_tyc (int x, int y, int z, int counter)
int write_vtk (int x, int y, int z, int counter)
int write_amira (int x, int y, int z, int counter)
int write_ifrit (int x, int y, int z, int counter)
int write_restart_tyc (int x, int y, int z)
int dt_calc (int x, int y, int z)
int dt_calc_first (int x, int y, int z)
int sweep_x (int x, int y, int z, int flag)
int sweep_y (int x, int y, int z, int flag)
int sweep_z (int x, int y, int z, int flag)
int ppm_step (int i, int j, int k, int direction, int flag, int nmin, int nmax, double *a_coef, double *ai_coef, double *b_coef, double *bi_coef, double *c_coef, double *ci_coef, double *d_x, double *diffa, double *da, double *ar, double *pl, double *p6, double *rl, double *r6, double *u6, double *ul, double *vl, double *v6, double *wl, double *w6, double *el, double *e6, double *ql, double *q6, double *dp, double *du, double *dr, double *dv, double *dw, double *dq, double *de, double *scratch1, double *scratch2, double *scratch3, double *plft, double *prgh, double *ulft, double *urgh, double *rlft, double *rrgh, double *Cdtdx, double *fCdtdx, double *steep, double *flat, double **para, double *clft, double *crgh, double *plfti, double *prghi, double *pmid, double *pmold, double *wlft, double *wrgh, double *zlft, double *zrgh, double *umidl, double *umidr, double *umid, double *dm, double *dtbdm, double *upmid, double *xa1, double *xa2, double *xa3, double *vx_1D_old, double *dvol, double *dvol0, double *dvol1, double *delta, double *fluxr, double *fluxu, double *fluxv, double *fluxw, double *fluxe, double *fluxq, double *dm0, double *e_int_1D, double *rho_1D, double *pre_1D, double *eng_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *marker_1D, double *pressure_solid_1D, double *dx0, double *xa0, double *xa, double *dx, int bound_checker, int lefter, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int set_boundary (int nmin, int nmax, int flag, int bound_checker, int lefter, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *pressure_solid_1D, double *xa0, double *dx0, double *xa, double *dx, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_zero_gradient (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_zero_gradient (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_reflecting (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_reflecting (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_small_padding_on_obstacle (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *pressure_solid_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_reflecting_on_obstacle (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *pressure_solid_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_reflecting_on_obstacle (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *pressure_solid_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_small_padding (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_small_padding (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_outflow (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_outflow (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_inflow (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_inflow (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int left_boundary_periodic (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int right_boundary_periodic (int nmin, int nmax, double *rho_1D, double *eng_1D, double *pre_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *xa0, double *dx0, double *xa, double *dx, int flag, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int viscosity_on_off, int dimension)
int para_coef (int nmin, int nmax, int flag1, double *a_coef, double *dx, double *ai_coef, double *b_coef, double *bi_coef, double *c_coef, double *d_x, double **para, double *ci_coef)
int volume (int nmin, int nmax, double *vol, double *dx, double *vol0, double *dx0)
int flatten (int nmin, int nmax, double *pre_1D, double *vx_1D, double *steep, double *flat)
int parabola (int nmin, int nmax, double *a, double *deltaa, double *a6, double *al, int flag1, double *diffa, double *da, double **para, double *ar, double *flat, double *scratch1, double *scratch2, double *scratch3)
int states (int nmin, int nmax, int flag, double *pre_1D, double *rho_1D, double *dx, double *Cdtdx, double *fCdtdx, double *plft, double *pl, double *dp, double *p6, double *ulft, double *ul, double *du, double *u6, double *rlft, double *rl, double *dr, double *r6, double *prgh, double *urgh, double *rrgh)
int riemann (int nmin, int nmax, double *clft, double *crgh, double *rlft, double *rrgh, double *plfti, double *prghi, double *pmid, double *pmold, double *plft, double *wrgh, double *prgh, double *wlft, double *zlft, double *zrgh, double *umidl, double *umidr, double *umid, double *urgh, double *ulft)
int evolve (int nmin, int nmax, int flag, double *rho_1D, double *dvol, double *dm, double *dtbdm, double *xa1, double *xa, double *dvol1, double *umid, double *upmid, double *pmid, double *xa2, double *dx, double *xa3, double *vx_1D_old, double *vx_1D, double *vy_1D, double *vz_1D, double *eng_1D, double *e_int_1D, double *pre_1D)
int remap (int nmin, int nmax, int flag, double *a_coef, double *dx, double *ai_coef, double *b_coef, double *bi_coef, double *c_coef, double *d_x, double **para, double *ci_coef, double *dr, double *r6, double *rl, double *diffa, double *da, double *ar, double *flat, double *scratch1, double *scratch2, double *scratch3, double *du, double *u6, double *ul, double *dv, double *v6, double *vl, double *w6, double *wl, double *dq, double *q6, double *ql, double *de, double *e6, double *el, double *xa, double *xa0, double *delta, double *fluxr, double *fluxu, double *fluxv, double *fluxw, double *dw, double *fluxe, double *fluxq, double *dm, double *rho_1D, double *dvol, double *dvol0, double *dm0, double *vx_1D, double *vy_1D, double *vz_1D, double *eng_1D, double *e_int_1D, double *pre_1D)
int advect (int nmin, int nmax, int flag, double *dx, double *vx_1D, double *marker_1D)
int diffusion (int x, int y, int z)
double alpha_heat_transfer (int x, int y, int z, int direction)
int copy_arrays_for_viscosity (int x, int y, int z)
int viscosity (int i, int j, int k, int flag, int nmin, int nmax, double *rho_1D, double *vx_1D, double *vy_1D, double *vz_1D, double *pre_1D, double *e_int_1D, double *eng_1D, int lefter, double *rhodown, double *rhoup, double *rhofront, double *rhoback, double *vxdown, double *vxup, double *vxfront, double *vxback, double *vydown, double *vyup, double *vyfront, double *vyback, double *vzdown, double *vzup, double *vzfront, double *vzback, int dimension)
double kinematic_viscosity (double temperature, double density)
double dynamic_viscosity (double temperature)
int wind (int x, int y, int z)
int upper_atmos (int x, int y, int z)
int velocity_field_analyser (int x, int y, int z)
int pressure_on_solid_calc (int x, int y, int z)
int boundary_velo_corrector (int x, int y, int z)
int insert_pressure (int x, int y, int z)
int reset_pressure_integrated (int x, int y, int z)
int prepare_the_dB_map (int x, int y, int z)
int pre_old_copy (int x, int y, int z)

Function Documentation

int advect ( int  nmin,
int  nmax,
int  flag,
double *  dx,
double *  vx_1D,
double *  marker_1D 
)

Advect the marker field with the velocities of the hydro-solver with a Second-order upwind scheme

Definition at line 18 of file advection.c.

References dt, spacing, x, xmax, y, ymax, z, and zmax.

Referenced by ppm_step().

{
int n;
double spacing;
if (flag == 0) spacing = 2.0 * xmax / (double) x;
if (flag == 1) spacing = 2.0 * ymax / (double) y;
if (flag == 2) spacing = 2.0 * zmax / (double) z;
//Advect the marker field
for (n = nmin; n <= nmax; n++) {
if (vx_1D[n] > 0.0)
marker_1D[n] = marker_1D[n]-(dt * vx_1D[n]*(3 * marker_1D[n] - 4 * marker_1D[n - 1] + marker_1D[n - 2])) / spacing;
if (vx_1D[n] < 0.0)
marker_1D[n] = marker_1D[n]-(dt * vx_1D[n]*(-1 * marker_1D[n + 2] + 4 * marker_1D[n + 1] - 3 * marker_1D[n])) / spacing;
//to prevent negative marker densities
if (marker_1D[n] < 0.0) marker_1D[n] = 0.0;
}
//Now the ghost cell resions are cleared
for (n = 1; n <= 6; n++) marker_1D[nmin - n] = 0.0;
for (n = 1; n <= 6; n++) marker_1D[nmax + n] = 0.0;
return 0;
}
double alpha_heat_transfer ( int  x,
int  y,
int  z,
int  direction 
)

Calculates the heat-transfer coefficient for the heat transfer between obstacles and gas. Here you can put your special physics for the heat transfer coefficient in. Example for flat wall.

Definition at line 25 of file alpha_heat_transfer.c.

References vx, vy, and vz.

Referenced by diffusion().

{
double heat_transfer_coefficient;
double velocity_component_at_obstacle;
//the x-y-z sweeps
if (direction == 0) velocity_component_at_obstacle = sqrt(pow(vy[x][y][z],2)+pow(vz[x][y][z],2));
if (direction == 1) velocity_component_at_obstacle = sqrt(pow(vx[x][y][z],2)+pow(vz[x][y][z],2));
if (direction == 2) velocity_component_at_obstacle = sqrt(pow(vx[x][y][z],2)+pow(vy[x][y][z],2));
if (velocity_component_at_obstacle <= 5) heat_transfer_coefficient = 5.6 + 4.0 * velocity_component_at_obstacle;
if (velocity_component_at_obstacle > 5) heat_transfer_coefficient = 7.2 + pow(velocity_component_at_obstacle, 0.78);
return heat_transfer_coefficient;
}
int boundary_velo_corrector ( int  x,
int  y,
int  z 
)

example function to suppress boundary streams; !!highly dangerous, only for testing!!

Definition at line 18 of file boundary_velo_corrector.c.

References small, vx, wind_direction, x, and y.

{
int i, j, k;
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (wind_direction == 2) {
vx[0][j][k] = small;
vx[x - 1][j][k] = small;
}
}
}
return 0;
}
int calculate_pressure ( int  x,
int  y,
int  z,
double  temperature 
)

If one needs the pressure from temperature.

Definition at line 93 of file make_ic.c.

References gasconstant, pre, rho, x, y, and z.

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
pre[i][j][k] = temperature * gasconstant * rho[i][j][k];
}
}
}
return 0;
}
int callocate_arrays_global ( int  x,
int  y,
int  z,
int  max_array_length 
)
int callocate_arrays_ppm ( int  max_array_length)
int callocate_arrays_sweeps ( int  max_array_length)
int copy_arrays_for_viscosity ( int  x,
int  y,
int  z 
)

Copies the density and velocity arrays before each hydro sweep for the viscosity calculation.

Definition at line 24 of file copy_arrays_for_viscosity.c.

References rho, rho_visc, vx, vx_visc, vy, vy_visc, vz, vz_visc, x, y, and z.

Referenced by hydro_sweeps().

{
int i, j, k;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x,y,z, rho_visc, \
vx_visc, vy_visc, vz_visc, \
rho, vx, vy, vz)
{
#endif
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
rho_visc[i][j][k] = rho[i][j][k];
vx_visc[i][j][k] = vx[i][j][k];
vy_visc[i][j][k] = vy[i][j][k];
vz_visc[i][j][k] = vz[i][j][k];
}
}
}
#ifdef _OPENMP
}
#endif
return 0;
}
int diffusion ( int  x,
int  y,
int  z 
)

In order to enable diffusion in an explicit way, this routine solves the diffusion equation in a very basic way using operator splitting. Use it with caution! This is only done within the computational domain of the obstacles.

Definition at line 25 of file diffusion.c.

References alpha_heat_transfer(), dimension, dom, dt, free_diffusion(), gasconstant, init_diffusion(), obstacle_heat_conductivity, pre, rho, specific_heat_capacity_gas, specific_heat_capacity_obstacle, volume(), x, xmax, xmin, y, ymax, ymin, z, zmax, and zmin.

Referenced by main().

{
int i, j, k, n;
double dxfac, dyfac, dzfac;
double coefficient_solid;
double alpha_solid_x, alpha_solid_y, alpha_solid_z;
double *temperature_1D, *temperature_1D_future;
double *mass;
double energy_left, energy_right;
double temperature_right_gas, temerpature_left_gas;
double A;
double heat_transfer_coefficient;
double volume;
int *dom_1D;
int dom_counter;
int i_local_min, i_local_max;
int condition;
dom_counter = 0;
i_local_min = 0;
i_local_max = 0;
temperature_right_gas = 0.0;
temerpature_left_gas = 0.0;
A = 0.0;
heat_transfer_coefficient = 0.0;
condition = 0;
// spacing in all three directions
dxfac = (xmax - xmin) / (double) x;
dyfac = (ymax - ymin) / (double) y;
dzfac = (zmax - zmin) / (double) z;
if (dimension == 1) volume = dxfac;
if (dimension == 2) volume = dxfac * dyfac;
if (dimension == 3) volume = dxfac * dyfac * dzfac;
dxfac = dxfac*dxfac;
dyfac = dyfac*dyfac;
dzfac = dzfac*dzfac;
coefficient_solid = obstacle_heat_conductivity;
if (dimension > 0) alpha_solid_x = coefficient_solid * dt / (dxfac);
if (dimension > 1) alpha_solid_y = coefficient_solid * dt / (dyfac);
if (dimension > 2) alpha_solid_z = coefficient_solid * dt / (dzfac);
if ((alpha_solid_x >= 0.3) && (dimension > 0)) {
dt = (0.3 * dxfac) / coefficient_solid;
}
if ((alpha_solid_y >= 0.3) && (dimension > 1)) {
dt = (0.3 * dyfac) / coefficient_solid;
}
if ((alpha_solid_z >= 0.3) && (dimension > 2)) {
dt = (0.3 * dzfac) / coefficient_solid;
}
//THE X-SWEEP=========================================================================================
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, n, temperature_1D, dom_1D, \
temperature_1D_future, mass, dom_counter, \
i_local_min, i_local_max, energy_left, energy_right, \
condition, heat_transfer_coefficient) \
shared(x, y, z, dom, rho, pre, dt, dxfac, \
dyfac, dzfac, alpha_solid_x, gasconstant, A, \
dimension, volume, \
specific_heat_capacity_gas, \
specific_heat_capacity_obstacle)
{
#endif
init_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
if (dimension == 1) A = 1;
if (dimension == 2) A = dyfac;
if (dimension == 3) A = dyfac * dzfac;
//the x-sweep
for (k = 0; k < z; k++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
condition = 0;
i_local_min = 0;
i_local_max = 0;
while (condition == 0) {
dom_counter = 0;
energy_left = 0.0;
energy_right = 0.0;
for (i = i_local_min; i < x; i++) {
temperature_1D[i] = pre[i][j][k] / (gasconstant * rho[i][j][k]);
mass[i] = rho[i][j][k] * volume;
dom_1D[i] = dom[i][j][k];
if (dom_1D[i] == 1) {
//Now we have the beginning- and the end-index of the solid rod
if (dom_counter == 0) i_local_min = i;
dom_counter++;
} else {
if (dom_counter > 0) {
i_local_max = i - 1;
break;
}
}
if (i == (x - 1)) {
i_local_max = i;
if (dom_counter == 0) i_local_min = i;
}
}
if (i == x) {
condition = 1;
}
//in the boundary of the obstacle
//case if i_local_min > 0
if (i_local_min != 0) {
heat_transfer_coefficient = alpha_heat_transfer(i_local_min - 1, j, k, 0);
energy_left = heat_transfer_coefficient * A * (temperature_1D[i_local_min - 1] - temperature_1D[i_local_min]) * dt;
}
if (i_local_max != (x - 1)) {
heat_transfer_coefficient = alpha_heat_transfer(i_local_max + 1, j, k, 0);
energy_right = heat_transfer_coefficient * A * (temperature_1D[i_local_max + 1] - temperature_1D[i_local_max]) * dt;
}
//temperature in the obstacle higher than in the gas left of it
if ((energy_left <= 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] + fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] - fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i_local_min - 1][j][k] = (gasconstant * rho[i_local_min - 1][j][k]) * temperature_1D[i_local_min - 1];
pre[i_local_min][j][k] = (gasconstant * rho[i_local_min][j][k]) * temperature_1D[i_local_min];
}
//temperature in the obstacle lower than in the gas left of it
if ((energy_left > 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] - fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] + fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i_local_min - 1][j][k] = (gasconstant * rho[i_local_min - 1][j][k]) * temperature_1D[i_local_min - 1];
pre[i_local_min][j][k] = (gasconstant * rho[i_local_min][j][k]) * temperature_1D[i_local_min];
}
//temperature in the gas is higher than in the gas right of it
if ((energy_right > 0) && (i_local_max != (x - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] + fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] - fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i_local_max][j][k] = (gasconstant * rho[i_local_max][j][k]) * temperature_1D[i_local_max];
pre[i_local_max + 1][j][k] = (gasconstant * rho[i_local_max + 1][j][k]) * temperature_1D[i_local_max + 1];
}
//temperature in the gas lower than in the obstacle left of it
if ((energy_right <= 0) && (i_local_max != (x - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] - fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] + fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i_local_max][j][k] = (gasconstant * rho[i_local_max][j][k]) * temperature_1D[i_local_max];
pre[i_local_max + 1][j][k] = (gasconstant * rho[i_local_max + 1][j][k]) * temperature_1D[i_local_max + 1];
}
if (dom_counter > 2) {
for (n = i_local_min + 1; n < i_local_max; n++) {
temperature_1D_future[n] = alpha_solid_x * temperature_1D[n + 1] +
(1 - 2 * alpha_solid_x) * temperature_1D[n] +
alpha_solid_x * temperature_1D[n - 1];
}
for (i = i_local_min + 1; i < i_local_max; i++) {
pre[i][j][k] = (gasconstant * rho[i][j][k]) * temperature_1D_future[i];
}
}
for (i = i_local_min; i < i_local_max; i++) {
temperature_1D[i] = 0.0;
temperature_1D_future[i] = 0.0;
mass[i] = 0.0;
dom_1D[i] = 0;
}
i_local_min = i_local_max + 1;
}
}
}
free_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
#ifdef _OPENMP
}
#endif
//THE Y-SWEEP=========================================================================================
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, n, temperature_1D, dom_1D, \
temperature_1D_future, mass, dom_counter, \
i_local_min, i_local_max, energy_left, \
condition, energy_right, \
heat_transfer_coefficient) \
shared(x, y, z, dom, rho, pre, dt, dxfac, \
dyfac, dzfac, alpha_solid_y, \
gasconstant, A, dimension, volume, \
specific_heat_capacity_gas, \
specific_heat_capacity_obstacle)
{
#endif
init_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
if (dimension == 1) A = 1;
if (dimension == 2) A = dxfac;
if (dimension == 3) A = dxfac * dzfac;
//the y-sweep
for (k = 0; k < z; k++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (i = 0; i < x; i++) {
condition = 0;
i_local_min = 0;
i_local_max = 0;
while (condition == 0) {
dom_counter = 0;
energy_left = 0.0;
energy_right = 0.0;
for (j = i_local_min; j < y; j++) {
temperature_1D[j] = pre[i][j][k] / (gasconstant * rho[i][j][k]);
mass[j] = rho[i][j][k] * volume;
dom_1D[j] = dom[i][j][k];
if (dom_1D[j] == 1) {
//Now we have the beginning- and the end-index of the solid rod
if (dom_counter == 0) i_local_min = j;
dom_counter++;
} else {
if (dom_counter > 0) {
i_local_max = j - 1;
break;
}
}
if (j == (y - 1)) {
i_local_max = j;
if (dom_counter == 0) i_local_min = j;
}
}
if (j == y) {
condition = 1;
}
//Now the heat transfer is calcuated to set the the right temerpature
//in the boundary of the obstacle
//case if i_local_min > 0
if (i_local_min != 0) {
heat_transfer_coefficient = alpha_heat_transfer(i, i_local_min - 1, k, 1);
energy_left = heat_transfer_coefficient * A * (temperature_1D[i_local_min - 1] - temperature_1D[i_local_min]) * dt;
}
if (i_local_max != (y - 1)) {
heat_transfer_coefficient = alpha_heat_transfer(i, i_local_max + 1, k, 1);
energy_right = heat_transfer_coefficient * A * (temperature_1D[i_local_max + 1] - temperature_1D[i_local_max]) * dt;
}
//temperature in the obstacle higher than in the gas left of it
if ((energy_left <= 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] + fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] - fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i][i_local_min - 1][k] = (gasconstant * rho[i][i_local_min - 1][k]) * temperature_1D[i_local_min - 1];
pre[i][i_local_min][k] = (gasconstant * rho[i][i_local_min][k]) * temperature_1D[i_local_min];
}
//temperature in the obstacle lower than in the gas left of it
if ((energy_left > 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] - fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] + fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i][i_local_min - 1][k] = (gasconstant * rho[i][i_local_min - 1][k]) * temperature_1D[i_local_min - 1];
pre[i][i_local_min][k] = (gasconstant * rho[i][i_local_min][k]) * temperature_1D[i_local_min];
}
//temperature in the obstacle higher than in the gas right of it
if ((energy_right > 0) && (i_local_max != (y - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] + fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] - fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i][i_local_max][k] = (gasconstant * rho[i][i_local_max][k]) * temperature_1D[i_local_max];
pre[i][i_local_max + 1][k] = (gasconstant * rho[i][i_local_max + 1][k]) * temperature_1D[i_local_max + 1];
}
//temperature in the obstacle lower than in the gas right of it
if ((energy_right <= 0) && (i_local_max != (y - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] - fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] + fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i][i_local_max][k] = (gasconstant * rho[i][i_local_max][k]) * temperature_1D[i_local_max];
pre[i][i_local_max + 1][k] = (gasconstant * rho[i][i_local_max + 1][k]) * temperature_1D[i_local_max + 1];
}
//printf("energy_left: %g energy_right: %g dt: %g\n", energy_left, energy_right, dt);
if (dom_counter > 2) {
for (n = i_local_min + 1; n < i_local_max; n++) {
//here the heat conductivity constant are determined
temperature_1D_future[n] = alpha_solid_y * temperature_1D[n + 1] +
(1 - 2 * alpha_solid_y) * temperature_1D[n] +
alpha_solid_y * temperature_1D[n - 1];
}
for (j = i_local_min + 1; j < i_local_max; j++) {
pre[i][j][k] = (gasconstant * rho[i][j][k]) * temperature_1D_future[j];
}
for (j = i_local_min; j < i_local_max; j++) {
temperature_1D[j] = 0.0;
temperature_1D_future[j] = 0.0;
mass[j] = 0.0;
dom_1D[j] = 0;
}
}
i_local_min = i_local_max + 1;
}
}
}
free_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
#ifdef _OPENMP
}
#endif
//THE Z-SWEEP=========================================================================================
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, n, temperature_1D, dom_1D, \
temperature_1D_future, mass, dom_counter, \
i_local_min, i_local_max, energy_left, \
condition, energy_right, \
heat_transfer_coefficient) \
shared(x, y, z, dom, rho, pre, dt, dxfac, \
dyfac, dzfac, alpha_solid_z, gasconstant, A, \
dimension, volume, \
specific_heat_capacity_gas, \
specific_heat_capacity_obstacle)
{
#endif
init_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
if (dimension == 1) A = 1;
if (dimension == 2) A = dxfac;
if (dimension == 3) A = dxfac * dyfac;
//the z-sweep
for (j = 0; j < y; j++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (i = 0; i < x; i++) {
condition = 0;
i_local_min = 0;
i_local_max = 0;
while (condition == 0) {
dom_counter = 0;
energy_left = 0.0;
energy_right = 0.0;
for (k = i_local_min; k < z; k++) {
temperature_1D[k] = pre[i][j][k] / (gasconstant * rho[i][j][k]);
mass[k] = rho[i][j][k] * volume;
dom_1D[k] = dom[i][j][k];
if (dom_1D[k] == 1) {
//Now we have the beginning- and the end-index of the solid rod
if (dom_counter == 0) i_local_min = k;
dom_counter++;
} else {
if (dom_counter > 0) {
i_local_max = k - 1;
break;
}
}
if (k == (z - 1)) {
i_local_max = k;
if (dom_counter == 0) i_local_min = k;
}
}
if (k == z) {
condition = 1;
}
//Now the heat transfer is calculated to set the the right temperature
//in the boundary of the obstacle
//case if i_local_min > 0
if (i_local_min != 0) {
heat_transfer_coefficient = alpha_heat_transfer(i, j, i_local_min - 1, 2);
energy_left = heat_transfer_coefficient * A * (temperature_1D[i_local_min - 1] - temperature_1D[i_local_min]) * dt;
}
if (i_local_max != (z - 1)) {
heat_transfer_coefficient = alpha_heat_transfer(i, j, i_local_max + 1, 2);
energy_right = heat_transfer_coefficient * A * (temperature_1D[i_local_max + 1] - temperature_1D[i_local_max]) * dt;
}
//temperature in the obstacle higher than in the gas left of it
if ((energy_left <= 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] + fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] - fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i][j][i_local_min - 1] = (gasconstant * rho[i][j][i_local_min - 1]) * temperature_1D[i_local_min - 1];
pre[i][j][i_local_min] = (gasconstant * rho[i][j][i_local_min]) * temperature_1D[i_local_min ];
}
//temperature in the obstacle lower than in the gas left of it
if ((energy_left > 0) && (i_local_min != 0)) {
temperature_1D[i_local_min - 1] = temperature_1D[i_local_min - 1] - fabs(energy_left / (specific_heat_capacity_gas * mass[i_local_min - 1]));
temperature_1D[i_local_min] = temperature_1D[i_local_min] + fabs(energy_left / (specific_heat_capacity_obstacle * mass[i_local_min]));
pre[i][j][i_local_min - 1] = (gasconstant * rho[i][j][i_local_min - 1]) * temperature_1D[i_local_min - 1];
pre[i][j][i_local_min] = (gasconstant * rho[i][j][i_local_min]) * temperature_1D[i_local_min ];
}
//temperature in the obstacle higher than in the gas right of it
if ((energy_right > 0) && (i_local_max != (z - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] + fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] - fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i][j][i_local_max] = (gasconstant * rho[i][j][i_local_max]) * temperature_1D[i_local_max ];
pre[i][j][i_local_max + 1] = (gasconstant * rho[i][j][i_local_max + 1]) * temperature_1D[i_local_max + 1];
}
//temperature in the obstacle lower than in the gas right of it
if ((energy_right <= 0) && (i_local_max != (z - 1))) {
temperature_1D[i_local_max] = temperature_1D[i_local_max] - fabs(energy_right / (specific_heat_capacity_obstacle * mass[i_local_max]));
temperature_1D[i_local_max + 1] = temperature_1D[i_local_max + 1] + fabs(energy_right / (specific_heat_capacity_gas * mass[i_local_max + 1]));
pre[i][j][i_local_max] = (gasconstant * rho[i][j][i_local_max]) * temperature_1D[i_local_max ];
pre[i][j][i_local_max + 1] = (gasconstant * rho[i][j][i_local_max + 1]) * temperature_1D[i_local_max + 1];
}
//to debug
//printf("energy_left: %g energy_right: %g dt: %g\n", energy_left, energy_right, dt);
if (dom_counter > 2) {
for (n = i_local_min + 1; n < i_local_max; n++) {
//here the heat conductivity constants are determined
temperature_1D_future[n] = alpha_solid_z * temperature_1D[n + 1] +
(1 - 2 * alpha_solid_z) * temperature_1D[n] +
alpha_solid_z * temperature_1D[n - 1];
}
for (k = i_local_min + 1; k < i_local_max; k++) {
pre[i][j][k] = (gasconstant * rho[i][j][k]) * temperature_1D_future[k];
}
for (k = i_local_min; k < i_local_max; k++) {
temperature_1D[k] = 0.0;
temperature_1D_future[k] = 0.0;
mass[k] = 0.0;
dom_1D[k] = 0;
}
}
i_local_min = i_local_max + 1;
}
}
}
free_diffusion(&temperature_1D, &temperature_1D_future, &mass, &dom_1D);
#ifdef _OPENMP
}
#endif
return 0;
}
int dt_calc ( int  x,
int  y,
int  z 
)

This function calculates the hydrodynamical timestep for the simulation. It is based on the signal velocity in the medium and the courant factor, specified in the parameterfile.

Definition at line 50 of file dt_calc.c.

References courant, dimension, dom, dt, Gamma1, gasconstant, kinematic_viscosity(), max_dt(), min_dt(), olddt, pre, rho, viscosity_on_off, vx, vy, vz, x, y, z, zdx, zdy, and zdz.

Referenced by main().

{
int i, j, k;
double rdt1, tmpdy, tmpdz, tmp;
double xvel, yvel, zvel, svel;
double max_tmp1, max_tmp2, max_tmp3, min_tmp1, dtx, dt3;
double kin_viscosity;
double s_visc;
double temperature;
rdt1 = 0.0;
svel = 0.0;
kin_viscosity = 0.0;
s_visc = 0.0;
/*
The signal velocity is calculated and compared to the
gas velocity in each cell. The routine searches for
the maximum in the whole computational domain.
*/
if (dimension == 1) {
k = 0;
j = 0;
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) {
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / zdx[i];
xvel = fabs(vx[i][j][k]) / zdx[i];
tmp = max_dt(svel, xvel);
rdt1 = max_dt(tmp, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = kin_viscosity / (tmp * tmp);
rdt1 = max_dt(s_visc, rdt1);
}
}
}
}
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, tmpdy, tmp, svel, xvel, \
yvel, max_tmp2, max_tmp3, temperature, \
kin_viscosity,s_visc) \
shared(x, y, z, dom, rho, pre, Gamma1, vx, \
vy, zdx, zdy, dimension, rdt1, \
viscosity_on_off, gasconstant)
{
#endif
if (dimension == 2) {
k = 0;
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
if (dom[i][j][k] == 0) {
tmpdy = zdy[j];
tmp = min_dt(zdx[i], tmpdy);
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / tmp;
xvel = fabs(vx[i][j][k]) / zdx[i];
yvel = fabs(vy[i][j][k]) / tmpdy;
max_tmp2 = max_dt(svel, xvel);
max_tmp3 = max_dt(max_tmp2, yvel);
rdt1 = max_dt(max_tmp3, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = kin_viscosity / (tmp * tmp);
rdt1 = max_dt(s_visc, rdt1);
}
}
}
}
}
#ifdef _OPENMP
}
#endif
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, tmpdy, tmp, tmpdz, svel, xvel, \
yvel, zvel, max_tmp1, max_tmp2, max_tmp3, \
min_tmp1, temperature, \
kin_viscosity,s_visc) \
shared(x, y, z, dom, rho, pre, Gamma1, vx, \
vy, vz, zdx, zdy, zdz,dimension, rdt1, \
viscosity_on_off, gasconstant)
{
#endif
if (dimension == 3) {
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 0) {
tmpdy = zdy[j];
tmpdz = zdz[k];
min_tmp1 = min_dt(tmpdy, tmpdz);
tmp = min_dt(zdx[i], min_tmp1);
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / tmp;
xvel = fabs(vx[i][j][k]) / zdx[i];
yvel = fabs(vy[i][j][k]) / tmpdy;
zvel = fabs(vz[i][j][k]) / tmpdz;
max_tmp1 = max_dt(xvel, yvel);
max_tmp2 = max_dt(zvel, svel);
max_tmp3 = max_dt(max_tmp1, max_tmp2);
rdt1 = max_dt(max_tmp3, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = kin_viscosity / (tmp * tmp);
rdt1 = max_dt(s_visc, rdt1);
}
}
}
}
}
}
#ifdef _OPENMP
}
#endif
// here the CFL condition is applied
dtx = courant / rdt1;
// In order to avoid strong time step changes
dt3 = 1.2 * olddt;
dt = min_dt(dt3, dtx);
if (dt == 0.0) {
printf("A time_simstep of zero ---> STOP\n");
exit(42);
}
return 0;
}
int dt_calc_first ( int  x,
int  y,
int  z 
)

This function calculates the hydrodynamical time step for the first time in the simulation It is based on the signal velocity in the medium and the courant factor, specified in the parameterfile.

Definition at line 50 of file dt_calc_first.c.

References courant, dimension, dom, dt, Gamma1, gasconstant, intial_soundspeed, kinematic_viscosity(), max_dt_first(), min_dt_first(), pre, rho, spacing, viscosity_on_off, vx, vy, vz, x, y, z, zdx, zdy, and zdz.

Referenced by main().

{
int i, j, k;
double rdt1, tmpdy, tmpdz, tmp;
double xvel, yvel, zvel, svel;
double max_tmp1, max_tmp2, max_tmp3, min_tmp1, dtx;
double kin_viscosity;
double s_visc;
double temperature;
rdt1 = 0.0;
svel = 0.0;
kin_viscosity = 0.0;
s_visc = 0.0;
/*
The signal velocity is calculated and compared to the
gas velocity in each cell. The routine searches for
the maximum in the whole computational domain.
*/
if (dimension == 1) {
j = 0;
k = 0;
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) {
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / zdx[i];
xvel = fabs(vx[i][j][k]) / zdx[i];
tmp = max_dt_first(svel, xvel);
rdt1 = max_dt_first(tmp, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = (kin_viscosity / (tmp * tmp));
rdt1 = max_dt_first(s_visc, rdt1);
}
}
}
}
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, tmpdy, tmp, svel, xvel, \
yvel, max_tmp2, max_tmp3, temperature, \
kin_viscosity,s_visc) \
shared(x, y, z, dom, rho, pre, Gamma1, vx, \
vy, zdx, zdy, dimension, rdt1, viscosity_on_off, \
courant, gasconstant)
{
#endif
if (dimension == 2) {
k = 0;
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
if (dom[i][j][k] == 0) {
tmpdy = zdy[j];
tmp = min_dt_first(zdx[i], tmpdy);
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / zdx[i];
xvel = fabs(vx[i][j][k]) / zdx[i];
yvel = fabs(vy[i][j][k]) / tmpdy;
max_tmp2 = max_dt_first(svel, xvel);
max_tmp3 = max_dt_first(max_tmp2, yvel);
rdt1 = max_dt_first(max_tmp3, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = (kin_viscosity / (tmp * tmp));
rdt1 = max_dt_first(s_visc, rdt1);
}
}
}
}
}
#ifdef _OPENMP
}
#endif
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, tmpdy, tmp, tmpdz, svel, xvel, \
yvel, zvel, max_tmp1, max_tmp2, max_tmp3, \
min_tmp1,temperature, viscosity_on_off, \
kin_viscosity, s_visc) \
shared(x, y, z, dom, rho, pre, Gamma1, vx, \
vy, vz, zdx, zdy, zdz,dimension, rdt1, gasconstant)
{
#endif
if (dimension == 3) {
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 0) {
tmpdy = zdy[j];
tmpdz = zdz[k];
min_tmp1 = min_dt_first(tmpdy, tmpdz);
tmp = min_dt_first(zdx[i], min_tmp1);
svel = sqrt(Gamma1 * pre[i][j][k] / rho[i][j][k]) / zdx[i];
xvel = fabs(vx[i][j][k]) / zdx[i];
yvel = fabs(vy[i][j][k]) / tmpdy;
zvel = fabs(vz[i][j][k]) / tmpdz;
max_tmp1 = max_dt_first(xvel, yvel);
max_tmp2 = max_dt_first(zvel, svel);
max_tmp3 = max_dt_first(max_tmp1, max_tmp2);
rdt1 = max_dt_first(max_tmp3, rdt1);
if (viscosity_on_off == 1) {
temperature = pre[i][j][k] / (gasconstant * rho[i][j][k]);
kin_viscosity = kinematic_viscosity(temperature, rho[i][j][k]);
s_visc = (kin_viscosity / (tmp * tmp));
rdt1 = max_dt_first(s_visc, rdt1);
}
}
}
}
}
}
#ifdef _OPENMP
}
#endif
// here the CFL condition is applied
dtx = courant / rdt1;
dt = dtx;
if (dt == 0.0) {
printf("A time_simstep of zero ---> STOP\n");
exit(42);
}
return 0;
}
double dynamic_viscosity ( double  temperature)

In order to enable viscosity in an explicit way, this routine calculates the dynamic_viscosity for a given temperature according to Sutherland's law.

Definition at line 42 of file kinematic_dyanmic_viscosity.c.

References C1_visc, dynamic_viscosity(), and S_visc.

Referenced by dynamic_viscosity(), and viscosity().

{
if ((temperature >= 200) && (temperature <= 1400)) {
dynamic_viscosity = (C1_visc * pow(temperature, 1.5)) / (temperature + S_visc);
} else {
dynamic_viscosity = 0.0;
}
}
int evolve ( int  nmin,
int  nmax,
int  flag,
double *  rho_1D,
double *  dvol,
double *  dm,
double *  dtbdm,
double *  xa1,
double *  xa,
double *  dvol1,
double *  umid,
double *  upmid,
double *  pmid,
double *  xa2,
double *  dx,
double *  xa3,
double *  vx_1D_old,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  eng_1D,
double *  e_int_1D,
double *  pre_1D 
)

Evolution of velocities and energies due to pressure acceleration and external forces.

Definition at line 32 of file evolve.c.

References dt, Gamma, grav_acc, gravity_on_off, max_evolve(), smallp, and smallr.

Referenced by ppm_step().

{
int i;
// Calculate the mass and upmid in a cell
for (i = nmin - 3; i <= nmax + 4; i++) {
dm[i] = rho_1D[i] * dvol[i];
dtbdm[i] = dt / dm[i];
xa1[i] = xa[i];
dvol1[i] = dvol[i];
xa[i] = xa[i] + dt * umid[i];
upmid[i] = umid[i] * pmid[i];
}
xa1[nmin - 4] = xa[nmin - 4];
xa1[nmax + 5] = xa[nmax + 5];
// Calculate the cell centered coordinates
for (i = nmin - 4; i <= nmax + 5; i++) {
xa2[i] = xa1[i] + 0.5 * dx[i];
dx[i] = xa[i + 1] - xa[i];
xa3[i] = xa[i] + 0.5 * dx[i];
}
for (i = nmin - 3; i <= nmax + 4; i++) {
dvol[i] = dx[i];
}
// new densities
for (i = nmin - 3; i <= nmax + 3; i++) {
rho_1D[i] = rho_1D[i]*(dvol1[i] / dvol[i]);
rho_1D[i] = max_evolve(rho_1D[i], smallr);
// velocity evolution due to pressure acceleration and external forces.
vx_1D_old[i] = vx_1D[i];
if (flag == 1) {
if (gravity_on_off == 1) {
vx_1D[i] = vx_1D[i] - dtbdm[i]*(pmid[i + 1] - pmid[i]) + dt * grav_acc;
eng_1D[i] = eng_1D[i] - dtbdm[i]*(upmid[i + 1] - upmid[i]) + 0.5 * dt *
grav_acc * (vx_1D_old[i] + vx_1D[i]);
}
if (gravity_on_off == 0) {
vx_1D[i] = vx_1D[i] - dtbdm[i]*(pmid[i + 1] - pmid[i]);
eng_1D[i] = eng_1D[i] - dtbdm[i]*(upmid[i + 1] - upmid[i]);
}
} else {
vx_1D[i] = vx_1D[i] - dtbdm[i]*(pmid[i + 1] - pmid[i]);
eng_1D[i] = eng_1D[i] - dtbdm[i]*(upmid[i + 1] - upmid[i]);
}
// total energy evolution
e_int_1D[i] = eng_1D[i] - 0.5 * (pow(vx_1D[i], 2) + pow(vy_1D[i], 2) + pow(vz_1D[i], 2));
pre_1D[i] = max_evolve(rho_1D[i] * e_int_1D[i] * Gamma, smallp);
}
return 0;
}
int flatten ( int  nmin,
int  nmax,
double *  pre_1D,
double *  vx_1D,
double *  steep,
double *  flat 
)

Look for presence of a shock using pressure gradient and sign of velocity jump: shock = 1 if there is a shock in the zone, else shock = 0 Compute steepness parameter based on steepness of pressure jump IF there is a shock. The flatting is needed to eliminated post-shock oscillations.

Definition at line 47 of file flatten.c.

References max_flatten(), min_flatten(), shock_or_not, and small.

Referenced by ppm_step().

{
int i;
double temp1, temp2, temp3;
double delp1, delp2, shock;
double epsilon, omega1, omega2;
epsilon = 0.3;
omega1 = 0.75;
omega2 = 5.0;
/*
Look for presence of a shock using pressure gradient and sign of
velocity jump: shock = 1 if there is a shock in the zone, else shock = 0
Compute steepness parameter based on steepness of pressure jump IF
there is a shock.
*/
for (i = nmin - 4; i <= nmax + 4; i++) {
// delp1 und delp2 are the pressure difference over the next and next after next cells
delp1 = pre_1D[i + 1] - pre_1D[i - 1];
delp2 = pre_1D[i + 2] - pre_1D[i - 2];
// the actual shock detection
if (fabs(delp2) < small) delp2 = small;
shock = fabs(delp1) / min_flatten(pre_1D[i + 1], pre_1D[i - 1]) - epsilon;
shock = max_flatten(0.0, shock);
if (shock > 0.0) shock = 1.0;
if (vx_1D[i - 1] < vx_1D[i + 1]) shock = 0.0;
temp1 = (delp1 / delp2 - omega1) * omega2;
// the steepness parameter
steep[i] = shock * max_flatten(0.0, temp1);
}
//Set phony boundary conditions for the steepness parameter
steep[nmin - 5] = steep[nmin - 4];
steep[nmax + 5] = steep[nmax + 4];
//Set flattening coefficient based on the steepness in neighboring zones
for (i = nmin - 4; i <= nmax + 4; i++) {
temp2 = max_flatten(steep[i - 1], steep[i]);
temp3 = max_flatten(steep[i + 1], temp2);
flat[i] = max_flatten(0.0, min_flatten(0.5, temp3));
if (flat[i] > 0) shock_or_not = 1;
}
return 0;
}
int free_ppm ( void  )
int free_sweep ( void  )
int hydro_sweeps ( int  x,
int  y,
int  z,
int  direction 
)

The forward and backward hydro sweeps the direction gives the forward [0] or backward [1] sweeps

Definition at line 18 of file hydro_sweeps.c.

References copy_arrays_for_viscosity(), dimension, sweep_x(), sweep_y(), sweep_z(), viscosity_on_off, wind(), and wind_on_off.

Referenced by main().

{
// Here we switch the wind on
if (wind_on_off == 1) wind(x, y, z);
if (direction == 0) {
sweep_x(x, y, z, 0);
if (dimension > 1) sweep_y(x, y, z, 1);
if (dimension == 3) sweep_z(x, y, z, 2);
}
if (direction == 1) {
if (dimension == 3) sweep_z(x, y, z, 2);
if (dimension > 1) sweep_y(x, y, z, 1);
sweep_x(x, y, z, 0);
}
return 0;
}
int init_diffusion ( double **  temperature_1D,
double **  temperature_1D_future,
double **  mass,
int **  dom_1D 
)

Definition at line 326 of file init.c.

References max_array_length.

Referenced by diffusion().

{
*temperature_1D = calloc((max_array_length + 4), sizeof **temperature_1D);
*temperature_1D_future = calloc((max_array_length + 4), sizeof **temperature_1D_future);
*mass = calloc((max_array_length + 4), sizeof **mass);
*dom_1D = calloc((max_array_length + 4), sizeof **dom_1D);
return 0;
}
int init_ppm ( double **  rho_1D,
double **  pre_1D,
double **  eng_1D,
double **  vx_1D,
double **  vy_1D,
double **  vz_1D,
double **  marker_1D,
double **  dx0,
double **  xa0,
double **  xa,
double **  dx,
double **  a_coef,
double **  ai_coef,
double **  b_coef,
double **  bi_coef,
double **  c_coef,
double **  ci_coef,
double **  d_x,
double **  da,
double **  ar,
double **  dp,
double **  dr,
double **  du,
double **  pl,
double **  p6,
double **  rl,
double **  r6,
double **  ul,
double **  u6,
double **  vl,
double **  v6,
double **  wl,
double **  w6,
double **  el,
double **  e6,
double **  ql,
double **  q6,
double **  deltaa,
double **  dv,
double **  dw,
double **  dq,
double **  de,
double **  scratch1,
double **  scratch2,
double **  scratch3,
double **  diffa,
double **  plft,
double **  prgh,
double **  ulft,
double **  urgh,
double **  rlft,
double **  rrgh,
double **  Cdtdx,
double **  fCdtdx,
double **  clft,
double **  crgh,
double **  plfti,
double **  prghi,
double **  pmid,
double **  pmold,
double **  wlft,
double **  wrgh,
double **  zlft,
double **  zrgh,
double **  umidl,
double **  umidr,
double **  umid,
double **  dm,
double **  dtbdm,
double **  upmid,
double **  xa1,
double **  xa2,
double **  xa3,
double **  vx_1D_old,
double **  e_int_1D,
double **  dvol,
double **  dvol0,
double **  dvol1,
double **  delta,
double **  fluxr,
double **  fluxu,
double **  fluxv,
double **  fluxw,
double **  fluxe,
double **  fluxq,
double **  dm0,
double **  steep,
double **  flat,
double ***  para,
double **  pressure_solid_1D,
double **  rhodown,
double **  rhoup,
double **  rhofront,
double **  rhoback,
double **  vxdown,
double **  vxup,
double **  vxfront,
double **  vxback,
double **  vydown,
double **  vyup,
double **  vyfront,
double **  vyback,
double **  vzdown,
double **  vzup,
double **  vzfront,
double **  vzback,
int  dimension 
)

all quantities used in the hydro computation are initiated with zeros

Definition at line 18 of file init.c.

References max_array_length.

Referenced by sweep_x(), sweep_y(), and sweep_z().

{
int i;
// the arrays which hold the hydro quantities
*rho_1D = calloc((max_array_length + 12), sizeof ** rho_1D);
*pre_1D = calloc((max_array_length + 12), sizeof ** pre_1D);
*eng_1D = calloc((max_array_length + 12), sizeof ** eng_1D);
*vx_1D = calloc((max_array_length + 12), sizeof ** vx_1D);
*vy_1D = calloc((max_array_length + 12), sizeof ** vy_1D);
*vz_1D = calloc((max_array_length + 12), sizeof ** vz_1D);
*marker_1D = calloc((max_array_length + 12), sizeof ** marker_1D);
*pressure_solid_1D = calloc((max_array_length + 12), sizeof ** pressure_solid_1D);
//for viscosity calculations
if (dimension > 1) {
*rhodown = calloc((max_array_length + 12), sizeof ** rhodown);
*rhoup = calloc((max_array_length + 12), sizeof ** rhoup);
*vxdown = calloc((max_array_length + 12), sizeof ** vxdown);
*vxup = calloc((max_array_length + 12), sizeof ** vxup);
*vydown = calloc((max_array_length + 12), sizeof ** vydown);
*vyup = calloc((max_array_length + 12), sizeof ** vyup);
*vzdown = calloc((max_array_length + 12), sizeof ** vzdown);
*vzup = calloc((max_array_length + 12), sizeof ** vzup);
}
if (dimension > 2) {
*rhofront = calloc((max_array_length + 12), sizeof ** rhofront);
*rhoback = calloc((max_array_length + 12), sizeof ** rhoback);
*vxfront = calloc((max_array_length + 12), sizeof ** vxfront);
*vxback = calloc((max_array_length + 12), sizeof ** vxback);
*vyfront = calloc((max_array_length + 12), sizeof ** vyfront);
*vyback = calloc((max_array_length + 12), sizeof ** vyback);
*vzfront = calloc((max_array_length + 12), sizeof ** vzfront);
*vzback = calloc((max_array_length + 12), sizeof ** vzback);
}
*dx0 = calloc((max_array_length + 12), sizeof ** dx0);
*xa0 = calloc((max_array_length + 12), sizeof ** xa0);
*xa = calloc((max_array_length + 12), sizeof ** xa);
*dx = calloc((max_array_length + 12), sizeof ** dx);
//allocates for the ppm routine
//for the parabolic interpolation constants
*a_coef = calloc((max_array_length + 12), sizeof ** a_coef);
*ai_coef = calloc((max_array_length + 12), sizeof ** ai_coef);
*b_coef = calloc((max_array_length + 12), sizeof ** b_coef);
*bi_coef = calloc((max_array_length + 12), sizeof ** bi_coef);
*c_coef = calloc((max_array_length + 12), sizeof ** c_coef);
*ci_coef = calloc((max_array_length + 12), sizeof ** ci_coef);
*d_x = calloc((max_array_length + 12), sizeof ** d_x);
//for the parabolic interpolation
*da = calloc((max_array_length + 12), sizeof ** da);
*ar = calloc((max_array_length + 12), sizeof ** ar);
*dp = calloc((max_array_length + 12), sizeof ** dp);
*dr = calloc((max_array_length + 12), sizeof ** dr);
*du = calloc((max_array_length + 12), sizeof ** du);
*pl = calloc((max_array_length + 12), sizeof ** pl);
*p6 = calloc((max_array_length + 12), sizeof ** p6);
*rl = calloc((max_array_length + 12), sizeof ** rl);
*r6 = calloc((max_array_length + 12), sizeof ** r6);
*ul = calloc((max_array_length + 12), sizeof ** ul);
*u6 = calloc((max_array_length + 12), sizeof ** u6);
*vl = calloc((max_array_length + 12), sizeof ** vl);
*v6 = calloc((max_array_length + 12), sizeof ** v6);
*wl = calloc((max_array_length + 12), sizeof ** wl);
*w6 = calloc((max_array_length + 12), sizeof ** w6);
*el = calloc((max_array_length + 12), sizeof ** el);
*e6 = calloc((max_array_length + 12), sizeof ** e6);
*ql = calloc((max_array_length + 12), sizeof ** ql);
*q6 = calloc((max_array_length + 12), sizeof ** q6);
*deltaa = calloc((max_array_length + 12), sizeof ** deltaa);
*dv = calloc((max_array_length + 12), sizeof ** dv);
*dw = calloc((max_array_length + 12), sizeof ** dw);
*dq = calloc((max_array_length + 12), sizeof ** dq);
*de = calloc((max_array_length + 12), sizeof ** de);
*scratch1 = calloc((max_array_length + 12), sizeof ** scratch1);
*scratch2 = calloc((max_array_length + 12), sizeof ** scratch2);
*scratch3 = calloc((max_array_length + 12), sizeof ** scratch3);
*diffa = calloc((max_array_length + 12), sizeof ** diffa);
//for the states
*plft = calloc((max_array_length + 12), sizeof ** plft);
*prgh = calloc((max_array_length + 12), sizeof ** prgh);
*ulft = calloc((max_array_length + 12), sizeof ** ulft);
*urgh = calloc((max_array_length + 12), sizeof ** urgh);
*rlft = calloc((max_array_length + 12), sizeof ** rlft);
*rrgh = calloc((max_array_length + 12), sizeof ** rrgh);
*Cdtdx = calloc((max_array_length + 12), sizeof ** Cdtdx);
*fCdtdx = calloc((max_array_length + 12), sizeof ** fCdtdx);
//for the riemann solver
*clft = calloc((max_array_length + 12), sizeof ** clft);
*crgh = calloc((max_array_length + 12), sizeof ** crgh);
*plfti = calloc((max_array_length + 12), sizeof ** plfti);
*prghi = calloc((max_array_length + 12), sizeof ** prghi);
*pmid = calloc((max_array_length + 12), sizeof ** pmid);
*pmold = calloc((max_array_length + 12), sizeof ** pmold);
*wlft = calloc((max_array_length + 12), sizeof ** wlft);
*wrgh = calloc((max_array_length + 12), sizeof ** wrgh);
*zlft = calloc((max_array_length + 12), sizeof ** zlft);
*zrgh = calloc((max_array_length + 12), sizeof ** zrgh);
*umidl = calloc((max_array_length + 12), sizeof ** umidl);
*umidr = calloc((max_array_length + 12), sizeof ** umidr);
*umid = calloc((max_array_length + 12), sizeof ** umid);
// for the evolution
*dm = calloc((max_array_length + 12), sizeof ** dm);
*dtbdm = calloc((max_array_length + 12), sizeof ** dtbdm);
*upmid = calloc((max_array_length + 12), sizeof ** upmid);
*xa1 = calloc((max_array_length + 12), sizeof ** xa1);
*xa2 = calloc((max_array_length + 12), sizeof ** xa2);
*xa3 = calloc((max_array_length + 12), sizeof ** xa3);
*vx_1D_old = calloc((max_array_length + 12), sizeof ** vx_1D_old);
*e_int_1D = calloc((max_array_length + 12), sizeof ** e_int_1D);
*dvol = calloc((max_array_length + 12), sizeof ** dvol);
*dvol0 = calloc((max_array_length + 12), sizeof ** dvol0);
*dvol1 = calloc((max_array_length + 12), sizeof ** dvol1);
// for remapping
*delta = calloc((max_array_length + 12), sizeof ** delta);
*fluxr = calloc((max_array_length + 12), sizeof ** fluxr);
*fluxu = calloc((max_array_length + 12), sizeof ** fluxu);
*fluxv = calloc((max_array_length + 12), sizeof ** fluxv);
*fluxw = calloc((max_array_length + 12), sizeof ** fluxw);
*fluxe = calloc((max_array_length + 12), sizeof ** fluxe);
*fluxq = calloc((max_array_length + 12), sizeof ** fluxq);
*dm0 = calloc((max_array_length + 12), sizeof ** dm0);
// steep and flat coefficients for the flatten function
*steep = calloc((max_array_length + 12), sizeof ** steep);
*flat = calloc((max_array_length + 12), sizeof ** flat);
//for the para_coefficient
*para = calloc((max_array_length + 12), sizeof **para);
for (i = 0; i < (max_array_length + 12); i++) {
*((*para) + i) = calloc(5, sizeof ***para);
}
return 0;
}
int initiate_domain ( int  x,
int  y,
int  z 
)

The form of the obstacle is defined in this function example of just a round thing.

Definition at line 112 of file make_ic.c.

References dom, obstacle_density, obstacle_temperature, pre, rho, vx, vy, vz, x, y, and z.

Referenced by main().

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
int i2 = i - x / 2.0;
int j2 = j - y / 2.0;
int xy = sqrt(i2 * i2 + j2 * j2);
if (xy < x / 20) {
dom[i][j][k] = 1;
rho[i][j][k] = obstacle_density;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
} else {
dom[i][j][k] = 0;
}
}
}
}
printf("Initiate domain done\n");
return 0;
}
int initiate_domain_dom ( int  x,
int  y,
int  z 
)

If the dom file is given the density and temperature for the solid are given here. Note that the pre array holds the temperature for the solid

Definition at line 147 of file make_ic.c.

References dom, obstacle_density, obstacle_temperature, pre, rho, vx, vy, vz, x, y, and z.

Referenced by main().

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 1) {
rho[i][j][k] = obstacle_density;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
}
}
}
}
printf("Initiate domain done\n");
return 0;
}
int initiate_domain_marker ( int  x,
int  y,
int  z 
)

If the marker file is given the density for the marker is defined here.

Definition at line 174 of file make_ic.c.

References marker, marker_density, x, y, and z.

Referenced by main().

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (marker[i][j][k] == 1) {
marker[i][j][k] = marker_density;
}
}
}
}
printf("Initiate domain done\n");
return 0;
}
int initiate_grid ( int  x,
double  xmin,
double  xmax,
int  y,
double  ymin,
double  ymax,
int  z,
double  zmin,
double  zmax 
)

In this function the grid-parameters, such as spacing and physical coordinates for each cell are calculated

Definition at line 16 of file initiate_grid.c.

References spacing, x, xmin, y, ymin, z, zdx, zdy, zdz, zmin, zxa, zxc, zya, zyc, zza, and zzc.

Referenced by main().

{
int i, j, k;
double dxfac, dyfac, dzfac;
// spacing in all three directions
dxfac = (xmax - xmin) / (double) x;
dyfac = (ymax - ymin) / (double) y;
dzfac = (zmax - zmin) / (double) z;
// the coordinate at the cell boundary and the cell centre in x-direction
for (i = 0; i < x; i++) {
zxa[i] = xmin + (double) (i) * dxfac;
zdx[i] = dxfac;
zxc[i] = zxa[i] + 0.5 * zdx[i];
}
// the coordinate at the cell boundary and the cell centre in x-direction
for (j = 0; j < y; j++) {
zya[j] = ymin + (double) (j) * dyfac;
zdy[j] = dyfac;
zyc[j] = zya[j] + 0.5 * zdy[j];
}
// the coordiante at the cell boundary and the cell centre in x-direction
for (k = 0; k < z; k++) {
zza[k] = zmin + (double) (k) * dzfac;
zdz[k] = dzfac;
zzc[k] = zza[k] + 0.5 * zdz[k];
}
printf("Initiate grid done.\n");
//A spacing in all directions
spacing = dxfac;
return 0;
}
int insert_pressure ( int  x,
int  y,
int  z 
)

To insert pressure seeds in some regions

Definition at line 314 of file make_ic.c.

References dom, gasconstant, pre, rho, x, y, and z.

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] != 1) {
if (j < y / 4) {
if (round((double) rand() / (double) RAND_MAX) == 1) {
pre[i][j][k] = 2000 * gasconstant * rho[i][j][k];
}
}
}
}
}
}
return 0;
}
double kinematic_viscosity ( double  temperature,
double  density 
)

In order to enable viscosity in an explicit way, this routine calculates the kinematic_viscosity for a given temperature according to Sutherland's law.

Definition at line 23 of file kinematic_dyanmic_viscosity.c.

References C1_visc, kinematic_viscosity(), and S_visc.

Referenced by dt_calc(), dt_calc_first(), and kinematic_viscosity().

{
if ((temperature >= 200) && (temperature <= 1400)) {
kinematic_viscosity = (C1_visc * pow(temperature, 1.5)) / (temperature + S_visc);
kinematic_viscosity = kinematic_viscosity / density;
} else {
kinematic_viscosity = 0.0;
}
}
int left_boundary_inflow ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

outflow boundary condition

Definition at line 1092 of file set_boundary.c.

References Gamma, gasconstant, inflow_density, inflow_temperature, and inflow_velocity.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = inflow_density;
/ (inflow_density * Gamma) + 0.5 * (pow(inflow_velocity, 2));
vx_1D[nmin - n] = inflow_velocity;
vy_1D[nmin - n] = 0.0;
vz_1D[nmin - n] = 0.0;
dx[nmin - n] = dx[nmin];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = inflow_density;
rhoup[nmin - n] = inflow_density;
vxdown[nmin - n] = inflow_velocity;
vxup[nmin - n] = inflow_velocity;
vydown[nmin - n] = 0.0;
vyup[nmin - n] = 0.0;
vzdown[nmin - n] = 0.0;
vzup[nmin - n] = 0.0;
}
if (dimension > 2) {
rhofront[nmin - n] = inflow_density;
rhoback[nmin - n] = inflow_density;
vxfront[nmin - n] = inflow_velocity;
vxback[nmin - n] = inflow_velocity;
vyfront[nmin - n] = 0.0;
vyback[nmin - n] = 0.0;
vzfront[nmin - n] = 0.0;
vzback[nmin - n] = 0.0;
}
}
}
return 0;
}
int left_boundary_outflow ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

outflow boundary condition

Definition at line 973 of file set_boundary.c.

References Gamma, and small.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = rho_1D[nmin];
pre_1D[nmin - n] = pre_1D[nmin];
if (vx_1D[nmin] > 0) {
vx_1D[nmin - n] = small;
eng_1D[nmin - n] = pre_1D[nmin] / (rho_1D[nmin] * Gamma) + 0.5 *
(pow(vx_1D[nmin], 2) + pow(vy_1D[nmin], 2) + pow(vz_1D[nmin], 2));
} else {
vx_1D[nmin - n] = vx_1D[nmin];
eng_1D[nmin - n] = eng_1D[nmin];
}
dx[nmin - n] = dx[nmin];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = rhodown[nmin];
rhoup[nmin - n] = rhoup[nmin];
vxdown[nmin - n] = vxdown[nmin];
vxup[nmin - n] = small;
vydown[nmin - n] = small;
vyup[nmin - n] = vyup[nmin];
vzdown[nmin - n] = vzdown[nmin];
vzup[nmin - n] = vzup[nmin];
}
if (dimension > 2) {
rhofront[nmin - n] = rhofront[nmin];
rhoback[nmin - n] = rhoback[nmin];
vxfront[nmin - n] = small;
vxback[nmin - n] = small;
vyfront[nmin - n] = vyfront[nmin];
vyback[nmin - n] = vyback[nmin];
vzfront[nmin - n] = vzfront[nmin];
vzback[nmin - n] = vzback[nmin];
}
}
}
return 0;
}
int left_boundary_periodic ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

periodic boundary conditions

Definition at line 1203 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = rho_1D[nmax + 1 - n];
pre_1D[nmin - n] = pre_1D[nmax + 1 - n];
eng_1D[nmin - n] = eng_1D[nmax + 1 - n];
vx_1D[nmin - n] = vx_1D[nmax + 1 - n];
vy_1D[nmin - n] = vy_1D[nmax + 1 - n];
vz_1D[nmin - n] = vz_1D[nmax + 1 - n];
dx[nmin - n] = dx[nmax + 1 - n];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmax + 1 - n];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = rhodown[nmax + 1 - n];
rhoup[nmin - n] = rhoup[nmax + 1 - n];
vxdown[nmin - n] = vxdown[nmax + 1 - n];
vxup[nmin - n] = vxup[nmax + 1 - n];
vydown[nmin - n] = vydown[nmax + 1 - n];
vyup[nmin - n] = vyup[nmax + 1 - n];
vzdown[nmin - n] = vzdown[nmax + 1 - n];
vzup[nmin - n] = vzup[nmax + 1 - n];
}
if (dimension > 2) {
rhofront[nmin - n] = rhofront[nmax + 1 - n];
rhoback[nmin - n] = rhoback[nmax + 1 - n];
vxfront[nmin - n] = vxfront[nmax + 1 - n];
vxback[nmin - n] = vxback[nmax + 1 - n];
vyfront[nmin - n] = vyfront[nmax + 1 - n];
vyback[nmin - n] = vyback[nmax + 1 - n];
vzfront[nmin - n] = vzfront[nmax + 1 - n];
vzback[nmin - n] = vzback[nmax + 1 - n];
}
}
}
return 0;
}
int left_boundary_reflecting ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Reflecting boundary condition

Definition at line 640 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = rho_1D[nmin + n - 1];
pre_1D[nmin - n] = pre_1D[nmin + n - 1];
eng_1D[nmin - n] = eng_1D[nmin + n - 1];
vx_1D[nmin - n] = -1 * vx_1D[nmin + n - 1];
vy_1D[nmin - n] = -1 * vy_1D[nmin + n - 1];
vz_1D[nmin - n] = -1 * vz_1D[nmin + n - 1];
dx[nmin - n] = dx[nmin + n - 1];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin + n - 1];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = rhodown[nmin + n - 1];
rhoup[nmin - n] = rhoup[nmin + n - 1];
vxdown[nmin - n] = -vxdown[nmin + n - 1];
vxup[nmin - n] = -vxup[nmin + n - 1];
vydown[nmin - n] = -vydown[nmin + n - 1];
vyup[nmin - n] = -vyup[nmin + n - 1];
vzdown[nmin - n] = -vzdown[nmin + n - 1];
vzup[nmin - n] = -vzup[nmin + n - 1];
}
if (dimension > 2) {
rhofront[nmin - n] = rhofront[nmin + n - 1];
rhoback[nmin - n] = rhoback[nmin + n - 1];
vxfront[nmin - n] = -vxfront[nmin + n - 1];
vxback[nmin - n] = -vxback[nmin + n - 1];
vyfront[nmin - n] = -vyfront[nmin + n - 1];
vyback[nmin - n] = -vyback[nmin + n - 1];
vzfront[nmin - n] = -vzfront[nmin + n - 1];
vzback[nmin - n] = -vzback[nmin + n - 1];
}
}
}
return 0;
}
int left_boundary_reflecting_on_obstacle ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  pressure_solid_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Reflecting boundary condition on obstacle

Definition at line 694 of file set_boundary.c.

Referenced by set_boundary().

{
int n, k;
k = 1;
pressure_solid_1D[nmin] = pre_1D[nmin];
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = rho_1D[nmin + n - 1];
pre_1D[nmin - n] = pre_1D[nmin + n - 1];
eng_1D[nmin - n] = eng_1D[nmin + n - 1];
vx_1D[nmin - n] = -1 * vx_1D[nmin + n - 1];
vy_1D[nmin - n] = -1 * vy_1D[nmin + n - 1];
vz_1D[nmin - n] = -1 * vz_1D[nmin + n - 1];
dx[nmin - n] = dx[nmin + n - 1];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin + n - 1];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = rhodown[nmin + n - 1];
rhoup[nmin - n] = rhoup[nmin + n - 1];
vxdown[nmin - n] = -vxdown[nmin + n - 1];
vxup[nmin - n] = -vxup[nmin + n - 1];
vydown[nmin - n] = -vydown[nmin + n - 1];
vyup[nmin - n] = -vyup[nmin + n - 1];
vzdown[nmin - n] = -vzdown[nmin + n - 1];
vzup[nmin - n] = -vzup[nmin + n - 1];
}
if (dimension > 2) {
rhofront[nmin - n] = rhofront[nmin + n - 1];
rhoback[nmin - n] = rhoback[nmin + n - 1];
vxfront[nmin - n] = -vxfront[nmin + n - 1];
vxback[nmin - n] = -vxback[nmin + n - 1];
vyfront[nmin - n] = -vyfront[nmin + n - 1];
vyback[nmin - n] = -vyback[nmin + n - 1];
vzfront[nmin - n] = -vzfront[nmin + n - 1];
vzback[nmin - n] = -vzback[nmin + n - 1];
}
}
}
return 0;
}
int left_boundary_small_padding ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Small number (e.g. 1E-50) ghost cell filling

Definition at line 865 of file set_boundary.c.

References small.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = small;
pre_1D[nmin - n] = small;
eng_1D[nmin - n] = small;
vx_1D[nmin - n] = small;
vy_1D[nmin - n] = small;
vz_1D[nmin - n] = small;
dx[nmin - n] = dx[nmin];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = small;
rhoup[nmin - n] = small;
vxdown[nmin - n] = small;
vxup[nmin - n] = small;
vydown[nmin - n] = small;
vyup[nmin - n] = small;
vzdown[nmin - n] = small;
vzup[nmin - n] = small;
}
if (dimension > 2) {
rhofront[nmin - n] = small;
rhoback[nmin - n] = small;
vxfront[nmin - n] = small;
vxback[nmin - n] = small;
vyfront[nmin - n] = small;
vyback[nmin - n] = small;
vzfront[nmin - n] = small;
vzback[nmin - n] = small;
}
}
}
return 0;
}
int left_boundary_small_padding_on_obstacle ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  pressure_solid_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)
int left_boundary_zero_gradient ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Zero gradient boundary condition

Definition at line 475 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmin - n] = rho_1D[nmin];
pre_1D[nmin - n] = pre_1D[nmin];
eng_1D[nmin - n] = eng_1D[nmin];
vx_1D[nmin - n] = vx_1D[nmin];
vy_1D[nmin - n] = vy_1D[nmin];
vz_1D[nmin - n] = vz_1D[nmin];
dx[nmin - n] = dx[nmin];
xa[nmin - n] = xa[nmin - n + 1] - dx[nmin - n];
dx0[nmin - n] = dx0[nmin];
xa0[nmin - n] = xa0[nmin - n + 1] - dx0[nmin - n];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmin - n] = rhodown[nmin];
rhoup[nmin - n] = rhoup[nmin];
vxdown[nmin - n] = vxdown[nmin];
vxup[nmin - n] = vxup[nmin];
vydown[nmin - n] = vydown[nmin];
vyup[nmin - n] = vyup[nmin];
vzdown[nmin - n] = vzdown[nmin];
vzup[nmin - n] = vzup[nmin];
}
if (dimension > 2) {
rhofront[nmin - n] = rhofront[nmin];
rhoback[nmin - n] = rhoback[nmin];
vxfront[nmin - n] = vxfront[nmin];
vxback[nmin - n] = vxback[nmin];
vyfront[nmin - n] = vyfront[nmin];
vyback[nmin - n] = vyback[nmin];
vzfront[nmin - n] = vzfront[nmin];
vzback[nmin - n] = vzback[nmin];
}
}
}
return 0;
}
int make_ic ( int  x,
int  y,
int  z 
)

An initial model is build in this function. If the parameter file defines strat_const_atmos a stratified atmosphere is build. If the parameter is set to zero a constant pressure/density distribution is realized.

Definition at line 19 of file make_ic.c.

References boundary::back, bound, boundary::down, boundary::front, gasconstant, grav_acc, inflow_velocity, boundary::left, pre, rho, boundary::right, small, starting_flow, strat_const_atmos, boundary::up, vx, vy, vz, x, y, ymax, and z.

Referenced by main().

{
int i, j, k;
double velo_x, velo_y, velo_z;
double T0, T, A, rho0, pre0;
//T(z)=T_0 + A*(z-z0)
T0 = 288.15; //[K]
A = -6.5E-3; //[K/m]
rho0 = 1.229; // Density at sea level [kg/m^3]
pre0 = 1.013E5; //pressure at sea level [N/m^2]
velo_x = small;
velo_y = small;
velo_z = small;
if (starting_flow == 1) {
if (bound.down == 4) velo_y = inflow_velocity;
if (bound.up == 4) velo_y = inflow_velocity;
if (bound.left == 4) velo_x = inflow_velocity;
if (bound.right == 4) velo_x = inflow_velocity;
if (bound.front == 4) velo_z = inflow_velocity;
if (bound.back == 4) velo_z = inflow_velocity;
}
if (strat_const_atmos == 1) {
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
T = T0 + A * ((ymax / y) * (y - j));
rho[i][j][k] = rho0 * pow((T / T0), (-grav_acc / (gasconstant * A) + 1));
pre[i][j][k] = pre0 * pow((T / T0), (-grav_acc / (gasconstant * A)));
vx[i][j][k] = velo_x;
vy[i][j][k] = velo_y;
vz[i][j][k] = velo_z;
}
}
}
}
if (strat_const_atmos == 0) {
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
rho[i][j][k] = 1.229;
pre[i][j][k] = 300 * gasconstant * rho[i][j][k];
vx[i][j][k] = velo_x;
vy[i][j][k] = velo_y;
vz[i][j][k] = velo_z;
}
}
}
}
// If you need a conversion from temperature to pressure
// calculate_pressure(x, y, z, temperature);
//just to add explosions
//insert_pressure(x, y, z);
return 0;
}
int make_kh_instabilities ( int  x,
int  y,
int  z 
)

A simple Kelvin Helmholtz Instability Setup

Definition at line 271 of file make_ic.c.

References dimension, pre, rho, vx, vy, vz, x, xmax, y, z, and zmax.

Referenced by main().

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if ((j < y / 4) || (j > 3 * y / 4)) {
rho[i][j][k] = 1;
pre[i][j][k] = 1E5;
vx[i][j][k] = -50;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
} else {
rho[i][j][k] = 2;
pre[i][j][k] = 1E5;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
}
if (dimension == 3) {
if (j == y / 4) vy[i][j][k] = sin(xmax / x * i) * cos(zmax / z * k);
if (j == 3 * y / 4) vy[i][j][k] = -1 * sin(xmax / x * i) * cos(zmax / z * k);
}
if (dimension == 2) {
if (j == y / 4) vy[i][j][k] = sin(xmax / x * i);
if (j == 3 * y / 4) vy[i][j][k] = -1 * sin(xmax / x * i);
}
}
}
}
return 0;
}
int make_sod_ic ( int  x,
int  y,
int  z 
)

A Sod Shock Tube is generated here

Definition at line 196 of file make_ic.c.

References dimension, pre, rho, vx, vy, vz, x, y, and z.

Referenced by main().

{
int i, j, k;
float radius, radius1;
if (dimension == 2) radius = sqrt(pow(x, 2) + pow(y, 2));
if (dimension == 3) radius = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dimension == 1) {
if (i < x / 2) {
rho[i][j][k] = 1.0;
pre[i][j][k] = 1.0 * 5E4;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
} else {
rho[i][j][k] = 0.15;
pre[i][j][k] = 0.10 * 5E4;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
}
}
if (dimension == 2) {
radius1 = sqrt(pow(i, 2) + pow(j, 2));
if (radius1 < radius / 2) {
rho[i][j][k] = 1.0;
pre[i][j][k] = 1.0 * 1E4;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
} else {
rho[i][j][k] = 0.15;
pre[i][j][k] = 0.10 * 1E2;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
}
}
if (dimension == 3) {
radius1 = sqrt(pow(i, 2) + pow(j, 2) + pow(k, 2));
if (radius1 <= radius / 2) {
rho[i][j][k] = 1.0;
pre[i][j][k] = 1.0;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
} else {
rho[i][j][k] = 0.15;
pre[i][j][k] = 0.10;
vx[i][j][k] = 0.0;
vy[i][j][k] = 0.0;
vz[i][j][k] = 0.0;
}
}
}
}
}
return 0;
}
long long int ntohll ( const long long int  data)

converts double values to BigEndian VTK binaries are in BigEndian format as well as AMIRA MESH Files

Definition at line 21 of file big_endian_converter.c.

References x.

Referenced by write_amira(), write_ic_amira(), write_ic_vtk(), and write_vtk().

{
enum {
TYP_INIT, TYP_SMLE, TYP_BIGE
};
union {
long long int ull;
uint8_t c[8];
} x;
// Test if on BigEndian machine
static int typ = TYP_INIT;
if (typ == TYP_INIT) {
x.ull = 0x01;
typ = (x.c[7] == 0x01) ? TYP_BIGE : TYP_SMLE;
}
// If system is BigEndian; return data as is.
if (typ == TYP_BIGE) {
return data;
}
// convert data to Big Endian
x.ull = data;
int8_t c = 0;
c = x.c[0];
x.c[0] = x.c[7];
x.c[7] = c;
c = x.c[1];
x.c[1] = x.c[6];
x.c[6] = c;
c = x.c[2];
x.c[2] = x.c[5];
x.c[5] = c;
c = x.c[3];
x.c[3] = x.c[4];
x.c[4] = c;
return x.ull;
}
int para_coef ( int  nmin,
int  nmax,
int  flag1,
double *  a_coef,
double *  dx,
double *  ai_coef,
double *  b_coef,
double *  bi_coef,
double *  c_coef,
double *  d_x,
double **  para,
double *  ci_coef 
)

Here the coefficients for the parabel functions are determined.

Definition at line 17 of file para_coef.c.

Referenced by ppm_step(), and remap().

{
int i;
for (i = nmin - 2; i <= nmax; i++) {
a_coef[i] = dx[i] + dx[i + 1];
//printf("%i %i %e %e\n", flag1, i, dx[i], dx[i+1]);
ai_coef[i] = 1.0 / a_coef[i];
b_coef[i] = a_coef[i] + dx[i];
bi_coef[i] = 1.0 / b_coef[i];
c_coef[i] = a_coef[i] + dx[i + 1];
ci_coef[i] = 1.0 / c_coef[i];
}
//a(j+.5) = a(j) + C1 * (a(j+1)-a(j)) + C2 * da(j+1) + C3 * da(j)
for (i = nmin - 1; i <= nmax; i++) {
d_x[i] = 1.0 / (a_coef[i - 1] + a_coef[i + 1]);
para[i][0] = dx[i] * ai_coef[i] + 2.0 * dx[i + 1] * dx[i] * d_x[i] * ai_coef[i] * (a_coef[i - 1] * bi_coef[i] - a_coef[i + 1] * ci_coef[i]);
// to debug
//printf("%i %i %f %f %f\n", i, flag1, d_x[i], a_coef[i-1], a_coef[i+1]);
//printf("in para_coef: %f %f %f %f\n %f %f %f %f %f %i flag:%i\n", para[i][0], dx[i],ai_coef[i],dx[i+1], d_x[i], a_coef[i-1], bi_coef[i], a_coef[i+1], ci_coef[i], i, flag1);
para[i][1] = -1 * d_x[i] * dx[i] * a_coef[i - 1] * bi_coef[i];
para[i][2] = d_x[i] * dx[i + 1] * a_coef[i + 1] * ci_coef[i];
}
//da(j) = D1 * (a(j+1) - a(j)) + D2 * (a(j) - a(j-1))
for (i = nmin - 1; i <= nmax; i++) {
d_x[i] = dx[i] / (a_coef[i - 1] + dx[i + 1]);
para[i][3] = d_x[i] * b_coef[i - 1] * ai_coef[i];
para[i][4] = d_x[i] * c_coef[i] * ai_coef[i - 1];
}
// to debug
//for (n=0; n<max_array_length+12; n++) printf("in para_coef: %g %g %g %g %g %i where:%i\n", para[n][0], para[n][1], para[n][2], para[n][3], para[n][4], n, flag1);
return 0;
}
int parabola ( int  nmin,
int  nmax,
double *  a,
double *  deltaa,
double *  a6,
double *  al,
int  flag1,
double *  diffa,
double *  da,
double **  para,
double *  ar,
double *  flat,
double *  scratch1,
double *  scratch2,
double *  scratch3 
)

Here the picewise parabolic interpolated quantities for the PPM scheme are calculated.

Definition at line 45 of file parabola.c.

References min_par(), and signum_parabola().

Referenced by ppm_step(), and remap().

{
int i;
double tmp1, tmp2, tmp3, onemfl;
for (i = nmin - 2; i <= nmax + 1; i++) {
diffa[i] = a[i + 1] - a[i];
}
//Equation 1.7 of Colella & Woodward, Journal of Computational Physics 53, 174-201. 1984
//da(j) = D1 * (a(j+1) - a(j)) + D2 * (a(j) - a(j-1))
for (i = nmin - 1; i <= nmax + 1; i++) {
da[i] = para[i][3] * diffa[i] + para[i][4] * diffa[i - 1];
tmp1 = min_par(fabs(da[i]), 2.0 * fabs(diffa[i - 1]));
tmp2 = min_par(2.0 * fabs(diffa[i]), tmp1);
tmp3 = signum_parabola(da[i]);
da[i] = tmp2*tmp3;
}
//zero da(n) if a(n) is a local max/min
for (i = nmin - 1; i <= nmax + 1; i++) {
if (diffa[i - 1] * diffa[i] < 0.0) da[i] = 0.0;
}
//Equation 1.6 of of Colella & Woodward, Journal of Computational Physics 53, 174-201. 1984
//a(j+.5) = a(j) + C1 * (a(j+1)-a(j)) + C2 * dma(j+1) + C3 * dma(j)
//MONOT: Limit ar(n) to the range defined by a(n) and a(n+1)
for (i = nmin - 1; i <= nmax; i++) {
ar[i] = a[i] + para[i][0] * diffa[i] + para[i][1] * da[i + 1] + para[i][2] * da[i];
al[i + 1] = ar[i];
}
//eqn. 4.1 - flatten interpolation in zones with a shock ( flat(n)->1. )
for (i = nmin; i <= nmax; i++) {
onemfl = 1.0 - flat[i];
ar[i] = flat[i] * a[i] + onemfl * ar[i];
al[i] = flat[i] * a[i] + onemfl * al[i];
}
/*
MONOTONICITY constraints:
compute delta_a, a_6
MONOT: if a is a local max/min, flatten zone structure ar,al -> a.
MONOT: compute monotonzsed values using eq. 1.10 of of Colella & Woodward, Journal of Computational Physics 53, 174-201. 1984
if parabola exceeds al/ar, reset ar/al so that slope -> 0.
Recalculate delta_a and a_6
*/
for (i = nmin; i <= nmax; i++) {
onemfl = 1.0 - flat[i];
ar[i] = flat[i] * a[i] + onemfl * ar[i];
al[i] = flat[i] * a[i] + onemfl * al[i];
deltaa[i] = ar[i] - al[i];
a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));
scratch1[i] = (ar[i] - a[i])*(a[i] - al[i]);
scratch2[i] = deltaa[i] * deltaa[i];
scratch3[i] = deltaa[i] * a6[i];
if (scratch1[i] <= 0.0) {
ar[i] = a[i];
al[i] = a[i];
}
if (scratch2[i] < +scratch3[i]) al[i] = 3.0 * a[i] - 2.0 * ar[i];
if (scratch2[i] < -scratch3[i]) ar[i] = 3.0 * a[i] - 2.0 * al[i];
deltaa[i] = ar[i] - al[i];
a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));
}
for (i = nmin; i <= nmax; i++) {
if (scratch1[i] <= 0.0) {
ar[i] = a[i];
al[i] = a[i];
}
if (scratch2[i] < +scratch3[i]) al[i] = 3.0 * a[i] - 2.0 * ar[i];
if (scratch2[i] < -scratch3[i]) ar[i] = 3.0 * a[i] - 2.0 * al[i];
}
for (i = nmin; i <= nmax; i++) {
deltaa[i] = ar[i] - al[i];
a6[i] = 6.0 * (a[i] - 0.5 * (al[i] + ar[i]));
}
return 0;
}
int ppm_free ( double **  rho_1D,
double **  pre_1D,
double **  eng_1D,
double **  vx_1D,
double **  vy_1D,
double **  vz_1D,
double **  marker_1D,
double **  pressure_solid_1D,
double **  dx0,
double **  xa0,
double **  xa,
double **  dx,
double **  a_coef,
double **  ai_coef,
double **  b_coef,
double **  bi_coef,
double **  c_coef,
double **  ci_coef,
double **  d_x,
double **  da,
double **  ar,
double **  dp,
double **  dr,
double **  du,
double **  pl,
double **  p6,
double **  rl,
double **  r6,
double **  ul,
double **  u6,
double **  vl,
double **  v6,
double **  wl,
double **  w6,
double **  el,
double **  e6,
double **  ql,
double **  q6,
double **  deltaa,
double **  dv,
double **  dw,
double **  dq,
double **  de,
double **  scratch1,
double **  scratch2,
double **  scratch3,
double **  diffa,
double **  plft,
double **  prgh,
double **  ulft,
double **  urgh,
double **  rlft,
double **  rrgh,
double **  Cdtdx,
double **  fCdtdx,
double **  clft,
double **  crgh,
double **  plfti,
double **  prghi,
double **  pmid,
double **  pmold,
double **  wlft,
double **  wrgh,
double **  zlft,
double **  zrgh,
double **  umidl,
double **  umidr,
double **  umid,
double **  dm,
double **  dtbdm,
double **  upmid,
double **  xa1,
double **  xa2,
double **  xa3,
double **  vx_1D_old,
double **  e_int_1D,
double **  dvol,
double **  dvol0,
double **  dvol1,
double **  delta,
double **  fluxr,
double **  fluxu,
double **  fluxv,
double **  fluxw,
double **  fluxe,
double **  fluxq,
double **  dm0,
double **  steep,
double **  flat,
double ***  para,
double **  rhodown,
double **  rhoup,
double **  rhofront,
double **  rhoback,
double **  vxdown,
double **  vxup,
double **  vxfront,
double **  vxback,
double **  vydown,
double **  vyup,
double **  vyfront,
double **  vyback,
double **  vzdown,
double **  vzup,
double **  vzfront,
double **  vzback,
int  dimension 
)

all quantities within the hydro part are freed in this function

Definition at line 174 of file init.c.

References max_array_length.

Referenced by sweep_x(), sweep_y(), and sweep_z().

{
int i;
// the arrays which hold the hydro quantities
free(*rho_1D);
free(*pre_1D);
free(*eng_1D);
free(*vx_1D);
free(*vy_1D);
free(*vz_1D);
free(*marker_1D);
free(*pressure_solid_1D);
//free the 1D quantities for the viscosity calculations
if (dimension > 1) {
free(*rhodown);
free(*rhoup);
free(*vxdown);
free(*vxup);
free(*vydown);
free(*vyup);
free(*vzdown);
free(*vzup);
}
if (dimension > 2) {
free(*rhofront);
free(*rhoback);
free(*vxfront);
free(*vxback);
free(*vyfront);
free(*vyback);
free(*vzfront);
free(*vzback);
}
free(*dx0);
free(*xa0);
free(*xa);
free(*dx);
//allocates for the ppm routine
//for the parabolic interpolation constants
free(*a_coef);
free(*ai_coef);
free(*b_coef);
free(*bi_coef);
free(*c_coef);
free(*ci_coef);
free(*d_x);
free(*da);
free(*ar);
free(*dp);
free(*dr);
free(*du);
free(*pl);
free(*p6);
free(*rl);
free(*r6);
free(*ul);
free(*u6);
free(*vl);
free(*v6);
free(*wl);
free(*w6);
free(*el);
free(*e6);
free(*ql);
free(*q6);
free(*deltaa);
free(*dv);
free(*dw);
free(*dq);
free(*de);
free(*scratch1);
free(*scratch2);
free(*scratch3);
free(*diffa);
//for states
free(*plft);
free(*prgh);
free(*ulft);
free(*urgh);
free(*rlft);
free(*rrgh);
free(*Cdtdx);
free(*fCdtdx);
//Riemann solver
free(*clft);
free(*crgh);
free(*plfti);
free(*prghi);
free(*pmid);
free(*pmold);
free(*wlft);
free(*wrgh);
free(*zlft);
free(*zrgh);
free(*umidl);
free(*umidr);
free(*umid);
//evolve
free(*dm);
free(*dtbdm);
free(*upmid);
free(*xa1);
free(*xa2);
free(*xa3);
free(*vx_1D_old);
free(*e_int_1D);
free(*dvol);
free(*dvol0);
free(*dvol1);
//remap
free(*delta);
free(*fluxr);
free(*fluxu);
free(*fluxv);
free(*fluxw);
free(*fluxe);
free(*fluxq);
free(*dm0);
//steep and flat for flatten
free(*steep);
free(*flat);
//for para_coef
for (i = 0; i < (max_array_length + 12); i++) {
free(*((*para) + i));
}
free(*para);
return 0;
}
int ppm_step ( int  i,
int  j,
int  k,
int  direction,
int  flag,
int  nmin,
int  nmax,
double *  a_coef,
double *  ai_coef,
double *  b_coef,
double *  bi_coef,
double *  c_coef,
double *  ci_coef,
double *  d_x,
double *  diffa,
double *  da,
double *  ar,
double *  pl,
double *  p6,
double *  rl,
double *  r6,
double *  u6,
double *  ul,
double *  vl,
double *  v6,
double *  wl,
double *  w6,
double *  el,
double *  e6,
double *  ql,
double *  q6,
double *  dp,
double *  du,
double *  dr,
double *  dv,
double *  dw,
double *  dq,
double *  de,
double *  scratch1,
double *  scratch2,
double *  scratch3,
double *  plft,
double *  prgh,
double *  ulft,
double *  urgh,
double *  rlft,
double *  rrgh,
double *  Cdtdx,
double *  fCdtdx,
double *  steep,
double *  flat,
double **  para,
double *  clft,
double *  crgh,
double *  plfti,
double *  prghi,
double *  pmid,
double *  pmold,
double *  wlft,
double *  wrgh,
double *  zlft,
double *  zrgh,
double *  umidl,
double *  umidr,
double *  umid,
double *  dm,
double *  dtbdm,
double *  upmid,
double *  xa1,
double *  xa2,
double *  xa3,
double *  vx_1D_old,
double *  dvol,
double *  dvol0,
double *  dvol1,
double *  delta,
double *  fluxr,
double *  fluxu,
double *  fluxv,
double *  fluxw,
double *  fluxe,
double *  fluxq,
double *  dm0,
double *  e_int_1D,
double *  rho_1D,
double *  pre_1D,
double *  eng_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  marker_1D,
double *  pressure_solid_1D,
double *  dx0,
double *  xa0,
double *  xa,
double *  dx,
int  bound_checker,
int  lefter,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

The inner PPM Hydro scheme. First the relevant 1D distributions from the computational domain is given to this function. The scheme is as followed: First fill the ghost cells according to the defined boundary conditions. Solve the diffusion equation if needed. Calculate the parabolic function coefficients, then the volumes and the flatten coefficients due toe the steepness of the neighboring cells. Now the parabolic interpolated quantities are determined. The quantities at the interpolated points are given. The Riemann solver solves now the shock-tube problem. Then the hydrodynamic quantities are evolved and finally re-mapped on the computational grid.

Definition at line 24 of file ppm_step.c.

References advect(), advection, evolve(), flatten(), para_coef(), parabola(), remap(), riemann(), set_boundary(), states(), viscosity(), and volume().

Referenced by sweep_x(), sweep_y(), and sweep_z().

{
int n;
set_boundary(nmin, nmax, flag, bound_checker, lefter, rho_1D, eng_1D, pre_1D, vx_1D,
vy_1D, vz_1D, pressure_solid_1D, xa0, dx0, xa, dx, rhodown, rhoup, rhofront,
rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown,
vzup, vzfront, vzback, viscosity_on_off, dimension);
para_coef(nmin - 4, nmax + 5, flag, a_coef, dx,
ai_coef, b_coef, bi_coef, c_coef,
d_x, para, ci_coef);
volume(nmin, nmax, dvol, dx, dvol0, dx0);
flatten(nmin, nmax, pre_1D, vx_1D, steep, flat);
parabola(nmin - 4, nmax + 4, pre_1D, dp, p6, pl, 0, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 4, nmax + 4, rho_1D, dr, r6, rl, 1, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 4, nmax + 4, vx_1D, du, u6, ul, 2, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
states(nmin, nmax, flag, pre_1D, rho_1D, dx, Cdtdx, fCdtdx, plft,
pl, dp, p6, ulft, ul, du, u6, rlft, rl, dr,
r6, prgh, urgh, rrgh);
riemann(nmin - 3, nmax + 4, clft, crgh, rlft, rrgh, plfti,
prghi, pmid, pmold, plft, wrgh, prgh, wlft,
zlft, zrgh, umidl, umidr, umid, urgh, ulft);
evolve(nmin, nmax, flag, rho_1D, dvol, dm, dtbdm,
xa1, xa, dvol1, umid, upmid, pmid, xa2,
dx, xa3, vx_1D_old, vx_1D, vy_1D, vz_1D,
eng_1D, e_int_1D, pre_1D);
// if viscosity is set on
if (viscosity_on_off == 1) {
viscosity(i, j, k, flag, nmin, nmax, rho_1D, vx_1D, vy_1D, vz_1D, pre_1D,
e_int_1D, eng_1D, lefter, rhodown, rhoup, rhofront, rhoback, vxdown, vxup,
vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup,
vzfront, vzback, dimension);
}
remap(nmin, nmax, flag, a_coef, dx,
ai_coef, b_coef, bi_coef, c_coef,
d_x, para, ci_coef, dr, r6, rl, diffa,
da, ar, flat, scratch1, scratch2, scratch3,
du, u6, ul, dv, v6, vl, w6, wl,
dq, q6, ql, de, e6, el, xa, xa0, delta,
fluxr, fluxu, fluxv, fluxw, dw, fluxe, fluxq,
dm, rho_1D, dvol, dvol0, dm0, vx_1D, vy_1D,
vz_1D, eng_1D, e_int_1D, pre_1D);
if (advection == 1) {
advect(nmin, nmax, flag, dx, vx_1D, marker_1D);
}
return 0;
}
int pre_old_copy ( int  x,
int  y,
int  z 
)

Here the present pressure is copied into the pre_old

Definition at line 21 of file pre_old_copy.c.

References pre, pre_old, x, y, and z.

Referenced by main().

{
int i, j, k;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, pre_old, pre)
{
#endif
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
pre_old[i][j][k] = pre[i][j][k];
}
}
}
#ifdef _OPENMP
}
#endif
return 0;
}
int prepare_the_dB_map ( int  x,
int  y,
int  z 
)

Definition at line 666 of file noise_generator.c.

References dB_map, dB_Map_ready, dt_integrated, pressure_integrated, with_one_pulse, x, y, and z.

Referenced by main().

{
int i, j, k;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, pressure_integrated, \
dB_map, mean_pressure, dt_integrated, \
with_one_pulse, dB_Map_ready)
{
#endif
//just to make sure 0.0 dB-Maps are not written out
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (pressure_integrated[i][j][k] > 0.0) {
if (with_one_pulse == 0) dB_map[i][j][k] = 20 * log10((sqrt((1.0 / dt_integrated) * pressure_integrated[i][j][k])) / 2.0E-5);
//Assumption perfect sinus sound emitter
if (with_one_pulse == 1) dB_map[i][j][k] = 20 * log10(pressure_integrated[i][j][k] / 2.0E-5);
} else {
dB_map[i][j][k] = 0.0;
}
}
}
}
#ifdef _OPENMP
}
#endif
return 0;
}
int pressure_on_solid_calc ( int  x,
int  y,
int  z 
)

Here the total force due to the pressure on the solid is determined.

Definition at line 124 of file data_explorer.c.

References dimension, dom, output_dir, pressure_on_solid, time_sim, x, xmax, and ymax.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k, l;
double total_pressure_force;
total_pressure_force = 0.0;
sprintf(filename, "%stotal_pressure_on_solid.txt", output_dir);
fd = fopen(filename, "aw");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
if (dimension == 3) {
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, l) \
shared(x, y, z, total_pressure_force, \
pressure_on_solid, dimension, dom, xmax, \
ymax)
{
#endif
for (i = 1; i < x - 1; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 1; j < y - 1; j++) {
for (k = 1; k < z - 1; k++) {
if (dom[i][j][k] == 1) {
for (l = -1; l < 2; l++) {
if (l == 0) continue;
if (dom[i + l][j][k] == 0) {
total_pressure_force += pressure_on_solid[i + l][j][k]*(xmax / x)*(ymax / y);
}
if (dom[i][j + l][k] == 0) {
total_pressure_force += pressure_on_solid[i][j + l][k]*(xmax / x)*(ymax / y);
}
if (dom[i][j][k + l] == 0) {
total_pressure_force += pressure_on_solid[i][j][k + l]*(xmax / x)*(ymax / y);
}
}
}
}
}
}
#ifdef _OPENMP
}
#endif
}
if (dimension == 2) {
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, l, \
pressure_on_solid, \
dimension, dom, \
total_pressure_force, \
xmax, ymax)
{
#endif
k = 0;
for (i = 1; i < x - 1; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 1; j < y - 1; j++) {
if (dom[i][j][k] == 1) {
for (l = -1; l < 2; l++) {
if (l == 0) continue;
if (dom[i + l][j][k] == 0) {
total_pressure_force += pressure_on_solid[i + l][j][k]*(xmax / x);
}
if (dom[i][j + l][k] == 0) {
total_pressure_force += pressure_on_solid[i][j + l][k]*(xmax / x);
}
}
}
}
}
#ifdef _OPENMP
}
#endif
}
fprintf(fd, "%e %e\n", time_sim, total_pressure_force);
fclose(fd);
return 0;
}
int read_dom ( int  x,
int  y,
int  z 
)

Definition at line 129 of file read_ic.c.

References dom, obst_ic, x, y, and z.

Referenced by main().

{
int i, j, k, tmp1;
char filename[200];
FILE *fd;
//The initial obstacles distribution
sprintf(filename, "%s", obst_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No initial obstacles file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp1, 1, sizeof (int), fd);
dom[i][j][k] = tmp1;
}
}
}
fclose(fd);
return 0;
}
int read_ic ( int  x,
int  y,
int  z 
)

If you want to read in initial conditions from an native TYCHO file.

Definition at line 17 of file read_ic.c.

References counter, counter_restart, dens_ic, dom, gasconstant, intial_velocity_file, obst_ic, pre, rho, temp_ic, time_sim, vel_ic, vx, vy, vz, with_obstacles, x, y, and z.

Referenced by main().

{
int i, j, k, tmp1;
double tmp;
char filename[200];
char buffer[10];
FILE *fd;
//The initial density distribution.
sprintf(filename, "%s", dens_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("-----------------------------\n");
printf("No initial density file found\n");
printf("-----------------------------\n");
exit(12);
}
fgets(buffer, 100, fd);
fgets(buffer, 100, fd);
time_sim = atof(buffer);
fgets(buffer, 100, fd);
x = atoi(buffer);
fgets(buffer, 100, fd);
y = atoi(buffer);
fgets(buffer, 100, fd);
z = atoi(buffer);
fgets(buffer, 100, fd);
counter = atoi(buffer);
fgets(buffer, 100, fd);
counter_restart = atoi(buffer);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
rho[i][j][k] = tmp;
}
}
}
fclose(fd);
//The initial temperature distribution
sprintf(filename, "%s", temp_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No initial temperature file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
pre[i][j][k] = (tmp) * gasconstant * rho[i][j][k];
;
}
}
}
fclose(fd);
//The initial velocity distribution
sprintf(filename, "%s", vel_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("------------------------------\n");
printf("No initial velocity file found\n");
printf("------------------------------\n");
exit(14);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
vx[i][j][k] = tmp;
fread(&tmp, 1, sizeof (double), fd);
vy[i][j][k] = tmp;
fread(&tmp, 1, sizeof (double), fd);
vz[i][j][k] = tmp;
}
}
}
fclose(fd);
}
if (with_obstacles == 1) {
//The initial obstacles distribution
sprintf(filename, "%s", obst_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No initial obstacles file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp1, 1, sizeof (int), fd);
dom[i][j][k] = tmp1;
}
}
}
fclose(fd);
}
return 0;
}
int read_marker_file ( int  x,
int  y,
int  z 
)

Definition at line 186 of file read_ic.c.

References marker, marker_ic, x, y, and z.

Referenced by main().

{
int i, j, k, tmp1;
char filename[200];
FILE *fd;
//The initial marker distribution
sprintf(filename, "%s", marker_ic);
fd = fopen(filename, "r");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No initial marker file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp1, 1, sizeof (int), fd);
marker[i][j][k] = tmp1;
}
}
}
fclose(fd);
return 0;
}
int read_restart ( int  x,
int  y,
int  z 
)

Read restart from an native TYCHO file.

Definition at line 17 of file read_restart.c.

References advection, counter, counter_restart, dom, gasconstant, marker, output_dir, pre, pressure_integrated, rho, soundemitter, time_sim, vx, vy, vz, wind_marker, wind_on_off, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
int i, j, k, tmp1;
double tmp;
char filename[200];
char filename1[200];
char buffer[10];
FILE *fd;
FILE *fd1;
int x1, y1, z1;
//The density distribution.
sprintf(filename, "%srho_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("-----------------------------\n");
printf("No restart density file found\n");
printf("-----------------------------\n");
exit(12);
}
fgets(buffer, 100, fd);
fgets(buffer, 100, fd);
time_sim = atof(buffer);
fgets(buffer, 100, fd);
x1 = atoi(buffer);
fgets(buffer, 100, fd);
y1 = atoi(buffer);
fgets(buffer, 100, fd);
z1 = atoi(buffer);
fgets(buffer, 100, fd);
counter = atoi(buffer);
fgets(buffer, 100, fd);
counter_restart = atoi(buffer);
fseek(fd, 200, SEEK_SET);
fseek(fd1, 200, SEEK_SET);
if ((x != x1) || (y != y1) || (z != z1)) {
printf("Restart File dimension mismatch.");
exit(21);
}
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
rho[i][j][k] = tmp;
}
}
}
fclose(fd);
//The temperature distribution
sprintf(filename, "%stemp_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart pressure file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
pre[i][j][k] = tmp * (gasconstant * rho[i][j][k]);
}
}
}
fclose(fd);
sprintf(filename, "%svel_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("------------------------------\n");
printf("No restart velocity file found\n");
printf("------------------------------\n");
exit(14);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
vx[i][j][k] = tmp;
fread(&tmp, 1, sizeof (double), fd);
vy[i][j][k] = tmp;
fread(&tmp, 1, sizeof (double), fd);
vz[i][j][k] = tmp;
}
}
}
fclose(fd);
if (with_obstacles == 1) {
//The obstacles distribution
sprintf(filename, "%sdom_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart obstacles file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp1, 1, sizeof (int), fd);
dom[i][j][k] = tmp1;
}
}
}
fclose(fd);
}
if (with_sound_emitter == 1) {
//The obstacles distribution
sprintf(filename, "%ssound_emitter_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart sound-emitter file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp1, 1, sizeof (int), fd);
soundemitter[i][j][k] = tmp1;
}
}
}
fclose(fd);
//The obstacles distribution
sprintf(filename, "%spressure_integrated_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart pressure-integrated restart file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
pressure_integrated[i][j][k] = tmp;
}
}
}
fclose(fd);
}
if (advection == 1) {
//The marker distribution
sprintf(filename, "%smarker_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart marker file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
marker[i][j][k] = tmp;
}
}
}
fclose(fd);
}
if (wind_on_off == 1) {
//The wind marker distribution
sprintf(filename, "%swind_restart.tyc", output_dir);
fd = fopen(filename, "rb");
if (fd == NULL) {
printf("---------------------------------\n");
printf("No restart wind marker file found\n");
printf("---------------------------------\n");
exit(13);
}
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
fread(&tmp, 1, sizeof (double), fd);
wind_marker[i][j][k] = tmp;
}
}
}
fclose(fd);
}
return 0;
}
int remap ( int  nmin,
int  nmax,
int  flag,
double *  a_coef,
double *  dx,
double *  ai_coef,
double *  b_coef,
double *  bi_coef,
double *  c_coef,
double *  d_x,
double **  para,
double *  ci_coef,
double *  dr,
double *  r6,
double *  rl,
double *  diffa,
double *  da,
double *  ar,
double *  flat,
double *  scratch1,
double *  scratch2,
double *  scratch3,
double *  du,
double *  u6,
double *  ul,
double *  dv,
double *  v6,
double *  vl,
double *  w6,
double *  wl,
double *  dq,
double *  q6,
double *  ql,
double *  de,
double *  e6,
double *  el,
double *  xa,
double *  xa0,
double *  delta,
double *  fluxr,
double *  fluxu,
double *  fluxv,
double *  fluxw,
double *  dw,
double *  fluxe,
double *  fluxq,
double *  dm,
double *  rho_1D,
double *  dvol,
double *  dvol0,
double *  dm0,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  eng_1D,
double *  e_int_1D,
double *  pre_1D 
)

Remap the new hydro-quantities on the computational domain grid.

Definition at line 30 of file remap.c.

References Gamma, max_remap(), para_coef(), parabola(), smallp, and smallr.

Referenced by ppm_step().

{
int n, nn;
double fractn, fractn2, ekin;
double deltx;
double fourthd = 4.0 / 3.0;
//Generate interpolation functions, saving da, al for
//constructing left and right total energy states.
para_coef(nmin - 1, nmax + 1, 1, a_coef, dx,
ai_coef, b_coef, bi_coef, c_coef,
d_x, para, ci_coef);
parabola(nmin - 1, nmax + 1, rho_1D, dr, r6, rl, 3, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 1, nmax + 1, vx_1D, du, u6, ul, 4, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 1, nmax + 1, vy_1D, dv, v6, vl, 5, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 1, nmax + 1, vz_1D, dw, w6, wl, 6, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 1, nmax + 1, e_int_1D, dq, q6, ql, 7, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
parabola(nmin - 1, nmax + 1, eng_1D, de, e6, el, 8, diffa,
da, para, ar, flat, scratch1, scratch2, scratch3);
for (n = nmin; n <= nmax + 1; n++) {
delta[n] = xa[n] - xa0[n];
}
//Calculate the total mass (fluxr), momentum (fluxu), and energy (fluxe)
//in the subshell created by the overlap of the Lagrangian and Eulerian grids.
//If the zone face has moved to the left (deltx > 0), use the integral from the
//left side of zone n (fluxrr). If the zone face has moved to the right
//(deltx < 0), use the integral from the right side of zone nn=n-1 (fluxrl).
for (n = nmin; n <= nmax + 1; n++) {
deltx = xa[n] - xa0[n];
if (deltx >= 0.0) {
nn = n - 1;
fractn = 0.5 * deltx / dx[nn];
fractn2 = 1.0 - fourthd*fractn;
fluxr[n] = (rl[nn] + dr[nn] - fractn * (dr[nn] - fractn2 * r6[nn])) * delta[n];
fluxu[n] = (ul[nn] + du[nn] - fractn * (du[nn] - fractn2 * u6[nn])) * fluxr[n];
fluxv[n] = (vl[nn] + dv[nn] - fractn * (dv[nn] - fractn2 * v6[nn])) * fluxr[n];
fluxw[n] = (wl[nn] + dw[nn] - fractn * (dw[nn] - fractn2 * w6[nn])) * fluxr[n];
fluxe[n] = (el[nn] + de[nn] - fractn * (de[nn] - fractn2 * e6[nn])) * fluxr[n];
fluxq[n] = (ql[nn] + dq[nn] - fractn * (dq[nn] - fractn2 * q6[nn])) * fluxr[n];
} else {
fractn = 0.5 * deltx / dx[n];
fractn2 = 1.0 + fourthd*fractn;
fluxr[n] = (rl[n] - fractn * (dr[n] + fractn2 * r6[n])) * delta[n];
fluxu[n] = (ul[n] - fractn * (du[n] + fractn2 * u6[n])) * fluxr[n];
fluxv[n] = (vl[n] - fractn * (dv[n] + fractn2 * v6[n])) * fluxr[n];
fluxw[n] = (wl[n] - fractn * (dw[n] + fractn2 * w6[n])) * fluxr[n];
fluxe[n] = (el[n] - fractn * (de[n] + fractn2 * e6[n])) * fluxr[n];
fluxq[n] = (ql[n] - fractn * (dq[n] + fractn2 * q6[n])) * fluxr[n];
}
}
//Advect mass, momentum, and energy by moving the sub-shell quantities
//into the appropriate Eulerian zone.
for (n = nmin; n <= nmax; n++) {
dm[n] = rho_1D[n] * dvol[n];
dm0[n] = dm[n] + fluxr[n] - fluxr[n + 1];
rho_1D[n] = dm0[n] / dvol0[n];
rho_1D[n] = max_remap(smallr, rho_1D[n]);
dm0[n] = 1.0 / (rho_1D[n] * dvol0[n]);
vx_1D[n] = (vx_1D[n] * dm[n] + fluxu[n] - fluxu[n + 1]) * dm0[n];
vy_1D[n] = (vy_1D[n] * dm[n] + fluxv[n] - fluxv[n + 1]) * dm0[n];
vz_1D[n] = (vz_1D[n] * dm[n] + fluxw[n] - fluxw[n + 1]) * dm0[n];
eng_1D[n] = (eng_1D[n] * dm[n] + fluxe[n] - fluxe[n + 1]) * dm0[n];
e_int_1D[n] = (e_int_1D[n] * dm[n] + fluxq[n] - fluxq[n + 1]) * dm0[n];
//If flow is highly supersonic remap on internal energy, else on total energy
ekin = 0.5 * (pow(vx_1D[n], 2) + pow(vy_1D[n], 2) + pow(vz_1D[n], 2));
if (ekin / e_int_1D[n] < 100.0) e_int_1D[n] = eng_1D[n] - ekin;
pre_1D[n] = Gamma * rho_1D[n] * e_int_1D[n];
pre_1D[n] = max_remap(smallp, pre_1D[n]);
}
return 0;
}
int reset_pressure_integrated ( int  x,
int  y,
int  z 
)

Definition at line 634 of file noise_generator.c.

References pressure_integrated, x, y, and z.

Referenced by main().

{
int i, j, k;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, pressure_integrated)
{
#endif
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
pressure_integrated[i][j][k] = 0.0;
}
}
}
#ifdef _OPENMP
}
#endif
return 0;
}
int riemann ( int  nmin,
int  nmax,
double *  clft,
double *  crgh,
double *  rlft,
double *  rrgh,
double *  plfti,
double *  prghi,
double *  pmid,
double *  pmold,
double *  plft,
double *  wrgh,
double *  prgh,
double *  wlft,
double *  zlft,
double *  zrgh,
double *  umidl,
double *  umidr,
double *  umid,
double *  urgh,
double *  ulft 
)

The Riemann solver for the shock tube problem.

Input variables are: lmin = zone number of first physical zone lmax = zone number of first ghost zone on right (lmax=nmax+1) gamma = equation of state gamma prgh = pressure state on the right side of the boundary plft = pressure state on the left side of the boundary urgh = velocity state on the right side of the boundary ulft = velocity state on the left side of the boundary vrgh = density state on the right side of the boundary rlft = density state on the left side of the boundary (rlft and vrgh are inverted to get the specific volume)

Output variables are: umid = time_sim averaged velocity at the zone interface pmid = time_sim averaged pressure at the zone interface

Definition at line 46 of file riemann.c.

References Gamma1, max_riemann(), and smallp.

Referenced by ppm_step().

{
int n, l;
double tol = 1.0E-3;
double gamfac2, gamfac1;
gamfac2 = Gamma1 + 1.0;
gamfac1 = 0.5 * (gamfac2) / Gamma1;
//Obtain first guess for Pmid by assuming Wlft, Wrgh = Clft, Crgh
for (n = nmin; n <= nmax; n++) {
clft[n] = sqrt(Gamma1 * plft[n] * rlft[n]);
crgh[n] = sqrt(Gamma1 * prgh[n] * rrgh[n]);
rlft[n] = 1.0 / rlft[n];
rrgh[n] = 1.0 / rrgh[n];
plfti[n] = 1.0 / plft[n];
prghi[n] = 1.0 / prgh[n];
pmid[n] = prgh[n] - plft[n] - crgh[n]*(urgh[n] - ulft[n]);
pmid[n] = plft[n] + pmid[n] * clft[n] / (clft[n] + crgh[n]);
pmid[n] = max_riemann(smallp, pmid[n]);
}
/*
Iterate up to 8 time_sims using Newton's method to converge on correct Pmid
-use previous guess for pmid to get wavespeeds: wlft, wrgh
-find the slope in the u-P plane for each state: zlft, zrgh
-use the wavespeeds and pmid to guess umid on each side: umidl, umidr
-project tangents from (pmid,umidl) and (pmid,umidr) to get new pmid
-make sure pmid does not fall below floor value for pressure
*/
for (n = nmin; n <= nmax; n++) {
for (l = 0; l < 12; l++) {
pmold[n] = pmid[n];
wlft[n] = 1.0 + gamfac1 * (pmid[n] - plft[n]) * plfti[n];
wrgh[n] = 1.0 + gamfac1 * (pmid[n] - prgh[n]) * prghi[n];
wlft[n] = clft[n] * sqrt(wlft[n]);
wrgh[n] = crgh[n] * sqrt(wrgh[n]);
zlft[n] = 4.0 * rlft[n] * wlft[n] * wlft[n];
zrgh[n] = 4.0 * rrgh[n] * wrgh[n] * wrgh[n];
zlft[n] = -zlft[n] * wlft[n] / (zlft[n] - gamfac2 * (pmid[n] - plft[n]));
zrgh[n] = zrgh[n] * wrgh[n] / (zrgh[n] - gamfac2 * (pmid[n] - prgh[n]));
umidl[n] = ulft[n] - (pmid[n] - plft[n]) / wlft[n];
umidr[n] = urgh[n] + (pmid[n] - prgh[n]) / wrgh[n];
pmid[n] = pmid[n] + (umidr[n] - umidl[n])*(zlft[n] * zrgh[n]) / (zrgh[n] - zlft[n]);
pmid[n] = max_riemann(smallp, pmid[n]);
if (fabs(pmid[n] - pmold[n]) / pmid[n] < tol) break;
}
}
//Calculate umid by averaging umidl, umidr based on new pmid
for (n = nmin; n <= nmax; n++) {
umidl[n] = ulft[n] - (pmid[n] - plft[n]) / wlft[n];
umidr[n] = urgh[n] + (pmid[n] - prgh[n]) / wrgh[n];
umid [n] = 0.5 * (umidl[n] + umidr[n]);
}
return 0;
}
int right_boundary_inflow ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

outflow boundary condition

Definition at line 1147 of file set_boundary.c.

References Gamma, gasconstant, inflow_density, inflow_temperature, and inflow_velocity.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmax + n] = inflow_density;
/ (inflow_density * Gamma) + 0.5 * (pow(inflow_velocity, 2));
vx_1D[nmax + n] = inflow_velocity;
vy_1D[nmax + n] = 0.0;
vz_1D[nmax + n] = 0.0;
dx[nmax + n] = dx[nmax];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmax];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = inflow_density;
rhoup[nmax + n] = inflow_density;
vxdown[nmax + n] = inflow_velocity;
vxup[nmax + n] = inflow_velocity;
vydown[nmax + n] = 0.0;
vyup[nmax + n] = 0.0;
vzdown[nmax + n] = 0.0;
vzup[nmax + n] = 0.0;
}
if (dimension > 2) {
rhofront[nmax + n] = inflow_density;
rhoback[nmax + n] = inflow_density;
vxfront[nmax + n] = inflow_velocity;
vxback[nmax + n] = inflow_velocity;
vyfront[nmax + n] = 0.0;
vyback[nmax + n] = 0.0;
vzfront[nmax + n] = 0.0;
vzback[nmax + n] = 0.0;
}
}
}
return 0;
}
int right_boundary_outflow ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

outflow boundary condition

Definition at line 1032 of file set_boundary.c.

References Gamma, and small.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmax + n] = rho_1D[nmax];
pre_1D[nmax + n] = pre_1D[nmax];
if (vx_1D[nmax] < 0) {
vx_1D[nmax + n] = small;
eng_1D[nmax + n] = pre_1D[nmax] / (rho_1D[nmax] * Gamma) + 0.5 *
(pow(vx_1D[nmax], 2) + pow(vy_1D[nmax], 2) + pow(vz_1D[nmax], 2));
} else {
vx_1D[nmax + n] = vx_1D[nmax];
eng_1D[nmax + n] = eng_1D[nmax];
}
dx[nmax + n] = dx[nmax];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmax];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = rhodown[nmax];
rhoup[nmax + n] = rhoup[nmax];
vxdown[nmax + n] = small;
vxup[nmax + n] = small;
vyup[nmax + n] = vyup[nmax];
vzdown[nmax + n] = vzdown[nmax];
vzup[nmax + n] = vzup[nmax];
}
if (dimension > 2) {
rhofront[nmax + n] = rhofront[nmax];
rhoback[nmax + n] = rhoback[nmax];
vxfront[nmax + n] = small;
vxback[nmax + n] = small;
vyfront[nmax + n] = vyfront[nmax];
vyback[nmax + n] = vyback[nmax];
vzfront[nmax + n] = vzfront[nmax];
vzback[nmax + n] = vzback[nmax];
}
}
}
return 0;
}
int right_boundary_periodic ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

periodic boundary conditions

Definition at line 1259 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[nmax + n] = rho_1D[nmin + n - 1];
pre_1D[nmax + n] = pre_1D[nmin + n - 1];
eng_1D[nmax + n] = eng_1D[nmin + n - 1];
vx_1D[nmax + n] = vx_1D[nmin + n - 1];
vy_1D[nmax + n] = vy_1D[nmin + n - 1];
vz_1D[nmax + n] = vz_1D[nmin + n - 1];
dx[nmax + n] = dx[nmin + n - 1];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmin + n - 1];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = rhodown[nmin + n - 1];
rhoup[nmax + n] = rhoup[nmin + n - 1];
vxdown[nmax + n] = vxdown[nmin + n - 1];
vxup[nmax + n] = vxup[nmin + n - 1];
vydown[nmax + n] = vydown[nmin + n - 1];
vyup[nmax + n] = vyup[nmin + n - 1];
vzdown[nmax + n] = vzdown[nmin + n - 1];
vzup[nmax + n] = vzup[nmin + n - 1];
}
if (dimension > 2) {
rhofront[nmax + n] = rhofront[nmin + n - 1];
rhoback[nmax + n] = rhoback[nmin + n - 1];
vxfront[nmax + n] = vxfront[nmin + n - 1];
vxback[nmax + n] = vxback[nmin + n - 1];
vyfront[nmax + n] = vyfront[nmin + n - 1];
vyback[nmax + n] = vyback[nmin + n - 1];
vzfront[nmax + n] = vzfront[nmin + n - 1];
vzback[nmax + n] = vzback[nmin + n - 1];
}
}
}
return 0;
}
int right_boundary_reflecting ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Reflecting boundary condition

Definition at line 752 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[n + nmax] = rho_1D[nmax + 1 - n];
pre_1D[n + nmax] = pre_1D[nmax + 1 - n];
eng_1D[n + nmax] = eng_1D[nmax + 1 - n];
vx_1D[n + nmax] = -vx_1D[nmax + 1 - n];
vy_1D[n + nmax] = -vy_1D[nmax + 1 - n];
vz_1D[n + nmax] = -vz_1D[nmax + 1 - n];
dx[n + nmax] = dx[nmax + 1 - n];
xa[n + nmax] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[n + nmax] = dx0[nmax + 1 - n];
xa0[n + nmax] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[n + nmax] = rhodown[nmax + 1 - n];
rhoup[n + nmax] = rhoup[nmax + 1 - n];
vxdown[n + nmax] = -vxdown[nmax + 1 - n];
vxup[n + nmax] = -vxup[nmax + 1 - n];
vydown[n + nmax] = -vydown[nmax + 1 - n];
vyup[n + nmax] = -vyup[nmax + 1 - n];
vzdown[n + nmax] = -vzdown[nmax + 1 - n];
vzup[n + nmax] = -vzup[nmax + 1 - n];
}
if (dimension > 2) {
rhofront[n + nmax] = rhofront[nmax + 1 - n];
rhoback[n + nmax] = rhoback[nmax + 1 - n];
vxfront[n + nmax] = -vxfront[nmax + 1 - n];
vxback[n + nmax] = -vxback[nmax + 1 - n];
vyfront[n + nmax] = -vyfront[nmax + 1 - n];
vyback[n + nmax] = -vyback[nmax + 1 - n];
vzfront[n + nmax] = -vzfront[nmax + 1 - n];
vzback[n + nmax] = -vzback[nmax + 1 - n];
}
}
}
return 0;
}
int right_boundary_reflecting_on_obstacle ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  pressure_solid_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Reflecting boundary condition on obstacle

Definition at line 807 of file set_boundary.c.

Referenced by set_boundary().

{
int n;
pressure_solid_1D[nmax] = pre_1D[nmax];
for (n = 1; n < 7; n++) {
rho_1D[n + nmax] = rho_1D[nmax + 1 - n];
pre_1D[n + nmax] = pre_1D[nmax + 1 - n];
eng_1D[n + nmax] = eng_1D[nmax + 1 - n];
vx_1D[n + nmax] = -vx_1D[nmax + 1 - n];
vy_1D[n + nmax] = -vy_1D[nmax + 1 - n];
vz_1D[n + nmax] = -vz_1D[nmax + 1 - n];
dx[n + nmax] = dx[nmax + 1 - n];
xa[n + nmax] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[n + nmax] = dx0[nmax + 1 - n];
xa0[n + nmax] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = rhodown[nmax + 1 - n];
rhoup[nmax + n] = rhoup[nmax + 1 - n];
vxdown[nmax + n] = -vxdown[nmax + 1 - n];
vxup[nmax + n] = -vxup[nmax + 1 - n];
vydown[nmax + n] = -vydown[nmax + 1 - n];
vyup[nmax + n] = -vyup[nmax + 1 - n];
vzdown[nmax + n] = -vzdown[nmax + 1 - n];
vzup[nmax + n] = -vzup[nmax + 1 - n];
}
if (dimension > 2) {
rhofront[nmax + n] = rhofront[nmax + 1 - n];
rhoback[nmax + n] = rhoback[nmax + 1 - n];
vxfront[nmax + n] = -vxfront[nmax + 1 - n];
vxback[nmax + n] = -vxback[nmax + 1 - n];
vyfront[nmax + n] = -vyfront[nmax + 1 - n];
vyback[nmax + n] = -vyback[nmax + 1 - n];
vzfront[nmax + n] = -vzfront[nmax + 1 - n];
vzback[nmax + n] = -vzback[nmax + 1 - n];
}
}
}
return 0;
}
int right_boundary_small_padding ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Small number (e.g. 1E-50) ghost cell filling

Definition at line 919 of file set_boundary.c.

References small.

Referenced by set_boundary().

{
int n;
for (n = 1; n < 7; n++) {
rho_1D[n + nmax] = small;
pre_1D[n + nmax] = small;
eng_1D[n + nmax] = small;
vx_1D[n + nmax] = small;
vy_1D[n + nmax] = small;
vz_1D[n + nmax] = small;
dx[nmax + n] = dx[nmax];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmax];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = small;
rhoup[nmax + n] = small;
vxdown[nmax + n] = small;
vxup[nmax + n] = small;
vydown[nmax + n] = small;
vyup[nmax + n] = small;
vzdown[nmax + n] = small;
vzup[nmax + n] = small;
}
if (dimension > 2) {
rhofront[nmax + n] = small;
rhoback[nmax + n] = small;
vxfront[nmax + n] = small;
vxback[nmax + n] = small;
vyfront[nmax + n] = small;
vyback[nmax + n] = small;
vzfront[nmax + n] = small;
vzback[nmax + n] = small;
}
}
}
return 0;
}
int right_boundary_zero_gradient ( int  nmin,
int  nmax,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
int  flag,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

Zero gradient boundary condition or if stratisfied atmosphere needed the atmosphere is extened into the ghost cells.

Definition at line 531 of file set_boundary.c.

References gasconstant, grav_acc, strat_const_atmos, y, and ymax.

Referenced by set_boundary().

{
double T0, T, A, rho0, pre0;
//T(z)=T_0 + A*(z-z0)
T0 = 288.15; //[K]
A = -6.5E-3; //[K/m]
rho0 = 1.229; // Density at sea level [kg/m^3]
pre0 = 1.013E5; //pressure at sea level [N/m^2]
int n;
if ((strat_const_atmos == 1) && (flag == 1)) {
for (n = 1; n < 7; n++) {
T = T0 + A * ((ymax / y) * (y + n - 1));
rho_1D[nmax + n] = rho0 * pow((T / T0), (-grav_acc / (gasconstant * A) + 1));
pre_1D[nmax + n] = pre0 * pow((T / T0), (-grav_acc / (gasconstant * A)));
eng_1D[nmax + n] = eng_1D[nmax];
vx_1D[nmax + n] = vx_1D[nmax];
vy_1D[nmax + n] = vy_1D[nmax];
vz_1D[nmax + n] = vz_1D[nmax];
dx[nmax + n] = dx[nmax];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmax];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = rhodown[nmax];
rhoup[nmax + n] = rhoup[nmax];
vxdown[nmax + n] = vxdown[nmax];
vxup[nmax + n] = vxup[nmax];
vydown[nmax + n] = vydown[nmax];
vyup[nmax + n] = vyup[nmax];
vzdown[nmax + n] = vzdown[nmax];
vzup[nmax + n] = vzup[nmax];
}
if (dimension > 2) {
rhofront[nmax + n] = rhofront[nmax];
rhoback[nmax + n] = rhoback[nmax];
vxfront[nmax + n] = vxfront[nmax];
vxback[nmax + n] = vxback[nmax];
vyfront[nmax + n] = vyfront[nmax];
vyback[nmax + n] = vyback[nmax];
vzfront[nmax + n] = vzfront[nmax];
vzback[nmax + n] = vzback[nmax];
}
}
}
} else {
for (n = 1; n < 7; n++) {
rho_1D[nmax + n] = rho_1D[nmax];
pre_1D[nmax + n] = pre_1D[nmax];
eng_1D[nmax + n] = eng_1D[nmax];
vx_1D[nmax + n] = vx_1D[nmax];
vy_1D[nmax + n] = vy_1D[nmax];
vz_1D[nmax + n] = vz_1D[nmax];
dx[nmax + n] = dx[nmax];
xa[nmax + n] = xa[nmax + n - 1] + dx[nmax + n - 1];
dx0[nmax + n] = dx0[nmax];
xa0[nmax + n] = xa0[nmax + n - 1] + dx0[nmax + n - 1];
if (viscosity_on_off == 1) {
if (dimension > 1) {
rhodown[nmax + n] = rhodown[nmax];
rhoup[nmax + n] = rhoup[nmax];
vxdown[nmax + n] = vxdown[nmax];
vxup[nmax + n] = vxup[nmax];
vydown[nmax + n] = vydown[nmax];
vyup[nmax + n] = vyup[nmax];
vzdown[nmax + n] = vzdown[nmax];
vzup[nmax + n] = vzup[nmax];
}
if (dimension > 2) {
rhofront[nmax + n] = rhofront[nmax];
rhoback[nmax + n] = rhoback[nmax];
vxfront[nmax + n] = vxfront[nmax];
vxback[nmax + n] = vxback[nmax];
vyfront[nmax + n] = vyfront[nmax];
vyback[nmax + n] = vyback[nmax];
vzfront[nmax + n] = vzfront[nmax];
vzback[nmax + n] = vzback[nmax];
}
}
}
}
return 0;
}
int set_boundary ( int  nmin,
int  nmax,
int  flag,
int  bound_checker,
int  lefter,
double *  rho_1D,
double *  eng_1D,
double *  pre_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  pressure_solid_1D,
double *  xa0,
double *  dx0,
double *  xa,
double *  dx,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  viscosity_on_off,
int  dimension 
)

The filling routine for the ghost cells according to the given boundary conditions.

Definition at line 17 of file set_boundary.c.

References boundary::back, bound, boundary::down, boundary::front, boundary::left, left_boundary_inflow(), left_boundary_outflow(), left_boundary_periodic(), left_boundary_reflecting(), left_boundary_reflecting_on_obstacle(), left_boundary_small_padding(), left_boundary_zero_gradient(), boundary::right, right_boundary_inflow(), right_boundary_outflow(), right_boundary_periodic(), right_boundary_reflecting(), right_boundary_reflecting_on_obstacle(), right_boundary_small_padding(), right_boundary_zero_gradient(), and boundary::up.

Referenced by ppm_step().

{
//* The case with no obstacles in the computational domain
if (bound_checker == 0) {
if ((bound.down == 5) && (flag == 1))
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.down == 4) && (flag == 1))
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.down == 3) && (flag == 1))
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.down == 2) && (flag == 1))
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.down == 1) && (flag == 1))
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.down == 0) && (flag == 1))
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 5) && (flag == 1))
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 4) && (flag == 1))
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 3) && (flag == 1))
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 2) && (flag == 1))
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 1) && (flag == 1))
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.up == 0) && (flag == 1))
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 5) && (flag == 0))
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 4) && (flag == 0))
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 3) && (flag == 0))
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 2) && (flag == 0))
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 1) && (flag == 0))
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.left == 0) && (flag == 0))
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 5) && (flag == 0))
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 4) && (flag == 0))
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 3) && (flag == 0))
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 2) && (flag == 0))
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 1) && (flag == 0))
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.right == 0) && (flag == 0))
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 5) && (flag == 2))
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 4) && (flag == 2))
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 3) && (flag == 2))
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 2) && (flag == 2))
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 1) && (flag == 2))
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.front == 0) && (flag == 2))
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 5) && (flag == 2))
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 4) && (flag == 2))
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 3) && (flag == 2))
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 2) && (flag == 2))
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 1) && (flag == 2))
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
if ((bound.back == 0) && (flag == 2))
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
} else {
// domain with obstacles
//the case at one side an obstacle at the other side a boundary of the computational domain is lefter 1 and 2
//at both sides of the computational domain an obstacle is lefter 3
if ((bound.down == 5) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.down == 4) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.down == 3) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.down == 2) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.down == 1) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.down == 0) && (flag == 1) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
}
if ((bound.up == 5) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup,
vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.up == 4) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.up == 3) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup,
vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.up == 2) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.up == 1) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.up == 0) && (flag == 1) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup,
vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 5) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 4) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup,
vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 3) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag,
rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 2) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 1) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.left == 0) && (flag == 0) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront,
rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off,
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup,
vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 5) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 4) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 3) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 2) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 1) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.right == 0) && (flag == 0) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 5) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 4) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 3) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 2) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 1) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.front == 0) && (flag == 2) && (bound_checker == 1) && (lefter == 1)) {
left_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 5) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_periodic(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 4) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_inflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup,
vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 3) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_outflow(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 2) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_small_padding(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback,
vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 1) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_reflecting(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
if ((bound.back == 0) && (flag == 2) && (bound_checker == 1) && (lefter == 2)) {
right_boundary_zero_gradient(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown,
vxup, vxfront, vxback, vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
//if both sides are belonging to an obstacle
if ((bound_checker == 1) && (lefter == 3)) {
right_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
left_boundary_reflecting_on_obstacle(nmin, nmax, rho_1D, eng_1D, pre_1D, vx_1D, vy_1D, vz_1D,
pressure_solid_1D, xa0, dx0, xa, dx, flag, rhodown, rhoup, rhofront, rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront, vyback,
vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
}
}
return 0;
}
int start_file_reader ( char  filename[])

The read routine for the parameterfile

Definition at line 19 of file start_file_reader.c.

References advection, boundary::back, bound, courant, dens_ic, dimension, boundary::down, endtime_sim, filetype, boundary::front, Gamma1, gasconstant, gravity_on_off, inflow_density, inflow_temperature, inflow_velocity, intial_velocity_file, boundary::left, make_ics, marker_density, marker_ic, minute_in_sec, number_of_threads, obst_ic, obstacle_density, obstacle_heat_conductivity, obstacle_temperature, obstalce_absorption_coefficient, output_dir, output_frequency, restart_frequency, boundary::right, sound_frequency, sound_ic, sound_pressure_level, sound_reflexion, specific_heat_capacity_gas, specific_heat_capacity_obstacle, starting_flow, strat_const_atmos, temp_ic, boundary::up, vel_ic, viscosity_on_off, wind_ic, wind_on_off, wind_speed, with_obstacles, with_one_pulse, with_sound_emitter, x, xmax, y, ymax, z, and zmax.

Referenced by main().

{
char data[55][200];
int l;
FILE *fd;
char buffer[200];
fd = fopen(filename, "r");
if (fd == NULL) {
printf("The Parameter File you specified does not exist.\n");
exit(10);
}
l = 0;
while (feof(fd) == 0) {
fgets(data[l], 200, fd);
if ((data[l][0] == '#') || (data[l][0] == '\n')) continue;
data[l][strlen(data[l]) - 1] = '\0';
l++;
}
fclose(fd);
filetype = atoi(data[0]);
make_ics = atoi(data[1]);
sprintf(dens_ic, "%s", data[2]);
sprintf(temp_ic, "%s", data[3]);
sprintf(vel_ic, "%s", data[4]);
sprintf(wind_ic, "%s", data[5]);
sprintf(obst_ic, "%s", data[6]);
sprintf(sound_ic, "%s", data[7]);
sprintf(marker_ic, "%s", data[8]);
intial_velocity_file = atoi(data[9]);
sprintf(output_dir, "%s", data[10]);
strat_const_atmos = atoi(data[11]);
x = atoi(data[12]);
y = atoi(data[13]);
z = atoi(data[14]);
dimension = atoi(data[15]);
xmax = atof(data[16]);
ymax = atof(data[17]);
zmax = atof(data[18]);
bound.down = atoi(data[19]);
bound.up = atoi(data[20]);
bound.left = atoi(data[21]);
bound.right = atoi(data[22]);
bound.front = atoi(data[23]);
bound.back = atoi(data[24]);
inflow_velocity = atof(data[25]);
inflow_density = atof(data[26]);
inflow_temperature = atof(data[27]);
starting_flow = atoi(data[28]);
endtime_sim = atof(data[29]);
output_frequency = atof(data[30]);
restart_frequency = atof(data[31]);
courant = atof(data[32]);
gravity_on_off = atoi(data[33]);
gasconstant = atof(data[34]);
Gamma1 = atof(data[35]);
wind_on_off = atoi(data[36]);
wind_speed = atof(data[37]);
number_of_threads = atoi(data[38]);
with_obstacles = atoi(data[39]);
obstacle_density = atof(data[40]);
obstacle_temperature = atof(data[41]);
obstacle_heat_conductivity = atof(data[42]);
specific_heat_capacity_gas = atof(data[43]);
advection = atoi(data[45]);
marker_density = atof(data[46]);
viscosity_on_off = atoi(data[47]);
with_sound_emitter = atoi(data[48]);
sound_pressure_level = atof(data[49]);
sound_pressure_level = pow(10, (sound_pressure_level / 20))*2.0E-5 * sqrt(2.0);
with_one_pulse = atoi(data[50]);
sound_frequency = atof(data[51]);
sound_reflexion = atof(data[52]);
//printf("%g\n", obstalce_absorption_coefficient);
//for debug
//printf("%i\n", l);
if (l != 54) {
printf("Simulation stops, because of too few data in the start file.\n");
exit(99);
}
return 0;
}
int states ( int  nmin,
int  nmax,
int  flag,
double *  pre_1D,
double *  rho_1D,
double *  dx,
double *  Cdtdx,
double *  fCdtdx,
double *  plft,
double *  pl,
double *  dp,
double *  p6,
double *  ulft,
double *  ul,
double *  du,
double *  u6,
double *  rlft,
double *  rl,
double *  dr,
double *  r6,
double *  prgh,
double *  urgh,
double *  rrgh 
)

Get hydroquantities at cell centres and faces.

Definition at line 30 of file states.c.

References dt, Gamma1, grav_acc, gravity_on_off, max_states(), smallp, and smallr.

Referenced by ppm_step().

{
int i, ii;
double hdt, svel;
double fourthd;
fourthd = 4.0 / 3.0;
svel = 0.0;
hdt = 0.5 * dt;
for (i = nmin - 4; i <= nmax + 4; i++) {
Cdtdx[i] = sqrt(Gamma1 * pre_1D[i] / rho_1D[i]) / (dx[i]);
svel = max_states(svel, Cdtdx[i]);
Cdtdx[i] = Cdtdx[i] * hdt;
fCdtdx[i] = 1.0 - fourthd * Cdtdx[i];
}
for (i = nmin - 4; i <= nmax + 4; i++) {
ii = i + 1;
plft[ii] = pl[i] + dp[i] - Cdtdx[i]*(dp[i] - fCdtdx[i] * p6[i]);
ulft[ii] = ul[i] + du[i] - Cdtdx[i]*(du[i] - fCdtdx[i] * u6[i]);
rlft[ii] = rl[i] + dr[i] - Cdtdx[i]*(dr[i] - fCdtdx[i] * r6[i]);
plft[ii] = max_states(smallp, plft[ii]);
rlft[ii] = max_states(smallr, rlft[ii]);
if (flag == 0) {
ulft[ii] = ulft[ii] + hdt * grav_acc;
} else {
ulft[ii] = ulft[ii];
}
prgh[i] = pl[i] + Cdtdx[i]*(dp[i] + fCdtdx[i] * p6[i]);
urgh[i] = ul[i] + Cdtdx[i]*(du[i] + fCdtdx[i] * u6[i]);
rrgh[i] = rl[i] + Cdtdx[i]*(dr[i] + fCdtdx[i] * r6[i]);
prgh[i] = max_states(smallp, prgh[i]);
rrgh[i] = max_states(smallr, rrgh[i]);
if (flag == 1) {
if (gravity_on_off == 1) urgh[i] = urgh[i] + hdt * grav_acc;
if (gravity_on_off == 0) urgh[i] = urgh[i];
} else {
urgh[i] = urgh[i];
}
}
return 0;
}
int sweep_x ( int  x,
int  y,
int  z,
int  flag 
)

The sweeping in all three directions (if 3D). This routine does the x-sweep and is parallelized using OpenMP for shared memory machines.

Definition at line 36 of file sweep_x.c.

References advection, boundary::back, bound, dimension, dom, DOM_FLUID, DOM_SOLID, boundary::down, boundary::front, Gamma, inflow_density, inflow_velocity, init_ppm(), marker, max_sweep_x(), obstacle_density, obstacle_temperature, ppm_free(), ppm_step(), pre, pressure_on_solid, rho, rho_visc, small, smallp, boundary::up, viscosity_on_off, vx, vx_visc, vy, vy_visc, vz, vz_visc, with_obstacles, x, y, z, zdx, and zxa.

Referenced by hydro_sweeps().

{
int i, j, k, n, nmin, nmax;
int direction = 0;
//1D variables
double *rho_1D, *pre_1D, *eng_1D, *vx_1D, *vy_1D, *vz_1D, *marker_1D;
//1D variables for viscosity
double *rhodown, *rhoup, *rhofront, *rhoback;
double *vxdown, *vxup, *vxfront, *vxback;
double *vydown, *vyup, *vyfront, *vyback;
double *vzdown, *vzup, *vzfront, *vzback;
//for pressure calculations on the solid
double *pressure_solid_1D;
double *xa, *dx;
double *dx0, *xa0;
double *a_coef, *ai_coef, *b_coef, *bi_coef, *c_coef, *ci_coef;
double *d_x;
double *diffa;
//parabola
double *da, *ar;
double *pl, *p6, *rl, *r6;
double *u6, *ul, *vl, *v6;
double *wl, *w6, *el, *e6;
double *ql, *q6, *dp, *du;
double *dv, *dw, *dq, *de;
double *scratch1, *scratch2, *scratch3;
double *dr, *deltaa;
//for states
double *plft, *prgh, *ulft, *urgh, *rlft, *rrgh, *Cdtdx, *fCdtdx;
// for flattening
double *steep, *flat;
double **para;
//riemann solver
double *clft, *crgh, *plfti, *prghi, *pmid, *pmold, *wlft, *wrgh, *zlft, *zrgh;
double *umidl, *umidr, *umid;
//evolve
double *dm, *dtbdm, *upmid, *xa1, *xa2, *xa3;
double *vx_1D_old;
double *dvol, *dvol0, *dvol1;
//remap
double *delta;
double *fluxr, *fluxu, *fluxv, *fluxw, *fluxe, *fluxq;
double *dm0;
double *e_int_1D;
dom_state state, state_next;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k, n, nmin, nmax, state, state_next, rho_1D, pre_1D, \
eng_1D, vx_1D, vy_1D, vz_1D, marker_1D, dx0, xa0, xa, dx, \
pressure_solid_1D, a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef, \
d_x, diffa, da, ar, pl, p6, rl, r6, \
u6, ul, vl, v6, wl, w6, \
el, e6, ql, q6, dp, du, dr, deltaa, \
dv, dw, dq, de, scratch1, scratch2, scratch3, \
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, \
steep, flat, para, clft, crgh, plfti, prghi, pmid, \
pmold, wlft, wrgh, zlft, zrgh, umidl, umidr, umid, \
dm, dtbdm, upmid, xa1, xa2, xa3, vx_1D_old, \
dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv, \
fluxw, fluxe, fluxq, dm0, e_int_1D, rhodown, rhoup, \
rhofront, rhoback, vxdown, vxup, vxfront, vxback, \
vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, \
vzback) \
shared(x, y, z, dom, rho, pre, vx, vy, vz, marker, zxa, zdx, \
pressure_on_solid, smallr, small, smallp, Gamma, max_array_length, flag, \
direction, obstacle_density, obstacle_temperature, advection, with_obstacles, \
viscosity_on_off, bound, inflow_density, inflow_velocity, dimension, \
rho_visc, vx_visc, vy_visc, vz_visc)
{
#endif
//==============================================================================
//allocate arrays for the 1D sweeps
init_ppm(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D, &dx0, &xa0, &xa, &dx,
&a_coef, &ai_coef, &b_coef, &bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &pressure_solid_1D, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
//==============================================================================
for (k = 0; k < z; k++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
int lefter;
nmin = 0;
nmax = 0;
lefter = 0;
for (i = 0; i < x; i++) {
n = i + 6 - nmin;
xa0[n] = zxa[i];
dx0[n] = zdx[i];
xa[n] = zxa[i];
dx[n] = zdx[i];
// Copy parts of a line from 3D domain into 1D domain
if (dom[i][j][k] == 0) {
state = DOM_FLUID;
rho_1D[n] = rho[i][j][k];
pre_1D[n] = pre[i][j][k];
vx_1D[n] = vx[i][j][k];
vy_1D[n] = vy[i][j][k];
vz_1D[n] = vz[i][j][k];
if (advection == 1) marker_1D[n] = marker[i][j][k];
if (with_obstacles == 1) pressure_solid_1D[n] = pressure_on_solid[i][j][k];
pre_1D[n] = max_sweep_x(smallp, pre_1D[n]);
eng_1D[n] = pre_1D[n] / (rho_1D[n] * Gamma) + 0.5 * ((pow(vx_1D[n], 2))+(pow(vy_1D[n], 2))+(pow(vz_1D[n], 2)));
// if viscosity is set on
if (viscosity_on_off == 1) {
if (dimension > 1) {
//====================================================
//first the j-1 case no obstacle
if ((j > 0) && (dom[i][j - 1][k] == 0) && (j < y - 1)) {
rhodown[n] = rho_visc[i][j - 1][k];
vxdown[n] = vx_visc[i][j - 1][k];
vydown[n] = vy_visc[i][j - 1][k];
vzdown[n] = vz_visc[i][j - 1][k];
}
if ((j > 0) && (dom[i][j - 1][k] != 0) && (j < y - 1)) {
rhodown[n] = 0.0;
vxdown[n] = 0.0;
vydown[n] = 0.0;
vzdown[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (j == 0) {
if (bound.down == 0) rhodown[n] = rho_visc[i][j][k];
if (bound.down == 1) rhodown[n] = rho_visc[i][j][k];
if (bound.down == 2) rhodown[n] = small;
if (bound.down == 3) rhodown[n] = rho_visc[i][j][k];
if (bound.down == 4) rhodown[n] = inflow_density;
if (bound.down == 5) rhodown[n] = rho_visc[i][y - 1][k];
if (bound.down == 0) vxdown[n] = vx_visc[i][j][k];
if (bound.down == 1) vxdown[n] = -vx_visc[i][j][k];
if (bound.down == 2) vxdown[n] = small;
if (bound.down == 3) vxdown[n] = vx_visc[i][j][k];
if (bound.down == 4) vxdown[n] = 0.0;
if (bound.down == 5) vxdown[n] = vx_visc[i][y - 1][k];
if (bound.down == 0) vydown[n] = vy_visc[i][j][k];
if (bound.down == 1) vydown[n] = -vy_visc[i][j][k];
if (bound.down == 2) vydown[n] = small;
if (bound.down == 3) {
if (vy_visc[i][j][k] > 0.0) vydown[n] = small;
if (vy_visc[i][j][k] <= 0.0) vydown[n] = vy_visc[i][j][k];
}
if (bound.down == 4) vydown[n] = inflow_velocity;
if (bound.down == 5) vydown[n] = vy_visc[i][y - 1][k];
if (bound.down == 0) vzdown[n] = vz_visc[i][j][k];
if (bound.down == 1) vzdown[n] = -vz_visc[i][j][k];
if (bound.down == 2) vzdown[n] = small;
if (bound.down == 3) vzdown[n] = vz_visc[i][j][k];
if (bound.down == 4) vzdown[n] = 0.0;
if (bound.down == 5) vzdown[n] = vz_visc[i][y - 1][k];
rhoup[n] = rho_visc[i][j + 1][k];
vxup[n] = vx_visc[i][j + 1][k];
vyup[n] = vy_visc[i][j + 1][k];
vzup[n] = vz_visc[i][j + 1][k];
}
//====================================================
//====================================================
//now the case j = y - 1 no obstacle
if ((j < y - 1) && (dom[i][j + 1][k] == 0) && (j > 0)) {
rhoup[n] = rho_visc[i][j + 1][k];
vxup[n] = vx_visc[i][j + 1][k];
vyup[n] = vy_visc[i][j + 1][k];
vzup[n] = vz_visc[i][j + 1][k];
}
if ((j < y - 1) && (dom[i][j + 1][k] != 0) && (j > 0)) {
rhoup[n] = 0.0;
vxup[n] = 0.0;
vyup[n] = 0.0;
vzup[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (j == y - 1) {
if (bound.up == 0) rhoup[n] = rho_visc[i][j][k];
if (bound.up == 1) rhoup[n] = rho_visc[i][j][k];
if (bound.up == 2) rhoup[n] = small;
if (bound.up == 3) rhoup[n] = rho_visc[i][j][k];
if (bound.up == 4) rhoup[n] = inflow_density;
if (bound.up == 5) rhoup[n] = rho_visc[i][0][k];
if (bound.up == 0) vxup[n] = vx_visc[i][j][k];
if (bound.up == 1) vxup[n] = -vx_visc[i][j][k];
if (bound.up == 2) vxup[n] = small;
if (bound.up == 3) vxup[n] = vx_visc[i][j][k];
if (bound.up == 4) vxup[n] = 0.0;
if (bound.up == 5) vxup[n] = vx_visc[i][0][k];
if (bound.up == 0) vyup[n] = vy_visc[i][j][k];
if (bound.up == 1) vyup[n] = -vy_visc[i][j][k];
if (bound.up == 2) vyup[n] = small;
if (bound.up == 3) {
if (vy_visc[i][j][k] < 0.0) vyup[n] = small;
if (vy_visc[i][j][k] >= 0.0) vyup[n] = vy_visc[i][j][k];
}
if (bound.up == 4) vyup[n] = inflow_velocity;
if (bound.up == 5) vyup[n] = vy_visc[i][0][k];
if (bound.up == 0) vzup[n] = vz_visc[i][j][k];
if (bound.up == 1) vzup[n] = -vz_visc[i][j][k];
if (bound.up == 2) vzup[n] = small;
if (bound.up == 3) vzup[n] = vz_visc[i][j][k];
if (bound.up == 4) vzup[n] = 0.0;
if (bound.up == 5) vzup[n] = vz_visc[i][0][k];
rhodown[n] = rho_visc[i][j - 1][k];
vxdown[n] = vx_visc[i][j - 1][k];
vydown[n] = vy_visc[i][j - 1][k];
vzdown[n] = vz_visc[i][j - 1][k];
}
//====================================================
}
if (dimension > 2) {
//====================================================
//now the k > 0 case no obstacle
if ((k > 0) && (dom[i][j][k - 1] == 0) && (k < z - 1)) {
rhofront[n] = rho_visc[i][j][k - 1];
vxfront[n] = vx_visc[i][j][k - 1];
vyfront[n] = vy_visc[i][j][k - 1];
vzfront[n] = vz_visc[i][j][k - 1];
}
if ((k > 0) && (dom[i][j][k - 1] != 0) && (k < z - 1)) {
rhofront[n] = 0.0;
vxfront[n] = 0.0;
vyfront[n] = 0.0;
vzfront[n] = 0.0;
}
//at k == 0 no obstacle is check-1ed before entering viscosity part
if (k == 0) {
if (bound.front == 0) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 1) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 2) rhofront[n] = small;
if (bound.front == 3) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 4) rhofront[n] = inflow_density;
if (bound.front == 5) rhofront[n] = rho_visc[i][j][z - 1];
if (bound.front == 0) vxfront[n] = vx_visc[i][j][k];
if (bound.front == 1) vxfront[n] = -vx_visc[i][j][k];
if (bound.front == 2) vxfront[n] = small;
if (bound.front == 3) vxfront[n] = vx_visc[i][j][k];
if (bound.front == 4) vxfront[n] = 0.0;
if (bound.front == 5) vxfront[n] = vx_visc[i][j][z - 1];
if (bound.front == 0) vyfront[n] = vy_visc[i][j][k];
if (bound.front == 1) vyfront[n] = -vy_visc[i][j][k];
if (bound.front == 2) vyfront[n] = small;
if (bound.front == 3) vyfront[n] = vy_visc[i][j][k];
if (bound.front == 4) vyfront[n] = 0.0;
if (bound.front == 5) vyfront[n] = vy_visc[i][y][z - 1];
if (bound.front == 0) vzfront[n] = vz_visc[i][j][k];
if (bound.front == 1) vzfront[n] = -vz_visc[i][j][k];
if (bound.front == 2) vzfront[n] = small;
if (bound.front == 3) {
if (vz_visc[i][j][k] > 0.0) vzfront[n] = small;
if (vz_visc[i][j][k] <= 0.0) vzfront[n] = vz_visc[i][j][k];
}
if (bound.front == 4) vzfront[n] = inflow_velocity;
if (bound.front == 5) vzfront[n] = vz_visc[i][j][z - 1];
rhoback[n] = rho_visc[i][j][k + 1];
vxback[n] = vx_visc[i][j][k + 1];
vyback[n] = vy_visc[i][j][k + 1];
vzback[n] = vz_visc[i][j][k + 1];
}
//====================================================
//====================================================
//now the k < z-1 case no obstacle
if ((k < z - 1) && (dom[i][j][k + 1] == 0) && (k > 0)) {
rhoback[n] = rho_visc[i][j][k + 1];
vxback[n] = vx_visc[i][j][k + 1];
vyback[n] = vy_visc[i][j][k + 1];
vzback[n] = vz_visc[i][j][k + 1];
}
if ((k < z - 1) && (dom[i][j][k + 1] != 0) && (k > 0)) {
rhoback[n] = 0.0;
vxback[n] = 0.0;
vyback[n] = 0.0;
vzback[n] = 0.0;
}
//at k == z - 1 no obstacle is check-1ed before entering viscosity part
if (k == z - 1) {
if (bound.back == 0) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 1) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 2) rhoback[n] = small;
if (bound.back == 3) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 4) rhoback[n] = inflow_density;
if (bound.back == 5) rhoback[n] = rho_visc[i][j][0];
if (bound.back == 0) vxback[n] = vx_visc[i][j][k];
if (bound.back == 1) vxback[n] = -vx_visc[i][j][k];
if (bound.back == 2) vxback[n] = small;
if (bound.back == 3) vxback[n] = vx_visc[i][j][k];
if (bound.back == 4) vxback[n] = 0.0;
if (bound.back == 5) vxback[n] = vx_visc[i][j][0];
if (bound.back == 0) vyback[n] = vy_visc[i][j][k];
if (bound.back == 1) vyback[n] = -vy_visc[i][j][k];
if (bound.back == 2) vyback[n] = small;
if (bound.back == 3) vyback[n] = vy_visc[i][j][k];
if (bound.back == 4) vyback[n] = 0.0;
if (bound.back == 5) vyback[n] = vy_visc[i][j][0];
if (bound.back == 0) vzback[n] = vz_visc[i][j][k];
if (bound.back == 1) vzback[n] = -vz_visc[i][j][k];
if (bound.back == 2) vzback[n] = small;
if (bound.back == 3) {
if (vz_visc[i][j][k] < 0.0) vzback[n] = small;
if (vz_visc[i][j][k] >= 0.0) vzback[n] = vz_visc[i][j][k];
}
if (bound.back == 4) vzback[n] = inflow_velocity;
if (bound.back == 5) vzback[n] = vz_visc[i][j][01];
rhofront[n] = rho_visc[i][j][k - 1];
vxfront[n] = vx_visc[i][j][k - 1];
vyfront[n] = vy_visc[i][j][k - 1];
vzfront[n] = vz_visc[i][j][k - 1];
}
}
//====================================================
}
} else if (dom[i][j][k] == 1) {
state = DOM_SOLID;
rho_1D[n] = obstacle_density;
pre_1D[n] = obstacle_temperature;
vx_1D[n] = 0.0;
vy_1D[n] = 0.0;
vz_1D[n] = 0.0;
if (advection == 1) marker_1D[n] = 0.0;
if (with_obstacles == 1) pressure_solid_1D[n] = 0.0;
pre_1D[n] = 0.0;
eng_1D[n] = 0.0;
}
if (i < x - 1) {
state_next = (dom[i + 1][j][k] == 0) ? DOM_FLUID : DOM_SOLID;
} else {
state_next = (state == DOM_FLUID) ? DOM_SOLID : DOM_FLUID;
}
if (state != state_next) {
if (state == DOM_FLUID) {
//*checks if we are at the most left or most right part of the domain
int bound_checker;
int ii;
int nminx2 = 6;
int nmaxx2 = (nmax - nmin) + 6;
//if the most left boundary is reached bound_checker is 0
//if the most right boundary is reached bound_checker is 0
if ((nmin == 0) || (nmax == (x - 1))) {
bound_checker = 0;
}
//Now we consider an obstacle in the row
if ((nmax - nmin) != (x - 1)) {
bound_checker = 1;
//is the left boundary at the edge of the computational domain
//lefter = 1
if (nmin == 0) lefter = 1;
//is the right boundary at the edge of the computational domain
//lefter = 2
if (nmax == (x - 1)) lefter = 2;
//if there is an obstacle left and right than
//lefter = 3
if ((nmin != 0) && (nmax != (x - 1))) lefter = 3;
}
ppm_step(i, j, k, direction, flag, nminx2, nmaxx2, a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef,
d_x, diffa, da, ar, pl, p6, rl, r6, u6, ul, vl, v6, wl, w6, el,
e6, ql, q6, dp, du, dr, dv, dw, dq, de, scratch1, scratch2, scratch3,
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, steep, flat,
para, clft, crgh, plfti, prghi, pmid, pmold, wlft, wrgh, zlft,
zrgh, umidl, umidr, umid, dm, dtbdm, upmid, xa1, xa2, xa3,
vx_1D_old, dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv,
fluxw, fluxe, fluxq, dm0, e_int_1D, rho_1D, pre_1D, eng_1D,
vx_1D, vy_1D, vz_1D, marker_1D, pressure_solid_1D,
dx0, xa0, xa, dx, bound_checker, lefter, rhodown, rhoup, rhofront,
rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
//put the solution back into the 3D arrays
for (ii = nmin; ii <= nmax; ii++) {
n = ii + 6 - nmin;
rho[ii][j][k] = rho_1D[n];
pre[ii][j][k] = pre_1D[n];
vx[ii][j][k] = vx_1D[n];
vy[ii][j][k] = vy_1D[n];
vz[ii][j][k] = vz_1D[n];
if (advection == 1) marker[ii][j][k] = marker_1D[n];
//for the pressure on the obstacle calculation
if (with_obstacles == 1) pressure_on_solid[ii][j][k] = pressure_solid_1D[n];
}
} else if (state == DOM_SOLID) {
nmin = nmax + 1;
}
}
nmax++;
}
}
}
//free section
ppm_free(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D,
&pressure_solid_1D, &dx0, &xa0, &xa, &dx, &a_coef, &ai_coef,
&b_coef, &bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
#ifdef _OPENMP
}
#endif
return 0;
}
int sweep_y ( int  x,
int  y,
int  z,
int  flag 
)

The sweeping in all three directions (if 3D). This routine does the y-sweep and is parallelized using OpenMP for shared memory machines.

Definition at line 35 of file sweep_y.c.

References advection, boundary::back, bound, dimension, dom, DOM_FLUID, DOM_SOLID, boundary::front, Gamma, inflow_density, inflow_velocity, init_ppm(), boundary::left, marker, max_sweep_y(), obstacle_density, obstacle_temperature, ppm_free(), ppm_step(), pre, pressure_on_solid, rho, rho_visc, boundary::right, small, smallp, viscosity_on_off, vx, vx_visc, vy, vy_visc, vz, vz_visc, with_obstacles, x, y, z, zdy, and zya.

Referenced by hydro_sweeps().

{
int i, j, k, n, nmin, nmax;
// direction setter 0==x, 1==y, 2==z
int direction = 1;
//1D variables
double *rho_1D, *pre_1D, *eng_1D, *vx_1D, *vy_1D, *vz_1D, *marker_1D;
//1D variables for viscosity
double *rhodown, *rhoup, *rhofront, *rhoback;
double *vxdown, *vxup, *vxfront, *vxback;
double *vydown, *vyup, *vyfront, *vyback;
double *vzdown, *vzup, *vzfront, *vzback;
//for pressure calculations on the solid
double *pressure_solid_1D;
double *xa, *dx;
double *dx0, *xa0;
double *a_coef, *ai_coef, *b_coef, *bi_coef, *c_coef, *ci_coef;
double *d_x;
double *diffa;
//parabola
double *da, *ar;
double *pl, *p6, *rl, *r6;
double *u6, *ul, *vl, *v6;
double *wl, *w6, *el, *e6;
double *ql, *q6, *dp, *du;
double *dv, *dw, *dq, *de;
double *scratch1, *scratch2, *scratch3;
double *dr, *deltaa;
//for states
double *plft, *prgh, *ulft, *urgh, *rlft, *rrgh, *Cdtdx, *fCdtdx;
// for flattening
double *steep, *flat;
double **para;
//riemann solver
double *clft, *crgh, *plfti, *prghi, *pmid, *pmold, *wlft, *wrgh, *zlft, *zrgh;
double *umidl, *umidr, *umid;
//evolve
double *dm, *dtbdm, *upmid, *xa1, *xa2, *xa3;
double *vx_1D_old;
double *dvol, *dvol0, *dvol1;
//remap
double *delta;
double *fluxr, *fluxu, *fluxv, *fluxw, *fluxe, *fluxq;
double *dm0;
double *e_int_1D;
dom_state state, state_next;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(i, j, k, n, nmin, nmax, state, state_next, rho_1D, pre_1D,\
eng_1D, vx_1D, vy_1D, vz_1D, marker_1D, \
pressure_solid_1D, dx0, xa0, xa, dx, \
a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef, \
d_x, diffa, da, ar, pl, p6, rl, r6, \
u6, ul, vl, v6, wl, w6, \
el, e6, ql, q6, dp, du, dr, deltaa, \
dv, dw, dq, de, scratch1, scratch2, scratch3, \
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, \
steep, flat, para, clft, crgh, plfti, prghi, pmid, \
pmold, wlft, wrgh, zlft, zrgh, umidl, umidr, umid, \
dm, dtbdm, upmid, xa1, xa2, xa3, vx_1D_old, \
dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv, \
fluxw, fluxe, fluxq, dm0, e_int_1D, rhodown, rhoup, \
rhofront, rhoback, vxdown, vxup, vxfront, vxback, \
vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, \
vzback) \
shared(x, y, z, rho, dom, \
pre, vx, vy, vz, marker, zya, zdy, \
pressure_on_solid, smallp, smallr, small, Gamma, max_array_length, flag, \
direction, obstacle_density, obstacle_temperature, advection, with_obstacles, \
viscosity_on_off, bound, inflow_density, inflow_velocity, dimension, \
rho_visc, vx_visc, vy_visc, vz_visc)
{
#endif
//==============================================================================
init_ppm(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D, &dx0, &xa0, &xa, &dx,
&a_coef, &ai_coef, &b_coef, &bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &pressure_solid_1D, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
//==============================================================================
for (k = 0; k < z; k++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (i = 0; i < x; i++) {
int lefter;
nmin = 0;
nmax = 0;
lefter = 0;
for (j = 0; j < y; j++) {
n = j + 6 - nmin;
xa[n] = zya[j];
dx[n] = zdy[j];
xa0[n] = zya[j];
dx0[n] = zdy[j];
// Copy parts of a line from 3D domain into 1D domain
if (dom[i][j][k] == 0) {
state = DOM_FLUID;
rho_1D[n] = rho[i][j][k];
pre_1D[n] = pre[i][j][k];
vx_1D[n] = vy[i][j][k];
vy_1D[n] = vz[i][j][k];
vz_1D[n] = vx[i][j][k];
if (advection == 1) marker_1D[n] = marker[i][j][k];
if (with_obstacles == 1) pressure_solid_1D[n] = pressure_on_solid[i][j][k];
pre_1D[n] = max_sweep_y(smallp, pre_1D[n]);
eng_1D[n] = pre_1D[n] / (rho_1D[n] * Gamma) + 0.5 * ((pow(vx_1D[n], 2))+(pow(vy_1D[n], 2))+(pow(vz_1D[n], 2)));
// if viscosity is set on
if (viscosity_on_off == 1) {
if (dimension > 1) {
//====================================================
//first the i-1 case no obstacle
if ((i > 0) && (dom[i - 1][j][k] == 0) && (i < x - 1)) {
rhodown[n] = rho[i - 1][j][k];
vxdown[n] = vy[i - 1][j][k];
vydown[n] = vz[i - 1][j][k];
vzdown[n] = vx[i - 1][j][k];
}
if ((i > 0) && (dom[i - 1][j][k] != 0) && (i < x - 1)) {
rhodown[n] = 0.0;
vxdown[n] = 0.0;
vydown[n] = 0.0;
vzdown[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (i == 0) {
if (bound.left == 0) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 1) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 2) rhodown[n] = small;
if (bound.left == 3) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 4) rhodown[n] = inflow_density;
if (bound.left == 5) rhodown[n] = rho_visc[x - 1][j][k];
if (bound.left == 0) vxdown[n] = vy_visc[i][j][k];
if (bound.left == 1) vxdown[n] = -vy_visc[i][j][k];
if (bound.left == 2) vxdown[n] = small;
if (bound.left == 3) vxdown[n] = vy_visc[i][j][k];
if (bound.left == 4) vxdown[n] = 0.0;
if (bound.left == 5) vxdown[n] = vy_visc[x - 1][j][k];
if (bound.left == 0) vydown[n] = vz_visc[i][j][k];
if (bound.left == 1) vydown[n] = -vz_visc[i][j][k];
if (bound.left == 2) vydown[n] = small;
if (bound.left == 3) {
if (vy_visc[i][j][k] > 0.0) vydown[n] = small;
if (vy_visc[i][j][k] <= 0.0) vydown[n] = vz_visc[i][j][k];
}
if (bound.left == 4) vydown[n] = 0.0;
if (bound.left == 5) vydown[n] = vz_visc[x - 1][j][k];
if (bound.left == 0) vzdown[n] = vx_visc[i][j][k];
if (bound.left == 1) vzdown[n] = -vx_visc[i][j][k];
if (bound.left == 2) vzdown[n] = small;
if (bound.left == 3) vzdown[n] = vx_visc[i][j][k];
if (bound.left == 4) vzdown[n] = inflow_velocity;
if (bound.left == 5) vzdown[n] = vz_visc[x - 1][j][k];
rhoup[n] = rho_visc[i + 1][j][k];
vxup[n] = vx_visc[i + 1][j][k];
vyup[n] = vy_visc[i + 1][j][k];
vzup[n] = vz_visc[i + 1][j][k];
}
//====================================================
//====================================================
//now the case j = y - 1 no obstacle
if ((i < x - 1) && (dom[i + 1][j][k] == 0) && (i > 0)) {
rhoup[n] = rho_visc[i + 1][j][k];
vxup[n] = vy_visc[i + 1][j][k];
vyup[n] = vz_visc[i + 1][j][k];
vzup[n] = vx_visc[i + 1 ][j][k];
}
if ((i < x - 1) && (dom[i + 1][j][k] != 0) && (i > 0)) {
rhoup[n] = 0.0;
vxup[n] = 0.0;
vyup[n] = 0.0;
vzup[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (i == x - 1) {
if (bound.right == 0) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 1) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 2) rhoup[n] = small;
if (bound.right == 3) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 4) rhoup[n] = inflow_density;
if (bound.right == 5) rhoup[n] = rho_visc[0][j][k];
if (bound.right == 0) vxup[n] = vy_visc[i][j][k];
if (bound.right == 1) vxup[n] = -vy_visc[i][j][k];
if (bound.right == 2) vxup[n] = small;
if (bound.right == 3) vxup[n] = vy_visc[i][j][k];
if (bound.right == 4) vxup[n] = 0.0;
if (bound.right == 5) vxup[n] = vx_visc[0][j][k];
if (bound.right == 0) vyup[n] = vz_visc[i][j][k];
if (bound.right == 1) vyup[n] = -vz_visc[i][j][k];
if (bound.right == 2) vyup[n] = small;
if (bound.right == 3) {
if (vy_visc[i][j][k] < 0.0) vyup[n] = small;
if (vy_visc[i][j][k] >= 0.0) vyup[n] = vz_visc[i][j][k];
}
if (bound.right == 4) vyup[n] = 0.0;
if (bound.right == 5) vyup[n] = vz_visc[0][j][k];
if (bound.right == 0) vzup[n] = vx_visc[i][j][k];
if (bound.right == 1) vzup[n] = -vx_visc[i][j][k];
if (bound.right == 2) vzup[n] = small;
if (bound.right == 3) vzup[n] = vx_visc[i][j][k];
if (bound.right == 4) vzup[n] = inflow_velocity;
if (bound.right == 5) vzup[n] = vx_visc[0][j][k];
rhodown[n] = rho_visc[i - 1][j][k];
vxdown[n] = vx_visc[i - 1][j][k];
vydown[n] = vy_visc[i - 1][j][k];
vzdown[n] = vz_visc[i - 1][j][k];
}
//====================================================
}
if (dimension > 2) {
//====================================================
//now the k > 0 case no obstacle
if ((k > 0) && (dom[i][j][k - 1] == 0) && (k < z - 1)) {
rhofront[n] = rho_visc[i][j][k - 1];
vxfront[n] = vy_visc[i][j][k - 1];
vyfront[n] = vz_visc[i][j][k - 1];
vzfront[n] = vx_visc[i][j][k - 1];
}
if ((k > 0) && (dom[i][j][k - 1] != 0) && (k < z - 1)) {
rhofront[n] = 0.0;
vxfront[n] = 0.0;
vyfront[n] = 0.0;
vzfront[n] = 0.0;
}
//at k == 0 no obstacle is check-1ed before entering viscosity part
if (k == 0) {
if (bound.front == 0) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 1) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 2) rhofront[n] = small;
if (bound.front == 3) rhofront[n] = rho_visc[i][j][k];
if (bound.front == 4) rhofront[n] = inflow_density;
if (bound.front == 5) rhofront[n] = rho_visc[i][j][z - 1];
if (bound.front == 0) vxfront[n] = vy_visc[i][j][k];
if (bound.front == 1) vxfront[n] = -vy_visc[i][j][k];
if (bound.front == 2) vxfront[n] = small;
if (bound.front == 3) vxfront[n] = vy_visc[i][j][k];
if (bound.front == 4) vxfront[n] = 0.0;
if (bound.front == 5) vxfront[n] = vy_visc[i][j][z - 1];
if (bound.front == 0) vyfront[n] = vz_visc[i][j][k];
if (bound.front == 1) vyfront[n] = -vz_visc[i][j][k];
if (bound.front == 2) vyfront[n] = small;
if (bound.front == 3) vyfront[n] = vz_visc[i][j][k];
if (bound.front == 4) vyfront[n] = 0.0;
if (bound.front == 5) vyfront[n] = vz_visc[i][j][z - 1];
if (bound.front == 0) vzfront[n] = vx_visc[i][j][k];
if (bound.front == 1) vzfront[n] = -vx_visc[i][j][k];
if (bound.front == 2) vzfront[n] = small;
if (bound.front == 3) {
if (vz_visc[i][j][k] > 0.0) vzfront[n] = small;
if (vz_visc[i][j][k] <= 0.0) vzfront[n] = vx_visc[i][j][k];
}
if (bound.front == 4) vzfront[n] = inflow_velocity;
if (bound.front == 5) vzfront[n] = vx_visc[i][j][z - 1];
rhoback[n] = rho_visc[i][j][k + 1];
vxback[n] = vx_visc[i][j][k + 1];
vyback[n] = vy_visc[i][j][k + 1];
vzback[n] = vz_visc[i][j][k + 1];
}
//====================================================
//====================================================
//now the k < z-1 case no obstacle
if ((k < z - 1) && (dom[i][j][k + 1] == 0) && (k > 0)) {
rhoback[n] = rho_visc[i][j][k + 1];
vxback[n] = vy_visc[i][j][k + 1];
vyback[n] = vz_visc[i][j][k + 1];
vzback[n] = vx_visc[i][j][k + 1];
}
if ((k < z - 1) && (dom[i][j][k + 1] != 0) && (k > 0)) {
rhoback[n] = 0.0;
vxback[n] = 0.0;
vyback[n] = 0.0;
vzback[n] = 0.0;
}
//at k == z - 1 no obstacle is check-1ed before entering viscosity part
if (k == z - 1) {
if (bound.back == 0) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 1) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 2) rhoback[n] = small;
if (bound.back == 3) rhoback[n] = rho_visc[i][j][k];
if (bound.back == 4) rhoback[n] = inflow_density;
if (bound.back == 5) rhoback[n] = rho_visc[i][j][0];
if (bound.back == 0) vxback[n] = vy_visc[i][j][k];
if (bound.back == 1) vxback[n] = -vy_visc[i][j][k];
if (bound.back == 2) vxback[n] = small;
if (bound.back == 3) vxback[n] = vy_visc[i][j][k];
if (bound.back == 4) vxback[n] = 0.0;
if (bound.back == 5) vxback[n] = vy_visc[i][j][0];
if (bound.back == 0) vyback[n] = vz_visc[i][j][k];
if (bound.back == 1) vyback[n] = -vz_visc[i][j][k];
if (bound.back == 2) vyback[n] = small;
if (bound.back == 3) vyback[n] = vz_visc[i][j][k];
if (bound.back == 4) vyback[n] = 0.0;
if (bound.back == 5) vyback[n] = vz_visc[i][j][0];
if (bound.back == 0) vzback[n] = vx_visc[i][j][k];
if (bound.back == 1) vzback[n] = -vx_visc[i][j][k];
if (bound.back == 2) vzback[n] = small;
if (bound.back == 3) {
if (vz_visc[i][j][k] < 0.0) vzback[n] = small;
if (vz_visc[i][j][k] >= 0.0) vzback[n] = vx_visc[i][j][k];
}
if (bound.back == 4) vzback[n] = inflow_velocity;
if (bound.back == 5) vzback[n] = vx_visc[i][j][0];
rhofront[n] = rho_visc[i][j][k - 1];
vxfront[n] = vx_visc[i][j][k - 1];
vyfront[n] = vy_visc[i][j][k - 1];
vzfront[n] = vz_visc[i][j][k - 1];
}
//====================================================
}
}
} else if (dom[i][j][k] == 1) {
state = DOM_SOLID;
rho_1D[n] = obstacle_density;
pre_1D[n] = obstacle_temperature;
vx_1D[n] = 0.0;
vy_1D[n] = 0.0;
vz_1D[n] = 0.0;
if (advection == 1) marker_1D[n] = 0.0;
if (with_obstacles == 1) pressure_solid_1D[n] = 0.0;
pre_1D[n] = 0.0;
eng_1D[n] = 0.0;
}
if (j < y - 1) {
state_next = (dom[i][j + 1][k] == 0) ? DOM_FLUID : DOM_SOLID;
} else {
state_next = (state == DOM_FLUID) ? DOM_SOLID : DOM_FLUID;
}
if (state != state_next) {
if (state == DOM_FLUID) {
//*checks if we are at the most left or most right part of the domain
int bound_checker;
int jj;
int nminy2 = 6;
int nmaxy2 = (nmax - nmin) + 6;
//if the most left boundary is reached bound_checker is 0
//if the most right boundary is reached bound_checker is 0
if ((nmin == 0) || (nmax == (y - 1))) {
bound_checker = 0;
}
//Now we consider an obstacle in the row
if ((nmax - nmin) != (y - 1)) {
bound_checker = 1;
//is the left boundary at the edge of the computational domain
//lefter = 1
if (nmin == 0) lefter = 1;
//is the right boundary at the edge of the computational domain
//lefter =2;
if (nmax == (y - 1)) lefter = 2;
//if there is an obstacle left and right than
//lefter = 3
if ((nmin != 0) && (nmax != (y - 1))) lefter = 3;
}
ppm_step(i, j, k, direction, flag, nminy2, nmaxy2, a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef,
d_x, diffa, da, ar, pl, p6, rl, r6, u6, ul, vl, v6, wl, w6, el,
e6, ql, q6, dp, du, dr, dv, dw, dq, de, scratch1, scratch2, scratch3,
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, steep, flat,
para, clft, crgh, plfti, prghi, pmid, pmold, wlft, wrgh, zlft,
zrgh, umidl, umidr, umid, dm, dtbdm, upmid, xa1, xa2, xa3,
vx_1D_old, dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv,
fluxw, fluxe, fluxq, dm0, e_int_1D, rho_1D, pre_1D, eng_1D,
vx_1D, vy_1D, vz_1D, marker_1D, pressure_solid_1D, dx0, xa0,
xa, dx, bound_checker, lefter, rhodown, rhoup, rhofront,
rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
//put the solution back into the 3D arrays
for (jj = nmin; jj <= nmax; jj++) {
n = jj + 6 - nmin;
rho[i][jj][k] = rho_1D[n];
pre[i][jj][k] = pre_1D[n];
vy[i][jj][k] = vx_1D[n];
vz[i][jj][k] = vy_1D[n];
vx[i][jj][k] = vz_1D[n];
if (advection == 1) marker[i][jj][k] = marker_1D[n];
//for the pressure on the obstacle calculation
if (with_obstacles == 1) pressure_on_solid[i][jj][k] = pressure_solid_1D[n];
}
} else if (state == DOM_SOLID) {
nmin = nmax + 1;
}
}
nmax++;
}
}
}
//free section
ppm_free(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D,
&pressure_solid_1D, &dx0, &xa0, &xa, &dx, &a_coef, &ai_coef,
&b_coef, &bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
#ifdef _OPENMP
}
#endif
return 0;
}
int sweep_z ( int  x,
int  y,
int  z,
int  flag 
)

The sweeping in all three directions (if 3D). This routine does the z-sweep and is parallelized using OpenMP for shared memory machines.

Definition at line 35 of file sweep_z.c.

References advection, bound, dimension, dom, DOM_FLUID, DOM_SOLID, boundary::down, Gamma, inflow_density, inflow_velocity, init_ppm(), boundary::left, marker, max_sweep_z(), obstacle_density, obstacle_temperature, ppm_free(), ppm_step(), pre, pressure_on_solid, rho, rho_visc, boundary::right, small, smallp, boundary::up, viscosity_on_off, vx, vx_visc, vy, vy_visc, vz, vz_visc, with_obstacles, x, y, z, zdz, and zza.

Referenced by hydro_sweeps().

{
int i, j, k, n, nmin, nmax;
//1D variables
double *rho_1D, *pre_1D, *eng_1D, *vx_1D, *vy_1D, *vz_1D, *marker_1D;
//1D variables for viscosity
double *rhodown, *rhoup, *rhofront, *rhoback;
double *vxdown, *vxup, *vxfront, *vxback;
double *vydown, *vyup, *vyfront, *vyback;
double *vzdown, *vzup, *vzfront, *vzback;
//for pressure calculations on the solid
double *pressure_solid_1D;
double *xa, *dx;
double *dx0, *xa0;
double *a_coef, *ai_coef, *b_coef, *bi_coef, *c_coef, *ci_coef;
double *d_x;
double *diffa;
//parabola
double *da, *ar;
double *pl, *p6, *rl, *r6;
double *u6, *ul, *vl, *v6;
double *wl, *w6, *el, *e6;
double *ql, *q6, *dp, *du;
double *dv, *dw, *dq, *de;
double *scratch1, *scratch2, *scratch3;
double *dr, *deltaa;
//for states
double *plft, *prgh, *ulft, *urgh, *rlft, *rrgh, *Cdtdx, *fCdtdx;
// for flattening
double *steep, *flat;
double **para;
//riemann solver
double *clft, *crgh, *plfti, *prghi, *pmid, *pmold, *wlft, *wrgh, *zlft, *zrgh;
double *umidl, *umidr, *umid;
//evolve
double *dm, *dtbdm, *upmid, *xa1, *xa2, *xa3;
double *vx_1D_old;
double *dvol, *dvol0, *dvol1;
//remap
double *delta;
double *fluxr, *fluxu, *fluxv, *fluxw, *fluxe, *fluxq;
double *dm0;
double *e_int_1D;
// direction setter 0==x, 1==y, 2==z
int direction = 2;
dom_state state, state_next;
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(i, j, k, n, nmin, nmax, state, state_next, rho_1D, pre_1D,\
eng_1D, vx_1D, vy_1D, vz_1D, marker_1D, \
pressure_solid_1D, dx0, xa0, xa, dx, \
a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef, \
d_x, diffa, da, ar, pl, p6, rl, r6, \
u6, ul, vl, v6, wl, w6, \
el, e6, ql, q6, dp, du, dr, deltaa, \
dv, dw, dq, de, scratch1, scratch2, scratch3, \
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, \
steep, flat, para, clft, crgh, plfti, prghi, pmid, \
pmold, wlft, wrgh, zlft, zrgh, umidl, umidr, umid, \
dm, dtbdm, upmid, xa1, xa2, xa3, vx_1D_old, \
dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv, \
fluxw, fluxe, fluxq, dm0, e_int_1D, rhodown, rhoup, \
rhofront, rhoback, vxdown, vxup, vxfront, vxback, \
vydown, vyup, vyfront, vyback, vzdown, vzup, vzfront, \
vzback) \
shared(x, y, z, rho, dom, \
pre, vx, vy, vz, marker, zza, zdz, \
pressure_on_solid, smallp, smallr, small, Gamma, max_array_length, flag, \
direction, obstacle_density, obstacle_temperature, advection, with_obstacles, \
viscosity_on_off, bound, inflow_density, inflow_velocity, dimension, \
rho_visc, vx_visc, vy_visc, vz_visc)
{
#endif
//==============================================================================
init_ppm(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D, &dx0, &xa0, &xa, &dx,
&a_coef, &ai_coef, &b_coef, &bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &pressure_solid_1D, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
//==============================================================================
for (j = 0; j < y; j++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (i = 0; i < x; i++) {
int lefter;
nmin = 0;
nmax = 0;
lefter = 0;
for (k = 0; k < z; k++) {
n = k + 6 - nmin;
xa[n] = zza[k];
dx[n] = zdz[k];
xa0[n] = zza[k];
dx0[n] = zdz[k];
// Copy parts of a line from 3D domain into 1D domain
if (dom[i][j][k] == 0) {
state = DOM_FLUID;
rho_1D[n] = rho[i][j][k];
pre_1D[n] = pre[i][j][k];
vx_1D[n] = vz[i][j][k];
vy_1D[n] = vx[i][j][k];
vz_1D[n] = vy[i][j][k];
if (advection == 1) marker_1D[n] = marker[i][j][k];
if (with_obstacles == 1) pressure_solid_1D[n] = pressure_on_solid[i][j][k];
pre_1D[n] = max_sweep_z(smallp, pre_1D[n]);
eng_1D[n] = pre_1D[n] / (rho_1D[n] * Gamma) + 0.5 * ((pow(vx_1D[n], 2))+(pow(vy_1D[n], 2))+(pow(vz_1D[n], 2)));
// if viscosity is set on
if (viscosity_on_off == 1) {
if (dimension > 1) {
//====================================================
//first the j-1 case no obstacle
if ((i > 0) && (dom[i - 1][j][k] == 0) && (i < x - 1)) {
rhodown[n] = rho[i - 1][j ][k];
vxdown[n] = vz[i - 1][j ][k];
vydown[n] = vy[i - 1][j][k];
vzdown[n] = vx[i - 1][j][k];
}
if ((i > 0) && (dom[i - 1][j][k] != 0) && (i < x - 1)) {
rhodown[n] = 0.0;
vxdown[n] = 0.0;
vydown[n] = 0.0;
vzdown[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (i == 0) {
if (bound.left == 0) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 1) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 2) rhodown[n] = small;
if (bound.left == 3) rhodown[n] = rho_visc[i][j][k];
if (bound.left == 4) rhodown[n] = inflow_density;
if (bound.left == 5) rhodown[n] = rho_visc[x - 1][y][k];
if (bound.left == 0) vxdown[n] = vz_visc[i][j][k];
if (bound.left == 1) vxdown[n] = -vz_visc[i][j][k];
if (bound.left == 2) vxdown[n] = small;
if (bound.left == 3) vxdown[n] = vz_visc[i][j][k];
if (bound.left == 4) vxdown[n] = 0.0;
if (bound.left == 5) vxdown[n] = vz_visc[x - 1][j][k];
if (bound.left == 0) vydown[n] = vx_visc[i][j][k];
if (bound.left == 1) vydown[n] = -vx_visc[i][j][k];
if (bound.left == 2) vydown[n] = small;
if (bound.left == 3) {
if (vy_visc[i][j][k] > 0.0) vydown[n] = small;
if (vy_visc[i][j][k] <= 0.0) vydown[n] = vx_visc[i][j][k];
}
if (bound.left == 4) vydown[n] = inflow_velocity;
if (bound.left == 5) vydown[n] = vy_visc[x - 1][j][k];
if (bound.left == 0) vzdown[n] = vy_visc[i][j][k];
if (bound.left == 1) vzdown[n] = -vy_visc[i][j][k];
if (bound.left == 2) vzdown[n] = small;
if (bound.left == 3) vzdown[n] = vy_visc[i][j][k];
if (bound.left == 4) vzdown[n] = 0.0;
if (bound.left == 5) vzdown[n] = vz_visc[x - 1][j][k];
rhoup[n] = rho_visc[i + 1][j][k];
vxup[n] = vx_visc[i + 1][j][k];
vyup[n] = vy_visc[i + 1][j][k];
vzup[n] = vz_visc[i + 1][j][k];
}
//====================================================
//====================================================
//now the case j = y - 1 no obstacle
if ((i < x - 1) && (dom[i + 1][j][k] == 0) && (i > 0)) {
rhoup[n] = rho_visc[i + 1][j][k];
vxup[n] = vz_visc[i + 1][j][k];
vyup[n] = vx_visc[i + 1][j][k];
vzup[n] = vy_visc[i + 1][j][k];
}
if ((i < x - 1) && (dom[i + 1][j][k] != 0) && (i > 0)) {
rhoup[n] = 0.0;
vxup[n] = 0.0;
vyup[n] = 0.0;
vzup[n] = 0.0;
}
//at j==0 no obstacle is checked before entering viscosity part
if (i == x - 1) {
if (bound.right == 0) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 1) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 2) rhoup[n] = small;
if (bound.right == 3) rhoup[n] = rho_visc[i][j][k];
if (bound.right == 4) rhoup[n] = inflow_density;
if (bound.right == 5) rhoup[n] = rho_visc[0][j][k];
if (bound.right == 0) vxup[n] = vz_visc[i][j][k];
if (bound.right == 1) vxup[n] = -vz_visc[i][j][k];
if (bound.right == 2) vxup[n] = small;
if (bound.right == 3) vxup[n] = vz_visc[i][j][k];
if (bound.right == 4) vxup[n] = 0.0;
if (bound.right == 5) vxup[n] = vx_visc[0][j][k];
;
if (bound.right == 0) vyup[n] = vx_visc[i][j][k];
if (bound.right == 1) vyup[n] = -vx_visc[i][j][k];
if (bound.right == 2) vyup[n] = small;
if (bound.right == 3) {
if (vy_visc[i][j][k] < 0.0) vyup[n] = small;
if (vy_visc[i][j][k] >= 0.0) vyup[n] = vx_visc[i][j][k];
}
if (bound.right == 4) vyup[n] = inflow_velocity;
if (bound.right == 5) vyup[n] = vx_visc[0][j][k];
if (bound.right == 0) vzup[n] = vy_visc[i][j][k];
if (bound.right == 1) vzup[n] = -vy_visc[i][j][k];
if (bound.right == 2) vzup[n] = small;
if (bound.right == 3) vzup[n] = vy_visc[i][j][k];
if (bound.right == 4) vzup[n] = 0.0;
if (bound.right == 5) vzup[n] = vy_visc[0][j][k];
rhodown[n] = rho_visc[i - 1][j][k];
vxdown[n] = vx_visc[i - 1][j][k];
vydown[n] = vy_visc[i - 1][j][k];
vzdown[n] = vz_visc[i - 1][j][k];
}
//====================================================
}
if (dimension > 2) {
//====================================================
//now the k > 0 case no obstacle
if ((j > 0) && (dom[i][j - 1][k] == 0) && (j < y - 1)) {
rhofront[n] = rho_visc[i][j - 1][k];
vxfront[n] = vz_visc[i][j - 1][k];
vyfront[n] = vx_visc[i][j - 1][k];
vzfront[n] = vy_visc[i][j - 1][k];
}
if ((j > 0) && (dom[i][j - 1][k] != 0) && (j < y - 1)) {
rhofront[n] = 0.0;
vxfront[n] = 0.0;
vyfront[n] = 0.0;
vzfront[n] = 0.0;
}
//at k == 0 no obstacle is check-1ed before entering viscosity part
if (j == 0) {
if (bound.down == 0) rhofront[n] = rho_visc[i][j][k];
if (bound.down == 1) rhofront[n] = rho_visc[i][j][k];
if (bound.down == 2) rhofront[n] = small;
if (bound.down == 3) rhofront[n] = rho_visc[i][j][k];
if (bound.down == 4) rhofront[n] = inflow_density;
if (bound.down == 5) rhofront[n] = rho_visc[i][y - 1][k];
if (bound.down == 0) vxfront[n] = vz_visc[i][j][k];
if (bound.down == 1) vxfront[n] = -vz_visc[i][j][k];
if (bound.down == 2) vxfront[n] = small;
if (bound.down == 3) vxfront[n] = vz_visc[i][j][k];
if (bound.down == 4) vxfront[n] = 0.0;
if (bound.down == 5) vxfront[n] = vz_visc[i][y - 1][k];
if (bound.down == 0) vyfront[n] = vx_visc[i][j][k];
if (bound.down == 1) vyfront[n] = -vx_visc[i][j][k];
if (bound.down == 2) vyfront[n] = small;
if (bound.down == 3) vyfront[n] = vx_visc[i][j][k];
if (bound.down == 4) vyfront[n] = inflow_velocity;
if (bound.down == 5) vyfront[n] = vx_visc[i][y - 1][k];
if (bound.down == 0) vzfront[n] = vy_visc[i][j][k];
if (bound.down == 1) vzfront[n] = -vy_visc[i][j][k];
if (bound.down == 2) vzfront[n] = small;
if (bound.down == 3) {
if (vz_visc[i][j][k] > 0.0) vzfront[n] = small;
if (vz_visc[i][j][k] <= 0.0) vzfront[n] = vy_visc[i][j][k];
}
if (bound.down == 4) vzfront[n] = 0.0;
if (bound.down == 5) vzfront[n] = vy_visc[i][y - 1][z];
rhoback[n] = rho_visc[i][j + 1][k];
vxback[n] = vx_visc[i][j + 1][k];
vyback[n] = vy_visc[i][j + 1][k];
vzback[n] = vz_visc[i][j + 1][k];
}
//====================================================
//====================================================
//now the k < z-1 case no obstacle
if ((j < y - 1) && (dom[i][j + 1][k ] == 0) && (j > 0)) {
rhoback[n] = rho_visc[i][j + 1][k];
vxback[n] = vz_visc[i][j + 1][k ];
vyback[n] = vx_visc[i][j + 1][k ];
vzback[n] = vy_visc[i][j + 1][k ];
}
if ((j < y - 1) && (dom[i][j + 1][k] != 0) && (j > 0)) {
rhoback[n] = 0.0;
vxback[n] = 0.0;
vyback[n] = 0.0;
vzback[n] = 0.0;
}
//at k == z - 1 no obstacle is check-1ed before entering viscosity part
if (j == y - 1) {
if (bound.up == 0) rhoback[n] = rho_visc[i][j][k];
if (bound.up == 1) rhoback[n] = rho_visc[i][j][k];
if (bound.up == 2) rhoback[n] = small;
if (bound.up == 3) rhoback[n] = rho_visc[i][j][k];
if (bound.up == 4) rhoback[n] = inflow_density;
if (bound.up == 5) rhoback[n] = rho_visc[i][0][k];
if (bound.up == 0) vxback[n] = vx_visc[i][j][k];
if (bound.up == 1) vxback[n] = -vx_visc[i][j][k];
if (bound.up == 2) vxback[n] = small;
if (bound.up == 3) vxback[n] = vx_visc[i][j][k];
if (bound.up == 4) vxback[n] = 0.0;
if (bound.up == 5) vxback[n] = vx_visc[i][0][k];
if (bound.up == 0) vyback[n] = vy_visc[i][j][k];
if (bound.up == 1) vyback[n] = -vy_visc[i][j][k];
if (bound.up == 2) vyback[n] = small;
if (bound.up == 3) vyback[n] = vy_visc[i][j][k];
if (bound.up == 4) vyback[n] = inflow_velocity;
if (bound.up == 5) vyback[n] = vy_visc[i][0][k];
if (bound.up == 0) vzback[n] = vz_visc[i][j][k];
if (bound.up == 1) vzback[n] = -vz_visc[i][j][k];
if (bound.up == 2) vzback[n] = small;
if (bound.up == 3) {
if (vz_visc[i][j][k] < 0.0) vzback[n] = small;
if (vz_visc[i][j][k] >= 0.0) vzback[n] = vz_visc[i][j][k];
}
if (bound.up == 4) vzback[n] = 0.0;
if (bound.up == 5) vzback[n] = vz_visc[i][0][k];
rhofront[n] = rho_visc[i][j - 1][k];
vxfront[n] = vx_visc[i][j - 1][k];
vyfront[n] = vy_visc[i][j - 1][k];
vzfront[n] = vz_visc[i][j - 1][k];
}
//====================================================
}
}
} else if (dom[i][j][k] == 1) {
state = DOM_SOLID;
rho_1D[n] = obstacle_density;
pre_1D[n] = obstacle_temperature;
vx_1D[n] = 0.0;
vy_1D[n] = 0.0;
vz_1D[n] = 0.0;
if (advection == 1) marker_1D[n] = 0.0;
if (with_obstacles == 1) pressure_solid_1D[n] = 0.0;
pre_1D[n] = 0.0;
eng_1D[n] = 0.0;
}
if (k < z - 1) {
state_next = (dom[i][j][k + 1] == 0) ? DOM_FLUID : DOM_SOLID;
} else {
state_next = (state == DOM_FLUID) ? DOM_SOLID : DOM_FLUID;
}
if (state != state_next) {
if (state == DOM_FLUID) {
//checks if we are at the most left or most right part of the domain
int bound_checker;
int kk;
int nminz2 = 6;
int nmaxz2 = (nmax - nmin) + 6;
//if the most left boundary is reached bound_checker is 0
//if the most right boundary is reached bound_checker is 0
if ((nmin == 0) || (nmax == (z - 1))) {
bound_checker = 0;
}
//Now we consider an obstacle in the row
if ((nmax - nmin) != (z - 1)) {
bound_checker = 1;
//is the left boundary at the edge of the computational domain
//lefter = 1
if (nmin == 0) lefter = 1;
//is the right boundary at the edge of the computational domain
//lefter =2;
if (nmax == (z - 1)) lefter = 2;
//if there is an obstacle left and right than
//lefter = 3
if ((nmin != 0) && (nmax != (z - 1))) lefter = 3;
}
ppm_step(i, j, k, direction, flag, nminz2, nmaxz2, a_coef, ai_coef, b_coef, bi_coef, c_coef, ci_coef,
d_x, diffa, da, ar, pl, p6, rl, r6, u6, ul, vl, v6, wl, w6, el,
e6, ql, q6, dp, du, dr, dv, dw, dq, de, scratch1, scratch2, scratch3,
plft, prgh, ulft, urgh, rlft, rrgh, Cdtdx, fCdtdx, steep, flat,
para, clft, crgh, plfti, prghi, pmid, pmold, wlft, wrgh, zlft,
zrgh, umidl, umidr, umid, dm, dtbdm, upmid, xa1, xa2, xa3,
vx_1D_old, dvol, dvol0, dvol1, delta, fluxr, fluxu, fluxv,
fluxw, fluxe, fluxq, dm0, e_int_1D, rho_1D, pre_1D, eng_1D,
vx_1D, vy_1D, vz_1D, marker_1D, pressure_solid_1D, dx0, xa0,
xa, dx, bound_checker, lefter, rhodown, rhoup, rhofront,
rhoback, vxdown, vxup, vxfront, vxback, vydown, vyup, vyfront,
vyback, vzdown, vzup, vzfront, vzback, viscosity_on_off, dimension);
//put the solution back into the 3D arrays
for (kk = nmin; kk <= nmax; kk++) {
n = kk + 6 - nmin;
rho[i][j][kk] = rho_1D[n];
pre[i][j][kk] = pre_1D[n];
vz[i][j][kk] = vx_1D[n];
vx[i][j][kk] = vy_1D[n];
vy[i][j][kk] = vz_1D[n];
if (advection == 1) marker[i][j][kk] = marker_1D[n];
//for the pressure on the obstacle calculation
if (with_obstacles == 1) pressure_on_solid[i][j][kk] = pressure_solid_1D[n];
}
} else if (state == DOM_SOLID) {
nmin = nmax + 1;
}
}
nmax++;
}
}
}
//free section
ppm_free(&rho_1D, &pre_1D, &eng_1D, &vx_1D, &vy_1D, &vz_1D, &marker_1D,
&pressure_solid_1D, &dx0, &xa0, &xa, &dx, &a_coef, &ai_coef, &b_coef,
&bi_coef, &c_coef, &ci_coef, &d_x, &da, &ar,
&dp, &dr, &du, &pl, &p6, &rl, &r6, &ul, &u6, &vl, &v6, &wl, &w6, &el, &e6, &ql,
&q6, &deltaa, &dv, &dw, &dq, &de, &scratch1, &scratch2, &scratch3, &diffa,
&plft, &prgh, &ulft, &urgh, &rlft, &rrgh, &Cdtdx, &fCdtdx, &clft, &crgh,
&plfti, &prghi, &pmid, &pmold, &wlft, &wrgh, &zlft, &zrgh, &umidl, &umidr,
&umid, &dm, &dtbdm, &upmid, &xa1, &xa2, &xa3, &vx_1D_old, &e_int_1D, &dvol,
&dvol0, &dvol1, &delta, &fluxr, &fluxu, &fluxv, &fluxw, &fluxe, &fluxq,
&dm0, &steep, &flat, &para, &rhodown, &rhoup, &rhofront,
&rhoback, &vxdown, &vxup, &vxfront, &vxback, &vydown, &vyup, &vyfront,
&vyback, &vzdown, &vzup, &vzfront, &vzback, dimension);
#ifdef _OPENMP
}
#endif
return 0;
}
int upper_atmos ( int  x,
int  y,
int  z 
)
int velocity_field_analyser ( int  x,
int  y,
int  z 
)

Quantities of the fluid are integrated here. Here you can start to implement you owns investigations of integrated quantities of the fluid.

Definition at line 25 of file data_explorer.c.

References dimension, dom, output_dir, rho, time_sim, vx, vy, vz, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
double velocity_x, velocity_y, velocity_z;
double velo_ratio;
sprintf(filename, "%stotal_quantities_of_fluid.txt", output_dir);
fd = fopen(filename, "aw");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
velocity_x = velocity_y = velocity_z = velo_ratio = 0.0;
if (dimension == 3) {
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, velocity_x, velocity_y, velocity_z, \
rho, dom, vx, vy, vz)
{
#endif
//Here we calculate a density * velocity quantity
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 0) {
velocity_x += rho[i][j][k] * vx[i][j][k];
velocity_y += rho[i][j][k] * vy[i][j][k];
velocity_z += rho[i][j][k] * vz[i][j][k];
}
}
}
}
#ifdef _OPENMP
}
#endif
}
if (dimension == 2) {
#ifdef _OPENMP
#pragma omp parallel default(none) \
private(j, i, k) \
shared(x, y, z, velocity_x, velocity_y, velocity_z, \
rho, dom, vx, vy, vz)
{
#endif
k = 0;
//Here we calculate a density * velocity quantity
for (i = 0; i < x; i++) {
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (j = 0; j < y; j++) {
if (dom[i][j][k] == 0) {
velocity_x += rho[i][j][k] * vx[i][j][k];
velocity_y += rho[i][j][k] * vy[i][j][k];
velocity_z += rho[i][j][k] * vz[i][j][k];
}
}
}
#ifdef _OPENMP
}
#endif
}
if (dimension == 2) {
velo_ratio = velocity_x / velocity_y;
fprintf(fd, "%e %e %e %e\n", time_sim, velo_ratio, velocity_x, velocity_y);
}
if (dimension == 3) {
fprintf(fd, "%e %e %e %e\n", time_sim, velocity_x, velocity_y, velocity_z);
}
fclose(fd);
return 0;
}
int viscosity ( int  i,
int  j,
int  k,
int  flag,
int  nmin,
int  nmax,
double *  rho_1D,
double *  vx_1D,
double *  vy_1D,
double *  vz_1D,
double *  pre_1D,
double *  e_int_1D,
double *  eng_1D,
int  lefter,
double *  rhodown,
double *  rhoup,
double *  rhofront,
double *  rhoback,
double *  vxdown,
double *  vxup,
double *  vxfront,
double *  vxback,
double *  vydown,
double *  vyup,
double *  vyfront,
double *  vyback,
double *  vzdown,
double *  vzup,
double *  vzfront,
double *  vzback,
int  dimension 
)

The velocity fluxes are changed due to viscosity Velocity-Flux = -nu * grad(v_x) This routine computes the velocity fluxes from viscosity and alters the velocity fluxes from the hydro step.

Definition at line 34 of file viscosity.c.

References dt, dynamic_viscosity(), gasconstant, max_array_length, x, xmax, xmin, y, ymax, ymin, z, zmax, and zmin.

Referenced by ppm_step().

{
int n;
double viscosity_term;
double temperature_i, temperature_ii;
double term_x, term_y, term_z;
double term_x_1, term_y_1, term_z_1;
double term_x_2, term_y_2, term_z_2;
double dx, dm, dm0, dtbdx;
double *dxflux, *dyflux, *dzflux;
dm = 0.0;
dm0 = 0.0;
dx = 0.0;
dtbdx = 0.0;
dxflux = calloc((max_array_length + 12), sizeof dxflux);
dyflux = calloc((max_array_length + 12), sizeof dyflux);
dzflux = calloc((max_array_length + 12), sizeof dzflux);
// spacing in all three directions
if (flag == 0) dx = (xmax - xmin) / (double) x;
if (flag == 1) dx = (ymax - ymin) / (double) y;
if (flag == 2) dx = (zmax - zmin) / (double) z;
for (n = nmin - 1; n <= nmax + 1; n++) {
term_x = 0.0;
term_y = 0.0;
term_z = 0.0;
term_x_1 = 0.0;
term_y_1 = 0.0;
term_z_1 = 0.0;
term_x_2 = 0.0;
term_y_2 = 0.0;
term_z_2 = 0.0;
//the core computation of viscosity
temperature_i = pre_1D[n] / (gasconstant * rho_1D[n]);
temperature_ii = pre_1D[n - 1] / (gasconstant * rho_1D[n - 1]);
viscosity_term = -0.5 * (dynamic_viscosity(temperature_i) + dynamic_viscosity(temperature_ii));
//the dxflux term----------------------------------------------------------------------------------
term_x = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vx_1D[n] - vx_1D[n - 1]));
if (dimension > 1) {
term_x_1 = (rhoup[n] + rhodown[n])*(2.0 / 3.0)*(vyup[n] - vydown[n])*0.5;
term_x_1 += (rhoup[n - 1] + rhodown[n - 1])*(2.0 / 3.0)*(vyup[n - 1] - vydown[n - 1])*0.5;
}
if (dimension > 2) {
term_x_2 = (rhoback[n] + rhofront[n])*(2.0 / 3.0)*(vzfront[n] - vzback[n])*0.5;
term_x_2 += (rhoback[n - 1] + rhofront[n - 1])*(2.0 / 3.0)*(vzfront[n - 1] - vzback[n - 1])*0.5;
}
dxflux[n] = term_x - 0.25 * (term_x_1 + term_x_2);
//the dxflux term----------------------------------------------------------------------------------
//the dyflux term----------------------------------------------------------------------------------
if (dimension > 1) {
term_y = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vy_1D[n] - vy_1D[n - 1]));
term_y_1 = (rhoup[n] + rhodown[n])*(vxup[n] - vxdown[n])*0.5;
term_y_1 += (rhoup[n - 1] + rhodown[n - 1])*(vxup[n - 1] - vxdown[n - 1])*0.5;
dyflux[n] = term_y + 0.25 * term_y_1;
}
//the dyflux term----------------------------------------------------------------------------------
//the dzflux term----------------------------------------------------------------------------------
if (dimension > 2) {
term_z = -viscosity_term / dx * (rho_1D[n]*(4.0 / 3.0)*(vz_1D[n] - vz_1D[n - 1]));
term_z_1 = (rhoback[n] - rhofront[n])*(vxback[n] - vxfront[n])*0.5;
term_z_1 += (rhoback[n - 1] + rhofront[n - 1])*(vxback[n - 1] - vxfront[n - 1])*0.5;
dzflux[n] = term_z + 0.25 * term_z_1;
}
//the dzflux term----------------------------------------------------------------------------------
}
//Now the viscosity effect on the hydro quantities will be calculated
for (n = nmin; n <= nmax; n++) {
dm0 = 1 / rho_1D[n];
dtbdx = dt / dx;
vx_1D[n] = (vx_1D[n] * rho_1D[n] - dtbdx * (dxflux[n + 1] - dxflux[n])) * dm0;
vy_1D[n] = (vy_1D[n] * rho_1D[n] - dtbdx * (dyflux[n + 1] - dyflux[n])) * dm0;
vz_1D[n] = (vz_1D[n] * rho_1D[n] - dtbdx * (dzflux[n + 1] - dzflux[n])) * dm0;
}
free(dxflux);
free(dyflux);
free(dzflux);
return 0;
}
int volume ( int  nmin,
int  nmax,
double *  vol,
double *  dx,
double *  vol0,
double *  dx0 
)

Definition at line 16 of file volume.c.

Referenced by diffusion(), and ppm_step().

{
int i;
for (i = nmin - 3; i <= nmax + 4; i++) {
dvol[i] = dx[i];
dvol0[i] = dx0[i];
}
return 0;
}
int wind ( int  x,
int  y,
int  z 
)

The Wind routine, which gives a constant flow with wind-speed velocity

Definition at line 39 of file wind.c.

References vx, vy, vz, wind_marker, wind_speed, x, y, and z.

Referenced by hydro_sweeps().

{
int i, j, k;
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (wind_marker[i][j][k] == 2) {
vx[i][j][k] = wind_speed;
vy[i][j][k] = vy[i][j][k];
vz[i][j][k] = vz[i][j][k];
}
if (wind_marker[i][j][k] == 3) {
vx[i][j][k] = -1 * wind_speed;
vy[i][j][k] = vy[i][j][k];
vz[i][j][k] = vz[i][j][k];
}
if (wind_marker[i][j][k] == 4) {
vx[i][j][k] = vx[i][j][k];
vy[i][j][k] = wind_speed;
vz[i][j][k] = vz[i][j][k];
}
if (wind_marker[i][j][k] == 5) {
vx[i][j][k] = vx[i][j][k];
vy[i][j][k] = -1 * wind_speed;
vz[i][j][k] = vz[i][j][k];
}
if (wind_marker[i][j][k] == 6) {
vx[i][j][k] = vx[i][j][k];
vy[i][j][k] = vy[i][j][k];
vz[i][j][k] = wind_speed;
}
if (wind_marker[i][j][k] == 7) {
vx[i][j][k] = vx[i][j][k];
vy[i][j][k] = vy[i][j][k];
vz[i][j][k] = -1 * wind_speed;
}
}
}
}
return 0;
}
int write_amira ( int  x,
int  y,
int  z,
int  counter 
)

Writes the initial model in a Amira Mesh format those binaries are in BigEndian format The slow order of the nested loops is mandatory here

Definition at line 20 of file write_amira.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, ntohll(), output_dir, pre, pressure_on_solid, rho, vx, vy, vz, with_obstacles, with_sound_emitter, x, xmax, xmin, y, ymax, ymin, z, zmax, and zmin.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
long long int tmp1, tmp1_vx, tmp1_vy, tmp1_vz;
double tmp, tmp_vx, tmp_vy, tmp_vz;
sprintf(filename, "%srho_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double[3] ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vx = vx[i][j][k];
tmp1_vx = ntohll(*((long long int*) & tmp_vx));
tmp_vy = vy[i][j][k];
tmp1_vy = ntohll(*((long long int*) & tmp_vy));
tmp_vz = vz[i][j][k];
tmp1_vz = ntohll(*((long long int*) & tmp_vz));
fwrite(&tmp1_vx, 1, sizeof (double), fd);
fwrite(&tmp1_vy, 1, sizeof (double), fd);
fwrite(&tmp1_vz, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_%i.am", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_ic_amira ( int  x,
int  y,
int  z 
)

Writes the initial model in a Amira Mesh format those binaries are in BigEndian format The slow order of the nested loops is mandatory here

Definition at line 20 of file write_ic_amira.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, ntohll(), output_dir, pre, pressure_on_solid, rho, vx, vy, vz, with_obstacles, with_sound_emitter, x, xmax, xmin, y, ymax, ymin, z, zmax, and zmin.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
long long int tmp1, tmp1_vx, tmp1_vy, tmp1_vz;
double tmp, tmp_vx, tmp_vy, tmp_vz;
sprintf(filename, "%srho_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double[3] ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vx = vx[i][j][k];
tmp1_vx = ntohll(*((long long int*) & tmp_vx));
tmp_vy = vy[i][j][k];
tmp1_vy = ntohll(*((long long int*) & tmp_vy));
tmp_vz = vz[i][j][k];
tmp1_vz = ntohll(*((long long int*) & tmp_vz));
fwrite(&tmp1_vx, 1, sizeof (double), fd);
fwrite(&tmp1_vy, 1, sizeof (double), fd);
fwrite(&tmp1_vz, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_ic.am", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# AmiraMesh BINARY 1.0\n");
fprintf(fd, "\n# Dimensions in x-, y-, and z-direction\n");
fprintf(fd, "define Lattice %i %i %i\n\n", x, y, z);
fprintf(fd, "Parameters {\n CoordType \"uniform\"\n");
fprintf(fd, " # BoundingBox is xmin xmax ymin ymax zmin zmax\n");
fprintf(fd, " BoundingBox %g %g %g %g %g %g\n", xmin, xmax, ymin, ymax, zmin, zmax);
fprintf(fd, "}\n\nLattice { double ScalarField } = @1\n\n");
fprintf(fd, "@1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_ic_ifrit ( int  x,
int  y,
int  z 
)

Writes the initial model in a IFRIT uniform scale binary data file The slow order of the nested loops is mandatory here

Definition at line 20 of file write_ic_ifrit.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, output_dir, pre, pressure_on_solid, rho, vx, vy, vz, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
int ntemp;
double tmp, tmp_vx, tmp_vy, tmp_vz;
float data1;
sprintf(filename, "%srho_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 4, 1, fd);
fclose(fd);
sprintf(filename, "%stemp_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
sprintf(filename, "%spressure_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
sprintf(filename, "%svel_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y*z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vx = vy[i][j][k];
data1 = (float) tmp_vx;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vy = vx[i][j][k];
data1 = (float) tmp_vy;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vz = vz[i][j][k];
data1 = (float) tmp_vz;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_ic_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_ic.bin", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
return 0;
}
int write_ic_tyc ( int  x,
int  y,
int  z 
)

Writes the initial model

Definition at line 17 of file write_ic_tyc.c.

References advection, counter, counter_restart, dB_map, dB_Map_ready, dom, gasconstant, marker, output_dir, pre, pressure_on_solid, rho, time_sim, vx, vy, vz, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k, tmp1;
double tmp;
sprintf(filename, "%srho_ic.tyc", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "TYCHO Density File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = rho[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
//printf("write: %f %i %i\n", tmp, i, j);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_ic.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Temperature File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_ic.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Pressure File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_ic.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Velocity File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = vx[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vy[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vz[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_ic.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO pressure on solid File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pressure_on_solid[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_ic.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO dba_map\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = dB_map[i][j][k];
if (isnan(tmp)) {
printf("NaN in dB_map array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_ic.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Marker File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = marker[i][j][k];
if (isnan(tmp)) {
printf("NaN in marker array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_ic_vtk ( int  x,
int  y,
int  z 
)

Writes the initial model in a RECTILINEAR_GRID VTK-File VTK binaries are in BigEndian format The slow order of the nested loops is mandatory here

Definition at line 20 of file write_ic_vtk.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, minute_in_sec, ntohll(), output_dir, pre, pressure_on_solid, rho, time_sim, vx, vy, vz, with_obstacles, with_sound_emitter, x, xmax, y, ymax, z, and zmax.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
long long int tmp1, tmp1_vx, tmp1_vy, tmp1_vz;
double tmp, tmp_vx, tmp_vy, tmp_vz;
sprintf(filename, "%srho_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Density File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS density double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Pressure File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Temperature File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS temperature double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Velocity File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "VECTORS velocity double 1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vx = vx[i][j][k];
tmp1_vx = ntohll(*((long long int*) & tmp_vx));
tmp_vy = vy[i][j][k];
tmp1_vy = ntohll(*((long long int*) & tmp_vy));
tmp_vz = vz[i][j][k];
tmp1_vz = ntohll(*((long long int*) & tmp_vz));
fwrite(&tmp1_vx, 1, sizeof (double), fd);
fwrite(&tmp1_vy, 1, sizeof (double), fd);
fwrite(&tmp1_vz, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO pressure on solid File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure_on_solid double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%TYCHO dB_map_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO dBA map file - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure_on_solid double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_ic.vtk", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Marker File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS marker_density double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_ifrit ( int  x,
int  y,
int  z,
int  counter 
)

Writes the initial model in a IFRIT uniform scala binary data file The slow order of the nested loops is mandatory here

Definition at line 20 of file write_ifrit.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, output_dir, pre, pressure_on_solid, rho, vx, vy, vz, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
int ntemp;
double tmp, tmp_vx, tmp_vy, tmp_vz;
float data1;
sprintf(filename, "%srho_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y*z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 4, 1, fd);
fclose(fd);
sprintf(filename, "%stemp_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y*z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
sprintf(filename, "%spressure_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
sprintf(filename, "%svel_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp_vx = vy[i][j][k];
data1 = (float) tmp_vx;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vy = vx[i][j][k];
data1 = (float) tmp_vy;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vz = vz[i][j][k];
data1 = (float) tmp_vz;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_%04i.bin", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
ntemp = 12;
fwrite(&ntemp, 1, sizeof (int), fd);
fwrite(&x, 1, sizeof (int), fd);
fwrite(&y, 1, sizeof (int), fd);
fwrite(&z, 1, sizeof (int), fd);
fwrite(&ntemp, 1, sizeof (int), fd);
ntemp = 4 * x * y * z;
fwrite(&ntemp, 1, sizeof (int), fd);
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
data1 = (float) tmp;
fwrite(&data1, 1, sizeof (data1), fd);
}
}
}
fwrite(&ntemp, 1, sizeof (int), fd);
fclose(fd);
}
return 0;
}
int write_restart_tyc ( int  x,
int  y,
int  z 
)

Writes the restart files

Definition at line 17 of file write_restart_tyc.c.

References advection, counter, counter_restart, dom, gasconstant, marker, output_dir, pre, pressure_integrated, rho, soundemitter, time_sim, vx, vy, vz, wind_marker, wind_on_off, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k, tmp1;
double tmp;
sprintf(filename, "%srho_restart.tyc", output_dir);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "TYCHO Density File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = rho[i][j][k];
if (isnan(tmp)) {
printf("NaN in density array %i %i %i\n", i, j, k);
exit(0);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Temperature File\n%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
if (isnan(tmp)) {
printf("NaN in temperature array %i %i %i\n", i, j, k);
exit(0);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Velocity File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = vx[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vy[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vz[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%sdom_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Dom File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp1 = dom[i][j][k];
if (isnan(tmp1)) {
printf("NaN in dom array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp1, 1, sizeof (int), fd);
}
}
}
fclose(fd);
}
if (with_sound_emitter == 1) {
sprintf(filename, "%ssound_emitter_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Dom File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp1 = soundemitter[i][j][k];
if (isnan(tmp1)) {
printf("NaN in sound_emitter array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp1, 1, sizeof (int), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_integrated_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Pressure Integrated File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pressure_integrated[i][j][k];
if (isnan(tmp)) {
printf("NaN in spressure_integrated_restart array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
if (advection == 1) {
sprintf(filename, "%smarker_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Marker File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = marker[i][j][k];
if (isnan(tmp)) {
printf("NaN in marker array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
if (wind_on_off == 1) {
sprintf(filename, "%swind_restart.tyc", output_dir);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Wind File%g\n%i\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter, counter_restart);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = wind_marker[i][j][k];
if (isnan(tmp)) {
printf("NaN in wind marker array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_tyc ( int  x,
int  y,
int  z,
int  counter 
)

write_raw.c

Author: Wolfgang Kapferer

In this routine the output-files are written.

Definition at line 17 of file write_tyc.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, output_dir, pre, pressure_on_solid, rho, time_sim, vx, vy, vz, with_obstacles, with_sound_emitter, x, y, and z.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k, tmp1;
double tmp;
sprintf(filename, "%srho_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "TYCHO Density File\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = rho[i][j][k];
if (isnan(tmp)) {
printf("NaN in density array %i %i %i\n", i, j, k);
exit(0);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Temperature File\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
if (isnan(tmp)) {
printf("NaN in temperature array %i %i %i\n", i, j, k);
printf("%g %g %i\n", pre[i][j][k], rho[i][j][k], dom[i][j][k]);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Pressure File\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
if (isnan(tmp)) {
printf("NaN in pressure array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Velocity File\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = vx[i][j][k];
if (isnan(tmp)) {
printf("NaN in vx array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vy[i][j][k];
if (isnan(tmp)) {
printf("NaN in vy array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
tmp = vz[i][j][k];
if (isnan(tmp)) {
printf("NaN in vz array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO pressure on solid File\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = pressure_on_solid[i][j][k];
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%sdB_map_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO dba_map\n%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = dB_map[i][j][k];
if (isnan(tmp)) {
printf("NaN in dB_map array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_%i.tyc", output_dir, counter);
fd = fopen(filename, "wb");
fprintf(fd, "TYCHO Marker File%g\n%i\n%i\n%i\n%i\n", time_sim, x, y, z, counter);
fseek(fd, 200, SEEK_SET);
for (i = 0; i < x; i++) {
for (j = 0; j < y; j++) {
for (k = 0; k < z; k++) {
tmp = marker[i][j][k];
if (isnan(tmp)) {
printf("NaN in marker array %i %i %i\n", i, j, k);
exit(1);
}
fwrite(&tmp, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}
int write_vtk ( int  x,
int  y,
int  z,
int  counter 
)

Writes the initial model in a RECTILINEAR_GRID VTK-File VTK binaries are in BigEndian format The slow order of the nested loops is mandatory here

Definition at line 21 of file write_vtk.c.

References advection, dB_map, dB_Map_ready, dom, gasconstant, marker, minute_in_sec, ntohll(), output_dir, pre, pressure_on_solid, rho, time_sim, vx, vy, vz, with_obstacles, with_sound_emitter, x, xmax, y, ymax, z, and zmax.

Referenced by main().

{
FILE *fd;
char filename[600];
int i, j, k;
long long int tmp1, tmp1_vx, tmp1_vy, tmp1_vz;
double tmp, tmp_vx, tmp_vy, tmp_vz;
sprintf(filename, "%srho_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Density File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS density double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = rho[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%stemp_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Temperature File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS temperature double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pre[i][j][k] / (gasconstant * rho[i][j][k]);
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%spressure_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Pressure File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
if (dom[i][j][k] == 0) tmp = pre[i][j][k];
if (dom[i][j][k] == 1) tmp = 0.0;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
sprintf(filename, "%svel_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Velocity File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "VECTORS velocity double 1\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp_vx = vx[i][j][k];
tmp1_vx = ntohll(*((long long int*) & tmp_vx));
tmp_vy = vy[i][j][k];
tmp1_vy = ntohll(*((long long int*) & tmp_vy));
tmp_vz = vz[i][j][k];
tmp1_vz = ntohll(*((long long int*) & tmp_vz));
fwrite(&tmp1_vx, 1, sizeof (double), fd);
fwrite(&tmp1_vy, 1, sizeof (double), fd);
fwrite(&tmp1_vz, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if (with_obstacles == 1) {
sprintf(filename, "%spressure_on_solid_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO pressure on solid File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure_on_solid double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = pressure_on_solid[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
if ((with_sound_emitter == 1) && (dB_Map_ready == 1)) {
sprintf(filename, "%TYCHO dB_map_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO dBA Map - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS pressure_on_solid double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = dB_map[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
}
if (advection == 1) {
sprintf(filename, "%smarker_%i.vtk", output_dir, counter);
fd = fopen(filename, "wb");
if (fd == NULL) {
printf("-----------------------------------\n");
printf("The output directory does not exist\n");
printf("-----------------------------------\n");
exit(13);
}
fprintf(fd, "# vtk DataFile Version 3.0\n");
fprintf(fd, "TYCHO Marker File - Time:%g\n", time_sim / minute_in_sec);
fprintf(fd, "BINARY\n");
fprintf(fd, "DATASET RECTILINEAR_GRID\n");
fprintf(fd, "DIMENSIONS %i %i %i\n", x, y, z);
fprintf(fd, "X_COORDINATES %i double\n", x);
for (i = 0; i < x; i++) {
tmp = ((double) xmax / (double) x) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nY_COORDINATES %i double\n", y);
for (i = 0; i < y; i++) {
tmp = ((double) ymax / (double) y) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nZ_COORDINATES %i double\n", z);
for (i = 0; i < z; i++) {
tmp = ((double) zmax / (double) z) * (double) i;
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
fprintf(fd, "\nPOINT_DATA %i\n", x * y * z);
fprintf(fd, "SCALARS marker_density double 1\n");
fprintf(fd, "LOOKUP_TABLE default\n");
for (k = 0; k < z; k++) {
for (j = 0; j < y; j++) {
for (i = 0; i < x; i++) {
tmp = marker[i][j][k];
tmp1 = ntohll(*((long long int*) & tmp));
fwrite(&tmp1, 1, sizeof (double), fd);
}
}
}
fclose(fd);
}
return 0;
}