← Back to team overview

dolfin team mailing list archive

Problems overloading eval for vector valued Expression

 

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?

Thank you very much,
    Nathan Borggren
-- 
This message was sent from Launchpad by
N.A. Borggren (https://launchpad.net/~nborggren)
using the "Contact this team" link on the DOLFIN Team team page
(https://launchpad.net/~dolfin).
For more information see
https://help.launchpad.net/YourAccount/ContactingPeople



Follow ups