Re: [firedrake] Interpolation in RealFunctionSpace
On Sun, 14 May 2017 at 21:12 Anna Kalogirou <A.Kalogirou@leeds.ac.uk> wrote:
Dear team,
I am facing a few problems with the real function space, again. I can’t seem to be able to interpolate on a real function, either with a C string expression or UFL. The following sample code
from firedrake import *
mesh = IntervalMesh(10, 1.0)
V = FunctionSpace(mesh, "CG", 1) V_R = FunctionSpace(mesh, "R", 0)
h = Function(V) Z = Function(V_R)
x = SpatialCoordinate(V.mesh())
h = interpolate(x[0], V) Z = interpolate(Expression("1.0"), V_R) Z = interpolate(1.0, V_R)
gives the error
Traceback (most recent call last): File "interpolation_reals.py", line 17, in <module> Z = interpolate(Expression("1.0"), V_R) File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 40, in interpolate return Interpolator(expr, V, subset=subset).interpolate() File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 60, in __init__ self.callable = make_interpolator(expr, V, subset) File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 129, in make_interpolator subset)) File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 189, in _interpolator args.append(dat(op2.WRITE, V.cell_node_map()[op2.i[0]])) TypeError: 'NoneType' object has no attribute '__getitem__'
I assume this functionality hasn’t been added for the real function space?
What does interpolation into R even mean? In general interpolating an expression into a FunctionSpace means evaluating the nodes of the FunctionSpace on the expression. Thus far we haven't actually even defined a Node for R (I guess integral over the domain normalised by domain volume might be it...)
Also, I noticed that when the UFL expression doesn’t include a coordinate x, e.g. in h = interpolate(1.0, V), I get the error:
Traceback (most recent call last): File "interpolation_reals.py", line 23, in <module> h = interpolate(1.0, V) File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 40, in interpolate return Interpolator(expr, V, subset=subset).interpolate() File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 60, in __init__ self.callable = make_interpolator(expr, V, subset) File "/Users/matak/firedrake/src/firedrake/firedrake/interpolation.py", line 94, in make_interpolator assert isinstance(expr, ufl.classes.Expr) AssertionError
Actually, as the error says, this error is because you need to pass a UFL expression into interpolate and 1.0 isn't a UFL expression. interpolate(Constant(1.0), V) would work fine.
Furthermore, I’m having trouble the exponential UFL expression, e.g.
exp_h = interpolate(exp(x[0]), V) TypeError: nb_float should return float object
I am unable to reproduce this problem. To be precise, ran the following script. It executed without error and printed what appears to be the right answer:
from firedrake import * mesh = IntervalMesh(10, 1.0) V = FunctionSpace(mesh, "CG", 1) x = SpatialCoordinate(V.mesh()) exp_h = interpolate(exp(x[0]), V) print exp_h.dat.data_ro Thank you very much for your help,
Anna.
P.S. At the start of every simulation, the following sentence is printed twice and delays the simulation for a couple of seconds: [warn] kq_init: detected broken kqueue; not using.: No such file or directory What does it mean and can we get rid of it?
The error message is some Mac issue. I see it too but I have no idea what causes it. I am not convinced that it causes any delay at all. It's simply the case that loading firedrake is not completely instantaneous. Regards, David -- Dr David Ham Department of Mathematics Imperial College London
On 15 May 2017, at 09:28, David Ham <david.ham@imperial.ac.uk> wrote:
P.S. At the start of every simulation, the following sentence is printed twice and delays the simulation for a couple of seconds: [warn] kq_init: detected broken kqueue; not using.: No such file or directory What does it mean and can we get rid of it?
The error message is some Mac issue. I see it too but I have no idea what causes it. I am not convinced that it causes any delay at all. It's simply the case that loading firedrake is not completely instantaneous.
FWIW, I believe this is this issue: https://github.com/Homebrew/homebrew-core/issues/2869 Plausibly $ brew update $ brew reinstall libevent $ brew reinstall openmpi Might fix things? Lawrence
participants (2)
- 
                
                David Ham
- 
                
                Lawrence Mitchell