def setrun(claw_pkg='amrclaw'): #------------------------------ from clawpack.clawutil import data assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) # ------------------------------------------------- # Custom parameters # ------------------------------------------------- # All examples use u(1) = revs_per_second; u(2) = v_speed example = 0 # Tfinal Tfinal = 1.0 # 0 : non-smooth; # 1 : q = 1 (for compressible velocity fields) # 2 : smooth (for computing errors) init_choice = 0 # geometry of the cylinder R = 1.0 H = 6.283185307179586 xc0 = 0.75 yc0 = 0.25 r0 = 0.5 # Speed revs_per_s = 1.0 v_speed = 1.0 # --------------------- AMR parameters --------------------------- # -1 : Always refine # 0 : Usual refinement based on threshold # 1 : xc < 0.5 # 2 : yc < 0.5 refine_pattern = 2 refine_threshold = 0.05 # Refine everywhere dt_initial = 2e-2 use_fixed_dt = True outstyle = 3 nout = 5 nstep = 1 ratioxy = 2 ratiok = 1 maxlevel = 2 # Course grid size mx = 16 my = 16 exact_metric = 0 # 0 = no qad # 1 = original qad # 2 = original (fixed to include call to rpn2qad) # 3 = new qad (should be equivalent to 2) qad_mode = 0 fluctuation_sync = 1 maux = 11 use_fwaves = True #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ probdata = rundata.new_UserData(name='probdata', fname='setprob.data') probdata.add_param('example', example, 'example') probdata.add_param('init_choice', init_choice, 'init_choice') probdata.add_param('refine_pattern', refine_pattern, 'refine_pattern') probdata.add_param('R', R, 'R') probdata.add_param('H', H, 'H') probdata.add_param('xc0', xc0, 'xc0') probdata.add_param('yc0', yc0, 'yc0') probdata.add_param('r0', r0, 'r0') probdata.add_param('revs_per_s', revs_per_s, 'revs_per_s') probdata.add_param('v_speed', v_speed, 'v_speed') probdata.add_param('fluctuation_sync', fluctuation_sync, 'fluctuation_sync') probdata.add_param('exact_metric', exact_metric, 'exact_metric') probdata.add_param('mx', mx, 'mx') probdata.add_param('mi', 1, 'mi') probdata.add_param('mj', 1, 'mj') probdata.add_param('maxlevel', maxlevel, 'maxlevel') probdata.add_param('reffactor', ratioxy, 'reffactor') probdata.add_param('qad_mode', qad_mode, 'qad_mode') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amrclaw.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated clawdata.num_dim = num_dim clawdata.lower[0] = 0 # xlower clawdata.upper[0] = 1 # xupper clawdata.lower[1] = 0 # ylower clawdata.upper[1] = 1 # yupper clawdata.num_cells[0] = mx # mx clawdata.num_cells[1] = my # my clawdata.num_eqn = 1 clawdata.num_aux = maux clawdata.capa_index = 1 # ---------------------------------------------------------- # Time stepping # ---------------------------------------------------------- clawdata.output_style = outstyle clawdata.dt_variable = not use_fixed_dt clawdata.dt_initial = dt_initial if clawdata.output_style == 1: clawdata.num_output_times = nout clawdata.tfinal = Tfinal elif clawdata.output_style == 2: clawdata.output_times = [0., 0.5, 1.0] elif clawdata.output_style == 3: clawdata.total_steps = nout clawdata.output_step_interval = nstep clawdata.output_format = 'ascii' # 'ascii', 'binary', 'netcdf' # --------------------------- # Misc time stepping and I/O # --------------------------- clawdata.cfl_desired = 0.900000 clawdata.cfl_max = 1.000000 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.t0 = 0.000000 clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00006' # File to use for restart data clawdata.output_q_components = 'all' # only 'all' clawdata.output_aux_components = 'none' # 'all' or 'none' clawdata.output_aux_onlyonce = False # output aux arrays only at t0? clawdata.dt_max = 1.000000e+99 clawdata.steps_max = 100000 # 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 = 2 # ---------------------------------------------------- # Clawpack parameters # ----------------------------------------------------- clawdata.order = 2 clawdata.dimensional_split = 'unsplit' clawdata.transverse_waves = 2 clawdata.num_waves = 1 # 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 = ['minmod'] clawdata.use_fwaves = True # True ==> use f-wave version of algorithms clawdata.source_split = 0 # -------------------- # Boundary conditions: # -------------------- clawdata.num_ghost = 2 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 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata amrdata.amr_levels_max = maxlevel amrdata.refinement_ratios_x = [ratioxy] * maxlevel amrdata.refinement_ratios_y = [ratioxy] * maxlevel amrdata.refinement_ratios_t = [ratiok] * maxlevel # If ratio_t == 1 if ratiok == 1: refine_factor = 1 for i in range(1, maxlevel): refine_factor *= amrdata.refinement_ratios_x[i] clawdata.dt_initial = dt_initial / refine_factor clawdata.total_steps = nout * refine_factor clawdata.output_step_interval = nstep * refine_factor print("clawdata.dt_initial = {:.6f}".format(clawdata.dt_initial)) print("clawdata.total_steps = {:d}".format(clawdata.total_steps)) print("clawdata.output_step_interval = {:d}".format( clawdata.output_step_interval)) # Refinement threshold amrdata.flag2refine_tol = refine_threshold # tolerance used in this routine # ------------------------------------------------------ # Misc AMR parameters # ------------------------------------------------------ amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.000000e+00 # Richardson tolerance amrdata.flag2refine = True # use this? amrdata.regrid_interval = 100 amrdata.regrid_buffer_width = 0 amrdata.clustering_cutoff = 1 # 0.800000 amrdata.verbosity_regrid = 0 # ---------------------------------------------------------------- # For mapped grid problem # 1 capacity # 2-5 Velocities projected onto left/right/top/bottom edges # 6-9 Edge lengths (normalized by dx or dy) # # All values are "center" values, since each cell stores # data for all four faces. This means that duplicate information # is stored, but we have to do it this way for conservation fix. # ---------------------------------------------------------------- amrdata.aux_type = ['capacity'] + ['center'] * 10 # ----- 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='amrclaw'): #------------------------------ from clawpack.clawutil import data assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) # --------------------------- # Physical problem parameters # --------------------------- # 0 = rigid body rotation; # 1 = horizontal flow # 2 = sine patch # 3 = horizontal flow with variable speed # 4 = time dependent in both x and y # 5 = spatially dependent example = 4 refine_pattern = 0 # 0 = constant theta; 1 = constant_r rps = -1 # units of theta/second (example=0) cart_speed = 1.092505803290319 # Horizontal speed (example=1) freq = 1 # Frequency for sine path # Region occupied by annulus beta = 0.4 theta = [0.125, 0.375] # Example 1 (constant horizontal speed) vcart = [cart_speed, 0] # Example 2 amplitude = 0.05 if example in [0, 1, 2, 3]: ravg = (1 + beta) / 2 t0 = np.pi / 2 * (1 + (1 / 8)) initial_location = ravg * np.array([np.cos(t0), np.sin(t0)]) elif example in [4]: # Vertical motion r0 = beta + 0.25 * (1 - beta) initial_location = [0, r0] # --------------- # Grid parameters # --------------- grid_mx = 32 # Size of ForestClaw grids mi = 4 # Number of ForestClaw blocks mj = 2 mx = mi * grid_mx my = mj * grid_mx # ------------- # Time stepping # ------------- if example in [0, 1, 2, 3]: dt_initial = 2.5e-3 nout = 100 # 400 steps => T=2 nsteps = 10 elif example == 4: dt_initial = 1.25e-3 # Stable for level 1 nout = 200 nsteps = 20 # ------------------ # AMRClaw parameters # ------------------ regrid_interval = 10000 # Don't regrid maxlevel = 2 ratioxy = 2 ratiok = 1 limiter = 'minmod' # 'none', 'minmod', 'superbee', 'vanleer', 'mc' # 0 = no qad # 1 = original qad # 2 = modified (fixed to include call to rpn2qad) # 3 = new qad (should be equivalent to 2) qad_mode = 2 maux = 15 use_fwaves = True #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ probdata = rundata.new_UserData(name='probdata', fname='setprob.data') # example 0 : Rigid body rotation (possibly using a streamfunction) # Make vertical speed small so we leave grid probdata.add_param('example', example, 'example') probdata.add_param('revolutions per second', rps, 'rps') probdata.add_param('cart_speed', cart_speed, 'cart_speed') probdata.add_param('vcart[0]', vcart[0], 'vcart[0]') probdata.add_param('vcart[1]', vcart[1], 'vcart[1]') probdata.add_param('amplitude', amplitude, 'amplitude') probdata.add_param('freq', freq, 'freq') probdata.add_param('initial radius', 0.05, 'init_radius') probdata.add_param('initial_location[0]', initial_location[0], 'initial_location[0]') probdata.add_param('initial_location[1]', initial_location[1], 'initial_location[1]') probdata.add_param('beta', beta, 'beta') probdata.add_param('theta1', theta[0], 'theta(1)') probdata.add_param('theta2', theta[1], 'theta(2)') probdata.add_param('grid_mx', grid_mx, 'grid_mx') probdata.add_param('mi', mi, 'mi') probdata.add_param('mj', mj, 'mj') probdata.add_param('maxlevel', maxlevel, 'maxlevel') probdata.add_param('reffactor', ratioxy, 'reffactor') probdata.add_param('refine_pattern', refine_pattern, 'refine_pattern') probdata.add_param('qad_mode', qad_mode, 'qad_mode') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amrclaw.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated clawdata.num_dim = num_dim clawdata.lower[0] = 0 # xlower clawdata.upper[0] = 1 # xupper clawdata.lower[1] = 0 # ylower clawdata.upper[1] = 1 # yupper clawdata.num_cells[0] = mx # mx clawdata.num_cells[1] = my # my clawdata.num_eqn = 1 clawdata.num_aux = maux clawdata.capa_index = 1 # ---------------------------------------------------------- # Time stepping # ---------------------------------------------------------- clawdata.output_style = 3 clawdata.dt_variable = False clawdata.dt_initial = dt_initial if clawdata.output_style == 1: clawdata.num_output_times = 16 clawdata.tfinal = 4.0 elif clawdata.output_style == 2: clawdata.output_times = [0., 0.5, 1.0] elif clawdata.output_style == 3: clawdata.total_steps = nout clawdata.output_step_interval = nsteps clawdata.output_format = 'ascii' # 'ascii', 'binary', 'netcdf' # --------------------------- # Misc time stepping and I/O # --------------------------- clawdata.cfl_desired = 0.900000 clawdata.cfl_max = 1.000000 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.t0 = 0.000000 clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00006' # File to use for restart data clawdata.output_q_components = 'all' # only 'all' clawdata.output_aux_components = 'none' # 'all' or 'none' clawdata.output_aux_onlyonce = False # output aux arrays only at t0? clawdata.dt_max = 1.000000e+99 clawdata.steps_max = 1000 # 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 = maxlevel # ---------------------------------------------------- # Clawpack parameters # ----------------------------------------------------- clawdata.order = 2 clawdata.dimensional_split = 'unsplit' clawdata.transverse_waves = 2 clawdata.num_waves = 1 # 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 = [limiter] clawdata.use_fwaves = use_fwaves # True ==> use f-wave version of algorithms clawdata.source_split = 0 # -------------------- # Boundary conditions: # -------------------- clawdata.num_ghost = 2 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 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata amrdata.amr_levels_max = maxlevel amrdata.refinement_ratios_x = [ratioxy] * maxlevel amrdata.refinement_ratios_y = [ratioxy] * maxlevel amrdata.refinement_ratios_t = [ratiok] * maxlevel # If we are taking a global time step (stable for maxlevel grids), we # probably want to increase number of steps taken to hit same # time 'tfinal'. if ratiok == 1: refine_factor = 1 for i in range(1, maxlevel): refine_factor *= amrdata.refinement_ratios_x[i] # Decrease time step clawdata.dt_initial = dt_initial / refine_factor # Increase number of steps taken. clawdata.total_steps = nout * refine_factor clawdata.output_step_interval = nsteps * refine_factor # Refinement threshold amrdata.flag2refine_tol = -1 # tolerance used in this routine # ------------------------------------------------------ # Misc AMR parameters # ------------------------------------------------------ amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.000000e+00 # Richardson tolerance amrdata.flag2refine = True # use this? amrdata.regrid_interval = regrid_interval amrdata.regrid_buffer_width = 0 amrdata.clustering_cutoff = 0.800000 amrdata.verbosity_regrid = 0 # ---------------------------------------------------------------- # Conservative form (cell-centered velocities) # 1 capacity # 2-3 Cell-centered velocities projected # 4-5 normal at x face # 6-7 normal at y face # 8-9 edgelengths at x/y faces # ---------------------------------------------------------------- if qad_mode in [0, 1]: amrdata.aux_type = ['capacity'] + ['center']*2 + ['xleft']*4 + \ ['yleft']*4 + ['xleft']*2 + ['yleft']*2 else: # Each cell has data for all four faces amrdata.aux_type = ['capacity'] + ['center'] * 14 # ----- 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'): assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) 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 = 5.e-1 refinement_data.deep_depth = 1e2 refinement_data.max_level_deep = 3 # index of max AMR level maxlevel = len(config.geoclaw["refinement_ratios"])+1 # load all topo files from topo_dir topo_data = rundata.topo_data topo_dir = config.geoclaw['topo_dir'] topo_files = glob.glob(topo_dir+"*.tt3") for file in topo_files: topo_data.topofiles.append([3,1,maxlevel,0.,1.e10, file]) dtopo_data = rundata.dtopo_data dtopo_data.dtopofiles.append([3,maxlevel,maxlevel,config.geoclaw['dtopo_path']]) dtopo_data.dt_max_dtopo = 0.2 #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amr2ez.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated # Number of space dimensions: clawdata.num_dim = num_dim # Lower and upper edge of computational domain: clawdata.lower[0] = config.model_bounds['lon_min'] # west longitude clawdata.upper[0] = config.model_bounds['lon_max'] # east longitude clawdata.lower[1] = config.model_bounds['lat_min'] # south latitude clawdata.upper[1] = config.model_bounds['lat_max'] # north latitude # Number of grid cells: Coarsest grid clawdata.num_cells[0] = config.geoclaw['xcoarse_grid'] clawdata.num_cells[1] = config.geoclaw['ycoarse_grid'] # 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 clawdata.output_style = 1 # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 1 clawdata.tfinal = config.geoclaw['run_time'] clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format = 'ascii' # 'ascii' or 'netcdf' 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 clawdata.verbosity = config.geoclaw['verbosity'] # -------------- # 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 = 2 clawdata.checkpt_times = [0.0] # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = maxlevel #JW: I'm not sure if this is going to work...check this :) # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = config.geoclaw['refinement_ratios'] amrdata.refinement_ratios_y = config.geoclaw['refinement_ratios'] amrdata.refinement_ratios_t = config.geoclaw['refinement_ratios'] # 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 = False amrdata.flag2refine_tol = 0.5 # 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 = True # 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] for key,region in config.regions.items(): rundata.regiondata.regions.append([maxlevel,maxlevel]+region) # --------------- # FGMax: # --------------- # == fgmax.data values == fgmax_files = rundata.fgmax_data.fgmax_files # for fixed grids append to this list names of any fgmax input files fgmax_files.append(config.fgmax['fgmax_grid_path']) rundata.fgmax_data.num_fgmax_val = 1 #------------------------------------------------------------------ # 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: # make symlink for adjoint adjointdata.adjoint_outdir = config.geoclaw['adjoint_outdir'] # time period of interest: adjointdata.t1 = rundata.clawdata.t0 adjointdata.t2 = rundata.clawdata.tfinal 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) #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # AmrClaw specific parameters: #------------------------------------------------------------------ rundata = setamr(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] = -12443619. - 100. clawdata.upper[0] = -12443619. + 700. clawdata.lower[1] = 4977641. - 650 clawdata.upper[1] = 4977641. + 150 # Number of grid cells: Coarsest grid clawdata.num_cells[0] = 200 clawdata.num_cells[1] = 200 # --------------- # 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 = 2 # 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. # 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 = 240 clawdata.tfinal = 28800 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., 1800.] elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 80 clawdata.total_steps = 4000 clawdata.output_t0 = True clawdata.output_format = 'binary' # 'ascii' 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 = 3 # -------------- # 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 = 1 # Initial time step for variable dt. # If dt_variable==0 then dt=dt_initial for all steps: dx = (clawdata.upper[0] - clawdata.lower[0]) / clawdata.num_cells[0] dy = (clawdata.upper[1] - clawdata.lower[1]) / clawdata.num_cells[1] dx /= numpy.prod( rundata.amrdata.refinement_ratios_x[:rundata.amrdata.amr_levels_max]) dy /= numpy.prod( rundata.amrdata.refinement_ratios_y[:rundata.amrdata.amr_levels_max]) vrate = rundata.landspill_data.point_sources.point_sources[0][-1][0] clawdata.dt_initial = 0.3 * dx * dy / vrate # Max time step to be allowed if variable dt used: clawdata.dt_max = 2.5 # Desired Courant number if variable dt used, and max to allow without # retaking step with a smaller dt: clawdata.cfl_desired = 0.9 clawdata.cfl_max = 0.95 # 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? (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] = 1 clawdata.bc_upper[0] = 1 clawdata.bc_lower[1] = 1 clawdata.bc_upper[1] = 1 # 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 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] = -88.0 # west longitude clawdata.upper[0] = -45.0 # east longitude clawdata.lower[1] = 9.0 # south latitude clawdata.upper[1] = 31.0 # north latitude # Number of grid cells: degree_factor = 4 # (0.25 deg,0.25 deg) ~ (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(8) 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 = 'binary' # '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 = 500000 # ------------------ # 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 = 7 # up to 7 # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = [2, 2, 2, 2, 4, 2] # 200 m amrdata.refinement_ratios_y = [2, 2, 2, 2, 4, 2] amrdata.refinement_ratios_t = [2, 2, 2, 2, 4, 2] # amrdata.refinement_ratios_x = [2, 2, 2, 2, 4, 8] # 50 m # amrdata.refinement_ratios_y = [2, 2, 2, 2, 4, 8] # amrdata.refinement_ratios_t = [2, 2, 2, 2, 4, 8] # 1 / (4*2*2*2*2*4*8) degrees # Note: 1 degree = 10 km # 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 = 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 # == Gauges == * gauges = rundata.gaugedata.gauges # Gauges from PLSMSL Stations https://www.psmsl.org/products/gloss/glossmap.html # 203: Port of Spain Trinidad and Tobago, 1, -61.517, 10.650, gauges.append( [1, -61.517, 10.650, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Gauges from Sea Level Station Monitoring Facility # Prickley Bay, Grenada Station, 2, -61.764828, 12.005392 gauges.append([ 2, -61.764828, 12.005392, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Calliaqua Coast Guard Base, Saint Vincent & Grenadines, 3, -61.1955, 13.129912 gauges.append( [3, -61.1955, 13.129912, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Ganter's Bay, Saint Lucia, 4,-60.997351, 14.016428 gauges.append([ 4, -60.997351, 14.016428, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Fort-de-France, Martinique2, 5, gauges.append([ 5, -61.063333, 14.601667, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Roseau Dominica, 6, 61.3891833, 15.31385 gauges.append([ 6, -61.3891833, 15.31385, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Pointe a Pitre, Guadeloupe, 7, -61.531452, 16.224398 gauges.append([ 7, -61.531452, 16.224398, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Parham (Camp Blizard), Antigua, 8, -61.7833, 17.15 gauges.append( [8, -61.7833, 17.15, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Blowing Point, Anguilla, 9, -63.0926167, 18.1710861 gauges.append([ 9, -63.0926167, 18.1710861, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Saint Croix, VI, 10, -64.69833, 17.74666 gauges.append([ 10, -64.69833, 17.74666, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # San Juan, PR, 11, -66.1167, 18.4617 gauges.append( [11, -66.1167, 18.4617, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Barahona, Dominican Republic, 12, -71.092154, 18.208137 gauges.append([ 12, -71.092154, 18.208137, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # George Town, Cayman Islands, 13, -81.383484, 19.295065 gauges.append([ 13, -81.383484, 19.295065, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Settlement pt, Bahamas, 14, -78.98333, 26.6833324 gauges.append([ 14, -78.98333, 26.6833324, rundata.clawdata.t0, rundata.clawdata.tfinal ]) # Force the gauges to also record the wind and pressure fields aux_out_fields = [4, 5, 6] # == 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] # Add gauge support dx = 1 / 3600 for g in gauges: t1 = g[3] t2 = g[4] x = g[1] y = g[2] regions.append([ amrdata.amr_levels_max, amrdata.amr_levels_max, t1, t2, x - dx, x + dx, y - dx, y + dx ]) # == fgmax_grids.data values == from clawpack.geoclaw import fgmax_tools # set num_fgmax_val = 1 to save only max depth, # 2 to also save max speed, # 5 to also save max hs,hss,hmin rundata.fgmax_data.num_fgmax_val = 1 # Save depth only # rundata.fgmax_data.num_fgmax_val = 2 # Save depth and speed fgmax_grids = rundata.fgmax_data.fgmax_grids # empty list to start # Now append to this list objects of class fgmax_tools.FGmaxGrid # specifying any fgmax grids. # Note: 1 arcsec = 30 m # Make sure x1 < x2, y1 < y2 fgmax_regions = [ { 'Name': 'Trinidad to Dominica; Winward Islands', 'x1': -62.6056, 'x2': -58.7494, 'y1': 9.9042, 'y2': 15.694, }, { 'Name': 'Guadeloupe to U.S. Virgin Islands; Leeward Islands', 'x1': -65.6021, 'x2': -60.6143, 'y1': 15.7242, 'y2': 18.8608, }, { 'Name': 'Virgin Islands, Puerto Rico and Hispaniola', 'x1': -75.1355, 'x2': -63.8306, 'y1': 16.7706, 'y2': 20.9674, }, { 'Name': 'Cuba, Jamaica, and the Cayman Islands', 'x1': -85.3088, 'x2': -73.9709, 'y1': 17.6605, 'y2': 23.3514, }, { 'Name': 'The Bahamas and The Turks and Caicos Islands', 'x1': -79.3542, 'x2': -70.1697, 'y1': 20.1819, 'y2': 27.5647, }, # {'Name':'Turks and Caicos', # 'x1': -73.9819, # 'x2': -70.9058, # 'y1': 20.8603, # 'y2': 22.0853, # 'dx': 5/3600 # }, # {'Name':'Dominica', # 'x1': -61.6594, # 'x2': -61.1307, # 'y1': 15.1234, # 'y2': 15.6933, # 'dx': 1/3600 # }, # {'Name':'Antigua and Barbuda', # 'x1': -62.1744, # 'x2': -61.4822, # 'y1': 16.9093, # 'y2': 17.8075, # 'dx': 1/3600 # }, ] for fr in fgmax_regions: # Points on a uniform 2d grid: fg = fgmax_tools.FGmaxGrid() fg.point_style = 2 # uniform rectangular x-y grid fg.x1 = fr['x1'] fg.x2 = fr['x2'] fg.y1 = fr['y1'] fg.y2 = fr['y2'] # desired resolution of fgmax grid if 'dx' in fr.keys(): fg.dx = fr['dx'] else: fg.dx = 5 / 3600. # fg.dx = 10 / 3600. fg.min_level_check = amrdata.amr_levels_max # which levels to monitor max on fg.tstart_max = clawdata.t0 # just before wave arrives fg.tend_max = clawdata.tfinal # when to stop monitoring max values fg.dt_check = 60. # how often to update max values fg.interp_method = 0 # 0 ==> pw const in cells, recommended fgmax_grids.append(fg) # written to fgmax_grids.data # ------------------------------------------------------------------ # GeoClaw specific parameters: # ------------------------------------------------------------------ rundata = setgeo(rundata) 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('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 = 4 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 = 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 = 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 = [90.0] 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(-150e3, 200e3, 350) for gaugeno, x in enumerate(xgauges): gauges.append([gaugeno, x, clawdata.upper[1] - 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, 2] amrdata.refinement_ratios_y = [2, 2, 2, 2, 2, 2] amrdata.refinement_ratios_t = [2, 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 = 0.0001 # 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
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') #------------------------------------------------------------------ # 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: # (47 W, 100 E, 31 N, -10 S) - bathy clawdata.lower[0] = 47 # west longitude clawdata.upper[0] = 100 # east longitude clawdata.lower[1] = -10 # south latitude clawdata.upper[1] = 31 # 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(landfall.days - 3) + landfall.seconds # clawdata.t0 = days2seconds(landfall.days - 12) + landfall.seconds # 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: # clawdata.tfinal = days2seconds(date2days('2008091400')) clawdata.tfinal = days2seconds(landfall.days + 1.0) + landfall.seconds # clawdata.tfinal = days2seconds(landfall.days) + landfall.seconds 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 'netcdf' 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 = 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.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 # clawdata.cfl_desired = 0.25 # clawdata.cfl_max = 0.5 # 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' # clawdata.source_split = 'strang' # -------------------- # 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 = 5 # List of refinement ratios at each level (length at least mxnest-1) # amrdata.refinement_ratios_x = [2,2,3,4,16] # amrdata.refinement_ratios_y = [2,2,3,4,16] # amrdata.refinement_ratios_t = [2,2,3,4,16] # amrdata.refinement_ratios_x = [2,2,2,6,16] # amrdata.refinement_ratios_y = [2,2,2,6,16] # amrdata.refinement_ratios_t = [2,2,2,6,16] amrdata.refinement_ratios_x = [2,2,2,6,4,4] amrdata.refinement_ratios_y = [2,2,2,6,4,4] amrdata.refinement_ratios_t = [2,2,2,6,4,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). 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 = 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 # == 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] # Mumbai Region regions.append([2, 5, rundata.clawdata.t0, rundata.clawdata.tfinal, 70, 75, 17, 22]) # Mumbai regions.append([4, 7, days2seconds(landfall.days - 1.0) + landfall.seconds, rundata.clawdata.tfinal, 72.6, 73, 18.80, 19.15]) # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([1, 72.811790, 18.936508, rundata.clawdata.t0, rundata.clawdata.tfinal]) rundata.gaugedata.gauges.append([2, 72.972316, 18.997762, rundata.clawdata.t0, rundata.clawdata.tfinal]) rundata.gaugedata.gauges.append([3, 72.819311, 18.818044, rundata.clawdata.t0, rundata.clawdata.tfinal]) #------------------------------------------------------------------ # 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_sea_level', True) #probdata.add_param('topo_missing', 100.) # value to use if topo missing at pt #------------------------------------------------------------------ # 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: # 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] = -122.75 - arcsec16 # west longitude clawdata.upper[0] = -122.25 - arcsec16 # east longitude clawdata.lower[1] = 47.5 - arcsec16 # south latitude clawdata.upper[1] = 47.8 - arcsec16 # north latitude # choose mx and my so coarsest grid has 30 second resolution: clawdata.num_cells[0] = 60 clawdata.num_cells[1] = 36 # --------------- # 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 = '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 = 8 clawdata.tfinal = 16*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 = 10 clawdata.total_steps = 10 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.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 = 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 = 3600.*np.arange(2,11,2) 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) # dx = dy = 30", 6", 2", 1/3" amrdata.refinement_ratios_x = [5,3,6] amrdata.refinement_ratios_y = [5,3,6] amrdata.refinement_ratios_t = [5,3,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 = 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.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 = True # 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: # --------------- # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] regions = rundata.regiondata.regions # Entire domain: regions.append([1,2,0,1e9,clawdata.lower[0]-0.1, clawdata.upper[0]+0.1, \ clawdata.lower[1]-0.1, clawdata.upper[1]+0.1]) # Seattle Fault source region out to passageways: regions.append([2,2, 0,1e9, -122.62, -122.1, 47.38, 48.08]) # region covering Bainbridge and Seattle: regions.append([2,3, 0.,1e9, -122.62, -122.3, 47.52, 47.755]) # around Eagle Harbor: regions.append([4,4, 0.,1e9, -122.56, -122.47, 47.61, 47.64]) # --------------- # Gauges: # --------------- # for gauges append lines of the form [gaugeno, x, y, t1, t2] gauges = rundata.gaugedata.gauges gauges.append([14, -122.5088982, 47.62221842, 0., 1e9]) gauges.append([15, -122.5307267, 47.62521048, 0., 1e9]) 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: #------------------------------------------------------------------ # theta_island locates the island: 220 or 260 in the paper (x axis is latter) # to get rid of island altogether, change make topo file to not include routine that # adds island to topography # if changed here need to do make data then make topo # then make .output as usual, or make .plots theta_island = 260. probdata = rundata.new_UserData(name='probdata',fname='setprob.data') probdata.add_param('theta_island', theta_island, 'angle to island') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ 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] = -20.0 # xlower clawdata.upper[0] = 20.0 # xupper clawdata.lower[1] = 20.0 # ylower clawdata.upper[1] = 60.0 # yupper #clawdata.lower[0] = -5.0 # xlower #clawdata.upper[0] = 5.0 # xupper #clawdata.lower[1] = 35.0 # ylower #clawdata.upper[1] = 45.0 # yupper # Number of grid cells: #clawdata.num_cells[0] = 40 # mx #clawdata.num_cells[1] = 40 # my clawdata.num_cells[0] = 100 # mx clawdata.num_cells[1] = 100 # my # --------------- # 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 + 1 + 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? # 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.chk00021' # 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 = 3 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 = 14 #clawdata.tfinal = 14000.0 clawdata.tfinal = 7000.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 = 100 clawdata.total_steps = 4000/1 # final time 6000 sec / dtinit of 2 sec clawdata.output_t0 = True # output at initial (or restart) time? #clawdata.output_format = 'binary' # 'ascii', 'binary' clawdata.output_format = 'ascii' # 'ascii', 'binary' 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 = 1 # -------------- # Time stepping: # -------------- # if dt_variable==True: variable time steps used based on cfl_desired, # if dt_variable==Falseixed time steps dt = dt_initial always used. #clawdata.dt_variable = True clawdata.dt_variable = False # Initial time step for variable dt. # (If dt_variable==0 then dt=dt_initial for all steps) #clawdata.dt_initial = 16.0 clawdata.dt_initial = 1.0 # 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.75 # 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 = 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 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] 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 = 1 # -------------------- # 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 # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gaugeno = 0 for d in [1570e3, 1590e3, 1610e3, 1630e3]: gaugeno = gaugeno+1 x,y = latlong(d, theta_island, 40., Rearth) gauges.append([gaugeno, x, y, 0., 1e10]) # for radially symmetric traveling wave test #gauges.append([1, 0.01, 40.01, 0, 1e10]) #gauges.append([2, 1.01, 40.01, 0, 1e10]) #gauges.append([3, 2.01, 40.01, 0, 1e10]) #gauges.append([4, 3.01, 40.01, 0, 1e10]) #for 1d test problem i use these gauges #gauges.append([1, -17.50, 40, 0, 1e10]) #gauges.append([2, -15.5, 40, 0, 1e10]) #gauges.append([3, -13.5, 40, 0, 1e10]) #gauges.append([4, -11.5, 40, 0, 1e10]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 1 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: (written to amr.data) # --------------- amrdata = rundata.amrdata # max number of refinement levels: #amrdata.amr_levels_max = 5 amrdata.amr_levels_max = 4 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [4, 4, 4, 4] amrdata.refinement_ratios_y = [4, 4, 4, 4] amrdata.refinement_ratios_t = [4, 4, 4, 1] # 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', 'capacity', 'yleft', 'center', 'center', 'center', 'center'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # 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.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 5 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] #regions.append([1, 3, 0., 5000., -5., 20., 35., 45.]) #regions.append([1, 2, 5000., 6900., 10., 20., 35., 45.]) #regions.append([1, 3, 5000., 6900., 12., 20., 39., 43.]) regions.append([1, 2, 0., 100000000., -20., 20., 20., 60.]) # Force refinement near the island as the wave approaches: (xisland,yisland) = latlong(1600.e3, theta_island, 40., Rearth) x1 = xisland - 1. x2 = xisland + 1. y1 = yisland - 1. y2 = yisland + 1. regions.append([4, 4, 2500., 1.e10, x1,x2,y1,y2]) x1 = xisland - 0.2 x2 = xisland + 0.2 y1 = yisland - 0.2 y2 = yisland + 0.2 regions.append([4, 5, 3000., 1.e10, x1,x2,y1,y2]) # ----- 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 = True # 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: #------------------------------------------------------------------ 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] = -240.0 # xlower clawdata.upper[0] = -60.0 # xupper clawdata.lower[1] = -76.0 # ylower clawdata.upper[1] = 64.0 # yupper # Number of grid cells: clawdata.num_cells[0] = 45 # mx clawdata.num_cells[1] = 35 # my # --------------- # 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? # 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.chk00205' # 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 = 4 clawdata.tfinal = 44*3600. clawdata.output_t0 = False # 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. #times1 = 3600. * np.linspace(1,12,12) times2 = 3600. * np.linspace(12,30,10) #clawdata.output_times = list(times1) + list(times2) clawdata.output_times = list(times2) 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 = False # 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==Falseixed 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.75 # 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 = 50000 # ------------------ # 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 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] 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 = 1 # -------------------- # 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 # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gauges.append([1, -183.82219, -37.60287, 12*3600., 1.e9]) # A Beacon # other gauges for fine grid runs: gauges.append([2, -183.8191,-37.6407, 12*3600., 1.e9]) # Tug Berth #gauges.append([3, -183.8191,-37.6596, 12*3600., 1.e9]) # Sulpher Pt wrong gauges.append([3, -183.8245,-37.6596, 12*3600., 1.e9]) # Sulpher Point gauges.append([4, -183.81623,-37.6307, 12*3600., 1.e9]) # Moturiki x_ADCP = 176.1656739914625 - 360 y_ADCP = -37.63462262944208 gauges.append([5, x_ADCP, y_ADCP, 12*3600., 1.e9]) # ADCP if 0: # across entrance to harbor (ADCP location) for i in range(6): x = -183.838 + i*0.001 gauges.append([10+i, x, -37.635, 12*3600., 1.e9]) for i in range(8): x = -183.841 + i*0.001 gauges.append([20+i, x, -37.6325, 12*3600., 1.e9]) for i in range(10): x = -183.843 + i*0.001 gauges.append([30+i, x, -37.63, 12*3600., 1.e9]) # -------------- # Checkpointing: # -------------- # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 1 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 = np.array([7.5,8,8.5,9,9.5]) * 3600. elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 100 # --------------- # AMR parameters: (written to amr.data) # --------------- 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) # 4 degree, 24', 4', 1', 6", 1", 1/3" amrdata.refinement_ratios_x = [10,6,4,10,6,3] amrdata.refinement_ratios_y = [10,6,4,10,6,3] amrdata.refinement_ratios_t = [10,6,4,10,6,3] # 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', 'capacity', 'yleft'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # 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.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions regions.append([1, 3, 0., 1e9, -360, 360, -90, 90]) regions.append([3, 4, 12*3600., 1e9, -189, -182, -38, -34]) regions.append([4, 5, 12.5*3600., 1e9, -184.5, -183, -38, -37]) regions.append([5, 6, 12.5*3600., 1e9, -184.1, -183.7, -37.75, -37.4]) regions.append([5, 7, 12.5*3600., 1e9, -183.85, -183.815, -37.665, -37.62]) if 0: regions.append([1, 1, 0., 1e9, -360, 360, -90, 90]) regions.append([1, 3, 0., 3*3600., -360, 360, -90, 90]) regions.append([1, 3, 3*3600., 5*3600, -220, -160, -60, 40]) regions.append([1, 3, 5*3600., 9*3600, -220, -170, -45, 10]) regions.append([1, 3, 9*3600., 11*3600, -220, -170, -45, 0]) regions.append([1, 3, 11*3600., 1e9, -220, -170, -45, -20]) regions.append([3, 4, 12*3600., 1e9, -189, -182, -38, -34]) # to see refinement around NZ at t=0: #regions.append([4, 4, 0., 10, -188, -181, -42,-34]) #regions.append([6, 6, 0., 10, -184.1, -183.7, -37.75, -37.4]) # ----- 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 """ assert claw_pkg.lower() == 'geoclaw', "Expected claw_pkg = 'geoclaw'" ndim = 2 rundata = data.ClawRunData(claw_pkg, ndim) #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ rundata.add_data(surge.FrictionData(), 'friction_data') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) # Defined below #------------------------------------------------------------------ # 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 = ndim # Lower and upper edge of computational domain: clawdata.lower[0] = 130. clawdata.upper[0] = 170. clawdata.lower[1] = 20. clawdata.upper[1] = 60. # Number of grid cells: clawdata.num_cells[0] = 20 clawdata.num_cells[1] = 20 # --------------- # 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 = 4 # 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? # 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.chk00036' # 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 = 16 clawdata.tfinal = 4 * 3600. clawdata.output_t0 = True elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = list(numpy.arange(0,3600,360)) \ + list(3600*numpy.arange(0,21,0.5)) elif clawdata.output_style == 3: # Output every iout timesteps with a total of ntot time steps: clawdata.output_step_interval = 2 clawdata.total_steps = 6 clawdata.output_t0 = True clawdata.output_format = 'binary' # 'ascii' or 'netcdf' clawdata.output_q_components = 'all' # need all clawdata.output_aux_components = 'all' # 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 = 5 # -------------- # 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 = 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 = 5 # List of refinement ratios at each level (length at least amr_levels_max-1) amrdata.refinement_ratios_x = [4, 6, 5, 4] amrdata.refinement_ratios_y = [4, 6, 5, 4] amrdata.refinement_ratios_t = [1, 1, 1, 1] # 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'] # 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 = 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 = True # 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] rundata.regiondata.regions.append([1, 3, 0., 1e9, 0, 360, -90, 90]) rundata.regiondata.regions.append([4, 5, 0., 1000., 140, 146, 35, 41]) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([21401, 152.583, 42.617, 1800., 1.e10]) rundata.gaugedata.gauges.append([21413, 152.1167, 30.5153, 1800., 1.e10]) # rundata.gaugedata.gauges.append([21414, 178.281, 48.938, 1800., 1.e10]) # rundata.gaugedata.gauges.append([21415, 171.849, 50.183, 1800., 1.e10]) # rundata.gaugedata.gauges.append([21416, 163.505, 48.052, 1800., 1.e10]) rundata.gaugedata.gauges.append([21418, 148.694, 38.711, 0., 1.e10]) rundata.gaugedata.gauges.append([21419, 155.736, 44.455, 1800., 1.e10]) # rundata.gaugedata.gauges.append([51407, 203.484, 19.642, 22000., 1.e10]) # rundata.gaugedata.gauges.append([52402, 154.116, 11.883, 10000., 1.e10]) rundata.gaugedata.gauges.append([1, 140.846971, 36.351141, 0.0, 1e10]) rundata.gaugedata.gauges.append([2, 141.115000, 37.420000, 0.0, 1e10]) rundata.gaugedata.gauges.append([3, 141.100000, 38.160000, 0.0, 1e10]) rundata.gaugedata.gauges.append([4, 141.328223, 38.325000, 0.0, 1e10]) rundata.gaugedata.gauges.append([5, 141.510000, 38.425000, 0.0, 1e10]) rundata.gaugedata.gauges.append([6, 141.525000, 38.575000, 0.0, 1e10]) rundata.gaugedata.gauges.append([7, 141.545000, 38.660000, 0.0, 1e10]) rundata.gaugedata.gauges.append([8, 141.730000, 38.880000, 0.0, 1e10]) rundata.gaugedata.gauges.append([9, 142.115489, 39.752675, 0.0, 1e10]) rundata.gaugedata.gauges.append([10, 142.140317, 39.752675, 0.0, 1e10]) rundata.gaugedata.gauges.append([11, 141.626825, 40.989026, 0.0, 1e10]) rundata.gaugedata.gauges.append([12, 141.133576, 42.133955, 0.0, 1e10]) rundata.gaugedata.gauges.append([13, 143.739806, 42.535828, 0.0, 1e10]) # ===================== # Set friction values # ===================== set_friction(rundata) 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: #------------------------------------------------------------------ # Sample setup to write one line to setprob.data ... probdata = rundata.new_UserData(name='probdata', fname='setprob.data') # Gamma EOS parameter for three materials: air, plastic and water probdata.add_param('gammagas', 1.4, 'gamma for ideal gas') probdata.add_param('gammaplas', 1.1, 'gamma est. for polystirene') probdata.add_param('gammawat', 7.15, 'gamma for water') # Pinf parameter for Tammann EOS for three materials: air, plastic and water # pinfplas Calculated with c^2=gamma*(p+pinf)/rho to make c =2240m/s (polystyrene speed of sound), # (c= 1484 in water). Values from water obtained from kirsten's paper in the references probdata.add_param('pinfgas', 0.0, 'pinf for stiffend gas/plastic') probdata.add_param('pinfplas', 4789425947.72, 'pinf for stiffend gas/plastic') probdata.add_param('pinfwat', 300000000.0, 'pinf for stiffend water') # Density at rest and at room temperature of: air, plastic and water probdata.add_param('rhog', 1.0, 'air density in kg/m^3') probdata.add_param('rhop', 1050.0, 'polystirene density in kg/m^3') probdata.add_param('rhow', 1000.0, 'water density in kg/m^3') # omegas, omeplas and omewat are not used in this code, but they can be used to extend the code # to a more general EOS with an extra parameter, like de Van der Waals EOS. probdata.add_param( 'omegas', 0.0, 'omega (specific excluded volume) for stiffend gas/plastic') probdata.add_param( 'omeplas', 0.0, 'omega (specific excluded volume) for stiffend gas/plastic') probdata.add_param('omewat', 0.0, 'omega (specific excluded volume) for stiffend water') # Parameters for mapped grid (if changed, they also need to be changed in mapc2p.py, also # double check the mapc2p.py test works correctly with the new parameters) probdata.add_param('rsqr', 0.039999, 'radius of outer square for mapped grid') probdata.add_param( 'rout', 0.015, 'radius of outer circle of ring inclusion for mapped grid') probdata.add_param( 'rinn', 0.010, 'radius of inner circle of ring inclusion for mapped grid') #------------------------------------------------------------------ # 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] = -0.05 #-0.055 # xlower clawdata.upper[0] = 0.05 #0.055 # xupper clawdata.lower[1] = 0.000000e+00 # ylower clawdata.upper[1] = 0.05000e+00 # yupper # Number of grid cells: # For original mapped grid, used multiples of 20x10, so the interface is aligned clawdata.num_cells[0] = 40 #40 #40 #56-mymapping #40-randys # mx clawdata.num_cells[1] = 20 #20 #14 #17-mymapping #14-randys # my # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 4 # Number of auxiliary variables in the aux array (initialized in setaux) clawdata.num_aux = 15 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 14 # ------------- # 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.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 = 150 clawdata.tfinal = 0.0002 #0.00025 #0.00015 #0.00015 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 = 1 clawdata.total_steps = 4 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.output_format == 'ascii' # 'ascii' 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. 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 = 1.000000e-07 # 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.5 #0.600000 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 0.6 #0.700000 # Maximum number of time steps to allow between output times: clawdata.steps_max = 500000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Use dimensional splitting? clawdata.dimensional_split = 'unsplit' # 'godunov' #'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 #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 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter (see inline limiter.f to # enable or disable modified minmod (TVD, only first order, "add viscosity") clawdata.limiter = [1, 1, 1] #[1, 1, 1] 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 = 1 # -------------------- # 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] = 'user' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper # -------------- # 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. ckouttime0 = 50.00 / 1000000.0 ckouttime1 = 63.33 / 1000000.0 clawdata.checkpt_times = [ckouttime0, ckouttime1] 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 # for gauges append lines of the form [gaugeno, x, y, t1, t2] gauges.append([0, -0.01, 0, 0., 1e9]) gauges.append([1, -0.01, 0.005, 0., 1e9]) gauges.append([2, -0.01, 0.01, 0., 1e9]) gauges.append([3, 0.0, 0, 0., 1e9]) gauges.append([4, 0.0, 0.005, 0., 1e9]) gauges.append([5, 0.0, 0.01, 0., 1e9]) gauges.append([6, 0.01, 0, 0., 1e9]) gauges.append([7, 0.01, 0.005, 0., 1e9]) gauges.append([8, 0.01, 0.01, 0., 1e9]) # --------------- # 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, 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', 'center', 'center', 'capacity', 'center' ] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.000000e-00 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 5000.0 #10000.0 #10000.0 #10.000000 #100000.0 #5.000000e-02 # tolerance used in this routine (100000000.000000) # 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 #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 # ------------------- # Refinement Regions: # ------------------- regions = rundata.regiondata.regions # Remove initial spurious wave from interface coupling by not refining until t_0 t_0 = 1.67 / 1000000.0 # NOT REQUIRED IF MAPPING NOT PRESENT # All of the water region (for level 2 with mapping) #regions.append([2,2,0,1e9,-0.0155,0.0155, 0.0, 0.0155]) # All of the water region (for level 3 with mapping) #regions.append([3,3,0,1e9,-0.0155,0.0155, 0.0, 0.0155]) # Regions along interface (for level 3 with mapping) #regions.append([3,3,0,1e9,-0.0155,-0.0145, 0.0, 0.0155]) #regions.append([3,3,0,1e9,0.0145,0.0155, 0.0, 0.0155]) #regions.append([3,3,0,1e9,-0.0155, 0.0155, 0.0145, 0.0155]) # Regions along interface (for level 4 with mapping) regions.append([4, 4, 0, 1e9, -0.0155, 0.0155, 0.0, 0.0155]) # Regions along interface (for level 5 with mapping) #regions.append([5,5,0,1e9,-0.0155,0.0155, 0.0, 0.0155]) # Regions along interface (for level 5 with mapping) #regions.append([5,5,0,1e9,-0.02,0.02, 0.0, 0.02]) # Regions along interface (for level 6 with mapping) #regions.append([6,6,0,1e9,-0.02,0.02, 0.0, 0.0155]) # Regions along interface (for level 6 without mapping) #regions.append([5,6,t_0,1e9,-0.025,0.025, 0.0, 0.025]) # Along one corner for Schlieren ##regions.append([6,6,t_0,1e9,-0.02,0.005, 0.005, 0.02]) ##regions.append([6,6,t_0,1e9,-0.02,0.02, -0.02, 0.02]) ##regions.append([6,6,t_0,1e9,-0.02,0.02, -0.02, 0.02]) ##regions.append([5,5,t_0,1e9,-0.01,0.02, 0.01, 0.02]) #regions.append([5,5,t_0,1e9,-0.02,-0.01, 0.01, 0.02]) #OTHER COMBINATIONS # Interface corners #regions.append([3,3,0,1e9,-0.0155,-0.0145, 0.0145, 0.0155]) #regions.append([3,3,0,1e9,0.0145,0.0155, 0.0145, 0.0155]) #regions.append([2,3,4e-6,1e9,-0.03,-0.029, 0.0, 0.030]) #regions.append([3,3,0,1e9,-0.02,0.02, 0.0, 0.02]) # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # ----- 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] = -118.0 # west longitude clawdata.upper[0] = -86.0 # east longitude clawdata.lower[1] = 7.0 # south latitude clawdata.upper[1] = 21.0 # north latitude # Number of grid cells res_factor = 1 clawdata.num_cells[0] = 32 * res_factor clawdata.num_cells[1] = 14 * res_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 = 4 # 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? # 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.chk00036' # 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 = 2 if clawdata.output_style == 1: # Output nout frames at equally spaced times up to tfinal: hours = 4 output_per_hour = 12 clawdata.num_output_times = hours * output_per_hour clawdata.tfinal = float(hours) * 3600.0 clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. clawdata.output_times = [float(time) for time in xrange(0, 250, 25)] acapulco_time_zoom = numpy.linspace(0.07, 0.2, 10) * 3600.0 for new_time in acapulco_time_zoom: clawdata.output_times.append(new_time) hours = 4 output_per_hour = 6 for time in numpy.linspace(0, hours * 3600, output_per_hour * hours + 1): if time > clawdata.output_times[-1]: clawdata.output_times.append(float(time)) 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 = 'binary' # 'ascii' or 'netcdf' 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 = 3 # -------------- # 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 = 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' # Specify when checkpoint files should be created that can be # used to restart a computation. clawdata.checkpt_style = 1 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 = 7 # List of refinement ratios at each level (length at least mxnest-1) # Level 1 - (1.0º,1.0º) - (100950.057205 m,110772.872596 m) # Level 2 - (0.25º,0.25º) - (25237.5143013 m,27693.2181489 m) # Level 3 - (0.125º,0.125º) - (12618.7571506 m,13846.6090744 m) # Level 4 - (0.0625º,0.0625º) - (6309.37857532 m,6923.30453722 m) # Level 5 - (0.0104166666667º,0.0104166666667º) - (1051.56309589 m,1153.88408954 m) # Level 6 - (0.00130208333333º,0.00130208333333º) - (131.445386986 m,144.235511192 m) # Level 7 - (8.13802083333e-05º,8.13802083333e-05º) - (8.21533668662 m,9.01471944951 m)) amrdata.refinement_ratios_x = [4, 2, 2, 6, 8, 8] amrdata.refinement_ratios_y = [4, 2, 2, 6, 8, 8] amrdata.refinement_ratios_t = [4, 2, 2, 6, 8, 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'] # 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 = 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 = True # 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 = [] rundata.regiondata.regions.append( [7, 7, 0.0, 1e10, -99.930021, -99.830477, 16.780640, 16.870122]) # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # Region Long (E) Lat (N) # Acapulco -99º 52' 41.10" 16º 50' 18.19" #rundata.regiondata.regions.append([1, 6, 0.0, 1e10, # -100.1, -99.66666667, # 16.7, 16.96666667]) # Ixtapa-Zihuatanejo -101º 33' 8.61" 17º 38' 15.15" # Puerto Angel -96º 29' 35.08" 15º 39' 53.28" # Lázaro Cárdenas -102º 9' 54.86" 17º 55' 30.66" #rundata.regiondata.regions.append([1, 6, 0.0, 1e10, # -102.2440361, -102.0918583, # 17.89015556, 17.99216667]) # --------------- # Gauges: # --------------- degminsec2dec = lambda deg, minutes, seconds: float(deg) + (float( minutes) + float(seconds) / 60.0) / 60.0 rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] # ID Location Name Lat Long # 1 Manzanillo, Col. 19º 3.4 N 104º 19.1 W # rundata.gaugedata.gauges.append([1, -104.3183333, 19.05666667, 0.0, 1.e10]) # 2 Ixtapa, Gro. 17º 40.1 N 101º 38.7 W # rundata.gaugedata.gauges.append([2, -101.645, 17.66833333, 0.0, 1.e10]) # 3 Zihuatanejo, Gro. 17º 38.2 N 101º 33.5 W # rundata.gaugedata.gauges.append([3, -101.5583333, 17.63666667, 0.0, 1.e10]) # 4 Acapulco, Gro. 16º 50.3 N 99º 54.2 W rundata.gaugedata.gauges.append([4, -99.90333333, 16.83833333, 0.0, 1.e10]) # 5 Isla Socorro, Col. 18º 43.5 N 110º 57.0 W # rundata.gaugedata.gauges.append([5, -110.95, 18.725, 0.0, 1.e10]) # 6 Puerto Angel, Oax  15º 40 N   96º 29.5 W # rundata.gaugedata.gauges.append([6, -degminsec2dec(96,29.5,0), degminsec2dec(15,40,0), 0.0, 1.e10]) # 7 Salina Cruz, Oax.   16º 19.1 N  95º 11.8 W rundata.gaugedata.gauges.append([ 7, -degminsec2dec(95, 11.8, 0), degminsec2dec(16, 19.1, 0.0), 0.0, 1.e10 ]) # 8 Puerto Madero, Chis   14º 42.7 N  92º 24.1 W # rundata.gaugedata.gauges.append([8, -degminsec2dec(92,24.1,0), degminsec2dec(14,42.7,0), 0.0, 1.e10]) # 9 Lazaro Cardenas, Mich  17º 56.4 N  102º 10.7 W # rundata.gaugedata.gauges.append([9, -degminsec2dec(102,10.7,0.0), degminsec2dec(17,56.4,0.0), 0.0, 1.e10]) # 10 Huatulco 15° 45'.2 N 96° 07'.8 W # rundata.gaugedata.gauges.append([10, -degminsec2dec(96,7.8,0.0), degminsec2dec(15,45.2,0.0), 0.0, 1.e10]) # 11 Acapulco 16°51'9.00"N  99°52'50"W rundata.gaugedata.gauges.append( [11, -degminsec2dec(99, 52, 50), degminsec2dec(16, 51, 9), 0.0, 1.e10]) # 12 Acapulco additional gauges rundata.gaugedata.gauges.append([12, -99.904294, 16.839721, 0.0, 1.e10]) rundata.gaugedata.gauges.append([13, -99.905197, 16.840743, 0.0, 1.e10]) rundata.gaugedata.gauges.append([14, -99.903940, 16.842113, 0.0, 1.e10]) rundata.gaugedata.gauges.append([15, -99.902489, 16.843462, 0.0, 1.e10]) rundata.gaugedata.gauges.append([16, -99.898397, 16.845365, 0.0, 1.e10]) rundata.gaugedata.gauges.append([17, -99.891848, 16.851036, 0.0, 1.e10]) rundata.gaugedata.gauges.append([18, -99.860943, 16.848830, 0.0, 1.e10]) rundata.gaugedata.gauges.append([19, -99.856680, 16.839136, 0.0, 1.e10]) rundata.gaugedata.gauges.append([20, -99.888627, 16.816910, 0.0, 1.e10]) return rundata
def setrun(claw_pkg='classic'): from clawpack.clawutil import data # 2D general data object rundata = data.ClawRunData(claw_pkg, 2) # 2 = number of dimensions # Problem-specific data probdata = rundata.new_UserData(name='probdata', fname='setprob.data') probdata.add_param('A1', 1., 'Amplitude of first Gaussian hump') probdata.add_param('beta1', 40., 'Decay rate of first Gaussian hump') probdata.add_param('x1', -0.5, 'X coordinate of center of first Gaussian hump') probdata.add_param('y1', 0., 'Y coordinate of center of first Gaussian hump') probdata.add_param('A2', -1., 'Amplitude of second Gaussian hump') probdata.add_param('beta2', 40., 'Decay rate of second Gaussian hump') probdata.add_param('x2', 0.5, 'X coordinate of center of second Gaussian hump') probdata.add_param('y2', 0., 'Y coordinate of center of second Gaussian hump') # General Clawpack control data clawdata = rundata.clawdata # Initialized when rundata is created # Size of computational domain clawdata.lower = [0.2, 0.] clawdata.upper = [1., 6.28318530718] # Grid dimensions clawdata.num_cells = [40, 120] # 40 radial, 120 azimuthal # Size of system clawdata.num_eqn = 1 clawdata.num_aux = 3 clawdata.capa_index = 3 # Output control clawdata.output_style = 1 clawdata.num_output_times = 25 clawdata.tfinal = 2.5 # Time stepping clawdata.dt_initial = 0.1 clawdata.cfl_desired = 0.9 clawdata.cfl_max = 1. clawdata.steps_max = 1000 clawdata.dt_variable = True # Details of the numerical method clawdata.order = 2 clawdata.transverse_waves = 2 clawdata.verbosity = 0 clawdata.source_split = 0 # Waves and limiting clawdata.num_waves = 1 clawdata.limiter = [3] # Boundary conditions # Zero-order extrapolation in radial direction, periodic in azimuthal clawdata.bc_lower = [1, 2] clawdata.bc_upper = [1, 2] 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) #------------------------------------------------------------------ # 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] = 0.e0 clawdata.upper[0] = domain_x clawdata.lower[1] = -domain_y/2.0 clawdata.upper[1] = domain_y/2.0 # Number of grid cells: Coarsest grid clawdata.num_cells[0] = x_cell clawdata.num_cells[1] = y_cell # --------------- # 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 = 1 # 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. # The solution at initial time t0 is always written in addition. clawdata.output_style = 2 if clawdata.output_style == 1: # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 30 clawdata.tfinal = 30.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. time_arr1 = np.arange(0.0, 27.0) time_arr2 = np.arange(27.0, 28.0, step=0.10) tfinal = 50.0 time_arr3 = np.arange(28.0, tfinal) time_arr = np.concatenate([time_arr1, time_arr2, time_arr3]) clawdata.output_times = time_arr 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 = '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 = 3 # -------------- # 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.004 # 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.25 clawdata.cfl_max = 0.26 # 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 = ['vanleer', 'vanleer', 'vanleer'] 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] = 'user' 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 = 1 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 = 4 # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = [2,2,2] amrdata.refinement_ratios_y = [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 maux, each element of which is one of: # 'center', 'capacity', 'xleft', or 'yleft' (see documentation). amrdata.aux_type = ['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 = 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] # regions.append([3, 4, 0., 1.e10, 39.20,41.20, -0.40,0.40]) # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] # rundata.gaugedata.gauges.append([]) x_front = 40.0-((domain_x)/x_cell) x_rear = 40.40+((domain_x)/x_cell) y_array = np.linspace((-0.2+((domain_x)/x_cell)),(0.2-(domain_x)/x_cell),5) # front gauges gaugeno = 0 for r in y_array: gaugeno = gaugeno+1 rundata.gaugedata.gauges.append([gaugeno, x_front, r, 0., 1e10]) # rear gauges for r in y_array: gaugeno = gaugeno+1 rundata.gaugedata.gauges.append([gaugeno, x_rear, r, 0., 1e10]) 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 = 1 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('betal', 0.5, 'Gaussian hump width parameter') probdata.add_param('betar', 0.5, 'for width of Gaussian data') probdata.add_param('freqrl', 10., 'frequency in wave packet') probdata.add_param('freqr', 15., 'frequency in wave packet') probdata.add_param('rhol', 1., 'Density left of interface') probdata.add_param('cl', 1., 'Sound speed left of interface') probdata.add_param('rhor', 1., 'Density right of interface') probdata.add_param('cr', 1., 'Sound speed right of interface') #------------------------------------------------------------------ # 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] = -12. # xlower clawdata.upper[0] = 12. # xupper # Number of grid cells: clawdata.num_cells[0] = 480 # mx # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 2 # Number of auxiliary variables in the aux array (initialized in setaux) rundata.clawdata.num_aux = 2 # Note: as required for original problem - modified below for adjoint # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 0 # ------------- # Initial time: # ------------- clawdata.t0 = 0. # 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 = 3 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 = 12 #16 clawdata.tfinal = 3. #8.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 = 1 clawdata.total_steps = 30 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 = '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 = 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.045 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.e9 # 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 = 50000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 2 # 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'] clawdata.limiter = [0, 0] 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] = 'wall' # at xlower clawdata.bc_upper[0] = 'wall' # at xupper # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, t1, t2] rundata.gaugedata.gauges.append([0, -1.0, 0., 1e9]) rundata.gaugedata.gauges.append([1, 1.0, 0., 1e9]) # -------------- # 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 = 8 #10 # List of refinement ratios at each level (length at least amr_level_max-1) amrdata.refinement_ratios_x = [4, 4, 2, 2, 2, 2, 2, 2, 2] amrdata.refinement_ratios_t = [4, 4, 2, 2, 2, 2, 2, 2, 2] # Specify type of each aux variable in clawdata.auxtype. # This must be a list of length num_aux, each element of which is one of: # 'center', 'capacity', or 'xleft' (see documentation). rundata.amrdata.aux_type = ['center', 'center'] # Note: as required for original problem - modified below for adjoint # set tolerances appropriate for adjoint flagging: # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = True amrdata.flag_richardson_tol = 0.00005 # for original #amrdata.flag_richardson_tol = 0.05 # when flagging on LTE # Flag for refinement using routine flag2refine: amrdata.flag2refine = False rundata.amrdata.flag2refine_tol = 1e-3 # suggested if using adjoint-mag # 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: # --------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2] #rundata.regiondata.regions.append([5,5,0,0.2,-8,8]) #------------------------------------------------------------------ # Adjoint specific data: #------------------------------------------------------------------ # Also need to set flagging method and appropriate tolerances above adjointdata = rundata.adjointdata adjointdata.use_adjoint = False # location of adjoint solution, must first be created: adjointdata.adjoint_outdir = os.path.abspath('adjoint/_output') # time period of interest: adjointdata.t1 = 11.5 adjointdata.t2 = 12.5 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) # ----- 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 = 1 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('bouss', dispersion, 'Include dispersive terms?') probdata.add_param('B_param', B_param, 'Parameter for the Boussinesq eq') probdata.add_param('sw_depth0', sw_depth0) probdata.add_param('sw_depth1', sw_depth1) probdata.add_param('radial', radial, 'Radial source term?') #------------------------------------------------------------------ # 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] = 0. # xlower clawdata.upper[0] = 1. # xupper # Number of grid cells: clawdata.num_cells[0] = mx # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 2 # 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: # ------------- clawdata.t0 = 0. # 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 = 30 clawdata.tfinal = 3000. clawdata.output_t0 = False # 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.2, 1.6, 2.9, 4.3, 5.6, 6.9, 8.3, 9.6, 10.9] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 10 clawdata.total_steps = 100 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 = 'all' # 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.01 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.e9 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.75 # 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 = 50000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 2 # 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 = [4, 4] 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 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_lower[0] = 'wall' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper # 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' (see documentation). # Isn't used for this non-amr version, but still expected in data. amrdata = rundata.amrdata amrdata.aux_type = ['center', 'capacity'] # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, t1, t2] xgauge = [-50e3, 0, 50e3, 100e3] for gaugeno, xp_g in enumerate(xgauge): # compute computational point xc_g that maps to xp_g: ii = np.where(xp < xp_g)[0][-1] xp_frac = (xp_g - xp[ii]) / (xp[ii + 1] - xp[ii]) xc_g = (ii + xp_frac) / float(grid.shape[0]) print('gaugeno = ', gaugeno) print(' ii, xp_g, xp[ii], xp[ii+1], xp_frac, xc_g:\n ', \ ii, xp_g, xp[ii], xp[ii+1], xp_frac, xc_g) rundata.gaugedata.gauges.append([gaugeno, xc_g, 0, 1e9]) # --------------- # geo data # --------------- geo_data = rundata.geo_data geo_data.sea_level = 0.0 geo_data.dry_tolerance = 1.e-3 # Friction source terms: # src_split > 0 required geo_data.friction_forcing = True geo_data.manning_coefficient = .025 geo_data.friction_depth = 1e6 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] = -240.0 # west longitude #clawdata.upper[0] = -100.0 # east longitude #clawdata.lower[1] = -41.0 # south latitude #clawdata.upper[1] = 65.0 # north latitude ### for chile, consider -48 as southern bdry and -66 as eastern ### , -240, -66; -47, 65. ### , delta long = 87; delta lat = 56 clawdata.lower[0] = -240.0 # west longitude clawdata.upper[0] = -66.0 # east longitude clawdata.lower[1] = -47.0 # south latitude clawdata.upper[1] = 65.0 # north latitude # Number of grid cells: Coarsest grid 2 degrees clawdata.num_cells[0] = 87 clawdata.num_cells[1] = 56 # --------------- # 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 = '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 = 2 #clawdata.output_style = 1 if clawdata.output_style == 1: # Output nout frames at equally spaced times up to tfinal: clawdata.num_output_times = 84 clawdata.tfinal = 16 * 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 = np.linspace(1, 26, 51) * 3600. #clawdata.output_times = np.linspace(0,3,7) * 3600. 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' or 'netcdf' clawdata.output_format = 'binary' # 'ascii' or 'netcdf' 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.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 = 8 # List of refinement ratios at each level (length at least mxnest-1) #1sec # 2 degree, 24', 4', 1', 12", 6", 1" for 7 levels. #amrdata.refinement_ratios_x = [5, 6, 4, 5, 2, 6] #amrdata.refinement_ratios_y = [5, 6, 4, 5, 2, 6] #amrdata.refinement_ratios_t = [5, 6, 4, 5, 2, 6] #2sec # 2 degree, 24', 4', 1', 12", 6", 2" for 7 levels. #amrdata.refinement_ratios_x = [5, 6, 4, 5, 2, 3] #amrdata.refinement_ratios_y = [5, 6, 4, 5, 2, 3] #amrdata.refinement_ratios_t = [5, 6, 4, 5, 2, 3] #1/3sec, trying one with 8 levels, including 6sec region # 2 degree, 24', 4', 1', 12", 6", 1", 1/3" for 8 levels. # level 5 is still 12". level 6 is 6", level 7 is 1 sec, and level 8 is 1/3 amrdata.refinement_ratios_x = [5, 6, 4, 5, 2, 6, 3] amrdata.refinement_ratios_y = [5, 6, 4, 5, 2, 6, 3] amrdata.refinement_ratios_t = [5, 6, 4, 5, 2, 6, 3] # 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 = 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 # --------------------------------------------------------------- #1sec # 2 degree, 24', 4', 1', 12", 1" 6 levels. # -------------------------------------------------------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # Ocean refinement from Chile, using adjoint, below is whole domain rundata.regiondata.regions.append([1, 5, 0., 1e9, -240, -66, -47, 65]) #rundata.regiondata.regions.append([1, 4, 13.0*3600., 1e9, -160,-120,34,62]) #rundata.regiondata.regions.append([1, 4, 10.5*3600., 1e9, -160,-110,18,34]) # Chile source: # Note, we are using 1 minute around the source. It may not be necessary. ### domain, -240, -66; -47, 65. ### pink deformation has region: -94.65, -67.9833; -46.294, -24.8641 #rundata.regiondata.regions.append([4, 4, 0., 4.0*3600, -96.0,-68.0,-47.0,-24.0]) # above region is from Loyce. Trying a smaller source region: rundata.regiondata.regions.append( [4, 4, 0., 4.0 * 3600, -80.0, -68.0, -40.0, -20.0]) #Port Orford (lat: 42degrees, 44.3min, long: 124degrees, 29.9min) #Crescent City (lat: 41degrees, 44.7min, long: 124degrees, 11.1min) #Arena Cove (lat: 38degrees, 54.9min, long: 123degrees, 42.7min) #San Luis (lat: 35degrees, 10.1min, long: 120degrees, 45.2min) #Make a new bigger A grid: #rundata.regiondata.regions.append([1, 4, 13.0*3600., 1e9, -129,-123,38,46]) #Diego's A grid becomes the B (12sec) grid: #rundata.regiondata.regions.append([4, 4, 14.0*3600., 1e9, -126.995,-123.535,40.515,44.495]) #rundata.regiondata.regions.append([1, 5, 14.0*3600., 1e9, -126.995,-123.535,40.515,44.495]) #Diego's B grid becomes a 6sec grid: rundata.regiondata.regions.append( [1, 6, 14.5 * 3600., 1e9, -124.6, -124.05, 41.5017, 41.9983]) #For the 1sec and 2sec runs, match Diego C grid as below for 7,7 #For the UW topo, use this one for the 1sec as well when doing 1/3 #Too much land #rundata.regiondata.regions.append([7, 7, 14.5*3600., 1e9, -124.2345, -124.1434,41.7168,41.7829]) #For the 1/3 run, make region 6 match the 1/3 data with 1sec computation #Use this even for UW 1/3 run rundata.regiondata.regions.append( [1, 7, 14.5 * 3600., 1e9, -124.2345, -124.1595, 41.7168, 41.76948]) #Trying a 1/3 grid close in (our D grid) rundata.regiondata.regions.append( [1, 8, 14.5 * 3600., 1e9, -124.202, -124.180, 41.733, 41.752]) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] #from Diego file rundata.gaugedata.gauges.append( [2, -124.18397, 41.74512, 14.5 * 3600., 1.e10]) #------------------------------------------------------------------ # Adjoint specific data: #------------------------------------------------------------------ # Do this last since it resets some parameters such as num_aux # as needed for adjoint flagging. rundata = setadjoint(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') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ 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] = 132.0 # xlower clawdata.upper[0] = 210.0 # xupper clawdata.lower[1] = 9.0 # ylower clawdata.upper[1] = 53.0 # yupper # Number of grid cells: clawdata.num_cells[0] = 39 # mx clawdata.num_cells[1] = 22 # my # --------------- # 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? # 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 = 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 = 26 clawdata.tfinal = 13 * 3600. 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 = np.linspace(7, 13, 4) * 3600. 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 = False # 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==Falseixed 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.75 # 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 = 50000 # ------------------ # 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 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] 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 = 1 # -------------------- # 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 # --------------- # Gauges: # --------------- gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gauges.append([1123, 203.52825, 20.9021333, 7.0 * 3600., 1.e9]) #Kahului # more accurate coordinates from Yong Wei at PMEL: gauges.append([5680, 203.530944, 20.895, 7.0 * 3600., 1.e9]) #TG Kahului # -------------- # 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: (written to amr.data) # --------------- amrdata = rundata.amrdata # max number of refinement levels: amrdata.amr_levels_max = 5 # Set to 6 originally # List of refinement ratios at each level (length at least amr_level_max-1) # 2 degree, 24', 4', 1', 10", 1/3" amrdata.refinement_ratios_x = [5, 6, 4, 6, 30] amrdata.refinement_ratios_y = [5, 6, 4, 6, 30] amrdata.refinement_ratios_t = [5, 6, 4, 6, 30] # 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', 'capacity', 'yleft'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # 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.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions inf = 1e9 # Region 0 : Global region. This assures a maximum refinement in any # regions not covered by other regions listed below. regions.append([1, 2, 0., inf, 0, 360, -90, 90]) # Region 1 : (from the dtopo file, below). # Time interval taken from dtopo file : [0,1] regions.append([3, 3, 0, 1, 135., 150., 30., 45.]) # Region 2 : Large region encompassing lower 3/4 of domain. # Time interval : (0,18000) regions.append([1, 3, 0., 5. * 3600., 132., 220., 5., 40.]) # Region 3 : Region including all Hawaiian Islands. # Time interval (18000,28800) regions.append([1, 3, 5. * 3600., 8. * 3600., 180., 220., 5., 40.]) # Region 4 : Region including Molekai and Maui. # Time interval : (23400.0, inf) regions.append([4, 4, 6.5 * 3600., inf, 202.5, 204, 20.4, 21.4]) # Region 5 : Strip including north shore of Maui. # Time interval : (25200, inf) regions.append([5, 5, 7. * 3600., inf, 203.0, 203.7, 20.88333, 21.]) # Region 6 : Includes port at Kailua. # Time interval : (26100.0, inf) regions.append([6, 6, 7.25 * 3600., inf, 203.52, 203.537, 20.89, 20.905]) # ----- 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) # ------------------------------------------------------------------ # 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] = -180.0 # west longitude clawdata.upper[0] = 180.0 # east longitude clawdata.lower[1] = -45.0 # south latitude clawdata.upper[1] = 45.0 # north latitude # Number of grid cells: degree_factor = 1 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 = 0.0 # clawdata.t0 = days2seconds(landfall.days - 1) + landfall.seconds # 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: # Note that this is overriden below when we know the storm length clawdata.tfinal = days2seconds(4.0) 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 = 'binary' # 'ascii' or 'netcdf' 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 = 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.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 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 = [4, 4] amrdata.refinement_ratios_y = [4, 4] amrdata.refinement_ratios_t = [4, 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). 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 = 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 # == 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] # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] city_locations = { "New York": { "location": [-74.042227, 40.567970], "gauge_id": 1 }, "Tampa Bay": { "location": [-82.789195, 27.547842], "gauge_id": 2 }, "Houston": { "location": [-94.704520, 29.334877], "gauge_id": 3 }, "Miami": { "location": [-80.125826, 25.730958], "gauge_id": 4 }, "New Orleans": { "location": [-88.825468, 30.118699], "gauge_id": 5 }, "Manila": { "location": [120.517863, 14.278543], "gauge_id": 6 }, "Hong Kong": { "location": [114.093341, 22.266447], "gauge_id": 7 }, "Bohai Sea (Beijing)": { "location": [118.787639, 38.604150], "gauge_id": 8 }, "Bangladesh": { "location": [89.954084, 21.797045], "gauge_id": 9 }, "Chennai": { "location": [80.307269, 13.108752], "gauge_id": 10 } } for (name, gauge_data) in city_locations.items(): rundata.gaugedata.gauges.append([ gauge_data["gauge_id"], gauge_data['location'][0], gauge_data['location'][1], rundata.clawdata.t0, rundata.clawdata.tfinal ]) # ------------------------------------------------------------------ # 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('bouss' , bouss ,'Include dispersive terms?') probdata.add_param('B_param' , B_param ,'Parameter for the Boussinesq eq') probdata.add_param('use_bous_sw_thresh', use_bous_sw_thresh,'Use the switching threshold') probdata.add_param('bous_sw_thresh' , bous_sw_thresh ,'Eta to depth ratio') probdata.add_param('sw_depth' , sw_depth ,'shallow depth') #------------------------------------------------------------------ # 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] =-100. clawdata.upper[0] = 100. clawdata.lower[1] =-100. clawdata.upper[1] = 100. # Number of grid cells: Coarsest grid clawdata.num_cells[0] = 100 clawdata.num_cells[1] = 100 # --------------- # 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 = 5 # 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? # 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 = '../_checkpoint_dx02/fort.chk03547' # 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 = 20 clawdata.tfinal = 40. clawdata.output_t0 = True # output at initial (or restart) time? elif clawdata.output_style == 2: # Specify a list of output times. tspan=6./np.sqrt(9.81) +np.linspace(0.,23./np.sqrt(9.81),23*10+1) clawdata.output_times = tspan 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' or '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==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.7 clawdata.cfl_max = 0.8 # Maximum number of time steps to allow between output times: clawdata.steps_max = 500000 # ------------------ # 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 = [3,3,3] 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 = 1 # -------------------- # 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] = 1 clawdata.bc_upper[0] = 1 clawdata.bc_lower[1] = 1 clawdata.bc_upper[1] = 1 # 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. tspan=np.linspace(6./np.sqrt(9.81),(14.+6.)/np.sqrt(9.81),15) clawdata.checkpt_times = tspan 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 = 1 # List of refinement ratios at each level (length at least mxnest-1) amrdata.refinement_ratios_x = [2,2,5,4] amrdata.refinement_ratios_y = [2,2,5,4] amrdata.refinement_ratios_t = [2,2,5,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). amrdata.aux_type = ['center','center','yleft','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 = 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] regions.append([1, 3, 0., 1e10, -1.e9, 1.e9, -1.e9, 1.e9]) #regions.append([3, 3, 0., 5., 1., 4., 18.5, 22.]) # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] # rundata.gaugedata.add_gauge() # --------------- # Gauges: # --------------- #rundata.gaugedata.gauges = [] gauges = rundata.gaugedata.gauges # for gauges append lines of the form [gaugeno, x, y, t1, t2] gauges.append([1, 50., 0., 0., 1e10]) gauges.append([2, 50./np.sqrt(2.), 50./np.sqrt(2.), 0., 1e10]) #gauges.append([3, 0., 50., 0., 1e10]) #gauges.append([3, 0., 100.*np.sqrt(2.), 0., 1e10]) 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='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') #------------------------------------------------------------------ # 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(ike_landfall.days - 3) + ike_landfall.seconds # clawdata.t0 = days2seconds(ike_landfall.days - 1) + ike_landfall.seconds # 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: # clawdata.tfinal = days2seconds(date2days('2008091400')) clawdata.tfinal = days2seconds(ike_landfall.days + 0.75) + ike_landfall.seconds 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 'netcdf' 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 = 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.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 # clawdata.cfl_desired = 0.25 # clawdata.cfl_max = 0.5 # 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' # clawdata.source_split = 'strang' # -------------------- # 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 = 7 # amrdata.amr_levels_max = 6 # List of refinement ratios at each level (length at least mxnest-1) # amrdata.refinement_ratios_x = [2,2,3,4,16] # amrdata.refinement_ratios_y = [2,2,3,4,16] # amrdata.refinement_ratios_t = [2,2,3,4,16] # amrdata.refinement_ratios_x = [2,2,2,6,16] # amrdata.refinement_ratios_y = [2,2,2,6,16] # amrdata.refinement_ratios_t = [2,2,2,6,16] amrdata.refinement_ratios_x = [2,2,2,6,4,4] amrdata.refinement_ratios_y = [2,2,2,6,4,4] amrdata.refinement_ratios_t = [2,2,2,6,4,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). 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 = 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 # == 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] # Latex shelf # regions.append([1, 5, rundata.clawdata.t0, rundata.clawdata.tfinal, # -97.5, -88.5, 27.5, 30.5]) # Galveston region # Galveston Sub-Domains regions.append([1, 4, rundata.clawdata.t0, rundata.clawdata.tfinal, -95.8666, -93.4, 28.63333, 30.2]) regions.append([1, 5, rundata.clawdata.t0, rundata.clawdata.tfinal, -95.3723, -94.5939, 29.2467, 29.9837]) regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, -95.25, -94.3, 28.85, 29.8]) # Galveston Channel Entrance (galveston_channel) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -94.84, -94.70, 29.30, 29.40]) # # Galveston area (galveston) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -94.922600000000003, -94.825786176806162, # 29.352, 29.394523768822882]) # # Lower Galveston Bay channel (lower_galveston_bay) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -94.903199999999998, -94.775835119593594, # 29.383199999999999, 29.530588208444357]) # # Middle Galveston Bay Channel (upper_galveston_bay) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -94.959199999999996, -94.859496211934697, # 29.517700000000001, 29.617610214127549]) # # Upper Galveston bay channel (houston_channel_2) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -95.048400000000001, -94.903076052178108, # 29.602699999999999, 29.688573241894751]) # # Lower Houston channel (houston_channel_3) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -95.094899999999996, -94.892808885060177, # 29.6769, 29.832958103058733]) # # Upper Houston channel (houston_harbor) # regions.append([1, 7, rundata.clawdata.t0, rundata.clawdata.tfinal, # -95.320999999999998, -95.074527281677078, # 29.699999999999999, 29.830461271340102]) # == setgauges.data values == # for gauges append lines of the form [gaugeno, x, y, t1, t2] # rundata.gaugedata.gauges.append([121, -94.70895, 29.2812, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([122, -94.38840, 29.4964, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([123, -94.12530, 29.5846, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Gauges from Ike AWR paper (2011 Dawson et al) rundata.gaugedata.gauges.append([1, -95.04, 29.07, rundata.clawdata.t0, rundata.clawdata.tfinal]) rundata.gaugedata.gauges.append([2, -94.71, 29.28, rundata.clawdata.t0, rundata.clawdata.tfinal]) rundata.gaugedata.gauges.append([3, -94.39, 29.49, rundata.clawdata.t0, rundata.clawdata.tfinal]) rundata.gaugedata.gauges.append([4, -94.13, 29.58, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([5, -95.00, 29.70, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([6, -95.14, 29.74, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([7, -95.08, 29.55, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([8, -94.75, 29.76, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([9, -95.27, 29.72, rundata.clawdata.t0, rundata.clawdata.tfinal]) # rundata.gaugedata.gauges.append([10, -94.51, 29.52, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Stations from Andrew Kennedy # Station R - 82 rundata.gaugedata.gauges.append([ord('R'),-97.1176, 27.6289, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station S - 83 rundata.gaugedata.gauges.append([ord('S'),-96.55036666666666, 28.207733333333334, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station U - 85 rundata.gaugedata.gauges.append([ord('U'),-95.75235, 28.62505, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station V - 86 rundata.gaugedata.gauges.append([ord('V'),-95.31511666666667, 28.8704, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station W: Same as gauge 1 # rundata.gaugedata.gauges.append([ord('W'),-95.03958333333334, 29.0714, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station X: Same as gauge 2 above # rundata.gaugedata.gauges.append([ord('X'),-94.70895, 29.281266666666667, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station Y: Same as gauge 3 above # rundata.gaugedata.gauges.append([ord('Y'),-94.3884, 29.496433333333332, rundata.clawdata.t0, rundata.clawdata.tfinal]) # Station Z: Same as gauge 4 above # rundata.gaugedata.gauges.append([ord('Z'),-94.12533333333333, 29.584683333333334, rundata.clawdata.t0, rundata.clawdata.tfinal]) #------------------------------------------------------------------ # 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 = 1 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') #------------------------------------------------------------------ # 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: # For nonuniform grid, 0 <= xc <= 1 and the file grid.data should # define the mapping to the physical domain clawdata.lower[0] = 0. # xlower clawdata.upper[0] = 1. # xupper # Number of grid cells: clawdata.num_cells[0] = mx from clawpack.geoclaw_1d.data import GridData1D rundata.add_data(GridData1D(),'grid_data') rundata.grid_data.grid_type = grid_type # should be set to 2 above rundata.grid_data.fname_celledges = fname_celledges from clawpack.geoclaw_1d.data import BoussData1D rundata.add_data(BoussData1D(),'bouss_data') rundata.bouss_data.bouss = True rundata.bouss_data.B_param = 1./15. rundata.bouss_data.sw_depth0 = 0.005 rundata.bouss_data.sw_depth1 = 0.005 # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 2 # 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: # ------------- clawdata.t0 = 0. # 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 = 48 clawdata.tfinal = 120. 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 = [] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 1 clawdata.total_steps = 10 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 = 'all' # 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.01 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.e9 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.25 # 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 = 50000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 2 # 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 = [4,4] 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 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] = 'user' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper # 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' (see documentation). # Isn't used for this non-amr version, but still expected in data. amrdata = rundata.amrdata amrdata.aux_type = ['center','capacity'] geo_data = rundata.geo_data geo_data.dry_tolerance = 1.e-6 # Friction source terms: # src_split > 0 required # currently only Manning friction with a single n=friction_coefficient # is supported in 1d. geo_data.friction_forcing = True geo_data.manning_coefficient =.025 geo_data.coordinate_system = 1 # linear distance (meters) topo_data = rundata.topo_data topo_data.topofiles.append([1, 'celledges.data']) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, t1, t2] # for gauges append [gauge id, xc, t1, t2]) # note that xc is the computational grid point, 0 <= xc <= 1, # so if you want to specify physical points xp, these need to be mapped # to corresponding xc as follows: if 1: #xp_gauges = [-150, -80., -40, -30, -20, -10, 0] xp_gauges = [-150, -80., -60, -50, -40, -32, -31.2, -30.8, -30, \ -28, -20, -10, -5] for k,xp_g in enumerate(xp_gauges): #gaugeno = k+1 gaugeno = int(-xp_g*10) # compute computational point xc_g that maps to xp_g: ii = np.where(xp_edge < xp_g)[0][-1] xp_frac = (xp_g - xp_edge[ii])/(xp_edge[ii+1] - xp_edge[ii]) xc_g = (ii + xp_frac)/float(mx) print('gaugeno = %i: physical location xp_g = %g maps to xc_g = %.12f' \ % (gaugeno,xp_g, xc_g)) rundata.gaugedata.gauges.append([gaugeno, xc_g, 0, 1e9]) return rundata
def setrun(claw_pkg='classic'): #------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "classic" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data assert claw_pkg.lower() == 'classic', "Expected claw_pkg = 'classic'" num_dim = 1 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') #RC = 1.5e3 #RD = np.sqrt(2.)*RC # with lip ##RD = RC # no lip #DC = 2.*RC/3. #probdata.add_param('RC', RC, 'inner radius of crater') #probdata.add_param('RD', RD, 'outer radius of crater') #probdata.add_param('DC', DC, 'depth of crater') probdata.add_param('bouss', dispersion, 'Include dispersive terms?') probdata.add_param('B_param', B_param, 'Parameter for the Boussinesq eq') probdata.add_param('sw_depth0', sw_depth0) probdata.add_param('sw_depth1', sw_depth1) probdata.add_param('radial', radial, 'Radial source term?') #------------------------------------------------------------------ # 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] = 0. # xlower clawdata.upper[0] = 1. # xupper # Number of grid cells: clawdata.num_cells[0] = 5000 # mx # --------------- # Size of system: # --------------- # Number of equations in the system: clawdata.num_eqn = 2 # 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: # ------------- clawdata.t0 = 0. # 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 = 20 clawdata.tfinal = 1000. clawdata.output_t0 = False # 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.2, 1.6, 2.9, 4.3, 5.6, 6.9, 8.3, 9.6, 10.9] elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 1 clawdata.total_steps = 20 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 = 'all' # 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 = 1. # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.e9 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.15 # max Courant number to allow without retaking step with a smaller dt: clawdata.cfl_max = 0.2 # Maximum number of time steps to allow between output times: clawdata.steps_max = 50000 # ------------------ # Method to be used: # ------------------ # Order of accuracy: 1 => Godunov, 2 => Lax-Wendroff plus limiters clawdata.order = 2 # Number of waves in the Riemann solution: clawdata.num_waves = 2 # 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 = [4, 4] 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 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_lower[0] = 'wall' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper 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') #------------------------------------------------------------------ # GeoClaw specific parameters: #------------------------------------------------------------------ rundata = setgeo(rundata) #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: #------------------------------------------------------------------ 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] = 204.905 # xlower clawdata.upper[0] = 204.965 # xupper clawdata.lower[1] = 19.71 # ylower clawdata.upper[1] = 19.758 # yupper # Number of grid cells: clawdata.num_cells[0] = 108 # 2-sec # mx clawdata.num_cells[1] = 88 # my # --------------- # 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? # 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 = 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 = 14 clawdata.tfinal = 7 * 3600. 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 = 3600. * np.linspace(1, 4, 97) elif clawdata.output_style == 3: # Output every step_interval timesteps over total_steps timesteps: clawdata.output_step_interval = 1 clawdata.total_steps = 10 clawdata.output_t0 = False # 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==Falseixed 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.75 # 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 = 50000 # ------------------ # 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 'vanleer' ==> van Leer # 4 or 'mc' ==> MC limiter clawdata.limiter = ['vanleer', 'vanleer', 'vanleer'] 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 = 1 # -------------------- # 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] gauges.append([1125, 204.91802, 19.74517, 0., 1.e9]) #Hilo gauges.append([1126, 204.93003, 19.74167, 0., 1.e9]) #Hilo # gauges.append([11261, 204.93003, 19.739, 0., 1.e9]) # #Hilo # Tide gauge: gauges.append([7760, 204.9437, 19.7306, 0., 1.e9]) # Hilo gauges.append([7761, 204.9447, 19.7308, 0., 1.e9]) # From Benchmark descr. gauges.append([7762, 204.9437, 19.7307, 0., 1.e9]) # Shift so depth > 0 # Gauge at point requested by Pat Lynett: gauges.append([3333, 204.93, 19.7576, 0., 1.e9]) if 0: # Array of synthetic gauges originally used to find S2 location: dx = .0005 for i in range(6): x = 204.93003 - i * dx for j in range(5): y = 19.74167 + (j - 2) * dx gauges.append([10 * (j + 1) + i + 1, x, y, 0., 1.e9]) # -------------- # 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 = np.array([7.5, 8, 8.5, 9, 9.5]) * 3600. elif clawdata.checkpt_style == 3: # Checkpoint every checkpt_interval timesteps (on Level 1) # and at the final time. clawdata.checkpt_interval = 5 # --------------- # AMR parameters: (written to amr.data) # --------------- 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, 3] amrdata.refinement_ratios_y = [2, 3] amrdata.refinement_ratios_t = [2, 3] # 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', 'capacity', 'yleft'] # Flag for refinement based on Richardson error estimater: amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.0 # Richardson tolerance # Flag for refinement using routine flag2refine: amrdata.flag2refine = True # use this? amrdata.flag2refine_tol = 0.5 # tolerance used in this routine # Note: in geoclaw the refinement tolerance is set as wave_tolerance below # and flag2refine_tol is unused! # 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.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 0 # --------------- # Regions: # --------------- regions = rundata.regiondata.regions regions.append([1, 1, 0., 1e9, 0, 360, -90, 90]) regions.append([1, 2, 0., 1e9, 204.9, 204.95, 19.7, 19.754]) regions.append([1, 3, 0., 1e9, 204.9, 204.95, 19.7, 19.751]) regions.append([1, 4, 0., 1e9, 204.9, 204.95, 19.72, 19.748]) # ----- 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='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? # 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 = 3 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 = 10 clawdata.total_steps = 10 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? (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 = '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] = 'user' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([1, 0.08, 0.9, 0., 10.]) rundata.gaugedata.gauges.append([2, 0.06, 0.391, 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.7 # print info about each regridding up to this level: amrdata.verbosity_regrid = 3 # --------------- # Regions: # --------------- rundata.regiondata.regions = [] # to specify regions of refinement append lines of the form # [minlevel,maxlevel,t1,t2,x1,x2,y1,y2] # rundata.regiondata.regions.append([1,1,0,1e10,0.,1.,0.,1.]) # rundata.regiondata.regions.append([1,3,0,1e10,0.,1.,0.,0.7]) # ----- 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 = 2 clawdata.tfinal = 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.0005 # 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 = True # print err est flags amrdata.edebug = True # even more err est flags amrdata.gprint = True # grid bisection/clustering amrdata.nprint = False # proper nesting output amrdata.pprint = False # proj. of tagged points amrdata.rprint = True # print regridding summary amrdata.sprint = False # space/memory output amrdata.tprint = True # 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] # all 3 levels anywhere, based on flagging: rundata.regiondata.regions.append([1, 3, 0., 1e9, -220, 0, -90, 90]) # earthquake source region - force refinement initially: # dtopo region, replacing minlevel in dtopofile specification: rundata.regiondata.regions.append([3, 3, 0., 10., -77, -67, -40, -30]) # later times from original test: rundata.regiondata.regions.append([3, 3, 0., 200., -85, -70, -38, -25]) # --------------- # Gauges: # --------------- rundata.gaugedata.gauges = [] # for gauges append lines of the form [gaugeno, x, y, t1, t2] rundata.gaugedata.gauges.append([1, -76, -36., 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='classic'): # ------------------------------ """ Define the parameters used for running Clawpack. INPUT: claw_pkg expected to be "classic" for this setrun. OUTPUT: rundata - object of class ClawRunData """ from clawpack.clawutil import data # from clawpack.riemann.shallow_roe_with_efix_2D_constants import num_eqn, num_waves assert claw_pkg.lower() == 'classic', "Expected claw_pkg = 'classic'" 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('grav', 9.81, 'gravitational constant') # ------------------------------------------------------------------ # 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] = 0.0000 # xlower clawdata.upper[0] = domain_x # xupper clawdata.lower[1] = -domain_y / 2.0 # ylower clawdata.upper[1] = domain_y / 2.0 # yupper # Number of grid cells: clawdata.num_cells[0] = x_cell # mx clawdata.num_cells[1] = y_cell # my # --------------- # 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 = 1 # Index of aux array corresponding to capacity function, if there is one: clawdata.capa_index = 0 # ------------- # Initial time: # ------------- clawdata.t0 = 0.000 # Restart from checkpoint file of a previous run? # 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 = 16 clawdata.tfinal = 8.000 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 = 'all' # 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 = 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 = 1.000000e-04 # Max time step to be allowed if variable dt used: clawdata.dt_max = 1.e9 # Desired Courant number if variable dt used clawdata.cfl_desired = 0.40 # 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 = 50000 # ------------------ # 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 = True # 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 = 0 # Number of waves in the Riemann solution: clawdata.num_waves = 3 # 3 for Roe and HLLC # 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 = [1, 1, 1] 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 = 1 # -------------------- # 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] = 'user' # at xlower clawdata.bc_upper[0] = 'extrap' # at xupper clawdata.bc_lower[1] = 'extrap' # at ylower clawdata.bc_upper[1] = 'extrap' # at yupper return rundata
def setrun(claw_pkg='amrclaw'): #------------------------------ from clawpack.clawutil import data assert claw_pkg.lower() == 'amrclaw', "Expected claw_pkg = 'amrclaw'" num_dim = 2 rundata = data.ClawRunData(claw_pkg, num_dim) # ------------------------------------------------- # Custom parameters # ------------------------------------------------- refine_threshold = 0.05 # Refine everywhere use_fixed_dt = True mx = 32 dt_initial = 5e-3 # -1 : Always refine # 0 : Usual refinement based on threshold # 1 : constant theta # 2 : constant r refine_pattern = 1 f = 5 uniform = True if uniform: # No refinement; just increase resolution on each patch maxlevel = 1 mx *= 2**f # Coarsest level dt_initial /= 2**f nout = 5 * 2**f nstep = 5 * 2**f adapt = not uniform if adapt: # Refinement everywhere refine_pattern = -1 # always adapt refine_pattern = 0 # usual refinement maxlevel = f + 1 # refine everywhere to this level nout = 50 # Number of coarse grid steps nstep = 50 outstyle = 3 # 0 : Rigid body rotation # 1 : Vertical flow u = (0,omega) # 2 : Horizontal flow (doesn't work for the torus) # 3 : Swirl example example = 3 # 0 : non-smooth; # 1 : q = 1 (for compressible velocity fields) # 2 : smooth (for computing errors) init_choice = 2 alpha = 0.4 beta = 0 # theta_range = [0.125, 0.375] theta_range = [0, 1] phi_range = [0, 1] init_radius = 0.4 if example == 0: revs_per_s = 1.0 elif example >= 1: revs_per_s = 1.0 cart_speed = 0.765366864730180 ratioxy = 2 ratiok = 2 grid_mx = mx mi = 5 mj = 2 mx = mi * grid_mx my = mj * grid_mx # 0 = no qad # 1 = original qad # 2 = original (fixed to include call to rpn2qad) # 3 = new qad (should be equivalent to 2) qad_mode = 2 maux = 11 use_fwaves = True #------------------------------------------------------------------ # Problem-specific parameters to be written to setprob.data: #------------------------------------------------------------------ probdata = rundata.new_UserData(name='probdata', fname='setprob.data') probdata.add_param('example', example, 'example') probdata.add_param('init_choice', init_choice, 'init_choice') probdata.add_param('refine_pattern', refine_pattern, 'refine_pattern') probdata.add_param('alpha', alpha, 'alpha') probdata.add_param('beta', beta, 'beta') probdata.add_param('init_radius', init_radius, 'init_radius') probdata.add_param('revs_per_s', revs_per_s, 'revs_per_s') probdata.add_param('cart_speed', cart_speed, 'cart_speed') probdata.add_param('theta0', theta_range[0], 'theta[0]') probdata.add_param('theta1', theta_range[1], 'theta[1]') probdata.add_param('phi0', phi_range[0], 'phi[0]') probdata.add_param('phi1', phi_range[1], 'phi[1]') probdata.add_param('grid_mx', grid_mx, 'grid_mx') probdata.add_param('mi', mi, 'mi') probdata.add_param('mj', mj, 'mj') probdata.add_param('maxlevel', maxlevel, 'maxlevel') probdata.add_param('reffactor', ratioxy, 'reffactor') probdata.add_param('qad_mode', qad_mode, 'qad_mode') #------------------------------------------------------------------ # Standard Clawpack parameters to be written to claw.data: # (or to amrclaw.data for AMR) #------------------------------------------------------------------ clawdata = rundata.clawdata # initialized when rundata instantiated clawdata.num_dim = num_dim clawdata.lower[0] = 0 # xlower clawdata.upper[0] = 1 # xupper clawdata.lower[1] = 0 # ylower clawdata.upper[1] = 1 # yupper clawdata.num_cells[0] = mx # mx clawdata.num_cells[1] = my # my clawdata.num_eqn = 1 clawdata.num_aux = maux clawdata.capa_index = 1 # ---------------------------------------------------------- # Time stepping # ---------------------------------------------------------- clawdata.output_style = outstyle clawdata.dt_variable = not use_fixed_dt clawdata.dt_initial = dt_initial if clawdata.output_style == 1: clawdata.num_output_times = 16 clawdata.tfinal = 4.0 elif clawdata.output_style == 2: clawdata.output_times = [0., 0.5, 1.0] elif clawdata.output_style == 3: clawdata.total_steps = nout clawdata.output_step_interval = nstep clawdata.output_format = 'ascii' # 'ascii', 'binary', 'netcdf' # --------------------------- # Misc time stepping and I/O # --------------------------- clawdata.cfl_desired = 0.900000 clawdata.cfl_max = 1.000000 clawdata.output_t0 = True # output at initial (or restart) time? clawdata.t0 = 0.000000 clawdata.restart = False # True to restart from prior results clawdata.restart_file = 'fort.chk00006' # File to use for restart data clawdata.output_q_components = 'all' # only 'all' clawdata.output_aux_components = 'none' # 'all' or 'none' clawdata.output_aux_onlyonce = False # output aux arrays only at t0? clawdata.dt_max = 1.000000e+99 clawdata.steps_max = 100000 # 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 # ---------------------------------------------------- # Clawpack parameters # ----------------------------------------------------- clawdata.order = 2 clawdata.dimensional_split = 'unsplit' clawdata.transverse_waves = 2 clawdata.num_waves = 1 # 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 = ['minmod'] clawdata.use_fwaves = True # True ==> use f-wave version of algorithms clawdata.source_split = 0 # -------------------- # Boundary conditions: # -------------------- clawdata.num_ghost = 2 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 # --------------- # AMR parameters: # --------------- amrdata = rundata.amrdata amrdata.amr_levels_max = maxlevel amrdata.refinement_ratios_x = [ratioxy] * maxlevel amrdata.refinement_ratios_y = [ratioxy] * maxlevel amrdata.refinement_ratios_t = [ratiok] * maxlevel # If ratio_t == 1 if ratiok == 1: refine_factor = 1 for i in range(1, maxlevel): refine_factor *= amrdata.refinement_ratios_x[i] clawdata.dt_initial = dt_initial / refine_factor clawdata.total_steps = nout * refine_factor clawdata.output_step_interval = nstep * refine_factor print("clawdata.dt_initial = {:.6f}".format(clawdata.dt_initial)) print("clawdata.total_steps = {:d}".format(clawdata.total_steps)) print("clawdata.output_step_interval = {:d}".format( clawdata.output_step_interval)) # Refinement threshold amrdata.flag2refine_tol = refine_threshold # tolerance used in this routine # ------------------------------------------------------ # Misc AMR parameters # ------------------------------------------------------ amrdata.flag_richardson = False # use Richardson? amrdata.flag_richardson_tol = 1.000000e+00 # Richardson tolerance amrdata.flag2refine = True # use this? amrdata.regrid_interval = 1 amrdata.regrid_buffer_width = 3 amrdata.clustering_cutoff = 0.800000 amrdata.verbosity_regrid = 0 # ---------------------------------------------------------------- # For torus problem # 1 capacity # 2-5 Velocities projected onto left/right/top/bottom edges # 6-9 Edge lengths (normalized by dx or dy) # # All values are "center" values, since each cell stores # data for all four faces. This means that duplicate information # is stored, but we have to do it this way for conservation fix. # ---------------------------------------------------------------- amrdata.aux_type = ['capacity'] + ['center'] * 10 # ----- 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