Пример #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())
Пример #2
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())