void pvrs(const double *WL, const double *WR, double *ps, double *us) { /* Primative variable approximate riemman solver. * Used in smooth regions to give estimates for pressure and velocity in star region. */ double rho_L = WL[0]; double u_L = WL[1]; double p_L = WL[2]; double rho_R = WR[0]; double u_R = WR[1]; double p_R = WR[2]; double a_L = sound_speed(p_L,rho_L); double a_R = sound_speed(p_R,rho_R); double rho__a_bar = .25*(rho_L + rho_R)*(a_L + a_R); *ps = .5*(p_L + p_R) - .5*(u_R - u_L) * rho_a__bar; *us = .5*(u_L + u_R) - .5*(p_R-p_L)/rho_a_bar; return; }
void trrs(const double *WL, const double *WR, double *ps, double *us) { /* Two rarefaction approximate riemman solver. * Used near rarefaction waves to give estimates for pressure and velocity in star region. */ double rho_L = WL[0]; double u_L = WL[1]; double p_L = WL[2]; double rho_R = WR[0]; double u_R = WR[1]; double p_R = WR[2]; double a_L = sound_speed(p_L,rho_L); double a_R = sound_speed(p_R,rho_R); double gamma_1 = (GAMMA - 1)/2.; double inv_gamma_1 = 1./gamma_1; double gamma_2 = (GAMMA - 1)/(2.*GAMMA); double inv_gamma_2 =1/gamma_2; double plr = pow(p_L/p_R,gamma_2); *ps = pow( ( a_L + a_R - gamma_1*(u_R - u_L))/(a_l*pow(p_L,-gamma_2) + a_R*pow(p_R,-gamma_2) ), inv_gamma_2); *us = (plr*u_L/a_L + u_R/a_R + inv_gamma_1 * (plr - 1) )/(plr/a_L + 1/a_R); return; }
EXPORT void fprint_raw_gas_data( FILE *file, Locstate state, int dim) { (void) fprintf(file,"state 0x%p\n",(POINTER)state); if (state == NULL) { (void) printf("NULL state\n"); return; } (void) fprintf(file,"\tState Data "); (void) fprintf(file,"\n"); switch (state_type(state)) { case GAS_STATE: g_fprint_raw_state(file,state,dim); break; case EGAS_STATE: g_fprint_raw_Estate(file,state,dim); break; case TGAS_STATE: g_fprint_raw_Tstate(file,state,dim); break; case FGAS_STATE: g_fprint_raw_Fstate(file,state,dim); break; case OBSTACLE_STATE: (void) fprintf(file,"Obstacle state type, " "printing as GAS_STATE\n"); g_fprint_raw_state(file,state,dim); break; case VGAS_STATE: g_fprint_raw_Tstate(file,state,dim); (void) printf("Specific internal energy = %"FFMT"\n",Int_en(state)); (void) printf("Entropy = %"FFMT"\n",Entropy(state)); (void) printf("Sound_speed = %"FFMT"\n",sound_speed(state)); #if defined(VERBOSE_GAS_PLUS) (void) printf("Enthalpy = %"FFMT"\n",Enthalpy(state)); (void) printf("Temperature = %"FFMT"\n",Temp(state)); #endif /* defined(VERBOSE_GAS_PLUS) */ break; case UNKNOWN_STATE: (void) fprintf(file,"Unknown state type, printing as GAS_STATE\n"); g_fprint_raw_state(file,state,dim); break; default: screen("ERROR in fprint_raw_gas_data(), " "unknown state type %d\n",state_type(state)); clean_up(ERROR); } } /*end fprint_raw_gas_data*/
EXPORT void g_verbose_fprint_state( FILE *file, const char *name, Locstate state) { bool bin_out; int i, dim; float p, c, S, v[SMAXD], speed; static char vname[3][3] = { "vx", "vy", "vz"}; static char mname[3][3] = { "mx", "my", "mz"}; if (name == NULL) name = ""; (void) fprintf(file,"\n%s:\n",name); (void) fprintf(file,"address %p\n",state); if (state == NULL || is_obstacle_state(state)) { (void) fprintf(file,"(OBSTACLE STATE)\n\n"); return; } dim = Params(state)->dim; p = pressure(state); c = sound_speed(state); S = entropy(state); (void) fprintf(file,"%-24s = %-"FFMT" %-24s = %-"FFMT"\n", "density",Dens(state), "specific internal energy", specific_internal_energy(state)); (void) fprintf(file,"%-24s = %-"FFMT" %-24s = %-"FFMT"\n","pressure",p, "sound speed",c); (void) fprintf(file,"%-24s = %-"FFMT" %-24s = %-"FFMT"\n","temperature", temperature(state),"specific entropy",S); speed = 0.0; for (i = 0; i < dim; i++) { v[i] = vel(i,state); speed += sqr(v[i]); (void) fprintf(file,"%-24s = %-"FFMT" %-24s = %-"FFMT"\n", mname[i],mom(i,state),vname[i],v[i]); } speed = sqrt(speed); (void) fprintf(file,"%-24s = %-"FFMT"","total energy",energy(state)); if (c > 0. && Dens(state) > 0.) (void) fprintf(file," %-24s = %-"FFMT"\n","Mach number",speed / c); else (void) fprintf(file,"\n"); #if defined(TWOD) if (dim == 2) (void) fprintf(file,"%-24s = %-"FFMT"\n","velocity angle", degrees(angle(v[0],v[1]))); #endif /* defined(TWOD) */ fprint_state_type(file,"State type = ",state_type(state)); (void) fprintf(file,"Params state = %llu\n", gas_param_number(Params(state))); bin_out = is_binary_output(); set_binary_output(NO); if (debugging("prt_params")) fprint_Gas_param(file,Params(state)); else (void) fprintf(file,"Gas_param = %llu\n", gas_param_number(Params(state))); set_binary_output(bin_out); //if(p< -2000 || p>10000) //{ // printf("#huge pressure\n"); // clean_up(0); //} #if !defined(COMBUSTION_CODE) (void) fprintf(file,"\n"); #else /* !defined(COMBUSTION_CODE) */ if (Composition_type(state) == PURE_NON_REACTIVE) { (void) fprintf(file,"\n"); return; } (void) fprintf(file,"%-24s = %-12s %-24s = %-"FFMT"\n","burned", Burned(state) ? "BURNED" : "UNBURNED", "q",Params(state)->q); (void) fprintf(file,"%-24s = %-"FFMT"\n","t_crit", Params(state)->critical_temperature); if (Composition_type(state) == PTFLAME) { (void) fprintf(file,"\n"); return; } (void) fprintf(file,"%-24s = %-"FFMT"\n","product density",Prod(state)); (void) fprintf(file,"%-24s = %-"FFMT"\n", "reaction progress",React(state)); if (Composition_type(state) == ZND) { (void) fprintf(file,"\n"); return; } (void) fprintf(file,"%-24s = %-"FFMT"\n","rho1",Dens1(state)); #endif /* !defined(COMBUSTION_CODE) */ (void) fprintf(file,"%-24s = %-24s %-24s = %-"FFMT"\n\n","gamma_set", Local_gamma_set(state)?"YES" : "NO","local_gamma", Local_gamma(state)); if(g_composition_type() == MULTI_COMP_NON_REACTIVE) { if(Params(state) != NULL && Params(state)->n_comps != 1) { for(i = 0; i < Params(state)->n_comps; i++) (void) fprintf(file,"partial density[%2d] = %"FFMT"\n", i,pdens(state)[i]); (void) fprintf(file,"\n"); /* TMP the following print is for the debuging display purpose */ for(i = 0; i < Params(state)->n_comps; i++) (void) fprintf(file,"[%d]Mass fraction = %-"FFMT"\n", i, pdens(state)[i]/Dens(state)); (void) fprintf(file,"\n"); } } } /*end g_verbose_fprint_state*/
LOCAL int i_polar_1( Locstate ahead, Locstate behind, Locstate refl_bow, Locstate refl_mach, ANGLE_DIRECTION i_to_a_dir, float *abs_v, float *refl_ang, float *cont_ang, float *mach_ang) { float p3; float theta12; /*turn angle across refl*/ float theta03; /*turn angle across mach*/ float vel0_ang; /*in steady frame*/ float vel1_ang; /* " " " */ float pmax, pmin; float M0_sq, M1_sq; float rel_v[MAXD]; bool Cplus_w0; /*wave 0 is mach stem*/ bool Cplus_w1; /*wave 1 is refl wave*/ RIEMANN_SOLVER_WAVE_TYPE wtype0; RIEMANN_SOLVER_WAVE_TYPE wtype1; int i, dim = Params(ahead)->dim; static Locstate st_0 = NULL, st_1 = NULL; static Locstate st_2 = NULL, st_3 = NULL; static bool first = YES; debug_print("ipolar1","Entered i_polar_1()\n"); if (first) { size_t sizest = Params(ahead)->sizest; first = NO; (*Params(ahead)->_alloc_state)(&st_0,sizest); (*Params(ahead)->_alloc_state)(&st_1,sizest); (*Params(ahead)->_alloc_state)(&st_2,sizest); (*Params(ahead)->_alloc_state)(&st_3,sizest); } set_state(st_0,TGAS_STATE,ahead); set_state(st_1,TGAS_STATE,behind); if (debugging("ipolar1")) { verbose_print_state("ahead",ahead); verbose_print_state("behind",behind); (void) printf("\tabs_v[0] = (%g, %g)\n",abs_v[0],abs_v[1]); print_angle_direction("\ti_to_a_dir =",i_to_a_dir,"\n"); } M0_sq = mach_number_squared(st_0,abs_v,rel_v); vel0_ang = angle(rel_v[0],rel_v[1]); if (debugging("ipolar1")) { print_angle("\tvel0 angle =",vel0_ang,"\n"); (void) printf("\tahead Mach number = %g\n", mag_vector(rel_v,dim)/sound_speed(st_0)); } if (mag_vector(rel_v,dim) < sound_speed(st_0)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1(), "); (void) printf("ahead is subsonic in the rest frame.\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } M1_sq = mach_number_squared(st_1,abs_v,rel_v); if (debugging("ipolar1")) { vel1_ang = angle(rel_v[0],rel_v[1]); print_angle("\tvel1 angle =",vel1_ang,"\n"); (void) printf("\tst1 Mach number = %g\n",sqrt(M1_sq)); } if (mag_vector(rel_v,dim) < sound_speed(st_1)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1(), "); (void) printf("behind is subsonic in the rest frame.\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } if (i_to_a_dir == CLOCKWISE) { Cplus_w0 = YES; Cplus_w1 = NO; } else { Cplus_w0 = NO; Cplus_w1 = YES; } if (pr_at_max_turn_angle(&pmin,M0_sq,st_0) == FUNCTION_FAILED) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1(), "); (void) printf("pr_at_max_turn_angle() failed\n"); } return NO; } pmax = max_behind_shock_pr(M1_sq,st_1); if (!intersection_of_two_shock_polars(st_0,st_1,abs_v,&p3, &pmin,&pmax,Cplus_w0, Cplus_w1,&wtype0,&wtype1)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1(), "); (void) printf("unable to compute refl_mach pressure\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } if ((wtype0 != SHOCK) || (wtype1 != SHOCK)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1() -- "); (void) printf("non-shock wave types.\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } if (!s_polar_3(st_1,YES,p3,Cplus_w1,YES,abs_v,st_2, refl_ang,&theta12)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1() -- "); (void) printf("unable to compute refl_bow.\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } if (!s_polar_3(st_0,YES,p3,Cplus_w0,YES,abs_v,st_3, mach_ang,&theta03)) { if (debugging("ipolar1")) { (void) printf("WARNING in i_polar_1() -- "); (void) printf("unable to compute refl_mach.\n"); } debug_print("ipolar1","Left i_polar_1()\n"); return NO; } *cont_ang = normalized_angle(vel0_ang + theta03); set_state(refl_bow,GAS_STATE,st_2); set_state(refl_mach,GAS_STATE,st_3); if (debugging("ipolar1")) { float ang; (void) printf("\n"); print_angle("\trefl angle = %g d\n",*refl_ang,"\n"); print_angle("\tcont angle = %g d\n",*cont_ang,"\n"); print_angle("\tMach angle = %g d\n",*mach_ang,"\n"); print_angle("\ttheta12 = %g d\n",theta12,"\n"); print_angle("\ttheta03 = %g d\n",theta03,"\n"); for (i = 0; i < dim; i++) rel_v[i] = vel(i,st_2) - abs_v[i]; ang = angle(rel_v[0],rel_v[1]); print_angle("\tvel2_ang =",ang,"\n"); for (i = 0; i < dim; i++) rel_v[i] = vel(i,st_3) - abs_v[i]; ang = angle(rel_v[0],rel_v[1]); print_angle("\tvel3_ang =",ang,"\n"); ang = (vel1_ang+theta12) - (vel0_ang+theta03); print_angle("(vel1_ang+theta12) - (vel0_ang+theta03) =", ang,"\n"); verbose_print_state("refl_bow",refl_bow); verbose_print_state("refl_mach",refl_mach); } debug_print("ipolar1","Left i_polar_1()\n"); return YES; } /*end i_polar_1*/
/*ARGSUSED*/ EXPORT void set_up_riemann_problem_region( int layer_label, int region_label, int surf_label, int ellip_label, float *coords, float *nor, SIDE ahead_side, Locstate ahead_st, Locstate st, LAYER_SYS *layer_sys, INIT_PHYSICS *ip, INIT_DATA *init) { COMP_TYPE *ct; _RAREFACTION_WAVE_1D *rw1d; LAYER *lyr, *llyr, *ulyr; Front *front = layer_sys->front; INTERFACE *intfc = front->interf; ELLIPSOID *ellip; LAYER_SURF *lsurf; Locstate sl, sr; Locstate left, right; Locstate sml, smr; float vl, vr; float pjump; float pml, pmr, uml, umr, ml, mr; float cl, cr, cml, cmr, Wl, Wr; float W, V; float dt, dh; RIEMANN_SOLVER_WAVE_TYPE l_wave, r_wave; int i, dim = front->rect_grid->dim; int w_type; size_t sizest = front->sizest; debug_print("layer","Entered set_up_riemann_problem_region()\n"); alloc_state(intfc,&left,max(sizeof(VGas),sizest)); alloc_state(intfc,&right,max(sizeof(VGas),sizest)); alloc_state(intfc,&sml,sizest); alloc_state(intfc,&smr,sizest); if (ahead_side == POSITIVE_SIDE) { sl = st; sr = ahead_st; } else { sl = ahead_st; sr = st; } set_state(right,TGAS_STATE,sr); set_state(left,TGAS_STATE,sl); lyr = layer_sys->layer[layer_label]; if (ellip_label > 0) { if (ellip_label <= lyr->num_ellips) ellip = lyr->ellip[ellip_label]; else { screen("ERROR in set_up_riemann_problem_region(), " "invalid ellip_label %d > num_ellips %d\n", ellip_label,lyr->num_ellips); clean_up(ERROR); } lsurf = NULL; } else { ellip = NULL; if (surf_label == layer_label) { lsurf = lyr->upper_surf; llyr = lyr; ulyr = layer_sys->layer[layer_label+1]; } else if (surf_label == layer_label-1) { lsurf = lyr->lower_surf; ulyr = lyr; llyr = layer_sys->layer[layer_label-1]; } else { screen("ERROR in set_up_riemann_problem_region(), " "invalid surf_label %d layer_label %d\n", surf_label,layer_label); clean_up(ERROR); } } if (ellip != NULL) { vr = Vel(right)[0]; vl = Vel(left)[0]; pjump = -ellip->surf_tension/ distance_between_positions(coords,ellip->cen,dim); } else { vr = scalar_product(Vel(right),nor,dim); vl = scalar_product(Vel(left),nor,dim); pjump = 0.0; } zero_state_velocity(right,dim); Vel(right)[0] = vr; zero_state_velocity(left,dim); Vel(right)[0] = vl; set_state_for_find_mid_state(right,right); set_state_for_find_mid_state(left,left); if (find_mid_state(left,right,pjump,&pml,&pmr,¨,&umr,&ml,&mr, &l_wave,&r_wave) != FUNCTION_SUCCEEDED) { screen("ERROR in set_up_riemann_problem_region(), " "find_mid_state() did not converge\n"); verbose_print_state("left",left); verbose_print_state("right",right); (void) printf("pjump = %g\n" "pml = %g, pmr = %g\n" "uml = %g, umr = %g\n" "ml = %g, mr = %g\n", pjump,pml,pmr,uml,umr,ml,mr); (void) printf("l_wave = %s, r_wave = %s\n", rsoln_wave_name(l_wave),rsoln_wave_name(r_wave)); clean_up(ERROR); } w_type = (l_wave == RAREFACTION) ? BACKWARD_SOUND_WAVE_TE : BACKWARD_SHOCK_WAVE; state_behind_sound_wave(left,sml,&cml,&Wl,0.0,ml,uml,pml,TGAS_STATE, w_type,l_wave,LEFT_FAMILY); w_type = (r_wave == RAREFACTION) ? FORWARD_SOUND_WAVE_TE : FORWARD_SHOCK_WAVE; state_behind_sound_wave(right,smr,&cmr,&Wr,0.0,mr,umr,pmr,TGAS_STATE, w_type,r_wave,RIGHT_FAMILY); cl = sound_speed(left); cr = sound_speed(right); W = max(fabs(Wl),fabs(Wr)); V = fabs(vl) + cl; W = max(W,V); V = fabs(vr) + cr; W = max(W,V); V = fabs(uml) + cml; W = max(W,V); V = fabs(umr) + cmr; W = max(W,V); for (dh = HUGE_VAL, i = 0; i < dim; ++i) dh = min(dh,front->rect_grid->h[i]); dt = 0.1*dh/W;/*TOLERANCE*/ layer_sys->dt = min(layer_sys->dt,dt); if (debugging("layer")) { (void) printf("States from Riemann solution\n"); verbose_print_state("left state",left); verbose_print_state("left mid state",sml); verbose_print_state("right mid state",smr); verbose_print_state("right state",right); (void) printf("l_wave = %s, r_wave = %s\n", rsoln_wave_name(l_wave),rsoln_wave_name(r_wave)); (void) printf("Wave speeds\n"); if (l_wave == RAREFACTION) { (void) printf("Left rarefaction leading edge speed = %g\n", vl-cl); (void) printf("Left rarefaction trailing edge speed = %g\n", uml-cml); } else if (l_wave == SHOCK) (void) printf("Left shock speed = %g\n",Wl); (void) printf("Contact speed = %g (uml = %g, umr = %g)\n", 0.5*(uml+umr),uml,umr); if (r_wave == RAREFACTION) { (void) printf("Right rarefaction trailing edge speed = %g\n", umr+cmr); (void) printf("Right rarefaction leading edge speed = %g\n", vr+cr); } else if (r_wave == SHOCK) (void) printf("Right shock speed = %g\n",Wr); } if (ellip == NULL) { LAYER *rlyr, *mlyr; LAYER_SURF *rlyr_le, *rlyr_te, *shock; float *nor = lsurf->nor; float vml, vmr; vml = Vel(sml)[0]; vmr = Vel(smr)[0]; for (i = 0; i < dim; ++i) { Vel(sml)[i] = vel(i,sl) + (vml-vl)*nor[i]; Vel(smr)[i] = vel(i,sr) + (vmr-vr)*nor[i]; } if (l_wave == RAREFACTION) { rlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); rlyr->lower_surf = alloc_layer_surf(); rlyr->upper_surf = alloc_layer_surf(); *rlyr->upper_surf = *lsurf; *rlyr->lower_surf = *lsurf; rlyr->lower_surf->reset_position = YES; rlyr->upper_surf->reset_position = YES; rlyr->lower_surf->surf_ten = 0.0; rlyr->upper_surf->surf_ten = 0.0; ct = comp_type(rlyr->comp); set_rarefaction_wave_1d_comp_type(ct,front); rw1d = Rarefaction_wave_1d(ct); rw1d->l_or_r = LEFT_FAMILY; rw1d->zbar = lsurf->pbar[dim-1]; rw1d->tbar = -HUGE_VAL; /*To be set later */ rw1d->el_lead = rw1d->el_trail = NULL; set_state(rw1d->stl,TGAS_STATE,sl); set_state(rw1d->stt,TGAS_STATE,sml); rw1d->spl = vl-cl; rw1d->spt = vml-cml; mlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); if (nor[dim-1] < 0.0) { rlyr_le = rlyr->upper_surf; rlyr_te = rlyr->lower_surf; mlyr->upper_surf = rlyr_te; mlyr->lower_surf = lsurf; rw1d->zt = rw1d->zmin = -HUGE_VAL;/*To be set later*/ rw1d->stmin = rw1d->stt; rw1d->zl = rw1d->zmax = HUGE_VAL;/*To be set later*/ rw1d->stmax = rw1d->stl; ulyr->lower_surf = rlyr_le; } else { rlyr_le = rlyr->lower_surf; rlyr_te = rlyr->upper_surf; mlyr->lower_surf = rlyr_te; mlyr->upper_surf = lsurf; rw1d->zl = rw1d->zmin = -HUGE_VAL;/*To be set later*/ rw1d->stmin = rw1d->stl; rw1d->zt = rw1d->zmax = HUGE_VAL;/*To be set later*/ rw1d->stmax = rw1d->stt; llyr->upper_surf = rlyr_le; } rw1d->lead = rlyr_le; rw1d->trail = rlyr_te; rlyr_le->l_comp = lsurf->l_comp; rlyr_le->r_comp = rlyr_te->l_comp = rlyr->comp; rlyr_le->wv_type = BACKWARD_SOUND_WAVE_LE; rlyr_te->wv_type = BACKWARD_SOUND_WAVE_TE; rlyr_te->r_comp = lsurf->l_comp = mlyr->comp; for (i = 0; i < dim; ++i) { rlyr_le->velocity[i] = rw1d->spl*nor[i]; rlyr_te->velocity[i] = rw1d->spt*nor[i]; } } else { mlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); shock = alloc_layer_surf(); *shock = *lsurf; if (nor[dim-1] < 0.0) { mlyr->upper_surf = shock; mlyr->lower_surf = lsurf; ulyr->lower_surf = shock; } else { mlyr->lower_surf = shock; mlyr->upper_surf = lsurf; llyr->upper_surf = shock; } shock->l_comp = lsurf->l_comp; shock->wv_type = BACKWARD_SHOCK_WAVE; shock->r_comp = lsurf->l_comp = mlyr->comp; shock->reset_position = YES; for (i = 0; i < dim; ++i) shock->velocity[i] = Wl*nor[i]; } ct = comp_type(mlyr->comp); set_ambient_comp_type(ct,front); set_state(Ambient(ct),GAS_STATE,sml); if (r_wave == RAREFACTION) { rlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); rlyr->lower_surf = alloc_layer_surf(); rlyr->upper_surf = alloc_layer_surf(); *rlyr->upper_surf = *lsurf; *rlyr->lower_surf = *lsurf; rlyr->lower_surf->reset_position = YES; rlyr->upper_surf->reset_position = YES; rlyr->lower_surf->surf_ten = 0.0; rlyr->upper_surf->surf_ten = 0.0; ct = comp_type(rlyr->comp); set_rarefaction_wave_1d_comp_type(ct,front); rw1d = Rarefaction_wave_1d(ct); rw1d->l_or_r = RIGHT_FAMILY; rw1d->zbar = lsurf->pbar[dim-1]; rw1d->tbar = -HUGE_VAL; /*To be set later */ rw1d->el_lead = rw1d->el_trail = NULL; set_state(rw1d->stl,TGAS_STATE,sr); set_state(rw1d->stt,TGAS_STATE,smr); rw1d->spl = vr+cr; rw1d->spt = vmr+cmr; rw1d->lead = rlyr_le; rw1d->trail = rlyr_te; mlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); if (nor[dim-1] < 0.0) { rlyr_le = rlyr->lower_surf; rlyr_te = rlyr->upper_surf; mlyr->lower_surf = rlyr_te; mlyr->upper_surf = lsurf; rw1d->zl = rw1d->zmin = -HUGE_VAL;/*To be set later*/ rw1d->stmin = rw1d->stl; rw1d->zt = rw1d->zmax = HUGE_VAL;/*To be set later*/ rw1d->stmax = rw1d->stt; llyr->upper_surf = rlyr_le; } else { rlyr_le = rlyr->upper_surf; rlyr_te = rlyr->lower_surf; mlyr->upper_surf = rlyr_te; mlyr->lower_surf = lsurf; rw1d->zt = rw1d->zmin = -HUGE_VAL;/*To be set later*/ rw1d->stmin = rw1d->stt; rw1d->zl = rw1d->zmax = HUGE_VAL;/*To be set later*/ rw1d->stmax = rw1d->stl; ulyr->lower_surf = rlyr_le; } rlyr_le->r_comp = lsurf->r_comp; rlyr_le->l_comp = rlyr_te->r_comp = rlyr->comp; rlyr_le->wv_type = FORWARD_SOUND_WAVE_LE; rlyr_te->wv_type = FORWARD_SOUND_WAVE_TE; rlyr_te->l_comp = lsurf->r_comp = mlyr->comp; for (i = 0; i < dim; ++i) { rlyr_le->velocity[i] = rw1d->spl*nor[i]; rlyr_te->velocity[i] = rw1d->spt*nor[i]; } } else { mlyr = add_new_layer(layer_sys,new_component(NEW_COMP)); shock = alloc_layer_surf(); *shock = *lsurf; if (nor[dim-1] < 0.0) { mlyr->lower_surf = shock; mlyr->upper_surf = lsurf; llyr->upper_surf = shock; } else { mlyr->upper_surf = shock; mlyr->lower_surf = lsurf; ulyr->lower_surf = shock; } shock->r_comp = lsurf->r_comp; shock->wv_type = FORWARD_SHOCK_WAVE; shock->l_comp = lsurf->r_comp = mlyr->comp; shock->reset_position = YES; for (i = 0; i < dim; ++i) shock->velocity[i] = Wr*nor[i]; } ct = comp_type(mlyr->comp); set_ambient_comp_type(ct,front); set_state(Ambient(ct),GAS_STATE,smr); lsurf->wv_type = CONTACT; lsurf->reset_position = YES; for (i = 0; i < dim; ++i) lsurf->velocity[i] = 0.5*(vml+vmr)*nor[i]; } else { set_riemann_problem_ellipsoid(front,lyr,ellip,l_wave,r_wave, Wl,Wr,sl,sml,smr,sr,ip); } free_these(4,left,right,sml,smr); debug_print("layer","Left set_up_riemann_problem_region()\n"); } /*end set_up_riemann_problem_region*/
LOCAL void set_riemann_problem_ellipsoid( Front *front, LAYER *lyr, ELLIPSOID *ellip, RIEMANN_SOLVER_WAVE_TYPE l_wave, RIEMANN_SOLVER_WAVE_TYPE r_wave, float Wl, float Wr, Locstate sl, Locstate sml, Locstate smr, Locstate sr, INIT_PHYSICS *ip) { _ELLIPTICAL *rel, *mel, *el; _RAREFACTION_WAVE_1D *rw1d; COMP_TYPE *rct, *mct, *ct; ELLIPSOID *le_ellip, *te_ellip, *shock; INTERFACE *intfc = front->interf; float rmax; int i, dim = intfc->dim; ct = comp_type(ellip->compin); rmax = max_radii(ellip); if (l_wave == RAREFACTION) { le_ellip = clone_ellipsoid(lyr,ellip); le_ellip->wv_type = BACKWARD_SOUND_WAVE_LE; te_ellip = clone_ellipsoid(lyr,ellip); te_ellip->wv_type = BACKWARD_SOUND_WAVE_TE; if (ellip->nor_orient == POSITIVE_ORIENTATION) { mct = clone_elliptical_comp_type(ellip,ct,front,ip); rct = clone_elliptical_comp_type(te_ellip,ct,front,ip); if (ct->type == ELLIPTICAL) { el = Elliptical(ct); el->ellipsoid = le_ellip; } le_ellip->compin = ellip->compin; le_ellip->compout = rct->comp; te_ellip->compin = le_ellip->compout; te_ellip->compout = mct->comp; ellip->compin = te_ellip->compout; inner_ellipsoid(le_ellip) = inner_ellipsoid(ellip); outer_ellipsoid(le_ellip) = te_ellip; inner_ellipsoid(te_ellip) = le_ellip; outer_ellipsoid(te_ellip) = ellip; inner_ellipsoid(ellip) = te_ellip; } else if (ellip->nor_orient == NEGATIVE_ORIENTATION) { rct = clone_elliptical_comp_type(le_ellip,ct,front,ip); mct = clone_elliptical_comp_type(te_ellip,ct,front,ip); le_ellip->compout = ellip->compout; le_ellip->compin = rct->comp; te_ellip->compout = le_ellip->compin; te_ellip->compin = mct->comp; ellip->compout = te_ellip->compin; outer_ellipsoid(le_ellip) = outer_ellipsoid(ellip); inner_ellipsoid(le_ellip) = te_ellip; outer_ellipsoid(te_ellip) = le_ellip; inner_ellipsoid(te_ellip) = ellip; outer_ellipsoid(ellip) = te_ellip; } else { screen("ERROR in set_up_riemann_problem_region(), " "ellip->nor_orient not set\n"); clean_up(ERROR); } rel = Elliptical(rct); rel->rw1d = rw1d = allocate_RAREFACTION_WAVE_1D(front); rw1d->l_or_r = LEFT_FAMILY; rw1d->zbar = rmax; rw1d->tbar = -HUGE_VAL; /*To be set later */ rw1d->el_lead = le_ellip; rw1d->el_trail = te_ellip; rw1d->lead = rw1d->trail = NULL; set_state(rw1d->stl,TGAS_STATE,sl); set_state(rw1d->stt,TGAS_STATE,sml); le_ellip->reset_position = te_ellip->reset_position = YES; rw1d->spl = vel(0,sl) - sound_speed(sl); rw1d->spt = vel(0,sml) - sound_speed(sml); for (i = 0; i < dim; ++i) { le_ellip->vr[i] = rw1d->spl*ellip->rad[i]/rmax; te_ellip->vr[i] = rw1d->spt*ellip->rad[i]/rmax; } if (ellip->nor_orient == POSITIVE_ORIENTATION) { rw1d->zl = rw1d->zmin = -HUGE_VAL; rw1d->zt = rw1d->zmax = HUGE_VAL; rw1d->stmin = rw1d->stl; rw1d->stmax = rw1d->stt; } else { rw1d->zt = rw1d->zmin = -HUGE_VAL; rw1d->zl = rw1d->zmax = HUGE_VAL; rw1d->stmin = rw1d->stt; rw1d->stmax = rw1d->stl; } } else { shock = clone_ellipsoid(lyr,ellip); shock->wv_type = BACKWARD_SHOCK_WAVE; if (ellip->nor_orient == POSITIVE_ORIENTATION) { mct = clone_elliptical_comp_type(ellip,ct,front,ip); if (ct->type == ELLIPTICAL) { el = Elliptical(ct); el->ellipsoid = shock; } shock->compin = ellip->compin; shock->compout = mct->comp; ellip->compin = shock->compout; inner_ellipsoid(shock) = inner_ellipsoid(ellip); outer_ellipsoid(shock) = ellip; inner_ellipsoid(ellip) = shock; } else if (ellip->nor_orient == NEGATIVE_ORIENTATION) { mct = clone_elliptical_comp_type(shock,ct,front,ip); shock->compout = ellip->compout; shock->compin = mct->comp; ellip->compout = shock->compin; outer_ellipsoid(shock) = outer_ellipsoid(ellip); inner_ellipsoid(shock) = ellip; outer_ellipsoid(ellip) = shock; } else { screen("ERROR in set_up_riemann_problem_region(), " "ellip->nor_orient not set\n"); clean_up(ERROR); } shock->reset_position = YES; for (i = 0; i < dim; ++i) shock->vr[i] = Wl*ellip->rad[i]/rmax; } mel = Elliptical(mct); set_state(mel->state,TGAS_STATE,sml); if (r_wave == RAREFACTION) { le_ellip = clone_ellipsoid(lyr,ellip); le_ellip->wv_type = FORWARD_SOUND_WAVE_LE; te_ellip = clone_ellipsoid(lyr,ellip); te_ellip->wv_type = FORWARD_SOUND_WAVE_TE; if (ellip->nor_orient == NEGATIVE_ORIENTATION) { mct = clone_elliptical_comp_type(ellip,ct,front,ip); rct = clone_elliptical_comp_type(te_ellip,ct,front,ip); if (ct->type == ELLIPTICAL) { el = Elliptical(ct); el->ellipsoid = le_ellip; } le_ellip->compin = ellip->compin; le_ellip->compout = rct->comp; te_ellip->compin = le_ellip->compout; te_ellip->compout = mct->comp; ellip->compin = te_ellip->compout; inner_ellipsoid(le_ellip) = inner_ellipsoid(ellip); outer_ellipsoid(le_ellip) = te_ellip; inner_ellipsoid(te_ellip) = le_ellip; outer_ellipsoid(te_ellip) = ellip; inner_ellipsoid(ellip) = te_ellip; } else if (ellip->nor_orient == POSITIVE_ORIENTATION) { rct = clone_elliptical_comp_type(le_ellip,ct,front,ip); mct = clone_elliptical_comp_type(te_ellip,ct,front,ip); le_ellip->compout = ellip->compout; le_ellip->compin = rct->comp; te_ellip->compout = le_ellip->compin; te_ellip->compin = mct->comp; ellip->compout = te_ellip->compin; outer_ellipsoid(le_ellip) = outer_ellipsoid(ellip); inner_ellipsoid(le_ellip) = te_ellip; outer_ellipsoid(te_ellip) = le_ellip; inner_ellipsoid(te_ellip) = ellip; outer_ellipsoid(ellip) = te_ellip; } else { screen("ERROR in set_up_riemann_problem_region(), " "ellip->nor_orient not set\n"); clean_up(ERROR); } rel = Elliptical(rct); rel->rw1d = rw1d = allocate_RAREFACTION_WAVE_1D(front); rw1d->l_or_r = RIGHT_FAMILY; rw1d->zbar = rmax; rw1d->tbar = -HUGE_VAL; /*To be set later */ rw1d->el_lead = le_ellip; rw1d->el_trail = te_ellip; rw1d->lead = rw1d->trail = NULL; set_state(rw1d->stl,TGAS_STATE,sr); set_state(rw1d->stt,TGAS_STATE,smr); le_ellip->reset_position = te_ellip->reset_position = YES; rw1d->spl = vel(0,sr) + sound_speed(sr); rw1d->spt = vel(0,smr) + sound_speed(smr); for (i = 0; i < dim; ++i) { le_ellip->vr[i] = rw1d->spl*ellip->rad[i]/rmax; te_ellip->vr[i] = rw1d->spt*ellip->rad[i]/rmax; } if (ellip->nor_orient == NEGATIVE_ORIENTATION) { rw1d->zl = rw1d->zmin = -HUGE_VAL; rw1d->zt = rw1d->zmax = HUGE_VAL; rw1d->stmin = rw1d->stl; rw1d->stmax = rw1d->stt; } else { rw1d->zt = rw1d->zmin = -HUGE_VAL; rw1d->zl = rw1d->zmax = HUGE_VAL; rw1d->stmin = rw1d->stt; rw1d->stmax = rw1d->stl; } } else { shock = clone_ellipsoid(lyr,ellip); shock->wv_type = FORWARD_SHOCK_WAVE; if (ellip->nor_orient == NEGATIVE_ORIENTATION) { mct = clone_elliptical_comp_type(ellip,ct,front,ip); if (ct->type == ELLIPTICAL) { el = Elliptical(ct); el->ellipsoid = shock; } shock->compin = ellip->compin; shock->compout = mct->comp; ellip->compin = shock->compout; inner_ellipsoid(shock) = inner_ellipsoid(ellip); outer_ellipsoid(shock) = ellip; inner_ellipsoid(ellip) = shock; } else if (ellip->nor_orient == POSITIVE_ORIENTATION) { mct = clone_elliptical_comp_type(shock,ct,front,ip); shock->compout = ellip->compout; shock->compin = mct->comp; ellip->compout = shock->compin; outer_ellipsoid(shock) = outer_ellipsoid(ellip); inner_ellipsoid(shock) = ellip; outer_ellipsoid(ellip) = shock; } else { screen("ERROR in set_up_riemann_problem_region(), " "ellip->nor_orient not set\n"); clean_up(ERROR); } shock->reset_position = YES; for (i = 0; i < dim; ++i) shock->vr[i] = Wr*ellip->rad[i]/rmax; } mel = Elliptical(mct); set_state(mel->state,TGAS_STATE,smr); ellip->wv_type = CONTACT; ellip->reset_position = YES; for (i = 0; i < dim; ++i) ellip->vr[i] = 0.5*(vel(0,sml)+vel(0,smr))*ellip->rad[i]/rmax; } /*end set_riemann_problem_ellipsoid*/