Skip to content

Instantly share code, notes, and snippets.

@c-f-h
Last active June 7, 2020 19:52
Show Gist options
  • Save c-f-h/1558b237a95eb88a0eaaa078a8a94f93 to your computer and use it in GitHub Desktop.
Save c-f-h/1558b237a95eb88a0eaaa078a8a94f93 to your computer and use it in GitHub Desktop.
import numpy as np
from pyiga import bspline, geometry, assemble, approx
def L2ErrEstimator_vf(dim):
from pyiga.vform import VForm, div, grad, dx, tree_print
vf = VForm(dim, arity=1)
u = vf.input('u')
v = vf.basisfuns()
Lu = div(grad(u, parametric=True), parametric=True)
vf.add(Lu**2 * v * dx)
return vf
kvs = 2 * (bspline.make_knots(2, 0.0, 1.0, 10),)
#geo = geometry.quarter_annulus()
geo = geometry.unit_square()
n = kvs[0].numdofs
u = bspline.BSplineFunc(kvs, approx.interpolate(kvs, lambda x,y: x**2 + 0.5*y**2))
# space of piecewise constants over the cells of the mesh
kvs_0 = 2 * (bspline.make_knots(0, 0.0, 1.0, 10),)
errors = assemble.assemble_vf(L2ErrEstimator_vf(2), kvs_0, geo=geo, u=u)
print(errors)
print(np.sum(errors))
~ ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment