示例#1
0
def test_mesh4():
    n1 = Node(1)
    n2 = Node(3)
    n3 = Node(4)
    n4 = Node(5)
    e1 = Element(n1, n2, order=3)
    e2 = Element(n2, n3, order=3)
    e3 = Element(n3, n4, order=3)
    nodes = (n1, n2, n3, n4)
    elements = (e1, e2, e3)
    m = Mesh(nodes, elements)
    ndofs = m.assign_dofs()
    assert m.elements[0].dofs[0] == 0
    assert m.elements[0].dofs[1] == 1
    assert m.elements[0].dofs[2] == 4
    assert m.elements[0].dofs[3] == 5

    assert m.elements[1].dofs[0] == 1
    assert m.elements[1].dofs[1] == 2
    assert m.elements[1].dofs[2] == 6
    assert m.elements[1].dofs[3] == 7

    assert m.elements[2].dofs[0] == 2
    assert m.elements[2].dofs[1] == 3
    assert m.elements[2].dofs[2] == 8
    assert m.elements[2].dofs[3] == 9

    assert ndofs == 10
示例#2
0
def test_mesh7():
    n1 = Node(1)
    n2 = Node(3)
    n3 = Node(4)
    n4 = Node(5)
    e1 = Element(n1, n2, order=3)
    e2 = Element(n2, n3, order=1)
    e3 = Element(n3, n4, order=2)
    nodes = (n1, n2, n3, n4)
    elements = (e1, e2, e3)
    m = Mesh(nodes, elements)
    m.set_bc(left=False, value=1)
    ndofs = m.assign_dofs()
    assert m.elements[0].dofs[0] == 0
    assert m.elements[0].dofs[1] == 1
    assert m.elements[0].dofs[2] == 3
    assert m.elements[0].dofs[3] == 4

    assert m.elements[1].dofs[0] == 1
    assert m.elements[1].dofs[1] == 2

    assert m.elements[2].dofs[0] == 2
    assert m.elements[2].dofs[1] == -1
    assert m.elements[2].dofs[2] == 5

    assert ndofs == 6
示例#3
0
def test_mesh8():
    n1 = Node(1)
    n2 = Node(3)
    n3 = Node(4)
    n4 = Node(5)
    e1 = Element(n1, n2, order=3)
    e2 = Element(n2, n3, order=1)
    e3 = Element(n3, n4, order=2)
    nodes = (n1, n2, n3, n4)
    elements = (e1, e2, e3)
    m1 = Mesh(nodes, elements)
    m1.set_bc(left=False, value=1)
    e4 = Element(n1, n2, order=3)
    e5 = Element(n2, n3, order=1)
    e6 = Element(n3, n4, order=2)
    elements = (e4, e5, e6)
    m2 = Mesh(nodes, elements)
    m2.set_bc(left=True, value=1)

    m1.assign_dofs()
    m2.assign_dofs()

    assert m1.elements[0].dofs[0] == 0
    assert m1.elements[0].dofs[1] == 1
    assert m1.elements[0].dofs[2] == 3
    assert m1.elements[0].dofs[3] == 4

    assert m1.elements[1].dofs[0] == 1
    assert m1.elements[1].dofs[1] == 2

    assert m1.elements[2].dofs[0] == 2
    assert m1.elements[2].dofs[1] == -1
    assert m1.elements[2].dofs[2] == 5

    assert m2.elements[0].dofs[0] == -1
    assert m2.elements[0].dofs[1] == 0
    assert m2.elements[0].dofs[2] == 3
    assert m2.elements[0].dofs[3] == 4

    assert m2.elements[1].dofs[0] == 0
    assert m2.elements[1].dofs[1] == 1

    assert m2.elements[2].dofs[0] == 1
    assert m2.elements[2].dofs[1] == 2
    assert m2.elements[2].dofs[2] == 5