ib = InteriorBasis(m, e, intorder=4) Ib = InteriorBasis(M, E, intorder=4) mapping = MappingMortar.init_2D(m, M, m.boundaries['contact'], 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
weak form of the linear elasticity problem is defined in :func:`skfem.models.elasticity.linear_elasticity`. """ import numpy as np from skfem import * from skfem.models.elasticity import linear_elasticity, lame_parameters m = MeshHex() m.refine(3) e1 = ElementHex1() e = ElementVectorH1(e1) ib = InteriorBasis(m, e, MappingIsoparametric(m, e1), 3) K = asm(linear_elasticity(*lame_parameters(1e3, 0.3)), ib) dofs = { 'left' : ib.get_dofs(lambda x: x[0] == 0.0), 'right': ib.get_dofs(lambda x: x[0] == 1.0), } u = np.zeros(K.shape[0]) u[dofs['right'].nodal['u^1']] = 0.3 I = ib.complement_dofs(dofs) u = solve(*condense(K, 0*u, I=I, x=u)) sf = 1.0 m.p += sf * u[ib.nodal_dofs]
""" from skfem import * from skfem.models.elasticity import linear_elasticity,\ lame_parameters import numpy as np from pathlib import Path m = MeshTet.load(Path(__file__).parent / 'meshes' / 'beams.msh') e1 = ElementTetP2() e = ElementVectorH1(e1) ib = Basis(m, e) K = asm(linear_elasticity(*lame_parameters(200.0e9, 0.3)), ib) rho = 8050.0 @BilinearForm def mass(u, v, w): from skfem.helpers import dot return dot(rho * u, v) M = asm(mass, ib) L, x = solve( *condense(K, M, D=ib.find_dofs()["fixed"]), solver=solver_eigen_scipy_sym() )
] mapping = MappingMortar.init_2D(m, M, m.boundaries['contact'], M.facets_satisfying(lambda x: x[0] == 1.0), np.array([0.0, 1.0])) mb = [ MortarFacetBasis(m, e, mapping=mapping, intorder=4, side=0, dofs=dofs1), MortarFacetBasis(M, E, mapping=mapping, intorder=4, side=1, dofs=dofs2), ] # define bilinear forms youngs_modulus = 1000.0 poisson_ratio = 0.3 Lambda, Mu = lame_parameters(youngs_modulus, poisson_ratio) weakform = linear_elasticity(Lambda, Mu) C = linear_stress(Lambda, Mu) alpha = 1000 limit = 0.3 # mortar forms @BilinearForm def bilin_mortar(u, v, w): # jumps ju = (-1.) ** w.idx[0] * dot(u, w.n) jv = (-1.) ** w.idx[1] * dot(v, w.n) nxn = prod(w.n, w.n) mu = .5 * ddot(nxn, C(sym_grad(u)))