← Back to team overview

dolfin team mailing list archive

Re: Problems overloading eval for vector valued Expression

 



On 10/11/10 17:44, N.A. Borggren wrote:
Hello,
     I am having some issues overloading eval for the class Expression
when I try to use vector valued functions.  For example the error occurs
for me in the Cahn-Hilliard demo copied directly from
http://www.fenicsproject.org/doc/demos/pde/cahn-
hilliard/python/documentation.html

$ python cahn.py

Got expression dimension = 0
Traceback (most recent call last):
   File "cahn.py", line 56, in<module>
     u.interpolate(u_init)
   File "cahn.py", line 10, in eval
     values[1] = 0.0
IndexError: index out of bounds

the problematic definition is:

class InitialConditions(Expression):
     def __init__(self):
         random.seed(2 + MPI.process_number())
     def eval(self, values, x):
         values[0] = 0.63 + 0.02*(0.5 - random.random())
         values[1] = 0.0
     def value_shape(self):
         return (2,)

What is this value_shape accomplishing?  The expression dimension seems
to still be zero.  How do I resolve this?


Which version of DOLFIN are you using?

Garth

Thank you very much,
     Nathan Borggren



Follow ups

References