diff options
-rw-r--r-- | boundaryDefinition.txt | 3 | ||||
-rwxr-xr-x | makeBoundary.py | 23 |
2 files changed, 15 insertions, 11 deletions
diff --git a/boundaryDefinition.txt b/boundaryDefinition.txt index db728e0..e526816 100644 --- a/boundaryDefinition.txt +++ b/boundaryDefinition.txt @@ -5,9 +5,6 @@ # topography: height_data: "../FullSWOF_2D-1.08.00/Examples/Simple/Inputs/topography.txt" -# Boundary location ("top", "bottom", "left", "right"): -location: "top" - # Enable plotting (True or False): plotting: True diff --git a/makeBoundary.py b/makeBoundary.py index bb6bfae..7301d61 100755 --- a/makeBoundary.py +++ b/makeBoundary.py @@ -5,6 +5,7 @@ import numpy as np import bisect import ast import math +import argparse #TODO: use YAML/ruamel.yaml for configuration file. def read_definition(filename): @@ -111,13 +112,19 @@ def save_bc(): -csa[ind_z]*Q_i[panel_x][-1]/csa_p[panel_x], zmax-zitem)) -# read boundary definition file. +# read command line argument: +parser = argparse.ArgumentParser( + description="generate FullSWOF boundary files") + +parser.add_argument("location", help="boundary location") +args = parser.parse_args() + +# read boundary definition file: definition_dict = read_definition('boundaryDefinition.txt') #for dd in definition_dict: # print(definition_dict[dd]) slope = abs(definition_dict["slope"]) # slope at top boundary target_flow = definition_dict["target_flow"] # imposed discharge -location = definition_dict["location"] # boundary location plotting = definition_dict["plotting"] # enable or disable plotting n_co = definition_dict["n_co"] # Manning's 'n' coefficients # TODO: use weighted mean 'n' values. See @@ -154,22 +161,22 @@ print('dX =', dX) # extract slices from height data array. Note: xyz format uses ncols # blocks, with nrows lines per block. -if location == 'top': +if args.location == 'top': xin = xtp[nrows-1:len(xtp):nrows] yin = ytp[nrows-1:len(xtp):nrows] zin = ztp[nrows-1:len(xtp):nrows] outputFilename = "BCTop.txt" -elif location == 'bottom': +elif args.location == 'bottom': xin = xtp[0:len(xtp):nrows] yin = ytp[0:len(xtp):nrows] zin = ztp[0:len(xtp):nrows] outputFilename = "BCBottom.txt" -elif location == 'left': +elif args.location == 'left': xin = xtp[:nrows] yin = ytp[:nrows] zin = ztp[:nrows] outputFilename = "BCLeft.txt" -elif location == 'right': +elif args.location == 'right': xin = xtp[nrows*(ncols-1):] yin = ytp[nrows*(ncols-1):] zin = ztp[nrows*(ncols-1):] @@ -184,9 +191,9 @@ num_panels = len(panel) # number of panels across boundary marker_ind = [0] for i in range(len(markers)): marker_ind.append(int(markers[i]/dX)) -if location == 'left' or location == 'right': +if args.location == 'left' or args.location == 'right': marker_ind.append(nrows) -elif location == 'top' or location == 'bottom': +elif args.location == 'top' or args.location == 'bottom': marker_ind.append(ncols) |