diff options
author | Paul Garlick <pgarlick@tourbillion-technology.com> | 2019-10-25 16:03:01 +0100 |
---|---|---|
committer | Paul Garlick <pgarlick@tourbillion-technology.com> | 2019-10-25 16:03:01 +0100 |
commit | a6b4aac5ee756b440852cbff117cd1012f565036 (patch) | |
tree | 496b859f5419c4ce44cb778b7d4d22ad763015b7 /makeBoundary.py | |
parent | 1e062c554376e16e442392a95e75b67c90177727 (diff) | |
download | fullSWOF-utils-a6b4aac5ee756b440852cbff117cd1012f565036.tar.gz |
read location from command line instead of boundary definition file.
Diffstat (limited to 'makeBoundary.py')
-rwxr-xr-x | makeBoundary.py | 23 |
1 files changed, 15 insertions, 8 deletions
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) |