Exemple #1
0
                                M.facets_satisfying(lambda x: x[0] == 1.0),
                                np.array([0.0, 1.0]))

mb = [
    FacetBasis(m, e, mapping=mapping, intorder=4, side=0),
    FacetBasis(M, E, mapping=mapping, intorder=4, side=1),
]

# define bilinear forms
E = 1000.0
nu = 0.3
Lambda, Mu = lame_parameters(E, nu)

weakform1 = linear_elasticity(Lambda, Mu)
weakform2 = linear_elasticity(Lambda, Mu)
C = linear_stress(Lambda, Mu)

alpha = 1000
limit = 0.3

# assemble the stiffness matrices
K1 = asm(weakform1, ib)
K2 = asm(weakform2, Ib)
K = [[K1, 0.], [0., K2]]
f = [None] * 2


def gap(x):
    """Initial gap between the bodies."""
    return (1. - np.sqrt(1. - x[1]**2))
Exemple #2
0
M = asm(mass, gb)

D = gb.find_dofs({'left': m.facets_satisfying(lambda x: x[0] == 0.)})
y = gb.zeros()

I = gb.complement_dofs(D)

L, x = solve(*condense(K, M, I=I),
             solver=solver_eigen_scipy_sym(k=6, sigma=0.0))

y = x[:, 4]

# calculate stress
sgb = gb.with_element(ElementVector(e))
C = linear_stress(lam, mu)
yi = gb.interpolate(y)

@LinearForm
def proj(v, _):
    return ddot(C(sym_grad(yi)), v)

sigma = projection(proj, sgb, gb)

if __name__ == "__main__":
    from skfem.visuals.matplotlib import plot, draw, show
    M = MeshQuad(np.array(m.p + y[gb.nodal_dofs]), m.t)
    ax = draw(M)
    plot(M, sigma[sgb.nodal_dofs[0]], ax=ax, colorbar=True)
    show()