Skip to content

Commit

Permalink
make helpers.jump() do nothing if not assembled through asm()
Browse files Browse the repository at this point in the history
  • Loading branch information
kinnala committed Jun 15, 2024
1 parent ee36af1 commit 70dc10d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
24 changes: 12 additions & 12 deletions docs/examples/ex07.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
bb = FacetBasis(m, e)
fb = [InteriorFacetBasis(m, e, side=i) for i in [0, 1]]


@BilinearForm
def dgform(u, v, p):
ju, jv = jump(p, u, v)
h = p.h
n = p.n
def dgform(u, v, w):
ju, jv = jump(w, u, v)
h = w.h
n = w.n
return ju * jv / (alpha * h) - dot(grad(u), n) * jv - dot(grad(v), n) * ju

@BilinearForm
def nitscheform(u, v, p):
h = p.h
n = p.n
return u * v / (alpha * h) - dot(grad(u), n) * v - dot(grad(v), n) * u

A = asm(laplace, ib)
A = laplace.assemble(ib)
C = dgform.assemble(bb)
b = unit_load.assemble(ib)

# calling asm(form, [...], [...]) will automatically
# assemble all combinations from the lists and sum
# the result
B = asm(dgform, fb, fb)
C = asm(nitscheform, bb)
b = asm(unit_load, ib)

x = solve(A + B + C, b)

Expand Down
3 changes: 1 addition & 2 deletions skfem/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

def jump(w: FormExtraParams, *args):
if not hasattr(w, 'idx'):
raise NotImplementedError("jump() can be used only if the form is "
"assembled through asm().")
return args
out = []
for i, arg in enumerate(args):
out.append((-1.) ** w.idx[i] * arg)
Expand Down

0 comments on commit 70dc10d

Please sign in to comment.