Subject: [FFC-dev] FFC error

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 17 May 2007 15:45:10 +0200

When trying to compile a form file, I'm getting the error

Computing tensor representation for term 0... *** dimensions too large.
*** To get more information about this error, rerun ffc with the option -d1.

Running with -d1,

  File
"/usr/lib/python2.5/site-packages/ffc/compiler/representation/tensor/monomialintegration.py", 

line 54, in integrate
     A0 = __compute_product(psis, vscaling * monomial.numeric * weights)
   File
"/usr/lib/python2.5/site-packages/ffc/compiler/representation/tensor/monomialintegration.py", 

line 268, in __compute_product
     A0 = numpy.transpose(A0, rearrangement)
   File "/usr/lib/python2.5/site-packages/numpy/core/fromnumeric.py",
line 118, in transpose
     return transpose(axes)
ValueError: dimensions too large.

I was able to compile this form last weeks. Below is the form.

Garth

scalar1 = FiniteElement("Lagrange", "triangle", 1)

r  = TestFunction(scalar1)
p1 = TrialFunction(scalar1)

p0   = Function(scalar1)
lam  = Function(scalar1)
FFF  = Function(scalar1)

stab = Function(scalar1)
h    = Constant("triangle")

k     = Constant("triangle")
theta = Constant("triangle")
dt    = Constant("triangle")

beta = mult(h,stab)
SUPG = - beta*lam*k*dot(grad(p0),grad(r))

L_saturation_stab = SUPG*lam*k*dot(grad(p0),grad(FFF))*dx

L = L_saturation_stab

---

From: Anders Logg <[email-masked]>
Date: Thu, 17 May 2007 18:28:48 +0200

I'll take a look.

/Anders

On Thu, May 17, 2007 at 03:45:10PM +0200, Garth N. Wells wrote:
> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/ffc-dev

---

From: "Garth N. Wells" <[email-masked]>
Date: Thu, 24 May 2007 21:55:15 +0200

Any ideas what going on here? It's causing problem for me.

Garth

---

From: Anders Logg <[email-masked]>
Date: Fri, 25 May 2007 01:35:10 +0200

I'm pretty sure the problem is a few changes we made to get BDM
elements working. I was looking at it but ran out of time. I'll fix it
as soon as I can (which should be early next week). If you want to
take a look, try to find out at which changeset it broke.

I tried to simplify the form a bit and find the simplest possible form
where it still breaks, but it seems it only breaks if the form is
complicated enough (has enough factors in it).

/Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 25 May 2007 09:01:04 +0200

> take a look, try to find out at which changeset it broke.

I tried to find an old changeset, but it still didn't work. I think that 
the example has an extra factor in it (which I didn't have before) which 
breaks things. It does work with quadrature.

Garth

---

From: Anders Logg <[email-masked]>
Date: Fri, 25 May 2007 09:46:39 +0200

> breaks things. It does work with quadrature.

Could it just be that numpy is generating the error since FFC tries to
create an array that is too large? (Product of all dimensions.)

/Anders

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 25 May 2007 09:48:39 +0200

> create an array that is too large? (Product of all dimensions.)

Yes. I had a quick look on the net, but couldn't find information on the 
limitations of numpy.

Garth

---

From: Kristian Oelgaard <[email-masked]>
Date: Fri, 25 May 2007 10:16:56 +0200

> Yes. I had a quick look on the net, but couldn't find information on the 

The following python script generates a similar error:
import numpy

n = 12 # ok
#n = 13 # not ok
shape = [2 for i in range(n)]
print "shape A: ", shape

A = numpy.zeros(shape, dtype= numpy.float)
print "A: ", A

rearr = range(n)
rearr = rearr[::-1]
print "rearr: ", rearr

Ar = numpy.transpose(A, rearr)
print "Ar", Ar
print "shape Ar: ", numpy.shape(Ar)

looks like there's a limitation in Numpy

Kristian

---

From: Anders Logg <[email-masked]>
Date: Fri, 25 May 2007 11:27:32 +0200

> looks like there's a limitation in Numpy

Yes, I was just looking at this myself. You will get the same thing
if you do

  import numpy

  n = 13
  shape = n*(1,)
  axes  = range(n)

  A = numpy.zeros(shape)
  numpy.transpose(A, axes)

I will ask some Python gurus.

/Anders