I have produced
from dolfin import *
mesh = RectangleMesh(0,0,1,1,160,160)
t0 = Timer("CG1 FunctionSpace definition")
V1 = FunctionSpace(mesh,'CG',1);
t0.stop()
t0 = Timer("CG2 FunctionSpace definition")
V2 = FunctionSpace(mesh,'CG',2)
t0.stop()
t0 = Timer("DG0 FunctionSpace definition")
S = FunctionSpace(mesh,'DG',0)
t0.stop()
t0 = Timer("DG0 TensorFunctionSpace definition")
St = TensorFunctionSpace(mesh,'DG',0)
t0.stop()
list_timings()
The code times the generation of
#1 scalar CG1 functionspace
#2 scalar CG2 functionspace
#3 scalar DG0 functionspace
#4 tensor DG0 functionspace
I get (seconds)
#1 0.056
#2 0.195
#3 0.023
#4 13.95
There is a factor of four difference in the number of DOF for #1 and #2, so this is completely reasonable. DG0 is faster than CG1 despite having twice the number of DOF, but what really strikes me is #4. I would expect this to take less than 0.1 (>4*0.023) seconds, but it takes 100 times longer !?