dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #17924
Re: [Question #105494]: random function
Question #105494 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/105494
Johan Hake posted a new comment:
Hi again!
Sorry for the incomplete answer. In dolfin 0.9.4 I think you have to pass the
Function space using the keyword argument V=V when you instantiate your
Expression.
randf1 = myrand(V=V)
It's actually there in the error message ;)
In later dolfin version you only need to instantiate your Expression
using
randf1 = myrand()
Johan
On Thursday March 25 2010 08:33:48 Achim Schroll wrote:
> Question #105494 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/105494
>
> Status: Answered => Open
>
> Achim Schroll is still having a problem:
> Hi Johan, I don't get it. Expression gives the error...
>
> class myrand(Expression):
> def eval(self, values, x):
> values[0] = gauss(0,1)
>
> mesh = UnitSquare(20, 20)
> V = FunctionSpace(mesh, "CG", 1)
>
> randf1 = myrand(V)
>
> Traceback (most recent call last):
> File "addnoise_ny.py", line 37, in <module>
> randf1 = myrand(V)
> File "/usr/lib/python2.5/site-packages/dolfin/expression.py", line 120,
> in __init__ raise TypeError, "Expression need to be initialized using
> either a 'cpp.FunctionSpace', using kwarg 'V', or an 'ufl.FiniteElement'
> using kwarg 'element'." TypeError: Expression need to be initialized using
> either a 'cpp.FunctionSpace', using kwarg 'V', or an 'ufl.FiniteElement'
> using kwarg 'element'.
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.