def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data as clawdata assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'classic'" num_dim = 2 rundata = clawdata.ClawRunData(claw_pkg, num_dim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ # probdata = rundata.new_UserData(name='probdata',fname='setprob.data') #------------------------------------------------------------------ # 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 # Lower and upper edge of computational domain: clawdata.lower[0] = -85 # west longitude clawdata.upper[0] = -65 # east longitude clawdata.lower[1] = 25 # south longitude clawdata.upper[1] = 40 # north longitude # Number of grid cells: degree_factor = 4 clawdata.num_cells[0] = int(clawdata.upper[0] - clawdata.lower[0]) * degree_factor clawdata.num_cells[1] = int(clawdata.upper[1] - clawdata.lower[1]) * degree_factor # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 9 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = days2seconds(-2) #start 2 days before landfall # 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. # The solution at initial time t0 is always written in addition. clawdata.output_style = 1 if clawdata.output_style==1: # Output nout frames at equally spaced times up to tfinal: # day s/hour hours/day clawdata.tfinal = days2seconds(1.5) # Output occurrence per day, 24 = every hour, 4 = every 6 hours recurrence = 24 clawdata.num_output_times = int((clawdata.tfinal - clawdata.t0) * recurrence / (60**2 * 24)) clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = [0.5, 1.0] elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 1 clawdata.total_steps = 1 clawdata.output_t0 = True clawdata.output_format = 'binary' # 'ascii' or 'binary' or 'netcdf' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'all' # could be list clawdata.output_aux_onlyonce = False # 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==1: variable time steps used based on cfl_desired, # if dt_variable==0: fixed time steps dt = dt_initial will always be 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.016 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.75 clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 2**16 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 1 # 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 = 1 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # 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 'mc' ==> MC limiter # 4 or 'vanleer' ==> van Leer clawdata.limiter = ['mc', 'mc', 'mc'] clawdata.use_fwaves = True # 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 => user specified (must modify bcN.f to use this option) # 1 => extrapolation (non-reflecting outflow) # 2 => periodic (must specify this at both boundaries) # 3 => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' clawdata.bc_upper[0] = 'extrap' clawdata.bc_lower[1] = 'extrap' clawdata.bc_upper[1] = 'extrap' # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 0 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 = [0.1,0.15] 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 mxnest-1) amrdata.refinement_ratios_x = [2,2,2,6,8,10,8] amrdata.refinement_ratios_y = [2,2,2,6,8,10,8] amrdata.refinement_ratios_t = [2,2,2,6,8,10,8] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center','capacity','yleft','center','center','center', 'center', 'center', 'center'] # Flag using refinement routine flag2refine rather than richardson error amrdata.flag_richardson = False # use Richardson? amrdata.flag2refine = True # 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 = 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.700000 # print info about each regridding up to this level: amrdata.verbosity_regrid = 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 # More AMR parameters can be set -- see the defaults in pyclaw/data.py # == setregions.data values == regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # Wilmington gauge regions.append([5,6,days2seconds(-2), days2seconds(1.5),-78.1,-77.8,33.9,34.4]) # Pamlico gauge regions.append([5,6,days2seconds(-2), days2seconds(1.5),-77.15,-76.6,35.2,35.6]) # Trent gauge regions.append([5,6,days2seconds(-0.5), days2seconds(1),-77.2,-76.6,34.7,35.2]) # append as many flagregions as desired to this list: flagregions = rundata.flagregiondata.flagregions flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_Coast_NC' flagregion.minlevel = 3 flagregion.maxlevel = 5 flagregion.t1 = days2seconds(-2) flagregion.t2 = days2seconds(1.5) flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = os.path.abspath('RuledRectangle_Coast_NC.data') flagregions.append(flagregion) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_Coast_SC' flagregion.minlevel = 3 flagregion.maxlevel = 5 flagregion.t1 = days2seconds(-1) flagregion.t2 = days2seconds(1.5) flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = os.path.abspath('RuledRectangle_Coast_SC.data') flagregions.append(flagregion) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Islands_NC' flagregion.minlevel = 5 flagregion.maxlevel = 7 flagregion.t1 = days2seconds(-1) flagregion.t2 = days2seconds(1) flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = os.path.abspath('RuledRectangle_NCIslands.data') flagregions.append(flagregion) # make Ruled Rectangle flagregions topo_path = os.path.join(scratch_dir, 'atlantic_1min.tt3') topo = topotools.Topography() topo.read(topo_path) # make RuledRectangle_Coast_NC.data: filter_region = (-79, -75, 33.3, 37) topo = topo.crop(filter_region) # specify a Ruled Rectangle the flagregion should lie in rrect = region_tools.RuledRectangle() rrect.ixy = 'x' rrect.s = np.array([-78.,-77,-76.5,-75.3]) rrect.lower = -131*np.ones(rrect.s.shape) rrect.upper = np.array([34.3,35,35.5,35.7]) rrect.method = 1 # Start with a mask defined by the ruled rectangle `rrect` defined above: mask_out = rrect.mask_outside(topo.X, topo.Y) # select onshore points within 2 grip points of shore: pts_chosen_Zabove0 = marching_front.select_by_flooding(topo.Z, mask=mask_out, prev_pts_chosen=None, Z1=0, Z2=1e6, max_iters=2) # select offshore points down to 700 m depth: pts_chosen_Zbelow0 = marching_front.select_by_flooding(topo.Z, mask=None, prev_pts_chosen=None, Z1=0, Z2=-700., max_iters=None) # buffer offshore points with another 10 grid cells: pts_chosen_Zbelow0 = marching_front.select_by_flooding(topo.Z, mask=None, prev_pts_chosen=pts_chosen_Zbelow0, Z1=0, Z2=-5000., max_iters=10) # Take the intersection of the two sets of points selected above: nearshore_pts = np.where(pts_chosen_Zabove0+pts_chosen_Zbelow0 == 2, 1, 0) print('Number of nearshore points: %i' % nearshore_pts.sum()) rr = region_tools.ruledrectangle_covering_selected_points(topo.X, topo.Y, nearshore_pts, ixy='y', method=0, verbose=True) # make .data file to use as a flagregion rr_name = 'RuledRectangle_Coast_NC' rr.write(rr_name + '.data') # make RuledRectangle_Coast_SC.data: filter_region = (-82, -77.5, 32, 34.5) topo = topo.crop(filter_region) #Specify a RuledRectangle the flagregion should lie in: rrect = region_tools.RuledRectangle() rrect.ixy = 'x' rrect.s = np.array([-79.5,-79,-78.9,-77.8]) rrect.lower = -131*np.ones(rrect.s.shape) rrect.upper = np.array([33.2,33.8,34,34]) rrect.method = 1 # Start with a mask defined by the ruled rectangle `rrect` defined above: mask_out = rrect.mask_outside(topo.X, topo.Y) # select onshore points within 3 grip points of shore: pts_chosen_Zabove0 = marching_front.select_by_flooding(topo.Z, mask=mask_out, prev_pts_chosen=None, Z1=0, Z2=1e6, max_iters=3) # select offshore points within 40 grip points of shore: pts_chosen_Zbelow0 = marching_front.select_by_flooding(topo.Z, mask=None, prev_pts_chosen=None, Z1=0, Z2=-500., max_iters=40) # buffer offshore points with another 10 grid cells: pts_chosen_Zbelow0 = marching_front.select_by_flooding(topo.Z, mask=None, prev_pts_chosen=pts_chosen_Zbelow0, Z1=0, Z2=-5000., max_iters=10) # Take the intersection of the two sets of points selected above: nearshore_pts = np.where(pts_chosen_Zabove0+pts_chosen_Zbelow0 == 2, 1, 0) print('Number of nearshore points: %i' % nearshore_pts.sum()) rr = region_tools.ruledrectangle_covering_selected_points(topo.X, topo.Y, nearshore_pts, ixy='y', method=0, verbose=True) # make .data file to use as a flagregion rr_name = 'RuledRectangle_Coast_SC' rr.write(rr_name + '.data') # make RuledRectangle_NCIslands.data: rr = region_tools.RuledRectangle() rr.ixy = 1 # so s refers to x, lower & upper are limits in y rr.s = np.array([-76.27,-75.7,-75.56,-75.55,-75.42]) rr.lower = np.array([34.9,35.1,35.17,35.18,35.25]) rr.upper = np.array([35.02,35.3,35.6,35.77,35.75]) rr.method = 1 # make .data file to use as a flagregion rr_name = 'RuledRectangle_NCIslands' rr.write(rr_name + '.data') # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] # Springmaid Pier gauge rundata.gaugedata.gauges.append([1,-78.85,33.68,clawdata.t0,clawdata.tfinal]) # Wilmington gauge rundata.gaugedata.gauges.append([2,-77.95,34.27,clawdata.t0,clawdata.tfinal]) # Wrightsville Beach gauge rundata.gaugedata.gauges.append([3,-77.80,34.18,clawdata.t0,clawdata.tfinal]) # Beaufort gauge rundata.gaugedata.gauges.append([4,-76.65,34.7,clawdata.t0,clawdata.tfinal]) # Hatteras gauge rundata.gaugedata.gauges.append([5,-75.70,35.25,clawdata.t0,clawdata.tfinal]) # Oregon Inlet Marina gauge rundata.gaugedata.gauges.append([6,-75.57,35.78,clawdata.t0,clawdata.tfinal]) # Pamlico River gauge rundata.gaugedata.gauges.append([7,-77.04,35.525,clawdata.t0,clawdata.tfinal]) # Trent River gauge rundata.gaugedata.gauges.append([8,-76.96,35.03,clawdata.t0,clawdata.tfinal]) # Force the gauges to also record the wind and pressure fields #rundata.gaugedata.aux_out_fields = [4, 5, 6] #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) return rundata
def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" 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('variable_eta_init', True) # now in qinit info #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: # x values should be integer multipes of 1/3" # y values should be integer multipes of 1/3" # Note: always satisfied if limits are multiples of 0.01 degree arcsec16 = 1./(6*3600.) # choose domain and offset edges by half a 1/3" cell so # cell centers are exactly at DEM grid points: clawdata.lower[0] = -1.9 - arcsec16 # west longitude clawdata.upper[0] = 0.1 - arcsec16 # east longitude clawdata.lower[1] = -1.9 - arcsec16 # south latitude clawdata.upper[1] = 1.9 - arcsec16 # north latitude # choose mx and my so coarsest grid has 2 minute resolution: clawdata.num_cells[0] = 60 clawdata.num_cells[1] = 114 # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # 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 = '' # ------------- # 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. # The solution at initial time t0 is always written in addition. clawdata.output_style = 1 if clawdata.output_style==1: # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 15 clawdata.tfinal = 30*60. clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = [0.5, 1.0] elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 1 clawdata.total_steps = 20 clawdata.output_t0 = True clawdata.output_format = 'binary' clawdata.output_q_components = 'all' # need all clawdata.output_aux_components = 'none' # eta=h+B is in q clawdata.output_aux_onlyonce = False # output aux arrays each frame # --------------------------------------------------- # 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 = 1 # -------------- # Time stepping: # -------------- # if dt_variable==1: variable time steps used based on cfl_desired, # if dt_variable==0: fixed time steps dt = dt_initial will always be 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.2 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.8 clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # 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 = 3 # 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 'mc' ==> MC limiter # 4 or 'vanleer' ==> van Leer clawdata.limiter = ['mc', 'mc', 'mc'] clawdata.use_fwaves = True # 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 => user specified (must modify bcN.f to use this option) # 1 => extrapolation (non-reflecting outflow) # 2 => periodic (must specify this at both boundaries) # 3 => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' clawdata.bc_upper[0] = 'extrap' clawdata.bc_lower[1] = 'extrap' clawdata.bc_upper[1] = 'extrap' # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. # negative checkpoint_style means alternate between aaaaa and bbbbb files # so that at most 2 checkpoint files exist at any time, useful when # doing frequent checkpoints of large problems. clawdata.checkpt_style = 0 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif clawdata.checkpt_style == 1: # Checkpoint only at tfinal. pass elif abs(clawdata.checkpt_style) == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = 3600.*np.arange(1,16,1) elif abs(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 = 4 # List of refinement ratios at each level (length at least mxnest-1) # dx = dy = 2', 10", 2", 1/3": amrdata.refinement_ratios_x = [12,5,6] amrdata.refinement_ratios_y = [12,5,6] amrdata.refinement_ratios_t = [12,5,6] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['center','capacity','yleft'] # Flag using refinement routine flag2refine rather than richardson error amrdata.flag_richardson = False # use Richardson? amrdata.flag2refine = True # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # 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.700000 # print info about each regridding up to this level: amrdata.verbosity_regrid = 1 # --------------- # Regions: # --------------- #rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # --------------- # NEW flagregions # --------------- flagregions = rundata.flagregiondata.flagregions # initialized to [] # now append as many flagregions as desired to this list: # The entire domain restricted to level 1 for illustration: # Note that this is a rectangle specified in the new way: # (other regions below will force/allow more refinement) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_domain' flagregion.minlevel = 1 flagregion.maxlevel = 1 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 1 # Rectangle # domain plus a bit so kml files look nicer: flagregion.spatial_region = [clawdata.lower[0] - 0.1, clawdata.upper[0] + 0.1, clawdata.lower[1] - 0.1, clawdata.upper[1] + 0.1] flagregions.append(flagregion) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_level3' flagregion.minlevel = 1 flagregion.maxlevel = 3 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 1 # Rectangle # domain plus a bit so kml files look nicer: flagregion.spatial_region = [-0.1,0.1,-0.1,0.1] flagregions.append(flagregion) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_level4' flagregion.minlevel = 4 flagregion.maxlevel = 4 flagregion.t1 = 5*60. flagregion.t2 = 1e9 flagregion.spatial_region_type = 1 # Rectangle # domain plus a bit so kml files look nicer: flagregion.spatial_region = [-0.005, 0.01, -0.011, 0.011] flagregions.append(flagregion) # --------------- # Gauges: # --------------- # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges = [] # Set GeoClaw specific runtime parameters. try: geo_data = rundata.geo_data except: print("*** Error, this rundata has no geo_data attribute") raise AttributeError("Missing geo_data attribute") # == Physics == geo_data.gravity = 9.81 geo_data.coordinate_system = 2 geo_data.earth_radius = 6367.5e3 # == Forcing Options geo_data.coriolis_forcing = False # == Algorithm and Initial Conditions == geo_data.sea_level = 0.0 geo_data.dry_tolerance = 1.e-3 geo_data.friction_forcing = True geo_data.manning_coefficient =.025 geo_data.friction_depth = 1e6 # Refinement settings refinement_data = rundata.refinement_data refinement_data.variable_dt_refinement_ratios = True refinement_data.wave_tolerance = 0.2 refinement_data.deep_depth = 1e2 refinement_data.max_level_deep = 30 # == settopo.data values == topofiles = rundata.topo_data.topofiles # for topography, append lines of the form # [topotype, minlevel, maxlevel, t1, t2, fname] topodir = 'input_files' topofiles.append([3, 1, 1, 0., 1e10, topodir + '/topo_ocean.tt3']) topofiles.append([3, 1, 1, 0., 1e10, topodir + '/topo_shore.tt3']) # == setdtopo.data values == dtopo_data = rundata.dtopo_data # for moving topography, append lines of the form : (<= 1 allowed for now!) # [topotype, minlevel,maxlevel,fname] dtopodir = 'input_files' dtopo_data.dtopofiles.append([3, 2, 2, \ dtopodir + '/dtopo_test.tt3']) dtopo_data.dt_max_dtopo = 1.0 # == setqinit.data values == rundata.qinit_data.qinit_type = 0 rundata.qinit_data.qinitfiles = [] # for qinit perturbations, append lines of the form: (<= 1 allowed for now!) # [minlev, maxlev, fname] # NEW feature to adjust sea level by dtopo: rundata.qinit_data.variable_eta_init = True # NEW feature to force dry land some locations below sea level: force_dry = ForceDry() force_dry.tend = 7*60. force_dry.fname = 'input_files/force_dry_init.tt3' rundata.qinit_data.force_dry_list.append(force_dry) # == fgmax.data values == #fgmax_files = rundata.fgmax_data.fgmax_files # for fixed grids append to this list names of any fgmax input files # ----- 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 # More AMR parameters can be set -- see the defaults in pyclaw/data.py return rundata
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('u', 0.5, 'ubar advection velocity') probdata.add_param('v', 1.0, 'vbar advection velocity') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = 0. # xlower clawdata.upper[0] = 1. # xupper clawdata.lower[1] = 0. # ylower clawdata.upper[1] = 1. # yupper # Number of grid cells: clawdata.num_cells[0] = 50 # mx clawdata.num_cells[1] = 50 # my # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 1 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 0 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 0 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # 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 = 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 = 10 clawdata.tfinal = 1.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 = [0., 0.1] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 2 clawdata.total_steps = 4 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format = 'ascii' # '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.016 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.9 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 100000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? 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 = 'all' # Number of waves in the Riemann solution: clawdata.num_waves = 1 # 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 = ['vanleer'] 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 = 'none' # -------------------- # 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] = 'periodic' # at xlower clawdata.bc_upper[0] = 'periodic' # at xupper clawdata.bc_lower[1] = 'periodic' # at ylower clawdata.bc_upper[1] = 'periodic' # at yupper # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([1, 0.6, 0.4, 0., 10.]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 0 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 = [0.1, 0.15] 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 = 3 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [2, 2] amrdata.refinement_ratios_y = [2, 2] amrdata.refinement_ratios_t = [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 = [] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 0.1 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.05 # tolerance used in this routine # User can modify flag2refine to change the criterion for flagging. # Default: check max-norm of difference between q in 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 = 3 # 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.9 # print info about each regridding up to this level: amrdata.verbosity_regrid = 3 # --------------- # Regions: (old style rectangles) # --------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # --------------- # NEW flagregions # --------------- flagregions = rundata.flagregiondata.flagregions # initialized to [] # now append as many flagregions as desired to this list: from clawpack.amrclaw.data import FlagRegion # The entire domain restricted to level 1 for illustration: # Note that this is a rectangle specified in the new way: # (other regions below will force/allow more refinement) flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_domain' flagregion.minlevel = 1 flagregion.maxlevel = 1 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 1 # Rectangle flagregion.spatial_region = [0., 1., 0., 1.] # = [x1,x2,y1,y2] flagregions.append(flagregion) # A more general ruled rectangle: flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_triangle' flagregion.minlevel = 1 flagregion.maxlevel = 3 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = \ os.path.abspath('RuledRectangle_Triangle.data') flagregions.append(flagregion) # code to make RuledRectangle_Triangle.data: rr = region_tools.RuledRectangle() rr.method = 1 # piecewiselinear edges between s values rr.ixy = 'x' # so s refers to x, lower & upper are limits in y rr.s = np.array([0.1, 0.8]) rr.lower = np.array([0.2, 0.8]) rr.upper = np.array([0.8, 0.8]) rr.write('RuledRectangle_Triangle.data') # A trapezoid: flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_trapezoid' flagregion.minlevel = 3 flagregion.maxlevel = 3 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = \ os.path.abspath('RuledRectangle_Trapezoid.data') flagregions.append(flagregion) # code to make RuledRectangle_Trapezoid.data: rr = region_tools.RuledRectangle() rr.method = 1 # piecewiselinear edges between s values rr.ixy = 'x' # so s refers to x, lower & upper are limits in y rr.s = np.array([0.2, 0.9]) rr.lower = np.array([0.05, 0.75]) rr.upper = np.array([0.15, 0.85]) rr.write('RuledRectangle_Trapezoid.data') # ----- 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
def setrun(claw_pkg='geoclaw'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" 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') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = -120.0 # west longitude clawdata.upper[0] = -60.0 # east longitude clawdata.lower[1] = -60.0 # south latitude clawdata.upper[1] = 0.0 # north latitude # Number of grid cells: Coarsest grid clawdata.num_cells[0] = 30 clawdata.num_cells[1] = 30 # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) # Note: as required for original problem - modified below for adjoint clawdata.num_aux = 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = 0.0 # Restart from checkpoint file of a previous run? # 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.chk00096' # 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. # The solution at initial time t0 is always written in addition. clawdata.output_style = 1 if clawdata.output_style == 1: # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 28 clawdata.tfinal = 7 * 3600. clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = [0.5, 1.0] elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 1 clawdata.total_steps = 3 clawdata.output_t0 = True clawdata.output_format = 'ascii' # 'ascii', 'binary', 'netcdf' clawdata.output_q_components = 'all' # need all clawdata.output_aux_components = 'all' # need this to plot inner product clawdata.output_aux_onlyonce = False # output aux arrays each frame # --------------------------------------------------- # 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 = 1 # -------------- # Time stepping: # -------------- # if dt_variable==1: variable time steps used based on cfl_desired, # if dt_variable==0: fixed time steps dt = dt_initial will always be 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.2 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.75 clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # 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 = 3 # 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 'mc' ==> MC limiter # 4 or 'vanleer' ==> van Leer clawdata.limiter = ['mc', 'mc', 'mc'] clawdata.use_fwaves = True # 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 => user specified (must modify bcN.f to use this option) # 1 => extrapolation (non-reflecting outflow) # 2 => periodic (must specify this at both boundaries) # 3 => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' clawdata.bc_upper[0] = 'extrap' clawdata.bc_lower[1] = 'extrap' clawdata.bc_upper[1] = 'extrap' # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 0 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 = [0.1, 0.15] 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 = 3 # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = [2, 4] amrdata.refinement_ratios_y = [2, 4] amrdata.refinement_ratios_t = [2, 4] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). # Note: as required for original problem - modified below for adjoint amrdata.aux_type = ['center', 'capacity', 'yleft'] # set tolerances appropriate for adjoint flagging: # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # Doesn't work for GeoClaw amrdata.flag_richardson_tol = 0.5 # Flag for refinement using routine flag2refine: amrdata.flag2refine = True rundata.amrdata.flag2refine_tol = 0.0001 # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # 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.700000 # print info about each regridding up to this level: amrdata.verbosity_regrid = 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 # More AMR parameters can be set -- see the defaults in pyclaw/data.py # --------------- # Regions: # --------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # Regions can still be specified this way for backward compatibility, # but the new flagregions approach below is preferable so this is # no longer used here. # allow 3 levels anywhere, based on flagging: #rundata.regiondata.regions.append([1, 3, 0., 1e9, -220,0,-90,90]) # earthquake source region - force refinement initially: #rundata.regiondata.regions.append([3, 3, 0., 200., -85,-70,-38,-25]) # --------------- # NEW flagregions # --------------- flagregions = rundata.flagregiondata.flagregions # initialized to [] # now append as many flagregions as desired to this list: from clawpack.amrclaw.data import FlagRegion # Allow 3 levels over entire domain: flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_domain' flagregion.minlevel = 1 flagregion.maxlevel = 3 flagregion.t1 = 0. flagregion.t2 = 1e9 flagregion.spatial_region_type = 1 # Rectangle flagregion.spatial_region = [ clawdata.lower[0], clawdata.upper[0], clawdata.lower[1], clawdata.upper[1] ] flagregions.append(flagregion) # Force 2 levels around source region initially: flagregion = FlagRegion(num_dim=2) flagregion.name = 'Region_source' flagregion.minlevel = 2 flagregion.maxlevel = 2 flagregion.t1 = 0. flagregion.t2 = 200. flagregion.spatial_region_type = 1 # Rectangle flagregion.spatial_region = [-85, -70, -38, -25] flagregions.append(flagregion) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([32412, -86.392, -17.975, 0., 1.e10]) #------------------------------------------------------------------ # Adjoint specific data: #------------------------------------------------------------------ # Also need to set flagging method and appropriate tolerances above adjointdata = rundata.adjointdata adjointdata.use_adjoint = True # location of adjoint solution, must first be created: adjointdata.adjoint_outdir = os.path.abspath('adjoint/_output') # time period of interest: adjointdata.t1 = rundata.clawdata.t0 adjointdata.t2 = rundata.clawdata.tfinal # or try a shorter time period of interest: #adjointdata.t1 = 3. * 3600. #adjointdata.t2 = 4.5 * 3600. if adjointdata.use_adjoint: # need an additional aux variable for inner product: rundata.amrdata.aux_type.append('center') rundata.clawdata.num_aux = len(rundata.amrdata.aux_type) adjointdata.innerprod_index = len(rundata.amrdata.aux_type) return rundata
def setrun(claw_pkg='geoclaw'): """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "geoclaw" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) # ------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) # ------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Set single grid parameters first. # See below for AMR parameters. # --------------- # Spatial domain: # --------------- # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = -99.0 # west longitude clawdata.upper[0] = -70.0 # east longitude clawdata.lower[1] = 8.0 # south latitude clawdata.upper[1] = 32.0 # north latitude # Number of grid cells: degree_factor = 4 # (0.25º,0.25º) ~ (25237.5 m, 27693.2 m) resolution clawdata.num_cells[0] = int(clawdata.upper[0] - clawdata.lower[0]) \ * degree_factor clawdata.num_cells[1] = int(clawdata.upper[1] - clawdata.lower[1]) \ * degree_factor # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 3 # Number of auxiliary variables in the aux array (initialized in setaux) # First three are from shallow GeoClaw, fourth is friction and last 3 are # storm fields clawdata.num_aux = 3 + 1 + 3 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 2 # ------------- # Initial time: # ------------- clawdata.t0 = -days2seconds(1) # Restart from checkpoint file of a previous run? # 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. # The solution at initial time t0 is always written in addition. clawdata.output_style = 1 if clawdata.output_style == 1: # Output nout frames at equally spaced times up to tfinal: clawdata.tfinal = days2seconds(0.25) recurrence = 4 clawdata.num_output_times = int( (clawdata.tfinal - clawdata.t0) * recurrence / (60**2 * 24)) clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = [0.5, 1.0] elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 1 clawdata.total_steps = 1 clawdata.output_t0 = True clawdata.output_format = 'ascii' # 'ascii' or 'binary' clawdata.output_q_components = 'all' # could be list such as [True,True] clawdata.output_aux_components = 'all' clawdata.output_aux_onlyonce = False # 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==1: variable time steps used based on cfl_desired, # if dt_variable==0: fixed time steps dt = dt_initial will always be 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.016 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1e+99 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.75 clawdata.cfl_max = 1.0 # Maximum number of time steps to allow between output times: clawdata.steps_max = 5000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 1 # 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 = 1 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # 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 'mc' ==> MC limiter # 4 or 'vanleer' ==> van Leer clawdata.limiter = ['mc', 'mc', 'mc'] clawdata.use_fwaves = True # 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 => user specified (must modify bcN.f to use this option) # 1 => extrapolation (non-reflecting outflow) # 2 => periodic (must specify this at both boundaries) # 3 => solid wall for systems where q(2) is normal velocity clawdata.bc_lower[0] = 'extrap' clawdata.bc_upper[0] = 'extrap' clawdata.bc_lower[1] = 'extrap' clawdata.bc_upper[1] = 'extrap' # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 0 if clawdata.checkpt_style == 0: # Do not checkpoint at all pass elif np.abs(clawdata.checkpt_style) == 1: # Checkpoint only at tfinal. pass elif np.abs(clawdata.checkpt_style) == 2: # Specify a list of checkpoint times. clawdata.checkpt_times = [0.1, 0.15] elif np.abs(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 mxnest-1) amrdata.refinement_ratios_x = [2, 2, 6, 8, 20, 15] amrdata.refinement_ratios_y = [2, 2, 6, 8, 20, 15] amrdata.refinement_ratios_t = [2, 2, 6, 8, 20, 15] # Specify type of each aux variable in amrdata.auxtype. # This must be a list of length maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = [ 'center', 'capacity', 'yleft', 'center', 'center', 'center', 'center' ] # Flag using refinement routine flag2refine rather than richardson error amrdata.flag_richardson = False # use Richardson? amrdata.flag2refine = True # steps to take on each level L between regriddings of level L+1: amrdata.regrid_interval = 3 # width of buffer zone around flagged points: # (typically the same as regrid_interval so waves don't escape): amrdata.regrid_buffer_width = 3 # 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 = 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 # More AMR parameters can be set -- see the defaults in pyclaw/data.py # == setregions.data values == regions = rundata.regiondata.regions ''' regions.append([6, 7, -10800, 21600, -81.8088888888, -81.8052222222, 26.127, 26.134]) regions.append([6, 7, -10800, 21600, -81.8777777777777, -81.866666666666, 26.644444444444, 26.65]) regions.append([6, 7, -10800, 21600, -81.811111111111, -81.80777777777, 24.500000, 24.57]) regions.append([6, 7, -10800, 21600, -81.11, -81.1027777777, 24.70694444444, 24.71388888888]) ''' # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] regions.append([5, 6, -21600, 21600, -81.835, -81.815, 26.12, 26.14]) #regions.append([5, 6, -21600, 21600, -81.9, -81.85, 26.62, 26.66]) regions.append([ 6, 7, -21600, 21600, -81.8777777777777, -81.866666666666, 26.644444444444, 26.65 ]) regions.append([5, 6, -21600, 21600, -81.815, -81.79, 24.54, 24.56]) regions.append([5, 6, -21600, 21600, -81.115, -81.095, 24.70, 24.72]) #Ruled Rectangle Implementation from clawpack.amrclaw.data import FlagRegion flagregion = FlagRegion(num_dim=2) flagregion.name = 'Fort Myers Coast' flagregion.minlevel = 6 flagregion.maxlevel = 7 flagregion.t1 = -21600 flagregion.t2 = 21600 flagregion.spatial_region_type = 2 # Ruled Rectangle flagregion.spatial_region_file = \ os.path.abspath('Ft_Myers_Coast.data') rundata.flagregiondata.flagregions.append(flagregion) #Specification of the Ruled Rectangle from clawpack.amrclaw import region_tools slu = vstack( ([26.4225, 26.5222, 26.5322, 26.6744], [-82.2194, -82.1958, -82.1033, -81.8778], [-81.9767, -81.9127, -81.9833, -81.8283])).T rr = region_tools.RuledRectangle(slu=slu) rr.method = 1 rr.ixy = 'y' rr.write('Ft_Myers_Coast.data') # creates data file ''' array([[ 26.4225, -82.2194 , -81.9767], [ 26.5222, -82.1958, -81.9127], [ 26.5322, -82.1033 , -81.9833], [ 26.6744, -81.8778 , -81.8283]]) rr_fortmyers = region_tools.RuledRectangle(slu=slu) rr_fortmyers.ixy = 'y' rr_fortmyers.method = 1 ''' #8725110; Naples, Gulf of Mexico, Fl; Start: 26,07,53 (26.0) + 81,48,32 (81.80888888); End: 26,07,53 (26.25) + 81,48,26 (81.807222222222) rundata.gaugedata.gauges.append([ 1, -81.82444444, 26.13166666666, rundata.clawdata.t0, rundata.clawdata.tfinal ]) #8725520; Fort Myers, Fl; 26,39,00 (26.65) + 81,52,00 (81.866666666666); 26,38,40 (26.6444444444) + 81,52,40 (81.8777777777777) ''' rundata.gaugedata.gauges.append([2, -81.87027777777, 26.6472222222222, rundata.clawdata.t0, rundata.clawdata.tfinal]) ''' rundata.gaugedata.gauges.append( [2, -82.15, 26.375, rundata.clawdata.t0, rundata.clawdata.tfinal]) #8724580; Key West, Fl; 24,33,00 (24.5500000) + 81,48,28 (81.80777777777); End: 24,33,15 (24.554166666666) + 81,48,40 (81.811111111111) rundata.gaugedata.gauges.append([ 3, -81.80805555555, 24.5511111111111, rundata.clawdata.t0, rundata.clawdata.tfinal ]) #8723970; Vaca Key, Florida Bay, Fl; Start 24,42,25 (24.70694444444) + 81,06,36 (81.11); End 24,42,50 (24.71388888888) + 81,06,10 (81.1027777777); rundata.gaugedata.gauges.append([ 4, -81.10638888888, 24.71083333333, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Force the gauges to also record the wind and pressure fields rundata.gaugedata.aux_out_fields = [4, 5, 6] # ------------------------------------------------------------------ # GeoClaw specific parameters: # ------------------------------------------------------------------ rundata = setgeo(rundata) return rundata