Exemple #1
0
def test_mesh_point_2d_quadrilateral():
    "Test mesh-point intersection in 2D for quadrilateral mesh"

    point = Point(0.1, 0.2)
    mesh = UnitSquareMesh.create(16, 16, CellType.Type.quadrilateral)

    intersection = intersect(mesh, point)

    assert intersection.intersected_cells() == [49]
def test_mesh_point_2d_quadrilateral():
    "Test mesh-point intersection in 2D for quadrilateral mesh"

    point = Point(0.1, 0.2)
    mesh = UnitSquareMesh.create(16, 16, CellType.Type.quadrilateral)

    intersection = intersect(mesh, point)

    assert intersection.intersected_cells() == [49]
Exemple #3
0
def dolfin_comparasion(Nx, Ny, f):
    from dolfin import (UnitSquareMesh, FunctionSpace, TrialFunction,
                        TestFunction, assemble, inner, grad, dx,
                        SpatialCoordinate, DirichletBC, Function, solve, pi,
                        CellType, sin, cos)
    mesh = UnitSquareMesh.create(Nx, Ny, CellType.Type.quadrilateral)
    V = FunctionSpace(mesh, "CG", 1)
    u, v = TrialFunction(V), TestFunction(V)
    a = inner(grad(u), grad(v)) * dx

    A_dol = assemble(a)
    x, y = SpatialCoordinate(mesh)
    f = eval(f)
    l_ = inner(f, v) * dx
    B_dol = assemble(l_)
    bc = DirichletBC(V, 0, "on_boundary")
    bc.apply(A_dol, B_dol)
    u_h = Function(V)
    solve(A_dol, u_h.vector(), B_dol)
    return u_h, assemble(u_h * dx)