Пример #1
0
def veExtensionUpdater(t, y, pdict):
    #interior function for incompressible background flow only
    #split up long vector into individual sections (force pts, Lagrangian pts, stress components)
    N = pdict['N']
    M = pdict['M']
    l = y[range(2 * N * M)]
    l2col = np.reshape(l, (N * M, 2))
    l3D = np.reshape(l, (N, M, 2))
    P = np.reshape(y[(2 * N * M):], (N, M, 2, 2))
    Ps = np.reshape(P, (N * M, 2, 2))
    #calculate tensor derivative
    Pd = pdict['beta'] * SD2D.tensorDiv(P, pdict['gridspc'], N, M)
    Pd = np.reshape(Pd, (N * M, 2))
    #calculate deformation matrix and its inverse
    F = SD2D.vectorGrad(l3D, pdict['gridspc'], N, M)
    F = np.reshape(F, (N * M, 2, 2))
    Finv = CM.matinv2x2(F)
    #calculate new velocities at all points of interest (Lagrangian points and force points)
    ub, gradub = pdict['myVelocity'](pdict, l, l2col)
    lt = ub + pdict['gridspc']**2 * CM.matmult(pdict['eps'], pdict['mu'],
                                               l2col, l2col, Pd)
    #calculate new stress time derivatives
    gradlt = pdict['gridspc']**2 * CM.derivop(pdict['eps'], pdict['mu'], l2col,
                                              l2col, Pd, F)
    Pt = np.zeros((N * M, 2, 2))
    for j in range(N * M):
        Pt[j, :, :] = np.dot(gradub[j, :, :], Ps[j, :, :]) + np.dot(
            np.dot(gradlt[j, :, :], Finv[j, :, :]), Ps[j, :, :]) - (
                1. / pdict['Wi']) * (Ps[j, :, :] - Finv[j, :, :].transpose())
    return np.append(lt, Pt.flatten())
def simresults(basename, basedir):
    '''Retrieve approximate solution from saved output'''
    mydict = fileops.loadPickle(basename=basename, basedir=basedir)
    l = mydict['l']
    S = mydict['S']
    F = []
    Finv = []
    P = []
    N = l[0].shape[0]
    M = l[0].shape[1]
    for k in range(len(mydict['t'])):
        Ft = SD2D.vectorGrad(l[k], mydict['pdict']['gridspc'], N, M)
        Ftemp = np.reshape(Ft, (N * M, 2, 2))
        Ftinv = CM.matinv2x2(Ftemp)
        Ftinv = np.reshape(Ftinv, (N, M, 2, 2))
        F.append(Ft.copy())
        Finv.append(Ftinv.copy())
        stress = np.zeros((N, M, 2, 2))
        for j in range(N):
            for m in range(M):
                stress[j,
                       m, :, :] = S[k][j,
                                       m, :, :] * Ftinv[j,
                                                        m, :, :].transpose()
        P.append(stress.copy())
    return l, P, S, F, Finv, mydict
Пример #3
0
def simresults(basename, basedir):
    '''Retrieve approximate solution from saved output'''
    mydict = loadPickle(basename, basedir)
    l = mydict['l']
    regridinds = findRegridTimes(l)
    S=mydict['S']
    P=[]
    for k in range(len(mydict['t'])):
        # N and M can change because of regridding
        N = l[k].shape[0]
        M = l[k].shape[1]
        Ft = SD2D.vectorGrad(l[k],mydict['pdict']['gridspc'],N,M)
        Ftemp = np.reshape(Ft,(N*M,2,2))
        Ftinv = CM.matinv2x2(Ftemp)
        Ftinv = np.reshape(Ftinv,(N,M,2,2))
        stressP = np.zeros((N,M,2,2))
        for j in range(N):
            for m in range(M):
                stressP[j,m,:,:] = S[k][j,m,:,:]*Ftinv[j,m,:,:].transpose()
        P.append(stressP.copy())
    return l, P, S, mydict, regridinds
Пример #4
0
def viscoElasticUpdaterKernelDeriv(t, y, pdict):
    #interior function for force pts only
    #split up long vector into individual sections (force pts, Lagrangian pts, stress components)
    if 'forcedict' not in pdict.keys():
        pdict['forcedict'] = {}
    pdict['forcedict']['t'] = t
    N = pdict['N']
    M = pdict['M']
    Q = len(y) / 2 - N * M - 2 * N * M
    fpts = np.reshape(y[:2 * Q], (Q, 2))
    l = y[range(2 * Q, 2 * Q + 2 * N * M)]
    l2col = np.reshape(l, (N * M, 2))
    l3D = np.reshape(l, (N, M, 2))
    allpts = y[:2 * Q + 2 * N * M]  #both force points and Lagrangian points
    ap = np.reshape(allpts, (Q + N * M, 2))
    P = np.reshape(y[(2 * Q + 2 * N * M):], (N, M, 2, 2))
    Ps = np.reshape(P, (N * M, 2, 2))
    #calculate tensor derivative
    Pd = pdict['beta'] * SD2D.tensorDiv(P, pdict['gridspc'], N, M)
    Pd = np.reshape(Pd, (N * M, 2))
    #calculate spring forces
    f = pdict['myForces'](fpts, pdict['xr'], pdict['K'], **pdict['forcedict'])
    #calculate deformation matrix and its inverse
    gl = SD2D.vectorGrad(l3D, pdict['gridspc'], N, M)
    gls = np.reshape(gl, (N * M, 2, 2))
    igls = CM.matinv2x2(gls)
    #calculate new velocities at all points of interest (Lagrangian points and force points)
    lt = pdict['gridspc']**2 * CM.matmult(
        pdict['eps'], pdict['mu'], ap, l2col, Pd) + CM.matmult(
            pdict['eps'], pdict['mu'], ap, fpts, f)
    #calculate new stress time derivatives
    glst = pdict['gridspc']**2 * CM.derivop(
        pdict['eps'], pdict['mu'], l2col, l2col, Pd, gls) + CM.derivop(
            pdict['eps'], pdict['mu'], l2col, fpts, f, gls)
    Pt = np.zeros((N * M, 2, 2))
    for j in range(N * M):
        Pt[j, :, :] = np.dot(np.dot(glst[j, :, :], igls[j, :, :]),
                             Ps[j, :, :]) - (1. / pdict['Wi']) * (
                                 Ps[j, :, :] - igls[j, :, :].transpose())
    return np.append(lt, Pt.flatten())
def simresults(basename, basedir):
    '''Retrieve approximate solution from saved output'''
    mydict = fileops.loadPickle(basename=basename, basedir=basedir)
    l = mydict['l']
    S=mydict['S']
    F=[]
    Finv=[]
    P=[]
    N = l[0].shape[0]
    M = l[0].shape[1]
    for k in range(len(mydict['t'])):
        Ft = SD2D.vectorGrad(l[k],mydict['pdict']['gridspc'],N,M)
        Ftemp = np.reshape(Ft,(N*M,2,2))
        Ftinv = CM.matinv2x2(Ftemp)
        Ftinv = np.reshape(Ftinv,(N,M,2,2))
        F.append(Ft.copy())
        Finv.append(Ftinv.copy())
        stress = np.zeros((N,M,2,2))
        for j in range(N):
            for m in range(M):
                stress[j,m,:,:] = S[k][j,m,:,:]*Ftinv[j,m,:,:].transpose()
        P.append(stress.copy())
    return l, P, S, F, Finv, mydict