Example #1
0
def test_errors():
    mesh = """\
a = %s
vertices =
{
  { 0, -1 }, # first vertex
  { 0.707106781, 0.707106781 }
}

elements =
{
  { 0, 1, 4, 3, 0 }
}

boundaries =
{
  { 0, 1, 1 }
}
    """
    # this works:
    read_hermes_format_str(mesh % "34")
    # this fails:
    assert raises(ParseError, "read_hermes_format_str(mesh % 'x x x')")
    assert raises(ParseError, "read_hermes_format_str(mesh % '3 3 3')")
    assert raises(ParseError, "read_hermes_format_str(mesh % '+')")
    assert raises(ParseError, "read_hermes_format_str(mesh % '^^')")
Example #2
0
def test_ScalarView_mpl_unknown():
    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_element(0)
    shapeset = H1Shapeset()
    pss = PrecalcShapeset(shapeset)

    # create an H1 space
    space = H1Space(mesh, shapeset)
    space.set_uniform_order(5)
    space.assign_dofs()

    # initialize the discrete problem
    wf = WeakForm(1)
    set_forms(wf)

    solver = DummySolver()
    sys = LinSystem(wf, solver)
    sys.set_spaces(space)
    sys.set_pss(pss)

    # assemble the stiffness matrix and solve the system
    sys.assemble()
    A = sys.get_matrix()
    b = sys.get_rhs()
    from scipy.sparse.linalg import cg
    x, res = cg(A, b)
    sln = Solution()
    sln.set_fe_solution(space, pss, x)

    view = ScalarView("Solution")
    assert raises(ValueError, 'view.show(sln, show=False, method="something_unknown_123")')
Example #3
0
def test_plot_mesh1c():
    mesh = Mesh()
    mesh.load(domain_mesh)

    view = MeshView("Solution")
    assert raises(
        ValueError,
        'view.show(mesh, lib="mpl", method="something_unknown_123")')
Example #4
0
def test_plot_mesh1c():
    mesh = Mesh()
    mesh.load(domain_mesh)

    view = MeshView("Solution")
    assert raises(ValueError, 'view.show(mesh, lib="mpl", method="something_unknown_123")')