LOCAL void check_add_pt( POINT ***pt_list, POINT *pt, int *num_pts, int *max_num_pts) { if (*num_pts >= *max_num_pts) { int i; POINT **pt_store; *max_num_pts += 100; FT_VectorMemoryAlloc((POINTER*)&pt_store,*max_num_pts, sizeof(POINT*)); for (i = 0; i < *num_pts; ++i) pt_store[i] = (*pt_list)[i]; if (*pt_list != NULL) free_these(1,*pt_list); *pt_list = pt_store; } if (!pointer_in_list((POINTER)pt,*num_pts,(POINTER*)*pt_list)) { (*pt_list)[*num_pts] = pt; (*num_pts)++; } } /* end check_add_pt */
LOCAL boolean check_add_tri( TRI ***tri_list, TRI *tri, int *num_tris, int *max_num_tris) { if (*num_tris >= *max_num_tris) { int i; TRI **tri_store; *max_num_tris += 100; FT_VectorMemoryAlloc((POINTER*)&tri_store,*max_num_tris, sizeof(TRI*)); for (i = 0; i < *num_tris; ++i) tri_store[i] = (*tri_list)[i]; if (*tri_list != NULL) free_these(1,*tri_list); *tri_list = tri_store; } if (!pointer_in_list((POINTER)tri,*num_tris,(POINTER*)*tri_list)) { (*tri_list)[*num_tris] = tri; (*num_tris)++; return YES; } else return NO; } /* end check_add_tri */
EXPORT int comps_consistent_at_node( NODE *node) { INTERFACE *intfc = node->interface; COMPONENT compi, compj; CURVE **c; int i, j; int ans; static O_NODE On; static int alloc_num_c = 0; /* Don't check for consistency on subdomain boundaries */ if (is_pp_node(node)) return YES; ans = YES; On.node = node; On.num_c = 0; On.prev = On.next = NULL; for (c = node->in_curves; c && *c; ++c) ++On.num_c; for (c = node->out_curves; c && *c; ++c) ++On.num_c; if (On.num_c == 0) return YES; if ((alloc_num_c == 0) || (alloc_num_c < On.num_c)) { if (alloc_num_c > 0) free_these(5,On.nc,On.nopp,On.pt,On.ang,On.orient); uni_array(&On.nc,On.num_c,sizeof(CURVE *)); uni_array(&On.nopp,On.num_c,sizeof(NODE *)); uni_array(&On.pt,On.num_c,sizeof(POINT *)); uni_array(&On.ang,On.num_c,FLOAT); uni_array(&On.orient,On.num_c,INT); alloc_num_c = On.num_c; } set_curves_at_onode(&On); for (i = 0; i < On.num_c; ++i) { j = (i + 1) % On.num_c; if (On.orient[i] == POSITIVE_ORIENTATION) compi = negative_component(On.nc[i]); else compi = positive_component(On.nc[i]); if (On.orient[j] == POSITIVE_ORIENTATION) compj = positive_component(On.nc[j]); else compj = negative_component(On.nc[j]); if (!equivalent_comps(compi,compj,intfc)) { ans = NO; break; } } return ans; } /*end comps_consistent_at_node*/
EXPORT bool output_spectral_in_time( char *basename, Wave *wave, Front *front) { COMPONENT comp; Locstate state; float *coords; float *L = wave->rect_grid->L; float *U = wave->rect_grid->U; float *h = wave->rect_grid->h; float kk,kx,ky,dk,Ek,Vk; int icoords[MAXD]; int dim = wave->rect_grid->dim; int status; char eng_name[100],vor_name[100]; static FILE *eng_file,*vor_file; static int first = YES; int i, ix, iy; int xmax, ymax, kmax, mx, my, dummy; COMPLEX **mesh_eng,**mesh_vor; Locstate lstate,rstate,bstate,tstate; debug_print("fft","Entered output_spectral_in_time()\n"); if (first) { first = NO; (void) sprintf(eng_name,"%s.energy-time.dat",basename); (void) sprintf(vor_name,"%s.vorticity-time.dat",basename); eng_file = fopen(eng_name,"w"); vor_file = fopen(vor_name,"w"); fprintf(eng_file,"VARIABLES=k,E(k)\n",xmax,ymax); fprintf(vor_file,"VARIABLES=k,V(k)\n",xmax,ymax); } xmax = wave->rect_grid->gmax[0]; ymax = wave->rect_grid->gmax[1]; if (!Powerof2(xmax,&mx,&dummy) || !Powerof2(ymax,&my,&dummy)) { screen("output_spectral_in_time() cannot analyze " "mesh not power of 2\n"); screen("xmax = %d ymax = %d\n",xmax,ymax); return FUNCTION_FAILED; } bi_array(&mesh_eng,xmax,ymax,sizeof(COMPLEX)); bi_array(&mesh_vor,xmax,ymax,sizeof(COMPLEX)); for (iy = 0; iy < ymax; ++iy) { for (ix = 0; ix < xmax; ++ix) { icoords[0] = ix; icoords[1] = iy; coords = Rect_coords(icoords,wave); comp = Rect_comp(icoords,wave); state = Rect_state(icoords,wave); if (ix != 0) icoords[0] = ix - 1; else icoords[0] = ix; lstate = Rect_state(icoords,wave); if (ix != xmax-1) icoords[0] = ix + 1; else icoords[0] = ix; rstate = Rect_state(icoords,wave); icoords[0] = ix; if (iy != 0) icoords[1] = iy - 1; else icoords[1] = iy; bstate = Rect_state(icoords,wave); if (iy != ymax-1) icoords[1] = iy + 1; else icoords[1] = iy; tstate = Rect_state(icoords,wave); mesh_eng[ix][iy].real = kinetic_energy(state); mesh_eng[ix][iy].imag = 0.0; mesh_vor[ix][iy].real = (Mom(rstate)[1]/Dens(rstate) - Mom(lstate)[1]/Dens(lstate))/h[0] - (Mom(tstate)[0]/Dens(tstate) - Mom(bstate)[0]/Dens(bstate))/h[1]; mesh_vor[ix][iy].imag = 0.0; } } fft2d(mesh_eng,xmax,ymax,1); fft2d(mesh_vor,xmax,ymax,1); kmax = xmax/2; dk = 2.0*PI/(U[0] - L[0]); fprintf(eng_file,"ZONE\n",kk,Ek); fprintf(vor_file,"ZONE\n",kk,Vk); for (i = 0; i < kmax; ++i) { Ek = 0.0; Vk = 0.0; kk = 2.0*i*PI/(U[0] - L[0]); for (iy = 0; iy < ymax/2; ++iy) { for (ix = 0; ix < xmax/2; ++ix) { kx = 2.0*ix*PI/(U[0] - L[0]); ky = 2.0*iy*PI/(U[1] - L[1]); if (sqrt(sqr(kx)+sqr(ky)) >= kk-0.5*dk && sqrt(sqr(kx)+sqr(ky)) < kk+0.5*dk) { Ek += 2.0*sqrt(sqr(mesh_eng[ix][iy].real) + sqr(mesh_eng[ix][iy].imag)); Vk += 2.0*sqrt(sqr(mesh_vor[ix][iy].real) + sqr(mesh_vor[ix][iy].imag)); } } } fprintf(eng_file,"%lf\t%lf\n",kk,Ek); fprintf(vor_file,"%lf\t%lf\n",kk,Vk); } fflush(eng_file); fflush(vor_file); free_these(2,mesh_eng,mesh_vor); debug_print("fft","Left output_spectral_in_time()\n"); return FUNCTION_SUCCEEDED; } /*end output_spectral_in_time*/
EXPORT bool output_spectral_analysis( char *basename, Wave *wave, Front *front) { COMPONENT comp; Locstate state; float *coords; float *L = wave->rect_grid->L; float *U = wave->rect_grid->U; float *h = wave->rect_grid->h; int icoords[MAXD]; int dim = wave->rect_grid->dim; int status; int step = front->step; char energy_name[100],vorticity_name[100], enstrophy_name[100],dens_name[100],pres_name[100]; FILE *energy_file,*vorticity_file, *enstrophy_file,*dens_file,*pres_file; debug_print("fft","Entered fft_energy_spectral()\n"); (void) sprintf(energy_name,"%s.energy%s.dat",basename, right_flush(step,TSTEP_FIELD_WIDTH)); (void) sprintf(vorticity_name,"%s.vorticity%s.dat",basename, right_flush(step,TSTEP_FIELD_WIDTH)); (void) sprintf(enstrophy_name,"%s.enstrophy%s.dat",basename, right_flush(step,TSTEP_FIELD_WIDTH)); (void) sprintf(dens_name,"%s.density%s.dat",basename, right_flush(step,TSTEP_FIELD_WIDTH)); (void) sprintf(pres_name,"%s.pressure%s.dat",basename, right_flush(step,TSTEP_FIELD_WIDTH)); energy_file = fopen(energy_name,"w"); vorticity_file = fopen(vorticity_name,"w"); enstrophy_file = fopen(enstrophy_name,"w"); dens_file = fopen(dens_name,"w"); pres_file = fopen(pres_name,"w"); if (wave->sizest == 0) { debug_print("fft","Left fft_energy_spectral()\n"); return FUNCTION_FAILED; } switch (dim) { #if defined(ONED) case 1: { int ix; int xmax; COMPLEX *mesh_energy; xmax = wave->rect_grid->gmax[0]; uni_array(&mesh_energy,xmax,sizeof(COMPLEX)); for (ix = 0; ix < xmax; ++ix) { icoords[0] = ix; coords = Rect_coords(icoords,wave); comp = Rect_comp(icoords,wave); state = Rect_state(icoords,wave); mesh_energy[ix].real = Energy(state); mesh_energy[ix].imag = 0.0; } break; } #endif /* defined(ONED) */ #if defined(TWOD) case 2: { int ix, iy; int xmax, ymax, mx, my, dummy; COMPLEX **mesh_energy,**mesh_vorticity,**mesh_enstrophy; Locstate lstate,rstate,bstate,tstate; float kk,kx,ky,dk; xmax = wave->rect_grid->gmax[0]; ymax = wave->rect_grid->gmax[1]; if (!Powerof2(xmax,&mx,&dummy) || !Powerof2(ymax,&my,&dummy)) { screen("fft_energy_spectral() cannot analyze " "mesh not power of 2\n"); screen("xmax = %d ymax = %d\n",xmax,ymax); return FUNCTION_FAILED; } bi_array(&mesh_energy,xmax,ymax,sizeof(COMPLEX)); bi_array(&mesh_vorticity,xmax,ymax,sizeof(COMPLEX)); fprintf(energy_file,"zone i=%d, j=%d\n",xmax,ymax); fprintf(vorticity_file,"zone i=%d, j=%d\n",xmax,ymax); fprintf(dens_file,"zone i=%d, j=%d\n",xmax,ymax); fprintf(pres_file,"zone i=%d, j=%d\n",xmax,ymax); fprintf(enstrophy_file,"zone i=%d, j=%d\n",xmax,ymax); for (iy = 0; iy < ymax; ++iy) { for (ix = 0; ix < xmax; ++ix) { icoords[0] = ix; icoords[1] = iy; coords = Rect_coords(icoords,wave); comp = Rect_comp(icoords,wave); state = Rect_state(icoords,wave); mesh_energy[ix][iy].real = kinetic_energy(state); mesh_energy[ix][iy].imag = 0.0; if (ix != 0) icoords[0] = ix - 1; else icoords[0] = ix; lstate = Rect_state(icoords,wave); if (ix != xmax-1) icoords[0] = ix + 1; else icoords[0] = ix; rstate = Rect_state(icoords,wave); icoords[0] = ix; if (iy != 0) icoords[1] = iy - 1; else icoords[1] = iy; bstate = Rect_state(icoords,wave); if (iy != ymax-1) icoords[1] = iy + 1; else icoords[1] = iy; tstate = Rect_state(icoords,wave); mesh_vorticity[ix][iy].real = (Mom(rstate)[1]/Dens(rstate) - Mom(lstate)[1]/Dens(lstate))/h[0] - (Mom(tstate)[0]/Dens(tstate) - Mom(bstate)[0]/Dens(bstate))/h[1]; mesh_vorticity[ix][iy].imag = 0.0; fprintf(energy_file,"%lf\n",kinetic_energy(state)); fprintf(vorticity_file,"%lf\n",mesh_vorticity[ix][iy].real); fprintf(enstrophy_file,"%lf\n", sqr(mesh_vorticity[ix][iy].real)); fprintf(dens_file,"%lf\n",Dens(state)); fprintf(pres_file,"%lf\n",pressure(state)); } } fft_output2d(basename,"energy",step,wave->rect_grid, mesh_energy); fft_output2d(basename,"vorticity",step,wave->rect_grid, mesh_vorticity); free_these(2,mesh_energy,mesh_vorticity); break; } #endif /* defined(TWOD) */ #if defined(THREED) case 3: { int ix, iy, iz; int xmax, ymax, zmax; COMPLEX ***mesh_energy; xmax = wave->rect_grid->gmax[0]; ymax = wave->rect_grid->gmax[1]; zmax = wave->rect_grid->gmax[2]; tri_array(&mesh_energy,xmax,ymax,zmax,sizeof(COMPLEX)); for (iz = 0; iz < zmax; ++iz) { icoords[2] = iz; for (iy = 0; iy < ymax; ++iy) { icoords[1] = iy; for (ix = 0; ix < xmax; ++ix) { icoords[0] = ix; coords = Rect_coords(icoords,wave); comp = Rect_comp(icoords,wave); state = Rect_state(icoords,wave); mesh_energy[ix][iy][iz].real = Energy(state); mesh_energy[ix][iy][iz].imag = 0.0; } } } break; } #endif /* defined(THREED) */ } fclose(energy_file); fclose(vorticity_file); fclose(enstrophy_file); fclose(dens_file); fclose(pres_file); debug_print("fft","Left fft_energy_spectral()\n"); return FUNCTION_SUCCEEDED; } /*end fft_energy_spectral*/
LOCAL void fabric_rigid_collision( Front *front, C_CURVE *cc) { int i,j,k,num_trs,num_tfs,num_pfs; TRI **tr_list,**tf_list,*tri_on; POINT *p,**pf_list; double scaled_gap_tol = 0.05; double **newpts; SIDE status; SURFACE *sr = NULL; SURFACE *sf = NULL; double nearest_pt[MAXD],nor[MAXD]; double hdir,*h = front->rect_grid->h; COMPONENT int_comp,ext_comp; POINT **pr_list; int num_prs,max_num_prs; int id; char dirname[200]; if (debugging("collision")) (void) printf("Entering fabric_rigid_collision()\n"); for (i = 0; i < 2; ++i) { if (wave_type(cc->s[i]) == NEUMANN_BOUNDARY || wave_type(cc->s[i]) == MOVABLE_BODY_BOUNDARY) sr = cc->s[i]; if (wave_type(cc->s[i]) == ELASTIC_BOUNDARY) sf = cc->s[i]; } if (sr == NULL) { (void) printf("In fabric_rigid_collision(): "); (void) printf("cannot find rigid body surface!\n"); clean_up(ERROR); } ext_comp = exterior_component(front->interf); int_comp = (positive_component(sr) == ext_comp) ? negative_component(sr) : positive_component(sr); set_tr_tf_pf_list(front,cc,&tr_list,&num_trs,&tf_list,&num_tfs, &pf_list,&num_pfs); FT_MatrixMemoryAlloc((POINTER*)&newpts,num_pfs,MAXD,sizeof(double)); for (i = 0; i < num_pfs; ++i) { status = nearest_point_to_tri_cluster(Coords(pf_list[i]),int_comp, sr,tr_list,num_trs,&tri_on,&id,nearest_pt,nor); hdir = grid_size_in_direction(nor,h,3); for (k = 0; k < 3; ++k) newpts[i][k] = nearest_pt[k] + scaled_gap_tol*hdir*nor[k]; } for (i = 0; i < num_pfs; ++i) { for (k = 0; k < 3; ++k) Coords(pf_list[i])[k] = newpts[i][k]; } if (debugging("collision")) { sprintf(dirname,"cross-tris/after-lifting-%d",front->step); gview_plot_crossing_tris(dirname,tr_list,num_trs,tf_list,num_tfs); } for (i = 0; i < num_pfs; ++i) { COMPONENT comp; p = pf_list[i]; comp = component_wrt_tri_cluster(Coords(p),sr,tr_list, num_trs); } num_prs = max_num_prs = 0; pr_list = NULL; for (i = 0; i < num_trs; ++i) { double v[MAXD]; for (k = 0; k < 3; ++k) { p = Point_of_tri(tr_list[i])[k]; status = nearest_point_to_tri_cluster(Coords(p),int_comp, sf,tf_list,num_tfs,&tri_on,&id,nearest_pt,nor); for (j = 0; j < 3; ++j) { v[j] = Coords(p)[j] - nearest_pt[j]; } if (Dot3d(v,nor) > 0.0) check_add_pt(&pr_list,p,&num_prs,&max_num_prs); } } add_to_debug("tri_cluster"); for (i = 0; i < num_prs; ++i) { p = pr_list[i]; status = nearest_point_to_tri_cluster(Coords(p),int_comp, sf,tf_list,num_tfs,&tri_on,&id,nearest_pt,nor); if (status == ONEDGE) printf("ie = %d\n",id); else printf("\n"); } remove_from_debug("tri_cluster"); if (debugging("collision")) { sprintf(dirname,"cross-tris/before-leaving-%d",front->step); gview_plot_crossing_tris(dirname,tr_list,num_trs,tf_list,num_tfs); } free_these(4,tr_list,tf_list,pf_list,newpts); } /* end fabric_rigid_collision */
/*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*/