← Back to team overview

dolfin team mailing list archive

Re: Problems overloading eval for vector valued Expression

 

>>> print dolfin.__version__,ufl.__version__
0.9.9 0.5.4

after removing ferari the code in the documentation works.

Thanks,
  Nathan

On Wed, Nov 10, 2010 at 3:15 PM, Johan Hake <johan.hake@xxxxxxxxx> wrote:

> On Wednesday November 10 2010 11:58:19 Nathan Borggren wrote:
> > After upgrading to the newest version the error repeats with value_shape
>
> Can you please report what the newest version means. The value_shape is
> introduced in the development version. It is not in the latests stable
> version.
>
> > but is indeed fixed with the replacement pointed out by Stepan.  After
> > making sure dim() was used I get two different errors, depending on if I
> > use the demo posted in the documentation, or if I use the demo from the
> > installation (which used the dim() method already).
> >
> > Thanks,
> >   Nathan
> >
> > ##the error in the demo from the web documentation
> >
> > $ python cahn.py
> > Got expression dimension = 2
> > Starting Newton solve.
> > Calling FFC just-in-time (JIT) compiler, this may take some time.
> > Traceback (most recent call last):
> >   File "cahn.py", line 90, in <module>
> >     solver.solve(problem, u.vector())
> >   File "cahn.py", line 22, in F
> >     assemble(self.L, tensor=b)
> >   File "/usr/lib/python2.6/dist-packages/dolfin/fem/assemble.py", line
> 100,
> > in assemble
> >     common_cell=common_cell)
> >   File "/usr/lib/python2.6/dist-packages/dolfin/fem/form.py", line 34, in
> > __init__
> >     (self._compiled_form, module, self.form_data) = jit(form,
> > form_compiler_parameters, common_cell)
> >   File "/usr/lib/python2.6/dist-packages/dolfin/compilemodules/jit.py",
> > line 47, in mpi_jit
> >     return local_jit(*args, **kwargs)
> >   File "/usr/lib/python2.6/dist-packages/dolfin/compilemodules/jit.py",
> > line 114, in jit
> >     return jit_compile(form, parameters=p, common_cell=common_cell)
> >   File "/usr/lib/python2.6/dist-packages/ffc/jitcompiler.py", line 64, in
> > jit
> >     return jit_form(object, parameters, common_cell)
> >   File "/usr/lib/python2.6/dist-packages/ffc/jitcompiler.py", line 122,
> in
> > jit_form
> >     compile_form(preprocessed_form, prefix=jit_object.signature(),
> > parameters=parameters)
> >   File "/usr/lib/python2.6/dist-packages/ffc/compiler.py", line 145, in
> > compile_form
> >     oir = optimize_ir(ir, parameters)
> >   File "/usr/lib/python2.6/dist-packages/ffc/optimization.py", line 38,
> in
> > optimize_ir
> >     oir_integrals = [_optimize_integral_ir(ir) for ir in ir_integrals]
> >   File "/usr/lib/python2.6/dist-packages/ffc/optimization.py", line 56,
> in
> > _optimize_integral_ir
> >     oir = r.optimize_integral_ir(ir)
> >   File
> "/usr/lib/python2.6/dist-packages/ffc/tensor/tensoroptimization.py",
> > line 42, in optimize_integral_ir
> >     ir["AK"][k] = (A0, GK, _optimize_tensor_contraction(A0.A0, rank))
> >   File
> "/usr/lib/python2.6/dist-packages/ffc/tensor/tensoroptimization.py",
> > line 80, in _optimize_tensor_contraction
> >     return optimize(A0)
> >   File "/usr/lib/python2.6/dist-packages/ferari/binary.py", line 390, in
> > optimize_action
> >     p = process( Adict )
> >   File "/usr/lib/python2.6/dist-packages/ferari/binary.py", line 188, in
> > process
> >     G = get_graph( vecs , rho )
> >   File "/usr/lib/python2.6/dist-packages/ferari/binary.py", line 72, in
> > get_graph
> >     (w,l) = dist( vecs[u] , vecs[v] )
> >   File "/usr/lib/python2.6/dist-packages/ferari/binary.py", line 58, in
> rho
> >     c = colinear( u , v )
> >   File "/usr/lib/python2.6/dist-packages/ferari/binary.py", line 44, in
> > colinear
> >     uhat = util.unit_vector( u )
> >   File "/usr/lib/python2.6/dist-packages/ferari/util.py", line 25, in
> > unit_vector
> >     raise RuntimeError, "divide by zero"
> > RuntimeError: divide by zero
>
> Could you try by uninstalling ferari:
>
>  sudo apt-get remove ferari
>
> You will probably be informed that the fenics package will be uninstalled
> bu
> that is ok. It is just a dummy package for all fenics packages.
>
> > ##and the error in the demo from the install
>
> What version of dolfin and ufl are you using. I a python shell do:
>
>  import dolfin, ufl
>  print dolfin.__version__, ufl.__version__
>
> > /FEniCS/dolfin-doc/demo/pde/cahn-hilliard/python$ python demo.py
> > *** Warning: The meaning of operator '+' has changed (no longer creating
> a
> > mixed function space).
>
> As the warning tells you we have changed the meaning of the + operator when
> dealing with FunctionSpace. You should now use '*'. It looks like your
> demos
> are out of sync with your fenics installation.
>
> > Traceback (most recent call last):
> >   File "demo.py", line 49, in <module>
> >     q, v  = TestFunctions(ME)
> > ValueError: need more than 1 value to unpack
>
> You get this error because ME is not a mixed FunctionSpace.
>
> > ##after fixing this and similar subsequent errors with q, v  =
> > TestFunctions(ME), TestFunctions(ME) we get another error:
>
> This will just create test and trial functions that are in the wrong
> FunctionSpace.
>
> Johan
>
> > $ python demo.py
> > *** Warning: The meaning of operator '+' has changed (no longer creating
> a
> > mixed function space).
> > Traceback (most recent call last):
> >   File "demo.py", line 62, in <module>
> >     mu = factor*(2.0*c*(1.0-c)*(1.0-c) - 2.0*c*c*(1.0-c))
> > TypeError: can't multiply sequence by non-int of type 'float'
>
>
>
> > Thanks,
> >    Nathan
> >
> > On Wed, Nov 10, 2010 at 2:29 PM, Stepan Roucka <stepan@xxxxxxxxx> wrote:
> > > I think you use dim() method instead:
> > >
> > > 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 dim(self):
> > >       return 2
> > >
> > > The documentation of demos seems to be outdated?
> > > The demos in the ppa packages use dim(), but in the
> > > sources
> > >
> > >
> http://bazaar.launchpad.net/~dolfin-core/dolfin/main/annotate/head%3A/dem<http://bazaar.launchpad.net/%7Edolfin-core/dolfin/main/annotate/head%3A/dem>
> > > o/pde/cahn-hilliard/python/demo.py<
> http://bazaar.launchpad.net/%7Edolfin-
> > >
> core/dolfin/main/annotate/head%3A/demo/pde/cahn-hilliard/python/demo.py>
> > > value_shape is still used, I don't understand why.
> > >
> > > Stepan
> > >
> > > On 10 November 2010 18:48, Garth N. Wells <gnw20@xxxxxxxxx> wrote:
> > > > 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
> > > >
> > > > _______________________________________________
> > > > Mailing list:
> > > > https://launchpad.net/~dolfin <https://launchpad.net/%7Edolfin><
> https://launchpad.net/%7Edolfin> Post to
> > > >     : dolfin@xxxxxxxxxxxxxxxxxxx
> > > > Unsubscribe :
> > > > https://launchpad.net/~dolfin <https://launchpad.net/%7Edolfin><
> https://launchpad.net/%7Edolfin> More
> > > > help   : https://help.launchpad.net/ListHelp
>

References