def test(mfault): from clawpack.clawutil.data import ClawData probdata = ClawData() probdata.read('setprob.data', force=True) fault = dtopotools.Fault(coordinate_specification='top_center') fault.read('fault.data') mapping = Mapping(fault) domain_depth = probdata.domain_depth domain_width = probdata.domain_width # num of cells here determined in a similar fashion to that in setrun.py dx = mapping.fault_width / mfault num_cells_above = numpy.rint(mapping.fault_depth / dx) dy = mapping.fault_depth / num_cells_above mx = int(numpy.ceil(domain_width / dx)) # mx my = int(numpy.ceil(domain_depth / dy)) # my mr = mx - mfault x = linspace( mapping.xcenter - 0.5 * mapping.fault_width - numpy.floor(mr / 2.0) * dx, mapping.xcenter + 0.5 * mapping.fault_width + numpy.ceil(mr / 2.0) * dx, mx + 1) y = linspace(-my * dy, 0.0, my + 1) xc, yc = meshgrid(x, y) xp, yp = mapping.mapc2p(xc, yc) figure() plot(xp, yp, 'k-') plot(xp.T, yp.T, 'k-') plot((mapping.xp1, mapping.xp2), (mapping.yp1, mapping.yp2), '-g') axis('scaled')
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ fault = dtopotools.Fault() fault.read(plotdata.outdir + '/fault.data') mapping = Mapping(fault) fault_width = mapping.fault_width xcenter = mapping.xcenter ycenter = mapping.ycenter xp1 = mapping.xp1 xp2 = mapping.xp2 yp1 = mapping.yp1 yp2 = mapping.yp2 probdata = ClawData() probdata.read('setprob.data',force=True) xlimits = [xcenter-0.5*probdata.domain_width,xcenter+0.5*probdata.domain_width] ylimits = [-probdata.domain_depth,0.0] from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' gaugedata = ClawData() gaugedata.read('gauges.data',force=True) ngauges = gaugedata.ngauges xc = np.zeros(ngauges) for j in range(ngauges): g = plotdata.getgauge(j) xc[j] = g.location[0] fault.create_dtopography(xc/LAT2METER,np.array([0.]),[1.0],y_disp=True) def plot_vertical_displacement(current_data): from pylab import plot,zeros,gca t = current_data.t ys = zeros(ngauges) for gaugeno in range(ngauges): g = plotdata.getgauge(gaugeno) for k in range(1,len(g.t)): if g.t[k] > t: break dt = g.t[k] - g.t[k-1] v = 0.5*(g.q[4,k]+g.q[4,k-1]) ys[gaugeno] += dt*v ax = gca() kwargs ={'linestyle':'-','color':'blue','label':'numerical'} plot(xc[:ngauges],ys,**kwargs) kwargs = {'linestyle':'--','color':'r','label':'Okada'} fault.plot_okada(ax,displacement='vertical',kwargs=kwargs) def plot_interfaces(current_data): from pylab import plot,zeros,gca,tick_params t = current_data.t ys = zeros(ngauges) for gaugeno in range(ngauges): g = plotdata.getgauge(gaugeno) for k in range(1,len(g.t)): if g.t[k] > t: break dt = g.t[k] - g.t[k-1] v = 0.5*(g.q[4,k]+g.q[4,k-1]) ys[gaugeno] += dt*v ax = gca() plot(xc[:ngauges],ys,linewidth=3) kwargs = {'linestyle':'--','color':'r','linewidth':3} fault.plot_okada(ax,displacement='vertical',kwargs=kwargs) tick_params(labelsize=20) def plot_fault(current_data): from pylab import linspace, plot xl = linspace(xp1,xp2,100) yl = linspace(yp1,yp2,100) plot(xl,yl,'k') def sigmatr(current_data): # return -trace(sigma) q = current_data.q return -(q[0,:,:] + q[1,:,:]) # Figure for surfaces and p-waves plotfigure = plotdata.new_plotfigure(name='surface_and_p_waves', figno=1) plotfigure.kwargs = {'figsize':(8,8)} # Set axes for vertical displacement: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = xlimits plotaxes.ylimits = [-0.3, 0.5] plotaxes.title = 'vertical displacement' plotaxes.scaled = False plotaxes.afteraxes = plot_vertical_displacement # Set axes for p waves: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = '-trace(sigma)' plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = sigmatr plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -1e6 plotitem.pcolor_cmax = 1e6 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapping.mapc2p # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Level 4 grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#effeee', '#eeffee', '#eeeffe', '#eeeeff', '#ffffff'] plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0,0,0,0,0,1] plotitem.MappedGrid = True plotitem.mapc2p = mapping.mapc2p # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? plotdata.parallel = True return plotdata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ fault = dtopotools.Fault() fault.read(plotdata.outdir + '/fault.data') mapping = Mapping(fault) fault_width = mapping.fault_width xcenter = mapping.xcenter ycenter = mapping.ycenter xp1 = mapping.xp1 xp2 = mapping.xp2 yp1 = mapping.yp1 yp2 = mapping.yp2 probdata = ClawData() probdata.read('setprob.data',force=True) xlimits = [xcenter-0.5*probdata.domain_width,xcenter+0.5*probdata.domain_width] ylimits = [-probdata.domain_depth,0.0] from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' def plot_fault(current_data): from pylab import linspace, plot xl = linspace(xp1,xp2,100) yl = linspace(yp1,yp2,100) plot(xl,yl,'k') def sigmatr(current_data): # return -trace(sigma) q = current_data.q return -(q[0,:,:] + q[1,:,:]) def slip_direction_vel(current_data): # return vel dot tau, where tau is tangent to fault tau_x = (xp2 - xp1)/fault_width tau_y = (yp2 - yp1)/fault_width tau_x = np.where(current_data.y > ycenter, -tau_x, tau_x) tau_y = np.where(current_data.y > ycenter, -tau_y, tau_y) u = current_data.q[3,:,:] v = current_data.q[4,:,:] return u*tau_x + v*tau_y # Figure for waves plotfigure = plotdata.new_plotfigure(name='waves', figno=1) plotfigure.kwargs = {'figsize':(10,8)} # Set up axes for trace(sigma): plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = '-trace(sigma)' plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = sigmatr plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -1e6 plotitem.pcolor_cmax = 1e6 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapping.mapc2p # Set up axes for slip_direction_velocity: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'slip-direction-velocity' plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = slip_direction_vel plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -0.1 plotitem.pcolor_cmax = 0.1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapping.mapc2p # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Level 6 grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#effeee', '#eeffee', '#eeeffe', '#eeeeff', '#ffffff'] plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0,0,0,0,0,1] plotitem.MappedGrid = True plotitem.mapc2p = mapping.mapc2p # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? # plotdata.parallel = True return plotdata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ slice_number = 3 os.chdir(plotdata.outdir) for filename in os.listdir('.'): if (filename.startswith('slice_%d' % slice_number)): shutil.copyfile( filename, filename.replace('slice_%d' % slice_number, 'fort', 1)) os.chdir('..') fault = dtopotools.Fault() fault.read('fault.data') mapping = Mapping(fault) xp1 = mapping.xp1 xp2 = mapping.xp2 zp1 = mapping.zp1 zp2 = mapping.zp2 xcenter = mapping.xcenter ycenter = mapping.ycenter probdata = ClawData() probdata.read('setprob.data', force=True) probdata.read(plotdata.outdir + '/setprob.data', force=True) xlimits = [ xcenter - 0.5 * probdata.domain_width, xcenter + 0.5 * probdata.domain_width ] ylimits = [ ycenter - 0.5 * probdata.domain_length, ycenter + 0.5 * probdata.domain_length ] zlimits = [-probdata.domain_depth, 0.0] def plot_fault_xz(current_data): from pylab import linspace, plot xl = linspace(xp1, xp2, 100) zl = linspace(zp1, zp2, 100) plot(xl, zl, 'k') if (slice_number is 1): x1limits = xlimits x2limits = ylimits mapc2p = mapping.mapc2p_xy plot_fault = None elif (slice_number is 2): x1limits = ylimits x2limits = zlimits mapping.set_slice_xval(0.0) mapc2p = mapping.mapc2p_yz plot_fault = None elif (slice_number is 3): x1limits = xlimits x2limits = zlimits mapc2p = mapping.mapc2p_xz plot_fault = plot_fault_xz from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data # plotdata.format = 'binary' def sigmatr(current_data): # return -trace(sigma) q = current_data.q return -(q[0, :, :] + q[1, :, :] + q[2, :, :]) # Figure for trace(sigma) plotfigure = plotdata.new_plotfigure(name='trace', figno=1) plotfigure.kwargs = {'figsize': (10, 8)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = x1limits plotaxes.ylimits = x2limits plotaxes.title = '-trace(sigma)' plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = sigmatr plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -1e6 plotitem.pcolor_cmax = 1e6 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapc2p # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = x1limits plotaxes.ylimits = x2limits plotaxes.title = 'x-velocity' plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 6 plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -1e-1 plotitem.pcolor_cmax = 1e-1 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapc2p # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = x1limits plotaxes.ylimits = x2limits plotaxes.title = 'Level 4 grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee', '#ffffff'] plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0, 0, 0, 1] plotitem.MappedGrid = True plotitem.mapc2p = mapc2p # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? # plotdata.parallel = True return plotdata
import clawpack.seismic.dtopotools_horiz_okada_and_1d as dtopotools from numpy import arange, cos, sin, pi reload(dtopotools) from clawpack.geoclaw.data import LAT2METER fault = dtopotools.Fault(coordinate_specification='top center') fault.subfaults = [] width = 50000.0 theta = 0.20 fault_top_center = [0.0, -20000.0] slip = 1.0 mu = 3e10 rupture_time = 0.0 rise_time = 1.0 nsubfaults = 1 longitude0 = fault_top_center[0] / LAT2METER dlongitude = width * cos(theta) / LAT2METER / nsubfaults ddepth = width * sin(theta) / nsubfaults subfault_width = width / nsubfaults for i in range(nsubfaults): subfault = dtopotools.SubFault() subfault.mu = mu subfault.dip = theta / pi * 180.0 subfault.width = subfault_width subfault.depth = -fault_top_center[1] + ddepth * i subfault.slip = slip subfault.rake = 90
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ slice_number = 1 # set to surface slice number os.chdir(plotdata.outdir) for filename in os.listdir('.'): if (filename.startswith('slice_%d' % slice_number)): shutil.copyfile( filename, filename.replace('slice_%d' % slice_number, 'fort', 1)) os.chdir('..') fault = dtopotools.Fault() fault.read('fault.data') mapping = Mapping(fault) xp1 = mapping.xp1 xp2 = mapping.xp2 zp1 = mapping.zp1 zp2 = mapping.zp2 xcenter = mapping.xcenter ycenter = mapping.ycenter probdata = ClawData() probdata.read('setprob.data', force=True) probdata.read(plotdata.outdir + '/setprob.data', force=True) xlimits = [ xcenter - 0.5 * probdata.domain_width, xcenter + 0.5 * probdata.domain_width ] ylimits = [ ycenter - 0.5 * probdata.domain_length, ycenter + 0.5 * probdata.domain_length ] from clawpack.visclaw import colormaps xc = np.linspace(-150e3, 200e3, 350) yc = np.linspace(-87.5e3, 87.5e3, 175) fault.create_dtopography(xc / LAT2METER, yc / LAT2METER.e3, [1.0]) okada_max = np.max(fault.dtopo.dZ[0, :, :]) clevels = np.linspace(-okada_max, okada_max, 10) plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' def plot_okada_contour(current_data): from pylab import gca kwargs = {'levels': clevels, 'colors': 'g'} ax = gca() fault.plot_okada_contour(axes=ax, kwargs=kwargs) def plot_okada(current_data): from pylab import gca kwargs = { 'cmap': colormaps.blue_white_red, 'vmin': clevels[0], 'vmax': clevels[-1] } ax = gca() fault.plot_okada(axes=ax, dim=2, kwargs=kwargs) kwargs = {'levels': clevels, 'colors': 'g', 'linewidths': 3} fault.plot_okada_contour(axes=ax, kwargs=kwargs) # Figure for vertical displacement plotfigure = plotdata.new_plotfigure(name='trace', figno=1) plotfigure.kwargs = {'figsize': (10, 8)} # Set axes for numerical solution: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(211)' plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Numerical solution' plotaxes.scaled = True plotaxes.afteraxes = plot_okada_contour # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = 9 plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = clevels[0] plotitem.pcolor_cmax = clevels[-1] plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = 9 plotitem.contour_colors = 'k' plotitem.contour_levels = clevels plotitem.kwargs = {'linewidths': 3} plotitem.amr_contour_show = [0, 0, 0, 1] plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] # Set axes for Okada solution: plotaxes = plotfigure.new_plotaxes() plotaxes.axescmd = 'subplot(212)' plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title_with_t = False plotaxes.title = 'Okada solution' plotaxes.scaled = True plotaxes.afteraxes = plot_okada # Figure for grid cells plotfigure = plotdata.new_plotfigure(name='cells', figno=2) # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = 'Level 4 grid patches' plotaxes.scaled = True # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_patch') plotitem.amr_patch_bgcolor = ['#ffeeee', '#eeeeff', '#eeffee', '#ffffff'] plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0, 0, 0, 1] # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? # plotdata.parallel = True return plotdata
def setrun(claw_pkg='amrclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "amrclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'" num_dim = 3 rundata = data.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ # Sample setup to write one line to setprob.data ... probdata = rundata.new_UserData(name='probdata',fname='setprob.data') probdata.add_param('domain_depth', 300e3, 'depth of domain') probdata.add_param('domain_width', 600e3, 'width of domain (in x direction)') probdata.add_param('domain_length', 300e3, 'length of domain (in y direction)') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated #------------------------------------------------------------------ # Read in fault information #------------------------------------------------------------------ fault = dtopotools.Fault() fault.read('fault.data') mapping = Mapping(fault) fault_length = mapping.fault_length fault_width = mapping.fault_width fault_depth = mapping.fault_depth fault_xcenter = mapping.xcenter fault_ycenter = mapping.ycenter rupture_rise_time = 0.0 for subfault in fault.subfaults: rupture_rise_time = max(rupture_rise_time,subfault.rupture_time + subfault.rise_time) # --------------- # Spatial domain # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Number of grid cells num_cells_fault_width = 10 num_cells_fault_length = 5 dx = fault_width/num_cells_fault_width dy = fault_length/num_cells_fault_length # determine cell number and set computational boundaries target_num_cells = np.rint(probdata.domain_width/dx) # x direction num_cells_below = np.rint((target_num_cells - num_cells_fault_width)/2.0) num_cells_above = target_num_cells - num_cells_below - num_cells_fault_width if (int(num_cells_below + num_cells_fault_width + num_cells_above) % 2 == 1): num_cells_above += 1 clawdata.lower[0] = fault_xcenter-0.5*fault_width-num_cells_below*dx clawdata.upper[0] = fault_xcenter+0.5*fault_width+num_cells_above*dx clawdata.num_cells[0] = int(num_cells_below + num_cells_fault_width + num_cells_above) target_num_cells = np.rint(probdata.domain_length/dy) # y direction num_cells_below = np.rint((target_num_cells - num_cells_fault_length)/2.0) num_cells_above = target_num_cells - num_cells_below - num_cells_fault_length if (int(num_cells_below + num_cells_fault_length + num_cells_above) % 2 == 1): num_cells_above += 1 clawdata.lower[1] = fault_ycenter-0.5*fault_length-num_cells_below*dy clawdata.upper[1] = fault_ycenter+0.5*fault_length+num_cells_above*dy clawdata.num_cells[1] = int(num_cells_below + num_cells_fault_length + num_cells_above) num_cells_above = np.rint(fault_depth/min(dx,dy)) # z direction dz = fault_depth/num_cells_above target_num_cells = np.rint(probdata.domain_depth/dz) num_cells_below = target_num_cells - num_cells_above if (int(num_cells_below + num_cells_above) % 2 == 1): num_cells_below += 1 clawdata.lower[2] = -fault_depth - num_cells_below*dz clawdata.upper[2] = 0.0 clawdata.num_cells[2] = int(num_cells_below + num_cells_above) # adjust probdata probdata.domain_width = clawdata.upper[0] - clawdata.lower[0] probdata.domain_length = clawdata.upper[1] - clawdata.lower[1] probdata.domain_depth = clawdata.upper[2] - clawdata.lower[2] # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 10 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 2 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- # should be set to final time in reload file if reloading clawdata.t0 = 0.000000 # Restart from checkpoint file of a previous run? # Note: If restarting, you must also change the Makefile to set: # RESTART = True # If restarting, t0 above should be from original run, and the # restart_file 'fort.chkNNNNN' specified below should be in # the OUTDIR indicated in Makefile. clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00006' # File to use for restart data # ------------- # Output times: #-------------- # Specify at what times the results should be written to fort.q files. # Note that the time integration stops after the final output time. clawdata.output_style = 2 if clawdata.output_style==1: # Output ntimes frames at equally spaced times up to tfinal: # Can specify num_output_times = 0 for no output clawdata.num_output_times = 50 clawdata.tfinal = 50.0 #6e-5 #0.0001800000 #0.00003 clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list or numpy array of output times: # Include t0 if you want output at the initial time. clawdata.output_times = [0.0, 4.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 1 clawdata.total_steps = 1 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format = 'ascii' # 'ascii' or 'binary' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'none' # could be list clawdata.output_aux_onlyonce = True # output aux arrays only at t0 # --------------------------------------------------- # Verbosity of messages to screen during integration: # --------------------------------------------------- # The current t, dt, and cfl will be printed every time step # at AMR levels <= verbosity. Set verbosity = 0 for no printing. clawdata.verbosity = 1 # -------------- # Time stepping: # -------------- # if dt_variable==True: variable time steps used based on cfl_desired, # if dt_variable==False: fixed time steps dt = dt_initial always used. clawdata.dt_variable = True # Initial time step for variable dt. # (If dt_variable==0 then dt=dt_initial for all steps) clawdata.dt_initial = 0.25 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.000000e+99 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.900000 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 1.000000 # Maximum number of time steps to allow between output times: clawdata.steps_max = 1000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? clawdata.dimensional_split = False # For unsplit method, transverse_waves can be # 0 or 'none' ==> donor cell (only normal solver used) # 1 or 'increment' ==> corner transport of waves # 2 or 'all' ==> corner transport of 2nd order corrections too clawdata.transverse_waves = 22 # Number of waves in the Riemann solution: clawdata.num_waves = 6 # List of limiters to use for each wave family: # Required: len(limiter) == num_waves # Some options: # 0 or 'none' ==> no limiter (Lax-Wendroff) # 1 or 'minmod' ==> minmod # 2 or 'superbee' ==> superbee # 3 or 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['mc', 'mc', 'mc', 'mc', 'mc','mc'] clawdata.use_fwaves = False # True ==> use f-wave version of algorithms # Source terms splitting: # src_split == 0 or 'none' ==> no source term (src routine never called) # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. clawdata.source_split = 'godunov' # -------------------- # Boundary conditions: # -------------------- # Number of ghost cells (usually 2) clawdata.num_ghost = 2 # Choice of BCs at xlower and xupper: # 0 or 'user' => user specified (must modify bcNamr.f to use this option) # 1 or 'extrap' => extrapolation (non-reflecting outflow) # 2 or 'periodic' => periodic (must specify this at both boundaries) # 3 or 'wall' => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper clawdata.bc_lower[2] = 'extrap' # at zlower clawdata.bc_upper[2] = 'user' # at zupper # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 2 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif clawdata.checkpt_style == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [1.0] elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # gauges for surface displacement #xgauges = np.linspace(-150e3,200e3,350) #ygauges = np.linspace(-87.5e3,87.5e3,350) #gcount = 0 #for x in xgauges: # for y in ygauges: # gauges.append([gcount, x, y, clawdata.upper[2]-1, 0.0, 1e9]) # gcount = gcount + 1 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = 4 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [2,2,2] amrdata.refinement_ratios_y = [2,2,2] amrdata.refinement_ratios_z = [2,2,2] amrdata.refinement_ratios_t = [2,2,2] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length num_aux, each element of which is one # of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['zleft','capacity'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.000000e+00 # Richardson to # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 1.0e-4 # tolerance used in this routine # Flags regions to be refined where tol is roughly the smallest amplitude of normal velocity to capture # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 4 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 4 # clustering alg. cutoff for (# flagged pts) / (total # of cells # refined) # (closer to 1.0 => more small grids may be needed to cover flagged # cells) amrdata.clustering_cutoff = 0.700000 # print info about each regridding up to this level: amrdata.verbosity_regrid = 4 # ------------------- # Refinement Regions: # ------------------- regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2,z1,z2] zbuffer = dz xcb = [fault_xcenter-0.5*fault_width,fault_xcenter+0.5*fault_width] ycb = [fault_ycenter-0.5*fault_length,fault_ycenter+0.5*fault_length] # high-resolution region to surround the fault during slip regions.append([amrdata.amr_levels_max,amrdata.amr_levels_max, 0,1, xcb[0],xcb[1], ycb[0],ycb[1], -fault_depth-dz, -fault_depth+dz]) # decreasing-resolution for cells further away from fault for j in range(amrdata.amr_levels_max-1): regions.append([1,amrdata.amr_levels_max-j, 0,1e9, -1e9,1e9, -1e9,1e9, -2.0*fault_depth-j*zbuffer,0.0]) regions.append([1,1, 0,1e9, -1.e9,1e9, -1e9,1e9,-1e9, 0.]) # ----- For developers ----- # Toggle debugging print statements: amrdata.dprint = False # print domain flags amrdata.eprint = False # print err est flags amrdata.edebug = False # even more err est flags amrdata.gprint = False # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = False # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = False # time step reporting each level amrdata.uprint = False # update/upbnd reporting # -------------- # Output Slices: # -------------- slicedata = SliceData() # use slicedata.add() to add output slices defined # by a point (x,y,z) and a normal direction (vx,vy,vz) # e.g. slicedata.add([x,y,z],[nx,ny,nz]) point = [fault_xcenter,fault_ycenter,-0.0001] # surface slice: slicedata.add(point,[0.0,0.0,1.0]) # cross section slices: slicedata.add(point,[1.0,0.0,0.0]) slicedata.add(point,[0.0,1.0,0.0]) slicedata.write() return rundata
def setplot(plotdata): #-------------------------- """ Specify what is to be plotted at each frame. Input: plotdata, an instance of clawpack.visclaw.data.ClawPlotData. Output: a modified version of plotdata. """ fault = dtopotools.Fault() fault.read(plotdata.outdir + '/fault.data') mapping = Mapping(fault) fault_width = mapping.fault_width * length_scale ycenter = mapping.ycenter xp1 = mapping.xp1 * length_scale xp2 = mapping.xp2 * length_scale yp1 = mapping.yp1 * length_scale yp2 = mapping.yp2 * length_scale from clawpack.visclaw import colormaps plotdata.clearfigures() # clear any old figures,axes,items data plotdata.format = 'binary' def mapc2p(xc, yc): xp, yp = mapping.mapc2p(xc, yc) return xp * length_scale, yp * length_scale def plot_fault(current_data): from pylab import linspace, plot, xlabel, ylabel, tick_params, annotate xl = linspace(xp1, xp2, 100) yl = linspace(yp1, yp2, 100) plot(xl, yl, 'k', linewidth=3) if (current_data.t == 0.0): arrowprops = {'arrowstyle': '->', 'linewidth': 3, 'color': 'g'} annotate('', (xp1, yp1 + 10), (xp2, yp2 + 10), arrowprops=arrowprops) annotate('', (xp2, yp2 - 10), (xp1, yp1 - 10), arrowprops=arrowprops) tick_params(labelsize=25) xlabel('kilometers', fontsize=25) ylabel('kilometers', fontsize=25) def sigmatr(current_data): # return -trace(sigma) q = current_data.q return -(q[0, :, :] + q[1, :, :]) def slip_direction_vel(current_data): # return vel dot tau, where tau is tangent to fault tau_x = (xp2 - xp1) / fault_width tau_y = (yp2 - yp1) / fault_width tau_x = np.where(current_data.y > ycenter, -tau_x, tau_x) tau_y = np.where(current_data.y > ycenter, -tau_y, tau_y) u = current_data.q[3, :, :] v = current_data.q[4, :, :] return u * tau_x + v * tau_y # Figure for results plotfigure = plotdata.new_plotfigure(name='results', figno=1) plotfigure.kwargs = {'figsize': (11, 8)} # Set up for axes in this figure: plotaxes = plotfigure.new_plotaxes() plotaxes.xlimits = xlimits plotaxes.ylimits = ylimits plotaxes.title = '' plotaxes.title_with_t = False plotaxes.scaled = True plotaxes.afteraxes = plot_fault # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_pcolor') plotitem.plot_var = sigmatr plotitem.pcolor_cmap = colormaps.blue_white_red plotitem.pcolor_cmin = -1e6 plotitem.pcolor_cmax = 1e6 plotitem.add_colorbar = False plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapc2p # Set up for item on these axes: plotitem = plotaxes.new_plotitem(plot_type='2d_contour') plotitem.plot_var = slip_direction_vel plotitem.contour_levels = np.linspace(0.06, 0.2, 3) plotitem.amr_contour_show = [0, 0, 1, 0] plotitem.kwargs = {'linewidths': 3} plotitem.amr_celledges_show = [0] plotitem.amr_patchedges_show = [0] plotitem.MappedGrid = True plotitem.mapc2p = mapc2p # Parameters used only when creating html and/or latex hardcopy # e.g., via clawpack.visclaw.frametools.printframes: plotdata.printfigs = True # print figures plotdata.print_format = 'png' # file format plotdata.print_framenos = 'all' # list of frames to print plotdata.print_fignos = 'all' # list of figures to print plotdata.html = True # create html files of plots? plotdata.html_homelink = '../README.html' # pointer for top of index plotdata.latex = True # create latex file of plots? plotdata.latex_figsperline = 2 # layout of plots plotdata.latex_framesperline = 1 # layout of plots plotdata.latex_makepdf = False # also run pdflatex? # plotdata.parallel = True return plotdata
def setrun(claw_pkg='amrclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "amrclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ probdata = rundata.new_UserData(name='probdata', fname='setprob.data') probdata.add_param('domain_depth', 300e3, 'depth of domain') probdata.add_param('domain_width', 600e3, 'width of domain') #------------------------------------------------------------------ # Read in fault information #------------------------------------------------------------------ fault = dtopotools.Fault() fault.read('fault.data') mapping = Mapping(fault) fault_width = mapping.fault_width fault_depth = mapping.fault_depth fault_center = mapping.xcenter rupture_rise_time = 0.0 for subfault in fault.subfaults: rupture_rise_time = max(rupture_rise_time, subfault.rupture_time + subfault.rise_time) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Number of grid cells: num_cells_fault = 10 dx = fault_width / num_cells_fault # determine cell number and set computational boundaries target_num_cells = np.rint(probdata.domain_width / dx) # x direction num_cells_below = np.rint((target_num_cells - num_cells_fault) / 2.0) num_cells_above = target_num_cells - num_cells_below - num_cells_fault clawdata.lower[0] = fault_center - 0.5 * fault_width - num_cells_below * dx clawdata.upper[0] = fault_center + 0.5 * fault_width + num_cells_above * dx clawdata.num_cells[0] = int(num_cells_below + num_cells_fault + num_cells_above) num_cells_above = np.rint(fault_depth / dx) # y direction dy = fault_depth / num_cells_above target_num_cells = np.rint(probdata.domain_depth / dy) num_cells_below = target_num_cells - num_cells_above clawdata.lower[1] = -fault_depth - num_cells_below * dy clawdata.upper[1] = 0.0 clawdata.num_cells[1] = int(num_cells_below + num_cells_above) # adjust probdata probdata.domain_width = clawdata.upper[0] - clawdata.lower[0] probdata.domain_depth = clawdata.upper[1] - clawdata.lower[1] # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 5 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 13 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 12 # ------------- # Initial time: # ------------- clawdata.t0 = 0.000000 # Restart from checkpoint file of a previous run? # Note: If restarting, you must also change the Makefile to set: # RESTART = True # If restarting, t0 above should be from original run, and the # restart_file 'fort.qNNNN' specified below should be in # the OUTDIR indicated in Makefile. clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.q0006' # File to use for restart data # ------------- # Output times: #-------------- # Specify at what times the results should be written to fort.q files. # Note that the time integration stops after the final output time. clawdata.output_style = 1 if clawdata.output_style == 1: # Output ntimes frames at equally spaced times up to tfinal: # Can specify num_output_times = 0 for no output clawdata.num_output_times = 50 clawdata.tfinal = 100.0 clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list or numpy array of output times: # Include t0 if you want output at the initial time. clawdata.output_times = list(np.linspace(0,5,11)) + \ range(6,61) elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 1 clawdata.total_steps = 40 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format = 'binary' # 'ascii', 'binary', 'netcdf' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'none' # could be list clawdata.output_aux_onlyonce = True # output aux arrays only at t0 # --------------------------------------------------- # Verbosity of messages to screen during integration: # --------------------------------------------------- # The current t, dt, and cfl will be printed every time step # at AMR levels <= verbosity. Set verbosity = 0 for no printing. # (E.g. verbosity == 2 means print only on levels 1 and 2.) clawdata.verbosity = 0 # -------------- # Time stepping: # -------------- # if dt_variable==True: variable time steps used based on cfl_desired, # if dt_variable==False: fixed time steps dt = dt_initial always used. clawdata.dt_variable = True # Initial time step for variable dt. # (If dt_variable==0 then dt=dt_initial for all steps) clawdata.dt_initial = 0.25 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.000000e+99 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.900000 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 1.000000 # Maximum number of time steps to allow between output times: clawdata.steps_max = 1000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? (not yet available for AMR) clawdata.dimensional_split = 'unsplit' # For unsplit method, transverse_waves can be # 0 or 'none' ==> donor cell (only normal solver used) # 1 or 'increment' ==> corner transport of waves # 2 or 'all' ==> corner transport of 2nd order corrections too clawdata.transverse_waves = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 4 # List of limiters to use for each wave family: # Required: len(limiter) == num_waves # Some options: # 0 or 'none' ==> no limiter (Lax-Wendroff) # 1 or 'minmod' ==> minmod # 2 or 'superbee' ==> superbee # 3 or 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['mc', 'mc', 'mc', 'mc'] clawdata.use_fwaves = False # True ==> use f-wave version of algorithms # Source terms splitting: # src_split == 0 or 'none' ==> no source term (src routine never called) # src_split == 1 or 'godunov' ==> Godunov (1st order) splitting used, # src_split == 2 or 'strang' ==> Strang (2nd order) splitting used, not recommended. clawdata.source_split = 0 # -------------------- # Boundary conditions: # -------------------- # Number of ghost cells (usually 2) clawdata.num_ghost = 2 # Choice of BCs at xlower and xupper: # 0 or 'user' => user specified (must modify bcNamr.f to use this option) # 1 or 'extrap' => extrapolation (non-reflecting outflow) # 2 or 'periodic' => periodic (must specify this at both boundaries) # 3 or 'wall' => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'user' # at yupper # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] # top edge: xgauges = np.linspace(clawdata.lower[0] + 1, clawdata.upper[0] - 1, np.rint(probdata.domain_width / 1e3)) for gaugeno, x in enumerate(xgauges): gauges.append([gaugeno, x, clawdata.upper[1] - 1, 0, 1e10]) ## bottom edge: #for gaugeno,x in enumerate(xgauges): # gauges.append([200+gaugeno,x,clawdata.lower[1]+1000,0,1e10]) ## above fault plane: #xgauges = np.linspace(probdata.fault_center-0.5*probdata.fault_width, # probdata.fault_center+0.5*probdata.fault_width) #for gaugeno,x in enumerate(xgauges): # gauges.append([300+gaugeno,x,-probdata.fault_depth+1,0,1e10]) # below fault plane: #for gaugeno,x in enumerate(xgauges): # gauges.append([400+gaugeno,x,-probdata.fault_depth-1,0,1e10]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 2 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif clawdata.checkpt_style == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [rupture_rise_time] elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = 6 # List of refinement ratios at each level (length at least # amr_level_max-1) amrdata.refinement_ratios_x = [2, 2, 2, 2, 2] amrdata.refinement_ratios_y = [2, 2, 2, 2, 2] amrdata.refinement_ratios_t = [2, 2, 2, 2, 2] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length num_aux, each element of which is one # of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center', 'center', 'center', 'center', 'center', \ 'center', 'center', 'center', 'center', 'center', 'center', \ 'capacity','yleft'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1. # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 1.0e-4 # tolerance used in this routine # User can modify flag2refine to change the criterion for flagging. # Default: check maximum absolute difference of first component of q # between a cell and each of its neighbors. # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 2 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 2 # clustering alg. cutoff for (# flagged pts) / (total # of cells # refined) # (closer to 1.0 => more small grids may be needed to cover flagged # cells) amrdata.clustering_cutoff = 0.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] ybuffer = dy # high-resolution region to surround the fault during slip regions.append([ amrdata.amr_levels_max, amrdata.amr_levels_max, 0, rupture_rise_time, fault_center - 0.5 * fault_width, fault_center + 0.5 * fault_width, -fault_depth - dx, -fault_depth + dx ]) for j in range(amrdata.amr_levels_max - 1): regions.append([ 1, amrdata.amr_levels_max - j, 0, 1e9, -1e9, 1e9, -2.0 * fault_depth - j * ybuffer, 0.0 ]) regions.append([1, 1, 0, 1e9, -1.e9, 1.e9, -1.e9, 0.0]) # ----- For developers ----- # Toggle debugging print statements: amrdata.dprint = False # print domain flags amrdata.eprint = False # print err est flags amrdata.edebug = False # even more err est flags amrdata.gprint = False # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = False # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = False # time step reporting each level amrdata.uprint = False # update/upbnd reporting return rundata