Bug in LocalAssembler when reorder_dofs_serial is turned off

Issue #578 resolved
Tormod Landet created an issue

I get different results out of the local assembler depending on whether reorder_dofs_serial is on or off. It seems like the behavior with reordering is correct, but when turning of reordering it is buggy.

I turn of reordering to be able to easier inspect and control global matrices for debugging. This bug is not major, but something to be aware of at least

The code below shows the bug. The code requires pull request #245 to run. The lines for method 1 and 2 are equal if dof reordering is on and different if dof reordering is off.

from dolfin import *
dolfin.parameters['reorder_dofs_serial'] = False

mesh = UnitSquareMesh(1, 1, 'right')
cell = Cell(mesh, 1)
n = FacetNormal(mesh)

V = FunctionSpace(mesh, 'DGT', 1)
v = TestFunction(V)

# Checkerboard initialization of known function w
w = Function(V)
for i in range(len(w.vector())):
    w.vector()[i] = 1 + i%2

####################################################
# Method 1: Flux in UFL
u_hat_ds = w
u_hat_dS = avg(w)*w('+')

# Calculate linear form
L = u_hat_ds*v*ds
for R in '+-':
    L += u_hat_dS*v(R)*dS
b = assemble_local(L, cell)
print 'Method 1, cell %d: %r' % (cell.index(), list(b))

####################################################
# Method 2: Flux in DGT

def project_to_dgt(u_hat_ds, u_hat_dS, V):
    u = TrialFunction(V)
    v = TestFunction(V)

    a = u*v*ds
    L = u_hat_ds*v*ds
    for R in '+-':
        a += u(R)*v(R)*dS
        L += u_hat_dS*v(R)*dS

    A, b = assemble_system(a, L)
    u_hat = Function(V)
    solve(A, u_hat.vector(), b)
    return u_hat

u_hat = project_to_dgt(u_hat_ds, u_hat_dS, V)

# Calculate linear form
L = u_hat*v*ds
for R in '+-':
    L += u_hat(R)*v(R)*dS
b = assemble_local(L, cell)
print 'Method 2, cell %d: %r' % (cell.index(), list(b))

Comments (4)

  1. Tormod Landet reporter

    This is a combination of multiple problems

    • Stupid initialization of the w function in above test case (mesh reordering changes w)
    • LocalAssembler not checking whether facet <-> cell connectivity has been initialized (the above test case has zero connected cells to each facet if dof reordering is off. If it is on then the connectivity is initialized by the reordering code somehow)
    • LocalAssembler does not properly handle + and - cells

    I am working on all of these now

  2. Log in to comment