""" This demo assembles the matrices corresponding to the variational forms inner(grad(v), grad(u)) and v*u on the reference triangle. Try to assemble the first form by hand and compare the result! """ from dolfin import * # Create mesh and define function space mesh = Mesh("triangle.xml") V = FunctionSpace(mesh, "CG", 1) # Define variational forms v = TestFunction(V) u = TrialFunction(V) a1 = inner(grad(v), grad(u))*dx a2 = v*u*dx A1 = assemble(a1) A2 = assemble(a2) # Print matrices print "A1: " print A1.array() print "A2: " print A2.array()