Пример #1
0
    def runTest(self):
        import numpy as np
        from spfem.mesh import MeshTri
        from spfem.asm import AssemblerAbstract, AssemblerElement
        from spfem.element import AbstractElementTriPp, ElementTriP1
        from spfem.utils import direct

        m = MeshTri()
        m.refine(3)

        e = AbstractElementTriPp(1)
        e1 = ElementTriP1()
        a = AssemblerAbstract(m,e)
        b = AssemblerElement(m,e1)

        A=a.iasm(lambda du,dv: du[0]*dv[0]+du[1]*dv[1])
        f=a.iasm(lambda v: 1.0*v)

        x=direct(A,f,I=m.boundary_nodes())

        K=a.inorm(lambda u: u[0], {0:x})

        self.assertAlmostEqual(np.sqrt(np.sum(K)),b.L2error(x,lambda X:0*X[0]))
Пример #2
0
    my = .3333 * np.sum(m.p[1, m.t], axis=0)
    ixlower = np.nonzero(my < 0.0)[0]
    ixupper = np.nonzero(my > 0.0)[0]
    mupper = MeshTri(*m.remove_elements(ixlower))
    mlower = MeshTri(*m.remove_elements(ixupper))
    return mlower, mupper


m1, m2 = contact_mesh(0.01)
m1.draw()
plt.hold('on')
m2.draw(nofig=True)

e1 = ElementTriP1()
e = ElementH1Vec(e1)
a1 = AssemblerElement(m1, e)
a2 = AssemblerElement(m2, e)

E1 = 1.0
nu1 = 0.3

E2 = 0.5
nu2 = 0.3

mu1 = E1 / (2.0 * (1.0 + nu1))
lam1 = nu1 * E1 / ((1.0 + nu1) * (1.0 - 2.0 * nu1))

mu2 = E2 / (2.0 * (1.0 + nu2))
lam2 = nu2 * E2 / ((1.0 + nu2) * (1.0 - 2.0 * nu2))

Пример #3
0
    def runTest(self):
        # solve Poisson by standard P1 method
        # and P1(dg) interior penalty method.
        #
        # this will test interior facet assembly and normal
        # vectors.
        from spfem.mesh import MeshTri
        from spfem.asm import AssemblerElement
        from spfem.element import ElementTriP1, ElementTriDG
        from spfem.utils import direct
        import numpy as np

        m = MeshTri()
        m.refine(3)

        e = ElementTriDG(ElementTriP1())
        e1 = ElementTriP1()
        a = AssemblerElement(m, e)
        a1 = AssemblerElement(m, e1)
        b1 = AssemblerElement(m, e1, e)

        A = a.iasm(lambda du, dv: du[0]*dv[0] + du[1]*dv[1])
        M = a.iasm(lambda u, v: u*v)
        b = a.iasm(lambda v, x: np.sin(2.0*np.pi*x[0])*v)

        B1 = a.fasm(lambda u1,u2,v1,v2,h: 1/h*(u1-u2)*(v1-v2), interior=True)
        B2 = a.fasm(lambda u,v,h: 1/h*u*v)
        B=B1+B2

        C1 = a.fasm(lambda du1,du2,v1,v2,n: 0.5*(du1[0]*n[0]*v1 - du2[0]*n[0]*v2
                                           + du1[1]*n[1]*v1 - du2[1]*n[1]*v2), interior=True)
        C2 = a.fasm(lambda du,v,n: (du[0]*n[0]+du[1]*n[1])*v)
        C=C1+C2

        D = C+C.T

        eps = 1e-3
        eta = 1e5
        x = direct(A + eta*B - 0*D, b)

        K = a1.iasm(lambda du, dv: du[0]*dv[0] + du[1]*dv[1])
        f = a1.iasm(lambda v, x: np.sin(2.0*np.pi*x[0])*v)

        y = direct(K, f, I=m.interior_nodes())

        P = b1.iasm(lambda u,v: u*v)

        self.assertAlmostEqual(np.linalg.norm(x-direct(M,P*y)),0,places=4)
Пример #4
0
        m.refine(nref)
    my=.3333*np.sum(m.p[1,m.t],axis=0)
    ixlower=np.nonzero(my<0.0)[0]
    ixupper=np.nonzero(my>0.0)[0]
    mupper=MeshTri(*m.remove_elements(ixlower))
    mlower=MeshTri(*m.remove_elements(ixupper))
    return mlower,mupper

m1,m2=contact_mesh(0.01)
m1.draw()
plt.hold('on')
m2.draw(nofig=True)

e1=ElementTriP1()
e=ElementH1Vec(e1)
a1=AssemblerElement(m1,e)
a2=AssemblerElement(m2,e)

E1=1.0
nu1=0.3

E2=0.5
nu2=0.3

mu1=E1/(2.0*(1.0+nu1))
lam1=nu1*E1/((1.0+nu1)*(1.0-2.0*nu1))

mu2=E2/(2.0*(1.0+nu2))
lam2=nu2*E2/((1.0+nu2)*(1.0-2.0*nu2))

def Eps(dU):