This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Quadratic Runtime for Creating VectorFunctionSpace( mesh, "DG", 0 )

+3 votes

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()

asked Jul 31, 2013 by hezo FEniCS Novice (230 points)

1 Answer

+2 votes
 
Best answer

This issue has been fixed since the release of 1.2.0 (not sure when). If you need it, I would suggest upgrading to a more recent version (using e.g. Dorsal).

answered Aug 1, 2013 by Øyvind Evju FEniCS Expert (17,700 points)
selected Aug 2, 2013 by Garth N. Wells

I am using ubuntu 12.04 and I have included the fenics ppa. How long could it take until the changes are available in the ppa?

I am not active in the development or maintenance of the ppa, so I can't really answer that. Perhaps someone else can?

But if you want it right away, installation using Dorsal on 12.04 is quite easy. Just set the option STABLE_BUILD=false in dorsal.cfg and run ./dorsal, and follow the instructions on screen.

Thank you, I will try that.

Using the dev version and the posted program, the time for CG1 and DG0 is about the same (0.18s for the finest mesh on my computer).

I tried to install fenics using dorsal. It worked good for the stable version, but the installation of the dev version broke with the message:

...
Fetching fiat
./dorsal.sh: Zeile 107: git: Kommando nicht gefunden.
Failure with exit status: 127
Exit message: Error fetching fiat.

The system was a fresh ubuntu 12.04 server with only build-essential and the packages mentioned at the beginning of the dorsal process installed. Are there any suggestions how to fix this in a simple way? Otherwise I think I have to wait until the changes have been merged into the ppa.

Install git. The error message says what the problem is "git: Kommando nicht gefunden.".

...