frompyro.utilimportmsgDEFAULT_INPUTS="inputs.dam.x"PROBLEM_PARAMS={"dam.direction":"x",# direction of the flow"dam.h_left":1.0,"dam.h_right":0.125,"dam.u_left":0.0,"dam.u_right":0.0}
[docs]definit_data(my_data,rp):""" initialize the dam problem """ifrp.get_param("driver.verbose"):msg.bold("initializing the dam problem...")# get the dam parametersh_left=rp.get_param("dam.h_left")h_right=rp.get_param("dam.h_right")u_left=rp.get_param("dam.u_left")u_right=rp.get_param("dam.u_right")# get the height, momenta, and energy as separate variablesh=my_data.get_var("height")xmom=my_data.get_var("x-momentum")ymom=my_data.get_var("y-momentum")X=my_data.get_var("fuel")# initialize the componentsxmin=rp.get_param("mesh.xmin")xmax=rp.get_param("mesh.xmax")ymin=rp.get_param("mesh.ymin")ymax=rp.get_param("mesh.ymax")direction=rp.get_param("dam.direction")xctr=0.5*(xmin+xmax)yctr=0.5*(ymin+ymax)myg=my_data.gridifdirection=="x":# leftidxl=myg.x2d<=xctrh[idxl]=h_leftxmom[idxl]=h_left*u_leftymom[idxl]=0.0X[idxl]=1.0# rightidxr=myg.x2d>xctrh[idxr]=h_rightxmom[idxr]=h_right*u_rightymom[idxr]=0.0X[idxr]=0.0else:# bottomidxb=myg.y2d<=yctrh[idxb]=h_leftxmom[idxb]=0.0ymom[idxb]=h_left*u_leftX[idxb]=1.0# topidxt=myg.y2d>yctrh[idxt]=h_rightxmom[idxt]=0.0ymom[idxt]=h_right*u_rightX[idxt]=0.0X[:,:]*=h
[docs]deffinalize():""" print out any information to the user at the end of the run """print(""" The script analysis/dam_compare.py can be used to compare this output to the exact solution. """)