コード例 #1
0
ファイル: adjoint_tools.py プロジェクト: rjleveque/adjoint
def read_data(outdir="_output", adjoint=False):

    from numpy import loadtxt
    fname = outdir + '/fort.H'
    B = loadtxt(fname)
    print "Loaded B"

    pd = ClawPlotData()
    pd.outdir = outdir

    times = []
    qxt = []
    for frameno in range(5001):
        try:
            frame = pd.getframe(frameno)
        except:
            break
        q = frame.state.q
        t = frame.state.t
        q[0, :] = B + q[0, :]
        qxt.append(q)
        times.append(t)

    x = frame.state.patch.x.centers
    x = x
    X, T = np.meshgrid(x, times)
    qxt = np.array(qxt)
    if adjoint:
        qxt = np.flipud(qxt)  # reverse t for adjoint
    return X, T, qxt
コード例 #2
0
ファイル: adjoint_tools.py プロジェクト: BrisaDavis/adjoint
def read_data(outdir="_output", adjoint=False):
    
    from numpy import loadtxt
    fname = outdir + '/fort.H'
    B = loadtxt(fname)
    print "Loaded B"
    
    pd = ClawPlotData()
    pd.outdir = outdir

    times = []
    qxt = []
    for frameno in range(5001):
        try:
            frame = pd.getframe(frameno)
        except:
            break
        q = frame.state.q
        t = frame.state.t
        q[0,:] = B + q[0,:]
        qxt.append(q)
        times.append(t)
    
    x = frame.state.patch.x.centers
    x = x
    X,T = np.meshgrid(x,times)
    qxt = np.array(qxt)
    if adjoint:
        qxt = np.flipud(qxt)  # reverse t for adjoint
    return X,T,qxt
コード例 #3
0
ファイル: adjoint_tools.py プロジェクト: rjleveque/adjoint
def read_data(outdir="_output", adjoint=False):
    pd = ClawPlotData()
    pd.outdir = outdir

    times = []
    qxt = []
    for frameno in range(5001):
        try:
            frame = pd.getframe(frameno)
        except:
            break
        q = frame.state.q
        t = frame.state.t
        qxt.append(q)
        times.append(t)
    
    x = frame.state.patch.x.centers
    x = x
    X,T = np.meshgrid(x,times)
    qxt = np.array(qxt)
    if adjoint:
        qxt = np.flipud(qxt)  # reverse t for adjoint
    return X,T,qxt
コード例 #4
0
    rundata.clawdata.lower[0] = xlower
    rundata.clawdata.upper[0] = xupper 
    rundata.clawdata.order = 1
    rundata.clawdata.bc_lower[0] = 'periodic'#'user'   # at xlower
    rundata.clawdata.bc_upper[0] = 'periodic'#'extrap'   # at xupper
    rundata.write()
    runclaw(xclawcmd='xclaw',outdir=outdir)	# xclaw.exe file produced after make .exe 

    #Get the material parameters
    aux = np.loadtxt(outdir+'/fort.a0000',skiprows=5)	# don't delate skiprows or set it equal 6 

    plotdata = ClawPlotData()
    plotdata.outdir=outdir

    #Read in the solution
    dat = plotdata.getframe(mframe)
    u = dat.q[0,:]

#    print u

    stress = np.exp(u*aux) - 1	# not sure why here don't need aux[0,:]
    stress = u

    #Compute parameter for error calculation
    reshape_para = mx_exact/mx

    #Compute error
    if i == 0:
	stress_exact = stress
    i = i + 1
    error = 0.0
コード例 #5
0
    rundata.clawdata.num_cells[0] = mx
    rundata.clawdata.num_output_times = 40	# output_times=1 won't work for high grid resolution
    rundata.clawdata.tfinal = .5000000e+02
    rundata.clawdata.lower[0] = xlower
    rundata.clawdata.upper[0] = xupper 
    rundata.write()
    runclaw(xclawcmd='xclaw',outdir=outdir)	# xclaw.exe file produced after make .exe 

    #Get the material parameters
    aux = np.loadtxt(outdir+'/fort.a0000',skiprows=5)	# don't delate skiprows or set it equal 6 

    plotdata = ClawPlotData()
    plotdata.outdir=outdir

    #Read in the solution
    dat = plotdata.getframe(40)
    u = dat.q[0,:]

    stress = np.exp(u*aux) - 1	# not sure why here don't need aux[0,:]

    print dat
#    print aux.shape

    #Compute parameter for error calculation
    reshape_para = mx_exact/mx

#    print reshape_para
#    print u.shape

    #Reshape stress to match dimension
    reshape_matrix = np.ones((1,reshape_para))