from dolfin import *
mesh = UnitSquareMesh(1,1)
V = FunctionSpace(mesh, 'CG', 2)
cf = CellFunction('size_t', mesh)
cf.set_all(0)
cf[0] = 1
dx = dx[cf]
u, v = TrialFunction(V), TestFunction(V)
# default rule
a = u*v*dx()
# form with default rule on 0 cells and, vertex rule on 1 cells
b = u*v*dx(0, {"quadrature_rule": "default"}) \
+ u*v*dx(1, {"quadrature_rule": "vertex"})
A, B = assemble(a), assemble(b)
print A.array() - B.array()
# now switch quadrature rules
cf.set_all(1)
cf[0] = 0
# form compilation is not required again
B = assemble(b)
print A.array() - B.array()
Form b
uses distinct quadrature rules according to value of cell function cf
. Your adaptivity comes into play by setting values of cf
according to your needs.