diff --git a/docs/examples/ex07.py b/docs/examples/ex07.py index 3e2443a3..58e1368e 100644 --- a/docs/examples/ex07.py +++ b/docs/examples/ex07.py @@ -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) diff --git a/skfem/helpers.py b/skfem/helpers.py index 2779bde7..422068f0 100644 --- a/skfem/helpers.py +++ b/skfem/helpers.py @@ -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)