I have noticed that the creation of a VectorFunctionSpace with piecewise constant functions takes quite long - much longer than a piecewise linear continuous VectorFunctinSpace for the same mesh.
Doing some tests on this I received the impression that there is a quadratic runtime with respect to the meshsize.
I tried to find out where the different VectorFunctionSpaces are implemented and to check if there is any hopefully unnecessary quadratic loop without success.
Thanks in advance for any help!
You can run the following code to see the effect:
import timeit
from dolfin import *
fileCG1 = open( "cg1.txt", "w" )
fileDG0 = open( "dg0.txt", "w" )
for i in range(1,31):
mesh = UnitCubeMesh( 10*i,10,10 )
print "meshsize", 10*i
print "CG 1"
tic = timeit.default_timer()
V1 = VectorFunctionSpace( mesh, "CG", 1 )
toc = timeit.default_timer()
time = toc - tic
fileCG1.write( str(time) + " " )
print "done in ", time
print "DG 0"
tic = timeit.default_timer()
V1 = VectorFunctionSpace( mesh, "DG", 0 )
toc = timeit.default_timer()
time = toc - tic
fileDG0.write( str(time) + " " )
print "done in ", time
print "\n"
fileCG1.close()
fileDG0.close()